private void Window_KeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.Left: GamePaddle.Direction = PaddleDirection.Left; GamePaddle.Move(GameArea); GamePaddle.Draw(GameArea); break; case Key.Right: GamePaddle.Direction = PaddleDirection.Right; GamePaddle.Move(GameArea); GamePaddle.Draw(GameArea); break; case Key.Escape: MessageBoxResult response = CustomMessageBox.ShowOKCancel("Are you sure to quit from the best game ever?", "Close confirmation", "Yes", "HellNO"); if (response == MessageBoxResult.OK) { this.Close(); } break; case Key.Space: gameTicker.IsEnabled = false; MessageBoxResult responseSpace = MessageBox.Show("Press OK to continue", "GAME PAUSED"); if (responseSpace == MessageBoxResult.OK) { gameTicker.IsEnabled = true; } break; } }
/// <summary> /// Check for any processes that match this one /// </summary> private void CheckRunningApp() { var processesArr = CheckRunningProcces(Process.GetCurrentProcess().ProcessName); if (processesArr.Length > 1) { var result = CustomMessageBox.ShowOKCancel("This program is already running on your computer", "Process already running", "Kill process", "Cancel", MessageBoxImage.Error); if (result == MessageBoxResult.OK) { KillProcess(processesArr); } else if (result == MessageBoxResult.Cancel) { KillCurrentProcess(processesArr); } } if (CheckRunningProcces("Millennium Tray App").Length < 1) { Process firstProc = new Process(); firstProc.StartInfo.FileName = "TrayIcon.exe"; firstProc.EnableRaisingEvents = true; //firstProc.Start(); } }
private void Abort_button_Click(object sender, EventArgs e) { if (CustomMessageBox.ShowOKCancel("Вы действительно хотите отменить изменения?", "Предупреждение", "Отменить", "Продолжить") == MessageBoxResult.OK) { loadData(); } }
private bool Verify() { Debug.WriteLine(_exception.InnerException); var result = CustomMessageBox.ShowOKCancel( "The program encountered an error, do you want to send this report to Millennium to help resolve this issue?", "Error", "Send error log", "Cancel"); return(result == MessageBoxResult.OK); }
private void changeLanguageDialog(string culture, string language) { var confirmResult = CustomMessageBox.ShowOKCancel(Properties.Resources.LanguageDialogText + language + "?", Properties.Resources.LanguageDialogTitle, Properties.Resources.Yes, Properties.Resources.No); if (confirmResult == MessageBoxResult.OK) { getCulture(culture); } }
private void ОтчиститьБазуДанныхToolStripMenuItem_Click(object sender, EventArgs e) { if (CustomMessageBox.ShowOKCancel("Вы действительно хотите безвозвратно удалить базу данных Вашей библиотеки?", "Предупреждение", "Удалить", "Отменить") == MessageBoxResult.OK) { NPOImethods methods = new NPOImethods(); methods.CreateBlank(); MessageBox.Show("База данных удалена"); } else { MessageBox.Show("База данных не удалена"); } }
public static bool ShowChoiceDialog(string messageBoxText, string caption, string okButtonText, string cancelButtonText) { MessageBoxResult result = CustomMessageBox.ShowOKCancel(messageBoxText, caption, okButtonText, cancelButtonText); if (result == MessageBoxResult.Cancel) { return(false); } else { return(true); } }
private void Update() { var d = Application.Current.Dispatcher; Action <int, int, string> lambdaSetFull = (v, m, t) => { d.Invoke(() => { Progress.Maximum = m; Progress.Value = v; InfoBox.Text = t; }); }; Action <string> lambdaFail = (t) => d.Invoke(() => Fail(t)); Action <string, bool> lambdaShowMessage = (m, c) => { d.Invoke(() => { if (c) { var r = CustomMessageBox.ShowOKCancel(m, "AlephNote AutoUpdater", "Continue", "Abort"); if (r != MessageBoxResult.OK) { Environment.Exit(-1); } } else { MessageBox.Show(m, "AlephNote AutoUpdater", MessageBoxButton.OK); } }); }; var updater = new ANUpdater(lambdaSetFull, lambdaFail, lambdaShowMessage, sourcePath, targetPath); try { updater.Run(); } catch (Exception e) { MessageBox.Show("AutoUpdater threw internal error:" + Environment.NewLine + e, "INTERNAL ERROR", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(-1); } d.Invoke(Close); }
/// <summary> /// Export receipt to pdf or excel /// </summary> private void ExportReceipt() { var result = CustomMessageBox.ShowOKCancel( "Which way do you want to export your receipt?", "Export receipt", "PDF", "Excel"); if (result == MessageBoxResult.OK) { WriteToPdf(); } if (result == MessageBoxResult.Cancel) { WriteToExcel(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (callClose) { var confirmResult = CustomMessageBox.ShowOKCancel(Properties.Resources.ExitDialogText, Properties.Resources.ExitDialogTitle, Properties.Resources.Yes, Properties.Resources.No); if (confirmResult == MessageBoxResult.Cancel) { e.Cancel = true; } if (confirmResult == MessageBoxResult.OK) { Environment.Exit(0); } } }
public MessageBoxResult ShowMessage(MessageViewModel model) { switch (model.Buttons) { case MessageBoxButton.OK: return(CustomMessageBox.ShowOK( model.Message, model.Title, model.OkText ?? MsgBoxStrings.Ok, model.Icon)); case MessageBoxButton.OKCancel: return(CustomMessageBox.ShowOKCancel( model.Message, model.Title, model.OkText ?? MsgBoxStrings.Ok, model.CancelText ?? MsgBoxStrings.Cancel, model.Icon)); case MessageBoxButton.YesNoCancel: return(CustomMessageBox.ShowYesNoCancel( model.Message, model.Title, model.OkText ?? MsgBoxStrings.Ok, model.NoText ?? MsgBoxStrings.No, model.CancelText ?? MsgBoxStrings.Cancel, model.Icon)); case MessageBoxButton.YesNo: return(CustomMessageBox.ShowYesNo( model.Message, model.Title, model.OkText ?? MsgBoxStrings.Ok, model.NoText ?? MsgBoxStrings.No, model.Icon)); default: throw new ArgumentException("Unknown enum value.", nameof(model.Buttons)); } }
private void SaveEdits() { if (CustomMessageBox.ShowOKCancel("Вы действительно хотите сохранить изменения?", "Предупреждение", "Сохранить", "Отменить") == MessageBoxResult.OK) { NPOImethods methods = new NPOImethods(); for (int i = 0; i < Data.Rows.Count; i++) { string[] currentRow = new string[methods.ColumsCnt]; for (int j = 0; j < methods.ColumsCnt; j++) { currentRow[j] = Data.Rows[i].Cells[j].Value.ToString(); } methods.SetNewValueInRow(currentRow, i + methods.startRow); } SaveEdits_button.Enabled = false; Abort_button.Enabled = false; } else { loadData(); } }
public void DoMergeImport(string otherFileName) { // our... var our = GetConfiguration(); var imported = new Configuration(); // read second try { using (var file = File.OpenRead(otherFileName)) { imported.Load(file); } } catch (Exception ex) { MessageBox.Show("Could not open file for import: " + ex.Message); return; } // merge Merge.Result result; try { result = Merge.Perform(our, imported); } catch (Exception ex) { MessageBox.Show("Could not merge from imported file : " + ex.Message); return; } // preview result... var sb = new StringBuilder(); int changes = 0; var noChanges = result.SitesMerged.Where(m => m.Which == Merge.MergedEntry.Resolution.Identical).ToList(); sb.AppendLine("Identical: " + noChanges.Count + " entries"); var firstNew = result.SitesMerged.Where(m => m.Which == Merge.MergedEntry.Resolution.FirstNew).ToList(); if (firstNew.Count > 0) { // this is just interesting and will not result in changes here sb.AppendLine("Will not affect import - not found in imported: " + firstNew.Count + " entries"); foreach (var item in firstNew) { sb.AppendLine(" site: " + item.First.SiteName + " (login='******' c=" + item.First.Counter + " t=" + item.First.Type + ")"); } } var firstNewer = result.SitesMerged.Where(m => m.Which == Merge.MergedEntry.Resolution.FirstNewer).ToList(); if (firstNewer.Count > 0) { // this is just interesting and will not result in changes here sb.AppendLine("Will not affect import - older in imported: " + firstNewer.Count + " entries"); foreach (var item in firstNewer) { sb.AppendLine(" site: " + item.Second.SiteName + " (login='******' c=" + item.Second.Counter + " t=" + item.Second.Type + ")"); } } var secondNew = result.SitesMerged.Where(m => m.Which == Merge.MergedEntry.Resolution.SecondNew).ToList(); if (secondNew.Count > 0) { changes += secondNew.Count; sb.AppendLine("Would be added: " + secondNew.Count + " entries"); foreach (var item in secondNew) { sb.AppendLine(" site: " + item.Second.SiteName + " (login='******' c=" + item.Second.Counter + " t=" + item.Second.Type + ")"); } } var secondNewer = result.SitesMerged.Where(m => m.Which == Merge.MergedEntry.Resolution.SecondNewer).ToList(); if (secondNewer.Count > 0) { changes += secondNewer.Count; sb.AppendLine("Would be updated: " + secondNewer.Count + " entries"); foreach (var item in secondNewer) { sb.AppendLine(" site: " + item.Second.SiteName + " (login='******' c=" + item.Second.Counter + " t=" + item.Second.Type + ")"); } } var conflicts = result.SitesMerged.Where(m => m.Which == Merge.MergedEntry.Resolution.Conflict).ToList(); if (conflicts.Count > 0) { changes += conflicts.Count; sb.AppendLine("Conflicts: " + conflicts.Count + " entries (would be added)"); foreach (var item in conflicts) { sb.AppendLine(" site: " + item.Second.SiteName + " (login='******' c=" + item.Second.Counter + " t=" + item.Second.Type + ")"); } } if (changes == 0) { // no changes found CustomMessageBox.Show("Merge found no candidates for changes.", "Import for Merge"); return; } sb.AppendLine(); sb.AppendLine("Summary Of Planned Changes:"); sb.AppendLine(" Add=" + secondNew.Count + " (new) Update=" + secondNewer.Count + " Add=" + conflicts.Count + " (conflict)"); if (CustomMessageBox.ShowOKCancel(sb.ToString(), "Do you want to apply these changes?", "Apply Changes", "Cancel") != MessageBoxResult.OK) { // not sure return; } // OK, apply changes foreach (var add in secondNew) { our.Sites.Add(add.Second); } foreach (var update in secondNewer) { // update.First is the original item in our.Sites -> update all from second update.First.Counter = update.Second.Counter; update.First.Login = update.Second.Login; update.First.Type = update.Second.Type; } foreach (var conflict in conflicts) { for (int i = 0; i < our.Sites.Count; i++) { if (our.Sites[i] == conflict.First) { // add here, after the original our.Sites.Insert(i + 1, conflict.Second); break; } } } // Update UI SynchronizeLists.Sync(Sites, our.Sites, siteXml => { var site = new ConfigurationSiteViewModel(); site.Login.Value = siteXml.Login; site.SiteName.Value = siteXml.SiteName; site.Counter.Value = siteXml.Counter; site.TypeOfPassword.Value = siteXml.Type; return(site); }); SelectedItem.Value = Sites.FirstOrDefault(); }