protected override void Run() { MessageBoxResult result = System.Windows.MessageBox.Show(Window.GetWindow(this), Message, Title, Buttons, Image, DefaultButton); Reset(); OnResult?.ExecuteIfPossible(result); switch (result) { case MessageBoxResult.OK: OnOk?.ExecuteIfPossible(null); break; case MessageBoxResult.Cancel: OnCancel?.ExecuteIfPossible(null); break; case MessageBoxResult.Yes: OnYes?.ExecuteIfPossible(null); break; case MessageBoxResult.No: OnNo?.ExecuteIfPossible(null); break; } }
protected override void Run() { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog() { Title = Title, Multiselect = true, InitialDirectory = InitialDirectory?.FullName, Filter = Filter }; bool?result = dialog.ShowDialog(Window.GetWindow(this)); Reset(); if (result.GetValueOrDefault()) { Files = dialog.FileNames.Select(name => new FileInfo(name)).ToObservableCollection(); OnResult?.ExecuteIfPossible(Files); } else { OnCancel?.ExecuteIfPossible(null); } }
protected override void Run() { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog() { Title = Title, Multiselect = false, InitialDirectory = InitialDirectory?.FullName ?? File?.DirectoryName, Filter = Filter }; bool?result = dialog.ShowDialog(Window.GetWindow(this)); Reset(); if (result.GetValueOrDefault()) { File = new FileInfo(dialog.FileName); OnResult?.ExecuteIfPossible(File); } else { OnCancel?.ExecuteIfPossible(null); } }