public MessageBoxResult ShowCheckedMessageBox(string message, string caption, string checkedMessage, ref bool?isChecked, MessageBoxButton button, MessageBoxImage image) { var parentWindow = ParentWindow; var localIsChecked = isChecked; var result = dispatcher.Invoke(() => CheckedMessageBox.Show(parentWindow, message, caption, button, image, checkedMessage, ref localIsChecked)); isChecked = localIsChecked; return(result); }
private void GenerateWdlButton_OnClick(object sender, RoutedEventArgs e) { var mapManager = WorldFrame.Instance.MapManager; if (mapManager.Continent == null) { MessageBox.Show("You have not entered the world yet. Cannot generate WDL."); return; } if (CheckedMessageBox.Show("Autosave for WDL", Strings.Message_AutosaveOnWdl, CheckedMessageBox.TagSaveOnWdlGeneration)) { WorldFrame.Instance.MapManager.OnSaveAllFiles(); } GenerateWdlButton.IsEnabled = false; var loadDialog = new WdlLoadingDialog(); Action <string, float> progressCallback = (action, progress) => { loadDialog.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { loadDialog.Progress = Math.Max(Math.Min(progress * 100, 100), 0); loadDialog.Action = action; })); }; WdlGenerator.Generate(mapManager.Continent, progressCallback, () => loadDialog.Dispatcher.BeginInvoke(new Action(() => { GenerateWdlButton.IsEnabled = true; loadDialog.ShouldClose = true; loadDialog.Close(); }))); loadDialog.Owner = Window.GetWindow(this); loadDialog.ShowDialog(); }