Advertisement
Nickun

GroupPluginFilterControl

Jun 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. using ConnectAPI;
  8.  
  9. namespace CommonControls
  10. {
  11.     public partial class GroupPluginFilterControl : UserControl, IPluginFilter
  12.     {
  13.         protected CommandManagerTimer commandManager = new CommandManagerTimer(SystemSettings.KeyboardRepeatDelay);
  14.  
  15.         private WorkflowItemsFilter _wfiFilter;
  16.  
  17.         public GroupPluginFilterControl()
  18.         {
  19.             InitializeComponent();
  20.             Initialization();
  21.         }
  22.  
  23.         private void Initialization()
  24.         {
  25.             treeList.StateChanged += TreeList_StateChanged;
  26.             treeList.AfterCheckNode += TreeList_AfterCheckNode;
  27.  
  28.             // moved here from the base class
  29.             treeList.FocusChanged += TreeList_FocusChanged;
  30.         }
  31.  
  32.  
  33.         private void TreeList_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
  34.         {
  35.             commandManager.ExecuteCommand(HashedCommand.Create(OnCheckedChanged));
  36.         }
  37.  
  38.         private void TreeList_StateChanged(object sender, EventArgs e)
  39.         {
  40.             commandManager.ExecuteCommand(HashedCommand.Create(OnCheckedChanged));
  41.         }
  42.  
  43.         private void TreeList_FocusChanged(object sender, EventArgs e)
  44.         {
  45.             commandManager.ExecuteCommand(HashedCommand.Create(OnFocusChanged));
  46.         }
  47.  
  48.         protected void OnFocusChanged()
  49.         {
  50.             _wfiFilter.FocusedGroup = treeList.FocusedObject as BaseUIObject;
  51.         }
  52.  
  53.         protected void OnCheckedChanged()
  54.         {
  55.             _wfiFilter.CheckedGroups = GetCheckedItems();
  56.         }
  57.  
  58.         private IEnumerable<BaseUIObject> GetCheckedItems()
  59.         {
  60.             return !CheckMode ?
  61.                 new BaseUIObject[0] :
  62.                 treeList
  63.                     //.TreeNodeCollection.Where(node => node.CheckState == CheckState.Checked)
  64.                     .GetAllCheckedNodes()
  65.                     .Select(node => treeList.GetDataSourceObject(node) as BaseUIObject);
  66.         }
  67.  
  68.         private bool CheckMode
  69.         {
  70.             get { return treeList.OptionsView.ShowCheckBoxes; }
  71.             set
  72.             {
  73.                 //bool needMembersReset = value != CheckMode;
  74.  
  75.                 treeList.OptionsView.ShowCheckBoxes = value;
  76.                 //treeList.OptionsView.ShowIndicator = !value;
  77.  
  78.                 treeList.OptionsSelection.InvertSelection = value;
  79.                 treeList.OptionsSelection.MultiSelect = !value;
  80.                 treeList.OptionsSelection.UseIndicatorForSelection = !value;
  81.  
  82.                 //if (needMembersReset)
  83.                 //    ResetMembers();
  84.             }
  85.         }
  86.  
  87.         public void OnPluginRegistered(BaseFilter filter)
  88.         {
  89.             _wfiFilter = filter as WorkflowItemsFilter;
  90.         }
  91.  
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement