"Fossies" - the Fresh Open Source Software Archive

Member "PowerShell-7.2.6/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/AddFilterRulePicker.cs" (11 Aug 2022, 3461 Bytes) of package /linux/misc/PowerShell-7.2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C# source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AddFilterRulePicker.cs" see the Fossies "Dox" file reference documentation.

    1 // Copyright (c) Microsoft Corporation.
    2 // Licensed under the MIT License.
    3 
    4 using System;
    5 using System.Collections.ObjectModel;
    6 using System.ComponentModel;
    7 using System.Windows.Controls;
    8 
    9 namespace Microsoft.Management.UI.Internal
   10 {
   11     /// <summary>
   12     /// The AddFilterRulePicker class is responsible for allowing users to
   13     /// add rules to an FilterRulePanel.
   14     /// </summary>
   15     [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
   16     public partial class AddFilterRulePicker : Control
   17     {
   18         #region Properties
   19 
   20         private ObservableCollection<AddFilterRulePickerItem> shortcutFilterRules = new ObservableCollection<AddFilterRulePickerItem>();
   21 
   22         /// <summary>
   23         /// Gets the collection of shortcut rules available for addition to the FilterRulePanel.
   24         /// </summary>
   25         public ObservableCollection<AddFilterRulePickerItem> ShortcutFilterRules
   26         {
   27             get
   28             {
   29                 return this.shortcutFilterRules;
   30             }
   31         }
   32 
   33         private ObservableCollection<AddFilterRulePickerItem> columnFilterRules = new ObservableCollection<AddFilterRulePickerItem>();
   34 
   35         /// <summary>
   36         /// Gets the collection of column rules available for addition to the FilterRulePanel.
   37         /// </summary>
   38         public ObservableCollection<AddFilterRulePickerItem> ColumnFilterRules
   39         {
   40             get
   41             {
   42                 return this.columnFilterRules;
   43             }
   44         }
   45 
   46         #endregion Properties
   47 
   48         #region Private Methods
   49 
   50         partial void OnOkAddFilterRulesCanExecuteImplementation(System.Windows.Input.CanExecuteRoutedEventArgs e)
   51         {
   52             e.CanExecute = (this.AddFilterRulesCommand != null)
   53                 ? CommandHelper.CanExecuteCommand(this.AddFilterRulesCommand, null, this.AddFilterRulesCommandTarget)
   54                 : false;
   55         }
   56 
   57         partial void OnOkAddFilterRulesExecutedImplementation(System.Windows.Input.ExecutedRoutedEventArgs e)
   58         {
   59             this.IsOpen = false;
   60 
   61             Collection<FilterRulePanelItem> addedRules = new Collection<FilterRulePanelItem>();
   62 
   63             foreach (AddFilterRulePickerItem item in this.shortcutFilterRules)
   64             {
   65                 if (item.IsChecked)
   66                 {
   67                     addedRules.Add(item.FilterRule);
   68                     item.IsChecked = false;
   69                 }
   70             }
   71 
   72             foreach (AddFilterRulePickerItem item in this.columnFilterRules)
   73             {
   74                 if (item.IsChecked)
   75                 {
   76                     addedRules.Add(item.FilterRule);
   77                     item.IsChecked = false;
   78                 }
   79             }
   80 
   81             if (addedRules.Count > 0)
   82             {
   83                 CommandHelper.ExecuteCommand(this.AddFilterRulesCommand, addedRules, this.AddFilterRulesCommandTarget);
   84             }
   85         }
   86 
   87         partial void OnCancelAddFilterRulesExecutedImplementation(System.Windows.Input.ExecutedRoutedEventArgs e)
   88         {
   89             this.IsOpen = false;
   90 
   91             foreach (AddFilterRulePickerItem item in this.shortcutFilterRules)
   92             {
   93                 item.IsChecked = false;
   94             }
   95 
   96             foreach (AddFilterRulePickerItem item in this.columnFilterRules)
   97             {
   98                 item.IsChecked = false;
   99             }
  100         }
  101 
  102         #endregion Private Methods
  103     }
  104 }