Exemplo n.º 1
0
        public bool Execute(List <CodeMember> codeMembers, Options options, Action <List <CodeMember> > sortMembers)
        {
            this.observableMembers = new ObservableCollection <CodeMember>(codeMembers);
            this.list.ItemsSource  = this.observableMembers;
            this.sortMembers       = sortMembers;
            this.list.SelectAll();
            this.onlyShowWhenShiftIsPressed.IsChecked = options.OnlyShowSortMembersDialogWhenShiftIsPressed;

            // http://www.wpf-tutorial.com/listview-control/listview-grouping/
            // Note: We'll group by the TypeDescription property, which will be bound to the GroupItem.Name property.
            // Then the XAML will use the GroupItem.Name to extract the type kind image (via ImageNameToSourceConverter).
            CollectionView           view             = (CollectionView)CollectionViewSource.GetDefaultView(this.list.ItemsSource);
            PropertyGroupDescription groupDescription = new("TypeDescription");

            view.GroupDescriptions.Add(groupDescription);

            bool result = false;

            if (this.ShowModal().GetValueOrDefault())
            {
                codeMembers.Clear();
                codeMembers.AddRange(this.observableMembers);

                options.OnlyShowSortMembersDialogWhenShiftIsPressed = this.onlyShowWhenShiftIsPressed.IsChecked.GetValueOrDefault();
                options.SaveSettingsToStorage();

                result = true;
            }

            return(result);
        }
Exemplo n.º 2
0
        public bool Execute(Options options)
        {
            LineOptions lineOptions = options.LineOptions;

            this.caseSensitive.IsChecked              = lineOptions.HasFlag(LineOptions.CaseSensitive);
            this.compareByOrdinal.IsChecked           = lineOptions.HasFlag(LineOptions.ByOrdinal);
            this.descending.IsChecked                 = lineOptions.HasFlag(LineOptions.Descending);
            this.ignoreWhitespace.IsChecked           = lineOptions.HasFlag(LineOptions.IgnoreWhitespace);
            this.ignorePunctuation.IsChecked          = lineOptions.HasFlag(LineOptions.IgnorePunctuation);
            this.wholeLines.IsChecked                 = lineOptions.HasFlag(LineOptions.WholeLines);
            this.eliminateDuplicates.IsChecked        = lineOptions.HasFlag(LineOptions.EliminateDuplicates);
            this.compareByLength.IsChecked            = lineOptions.HasFlag(LineOptions.ByLength);
            this.onlyShowWhenShiftIsPressed.IsChecked = options.OnlyShowSortLinesDialogWhenShiftIsPressed;

            bool result = false;

            if (this.ShowModal().GetValueOrDefault())
            {
                lineOptions = LineOptions.None;
                void AddOption(CheckBox checkBox, LineOptions option)
                {
                    if (checkBox.IsChecked.GetValueOrDefault())
                    {
                        lineOptions |= option;
                    }
                }

                AddOption(this.caseSensitive, LineOptions.CaseSensitive);
                AddOption(this.compareByOrdinal, LineOptions.ByOrdinal);
                AddOption(this.descending, LineOptions.Descending);
                AddOption(this.ignoreWhitespace, LineOptions.IgnoreWhitespace);
                AddOption(this.ignorePunctuation, LineOptions.IgnorePunctuation);
                AddOption(this.wholeLines, LineOptions.WholeLines);
                AddOption(this.eliminateDuplicates, LineOptions.EliminateDuplicates);
                AddOption(this.compareByLength, LineOptions.ByLength);
                options.LineOptions = lineOptions;

                options.OnlyShowSortLinesDialogWhenShiftIsPressed = this.onlyShowWhenShiftIsPressed.IsChecked.GetValueOrDefault();

                options.SaveSettingsToStorage();
                result = true;
            }

            return(result);
        }