diff --git a/Slideshow/App.xaml b/Slideshow/App.xaml index 8d1d1ba..57bf03a 100644 --- a/Slideshow/App.xaml +++ b/Slideshow/App.xaml @@ -1,6 +1,7 @@  diff --git a/Slideshow/App.xaml.cs b/Slideshow/App.xaml.cs index e816a15..a410f5d 100644 --- a/Slideshow/App.xaml.cs +++ b/Slideshow/App.xaml.cs @@ -23,5 +23,18 @@ namespace Slideshow /// public partial class App : Application { + void App_Startup(object sender, StartupEventArgs e) + { + if (e.Args.Length > 0) + { + dragNdropArg = e.Args[0]; + } + else + { + dragNdropArg = ""; + } + } + + public static string dragNdropArg; } } diff --git a/Slideshow/MainWindow.xaml.cs b/Slideshow/MainWindow.xaml.cs index 4c6251b..36524be 100644 --- a/Slideshow/MainWindow.xaml.cs +++ b/Slideshow/MainWindow.xaml.cs @@ -123,12 +123,18 @@ void MainWindow_KeyDown(object sender, KeyEventArgs e) case Key.Subtract: // Break intentionally omitted. case Key.OemMinus: - if (imageDurationSeconds - imageDurationOffset < 1) + if (imageDurationSeconds <= 1) { break; } - - imageDurationSeconds -= imageDurationOffset; + if (imageDurationSeconds >= (imageDurationOffset * 2)) + { + imageDurationSeconds -= imageDurationOffset; + } + else + { + imageDurationSeconds /= 2; + } imageTimer.Interval = new TimeSpan(0, 0, imageDurationSeconds); Toast(String.Format("Decreased duration to {0} seconds", imageDurationSeconds)); break; @@ -233,7 +239,15 @@ private void ReadExifInfo(FileStream imageStream) private void LoadImages() { string[] validExtensions = new string[] { ".jpg", ".jpeg" }; - DirectoryInfo directory = new DirectoryInfo(GetAssemblyDirectory()); + DirectoryInfo directory; + if (Slideshow.App.dragNdropArg.Length > 0) + { + directory = new DirectoryInfo(GetSelectedDirectory(Slideshow.App.dragNdropArg)); + } + else + { + directory = new DirectoryInfo(GetAssemblyDirectory()); + } IEnumerable files = from f in directory.EnumerateFiles() where validExtensions.Any(f.Extension.ToLower().Contains) select f; @@ -253,5 +267,16 @@ private string GetAssemblyDirectory() string assemblyPath = Uri.UnescapeDataString(uri.Path); return Path.GetDirectoryName(assemblyPath); } + + private string GetSelectedDirectory(string arg) + { + UriBuilder uri = new UriBuilder(arg); + string argPath = Uri.UnescapeDataString(uri.Path); + if (Directory.Exists(argPath)) + { + return argPath; + } + return Path.GetDirectoryName(argPath); + } } }