private void modifyCommand(object parameter) { if (string.IsNullOrEmpty(Firstname) || string.IsNullOrEmpty(Lastname)) { return; } if (ModifyContent.ToLower() == "add") { modifyEntity(); runTask(SQLFunctionType.Add); } else { if (dataModified() == false) { return; } WindowMessageResult modifyResult = MessageBoxEnhanced.Show( "Question...", "You are about to modify a record in the database! Do you wish to continue?", WindowMessageButtons.YesNo, WindowMessageIcon.Question); if (modifyResult == WindowMessageResult.Yes) { modifyEntity(); runTask(SQLFunctionType.Modify); } } }
private void deleteCommand(object parameter) { WindowMessageResult deleteResult = MessageBoxEnhanced.Show( "Question...", "You are about to delete a record from the database! Do you wish to continue?", WindowMessageButtons.YesNo, WindowMessageIcon.Question); if (deleteResult == WindowMessageResult.Yes) { runTask(SQLFunctionType.Delete); } }
private void Button_Delete_Click(object sender, RoutedEventArgs e) { ListViewItemTableTile selectedItem = ListView_TableTiles.SelectedItem as ListViewItemTableTile; if (selectedItem != null) { WindowMessageResult result = WindowMessage.ShowDialog(string.Format("Do you want to delete '{0}'?", selectedItem.TableTile.Name), "Delete", WindowMessageButtons.YesNoCancel, WindowMessageImage.Question, App.WindowMain); if (result == WindowMessageResult.Yes) { App.TableTileManager.Remove(selectedItem.TableTile); UpdateListView(); } } }
// Custom dialog: public static void ExampleTwo(object parameter) { DialogData data = new DialogData() { WindowTitle = "Example...", DialogWindowStyle = WindowStyle.SingleBorderWindow, WindowIconURI = "pack://application:,,,/Resources/gear_icon2.ico", Topmost = true, }; CustomDialogViewModel customDialogViewModel = new CustomDialogViewModel(data); DialogUserControlView dialogUserControlView = new DialogUserControlView(customDialogViewModel, new CustomDialog(data)); WindowMessageResult result = DialogService.OpenDialog(dialogUserControlView, parameter as Window); }
private void resetCommand(object parameter) { WindowMessageResult resetResult = MessageBoxEnhanced.Show( "Warning...", "You are about to reset the database!", "Any changes you have made to the current database will lost. Are you sue you wish to continue?", WindowMessageButtons.YesNo, WindowMessageIcon.Warning); if (resetResult == WindowMessageResult.Yes) { SQLConnection.Close(); Statics.LoadResourceDatabase(true); CloseDialogWithResult(WindowMessageResult.Yes); } }
private void settingsCommand(object parameter) { DialogData settingsData = new DialogData(); settingsData.WindowTitle = "Settings..."; settingsData.Topmost = false; settingsData.Background = ColorSets.HexConverter("#FF1E1E1E"); DialogBaseWindowViewModel viewmodel = new SettingsViewModel(settingsData); WindowMessageResult settingsResult = DialogService.OpenDialog(viewmodel, parameter as Window, ShutdownMode.OnLastWindowClose); if (settingsResult == WindowMessageResult.Yes) { ChangeContent.Select(MainContent.Connect); } }
// Opens Custom Windows style Dialog Window and setting the owner of that window to the passed in paramater. Optinal use since a dialog can be directly opened. public static WindowMessageResult OpenWindowsDialog(DialogData data, Window window) { WindowMessageResult result = WindowMessageResult.Undefined; if (Application.Current == null) { return(result); } // This will allow for use of this method from threads outside the UI thread. window.Dispatcher.Invoke((Action) delegate { result = MessageBoxEnhanced.OpenWindowMessage(data, window); }); return(result); }
private void Button_RestoreDefaultLocations_Click(object sender, RoutedEventArgs e) { WindowMessageResult windowMessageResult = WindowMessage.ShowDialog( "Do you want to restore default locations?", "Restore Default Locations", WindowMessageButtons.YesNoCancel, WindowMessageImage.Warning, App.WindowMain); if (windowMessageResult == WindowMessageResult.Yes) { for (int tableSize = 0; tableSize < 11; tableSize++) { Config.HudTimerLocationsX[tableSize] = Config.DefaultHudTimerLocationsX[tableSize]; Config.HudTimerLocationsY[tableSize] = Config.DefaultHudTimerLocationsY[tableSize]; } } }
private void addCommand(object parameter) { DialogData modifyData = new DialogData(); modifyData.WindowTitle = "Modify Database..."; modifyData.Topmost = false; modifyData.Background = ColorSets.HexConverter("#FF1E1E1E"); DialogBaseWindowViewModel viewmodel = new AddEditViewModel(modifyData); WindowMessageResult settingsResult = DialogService.OpenDialog(viewmodel, parameter as Window, ShutdownMode.OnLastWindowClose); // Data was deleted and the view needs to reloaded. // Sloppy and could be better by updating page counts or adding to the existing page if it matches the current search pattern. if (settingsResult == WindowMessageResult.Accept) { querySQL(PageCurrent); } }
private void Button_RestoreDefaults_Click(object sender, RoutedEventArgs e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Do you want to restore default table tile configs?"); sb.AppendLine("This will overwrite only default named table tile configs."); sb.AppendLine("Custom table tile cofigs will remain untouched."); sb.AppendLine(); sb.AppendLine("Default table tile configs:"); sb.AppendLine(); List <TableTile> defaultTableTiles = TableTile.GetDefaultValues().ToList(); foreach (TableTile tableTile in defaultTableTiles) { sb.AppendLine(" " + tableTile.Name); } WindowMessageResult windowMessageResult = WindowMessage.ShowDialog( sb.ToString(), "Restore Default Table Tile Configs", WindowMessageButtons.YesNoCancel, WindowMessageImage.Warning, App.WindowMain); if (windowMessageResult == WindowMessageResult.Yes) { foreach (TableTile tableTile in App.TableTileManager.GetTableTilesCopy()) { if (!defaultTableTiles.Any(a => a.Name.Equals(tableTile.Name))) { defaultTableTiles.Add(tableTile); } } App.TableTileManager.RemoveAll(); App.TableTileManager.Add(defaultTableTiles); UpdateListView(); } }
private void Button_RestoreDefaults_Click(object sender, RoutedEventArgs e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Do you want to restore default poker type values?"); sb.AppendLine("This will overwrite only default named poker types."); sb.AppendLine("Custom poker types will remain untouched."); sb.AppendLine(); sb.AppendLine("Default poker types:"); sb.AppendLine(); List <PokerType> defaultPokerTypes = PokerType.GetDefaultValues().ToList(); foreach (PokerType pokerType in defaultPokerTypes) { sb.AppendLine(" " + pokerType.Name); } WindowMessageResult windowMessageResult = WindowMessage.ShowDialog( sb.ToString(), "Restore Default Poker Types", WindowMessageButtons.YesNoCancel, WindowMessageImage.Warning, App.WindowMain); if (windowMessageResult == WindowMessageResult.Yes) { foreach (PokerType pokerType in App.PokerTypeManager.GetPokerTypesCopy()) { if (!defaultPokerTypes.Any(a => a.Name.Equals(pokerType.Name))) { defaultPokerTypes.Add(pokerType); } } App.PokerTypeManager.RemoveAll(); App.PokerTypeManager.Add(defaultPokerTypes); UpdateListView(); } }
// Primary method for opening a dialog. private static WindowMessageResult openDialogWork(Window dialogWindow, DialogViewModel dialogWindowViewModel, Window parentWindow, ShutdownMode shutdownMode) { bool applicationUIThreadAccess = CheckApplicationUIThreadAccess(); if (applicationUIThreadAccess && shutdownMode != CurrentApplicationShutdownMode()) { // Param shutdownMode can used to prevent the Application.Current from going null. It can be turned off by setting ApplicationExplicitShutdown. // This should not throw. Possible investigation should be made to check on this. Application.Current.ShutdownMode = shutdownMode; } // We need to find a dispatcher to display this message. Dispatcher dispatcher = null; if (parentWindow == null && applicationUIThreadAccess == false) { return(WindowMessageResult.Undefined); } else if (parentWindow == null && applicationUIThreadAccess) { try { dialogWindow.Owner = Application.Current.Windows.OfType <Window>().FirstOrDefault(x => x.IsActive); } catch (Exception Ex) { LogMVVM.Exception("MVVM Exception: Dialog Service error when trying to get window owner.", Ex); // This should not throw. Possible investigation should be made to check on this. if (Application.Current.Windows.Count > 0) { dialogWindow.Owner = Application.Current.Windows[0]; } else { dialogWindow.Owner = null; } } if (dialogWindow.Owner == null) { dispatcher = Application.Current.Dispatcher; } else { dispatcher = dialogWindow.Owner.Dispatcher; } } else // This should ONLY happen if parentWindow is NOT null. { dialogWindow.Owner = parentWindow; dispatcher = parentWindow.Dispatcher; } try { if (dispatcher.CheckAccess() == false) { return(WindowMessageResult.Undefined); } WindowMessageResult result = WindowMessageResult.Undefined; dispatcher.Invoke((Action) delegate { dialogWindow.ShowDialog(); result = dialogWindowViewModel.Result; }); return(result); } catch (Exception Ex) { LogMVVM.Exception("MVVM Exception: Dialog service error when opening dialog window.", Ex); return(WindowMessageResult.Undefined); } }
private void Button_Cancel_Click(object sender, RoutedEventArgs e) { Result = WindowMessageResult.Cancel; Close(); }
public void CloseDialogWithResult(WindowMessageResult result) { Result = result; Events.CloseDialog(); }
private void Button_Yes_Click(object sender, RoutedEventArgs e) { Result = WindowMessageResult.Yes; Close(); }