public async Task <AcControlsConflictSolution> Resolve(string inputDisplayName, IEnumerable <string> existingAssignments) { var list = existingAssignments.Select(x => $"“{x}”").ToList(); var message = list.Count > 1 ? string.Format(AppStrings.Controls_AlreadyUsed_MultipleMessage, inputDisplayName, list.SkipLast(1).JoinToString(@", "), list.Last()) : string.Format(AppStrings.Controls_AlreadyUsed_Message, inputDisplayName, list.First()); var dlg = new ModernDialog { Title = AppStrings.Controls_AlreadyUsed, Content = new ScrollViewer { Content = new BbCodeBlock { BbCode = message, Margin = new Thickness(0, 0, 0, 8) }, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled }, MinHeight = 0, MinWidth = 0, MaxHeight = 480, MaxWidth = 640 }; dlg.Buttons = new[] { dlg.CreateCloseDialogButton(AppStrings.Controls_RemoveOld, true, false, MessageBoxResult.Yes), dlg.CreateCloseDialogButton(AppStrings.Controls_ApplyToAll, false, false, MessageBoxResult.No), dlg.CreateCloseDialogButton(AppStrings.Controls_SwapUsings, false, false, MessageBoxResult.OK), dlg.CreateCloseDialogButton(UiStrings.Cancel, false, true, MessageBoxResult.Cancel), }; await dlg.ShowDialogAsync(); switch (dlg.MessageBoxResult) { case MessageBoxResult.Yes: return(AcControlsConflictSolution.ClearPrevious); case MessageBoxResult.No: return(AcControlsConflictSolution.KeepEverything); case MessageBoxResult.OK: return(AcControlsConflictSolution.Flip); case MessageBoxResult.Cancel: return(AcControlsConflictSolution.Cancel); default: throw new ArgumentOutOfRangeException(); } }
public static Button CreateFixItButton([NotNull] this ModernDialog dlg, [CanBeNull] NonfatalErrorSolution solution, NonfatalErrorEntry entry = null) { if (dlg == null) { throw new ArgumentNullException(nameof(dlg)); } return(solution == null ? null : dlg.CreateCloseDialogButton(solution.DisplayName, false, false, MessageBoxResult.OK, solution)); }
private static bool ShowStarterDoesNotFitMessage() { var dlg = new ModernDialog { Title = ToolsStrings.Common_Warning, Content = new ScrollViewer { Content = new SelectableBbCodeBlock { BbCode = $"You’re using {SettingsHolder.Drive.SelectedStarterType.DisplayName} Starter. With it, you won’t get a Steam achievment, so progress won’t be saved. Are you sure you want to continue?", Margin = new Thickness(0, 0, 0, 8) }, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled }, MinHeight = 0, MinWidth = 0, MaxHeight = 480, MaxWidth = 640 }; dlg.Buttons = new[] { dlg.YesButton, dlg.CreateCloseDialogButton("Switch To Official Starter", false, false, MessageBoxResult.OK), dlg.NoButton }; dlg.ShowDialog(); switch (dlg.MessageBoxResult) { case MessageBoxResult.Yes: return(true); case MessageBoxResult.OK: SettingsHolder.Drive.SelectedStarterType = SettingsHolder.Drive.StarterTypes.First(); return(true); case MessageBoxResult.None: case MessageBoxResult.Cancel: case MessageBoxResult.No: return(false); default: throw new ArgumentOutOfRangeException(); } }
private static TrackDoesNotFitRespond ShowTrackDoesNotFitMessage(string message) { var dlg = new ModernDialog { Title = ToolsStrings.Common_Warning, Content = new ScrollViewer { Content = new SelectableBbCodeBlock { BbCode = $"Most likely, track won’t work with selected mode: {message.ToSentenceMember()}. Are you sure you want to continue?", Margin = new Thickness(0, 0, 0, 8) }, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled }, MinHeight = 0, MinWidth = 0, MaxHeight = 480, MaxWidth = 640 }; dlg.Buttons = new[] { dlg.YesButton, dlg.CreateCloseDialogButton("Yes, And Fix It", false, false, MessageBoxResult.OK), dlg.NoButton }; dlg.ShowDialog(); switch (dlg.MessageBoxResult) { case MessageBoxResult.Yes: return(TrackDoesNotFitRespond.Go); case MessageBoxResult.OK: return(TrackDoesNotFitRespond.FixAndGo); case MessageBoxResult.None: case MessageBoxResult.Cancel: case MessageBoxResult.No: return(TrackDoesNotFitRespond.Cancel); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Shows dialog with all information about shared entry and offers a choise to user what to do with it. /// </summary> /// <param name="shared">Shared entry.</param> /// <param name="additionalButton">Label of additional button.</param> /// <param name="saveable">Can be saved.</param> /// <param name="applyable">Can be applied.</param> /// <param name="appliableWithoutSaving">Can be applied without saving.</param> /// <returns>User choise.</returns> private Choise ShowDialog(SharedEntry shared, string additionalButton = null, bool saveable = true, bool applyable = true, bool appliableWithoutSaving = true) { var description = string.Format(AppStrings.Arguments_SharedMessage, shared.Name ?? AppStrings.Arguments_SharedMessage_EmptyValue, shared.EntryType == SharedEntryType.Weather ? AppStrings.Arguments_SharedMessage_Id : AppStrings.Arguments_SharedMessage_For, shared.Target ?? AppStrings.Arguments_SharedMessage_EmptyValue, shared.Author ?? AppStrings.Arguments_SharedMessage_EmptyValue); var dlg = new ModernDialog { Title = shared.EntryType.GetDescription().ToTitle(), Content = new ScrollViewer { Content = new BbCodeBlock { BbCode = description + '\n' + '\n' + ( saveable ? AppStrings.Arguments_Shared_ShouldApplyOrSave : AppStrings.Arguments_Shared_ShouldApply), Margin = new Thickness(0, 0, 0, 8) }, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled }, MinHeight = 0, MinWidth = 0, MaxHeight = 480, MaxWidth = 640 }; dlg.Buttons = new[] { applyable&& saveable?dlg.CreateCloseDialogButton( appliableWithoutSaving?AppStrings.Arguments_Shared_ApplyAndSave : AppStrings.Arguments_Shared_SaveAndApply, true, false, MessageBoxResult.Yes) : null, appliableWithoutSaving&& applyable ? dlg.CreateCloseDialogButton(saveable ? AppStrings.Arguments_Shared_ApplyOnly : AppStrings.Arguments_Shared_Apply, true, false, MessageBoxResult.OK) : null, saveable ? dlg.CreateCloseDialogButton( applyable && appliableWithoutSaving ? AppStrings.Arguments_Shared_SaveOnly : AppStrings.Toolbar_Save, true, false, MessageBoxResult.No) : null, additionalButton == null ? null : dlg.CreateCloseDialogButton(additionalButton, true, false, MessageBoxResult.None), dlg.CancelButton }.NonNull(); dlg.ShowDialog(); switch (dlg.MessageBoxResult) { case MessageBoxResult.None: return(Choise.Extra); case MessageBoxResult.OK: return(Choise.Apply); case MessageBoxResult.Cancel: return(Choise.Cancel); case MessageBoxResult.Yes: return(Choise.ApplyAndSave); case MessageBoxResult.No: return(Choise.Save); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Shows dialog with all information about shared entry and offers a choise to user what to do with it. /// </summary> /// <param name="shared">Shared entry.</param> /// <param name="justGo">Apply instantaneously</param> /// <param name="additionalButton">Label of additional button.</param> /// <param name="saveable">Can be saved.</param> /// <param name="applyable">Can be applied.</param> /// <param name="appliableWithoutSaving">Can be applied without saving.</param> /// <returns>User choise.</returns> private static Choise ShowDialog(SharedEntry shared, bool justGo, string additionalButton = null, bool saveable = true, bool applyable = true, bool appliableWithoutSaving = true) { if (justGo) { if (additionalButton == AppStrings.Arguments_Shared_JustGo) { return(Choise.Extra); } if (applyable) { return(Choise.Apply); } } if (shared.LocalSource != null && FileUtils.IsAffectedBy(shared.LocalSource, PresetsManager.Instance.RootDirectory)) { saveable = false; } var description = shared.LocalSource != null ? string.Format(AppStrings.Arguments_SharedMessage_LocalSource, shared.Name ?? AppStrings.Arguments_SharedMessage_EmptyValue) : string.Format(AppStrings.Arguments_SharedMessage, shared.Name ?? AppStrings.Arguments_SharedMessage_EmptyValue, shared.EntryType == SharedEntryType.Weather ? AppStrings.Arguments_SharedMessage_Id : AppStrings.Arguments_SharedMessage_For, shared.Target ?? AppStrings.Arguments_SharedMessage_EmptyValue, shared.Author ?? AppStrings.Arguments_SharedMessage_EmptyValue); var dlg = new ModernDialog { Title = shared.EntryType.GetDescription().ToTitle(), Content = new ScrollViewer { Content = new BbCodeBlock { Text = description + '\n' + '\n' + ( saveable ? AppStrings.Arguments_Shared_ShouldApplyOrSave : AppStrings.Arguments_Shared_ShouldApply), Margin = new Thickness(0, 0, 0, 8) }, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled }, MinHeight = 0, MinWidth = 0, MaxHeight = 480, MaxWidth = 640, DoNotAttachToWaitingDialogs = true }; dlg.Buttons = new[] { applyable&& saveable?dlg.CreateCloseDialogButton( appliableWithoutSaving?AppStrings.Arguments_Shared_ApplyAndSave : AppStrings.Arguments_Shared_SaveAndApply, true, false, MessageBoxResult.Yes) : null, appliableWithoutSaving&& applyable ? dlg.CreateCloseDialogButton(saveable ? AppStrings.Arguments_Shared_ApplyOnly : AppStrings.Arguments_Shared_Apply, true, false, MessageBoxResult.OK) : null, saveable ? dlg.CreateCloseDialogButton( applyable && appliableWithoutSaving ? AppStrings.Arguments_Shared_SaveOnly : AppStrings.Toolbar_Save, true, false, MessageBoxResult.No) : null, additionalButton == null ? null : dlg.CreateCloseDialogButton(additionalButton, true, false, MessageBoxResult.None), dlg.CancelButton }.NonNull(); dlg.ShowDialog(); switch (dlg.MessageBoxResult) { case MessageBoxResult.None: return(Choise.Extra); case MessageBoxResult.OK: return(Choise.Apply); case MessageBoxResult.Cancel: return(Choise.Cancel); case MessageBoxResult.Yes: return(Choise.ApplyAndSave); case MessageBoxResult.No: return(Choise.Save); default: throw new ArgumentOutOfRangeException(); } }