예제 #1
0
        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();
            }
        }