Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using ConnectAPI;
- namespace CommonControls
- {
- public partial class GroupPluginFilterControl : UserControl, IPluginFilter
- {
- protected CommandManagerTimer commandManager = new CommandManagerTimer(SystemSettings.KeyboardRepeatDelay);
- private WorkflowItemsFilter _wfiFilter;
- public GroupPluginFilterControl()
- {
- InitializeComponent();
- Initialization();
- }
- private void Initialization()
- {
- treeList.StateChanged += TreeList_StateChanged;
- treeList.AfterCheckNode += TreeList_AfterCheckNode;
- // moved here from the base class
- treeList.FocusChanged += TreeList_FocusChanged;
- }
- private void TreeList_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
- {
- commandManager.ExecuteCommand(HashedCommand.Create(OnCheckedChanged));
- }
- private void TreeList_StateChanged(object sender, EventArgs e)
- {
- commandManager.ExecuteCommand(HashedCommand.Create(OnCheckedChanged));
- }
- private void TreeList_FocusChanged(object sender, EventArgs e)
- {
- commandManager.ExecuteCommand(HashedCommand.Create(OnFocusChanged));
- }
- protected void OnFocusChanged()
- {
- _wfiFilter.FocusedGroup = treeList.FocusedObject as BaseUIObject;
- }
- protected void OnCheckedChanged()
- {
- _wfiFilter.CheckedGroups = GetCheckedItems();
- }
- private IEnumerable<BaseUIObject> GetCheckedItems()
- {
- return !CheckMode ?
- new BaseUIObject[0] :
- treeList
- //.TreeNodeCollection.Where(node => node.CheckState == CheckState.Checked)
- .GetAllCheckedNodes()
- .Select(node => treeList.GetDataSourceObject(node) as BaseUIObject);
- }
- private bool CheckMode
- {
- get { return treeList.OptionsView.ShowCheckBoxes; }
- set
- {
- //bool needMembersReset = value != CheckMode;
- treeList.OptionsView.ShowCheckBoxes = value;
- //treeList.OptionsView.ShowIndicator = !value;
- treeList.OptionsSelection.InvertSelection = value;
- treeList.OptionsSelection.MultiSelect = !value;
- treeList.OptionsSelection.UseIndicatorForSelection = !value;
- //if (needMembersReset)
- // ResetMembers();
- }
- }
- public void OnPluginRegistered(BaseFilter filter)
- {
- _wfiFilter = filter as WorkflowItemsFilter;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement