Esempio n. 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            ToolBoxItem item = GetToolboxItemByPoint(e.Location);

            if (item != null)
            {
                if (item is ToolBoxCategory)
                {
                    ToolBoxCategory tbc = item as ToolBoxCategory;
                    tbc.IsOpen = !tbc.IsOpen;
                    RefreshScrollBar();
                    Invalidate();
                }
                else
                {
                    _selectedItem = item;

                    if (null != SelectedItemChanged)
                    {
                        SelectedItemChanged(this, _selectedItem);
                    }
                    if (2 == e.Clicks && null != ItemDoubleClicked)
                    {
                        ItemDoubleClicked(this, _selectedItem);
                    }

                    Invalidate();
                }
            }
            Focus();
        }
Esempio n. 2
0
        private void OnCategoryCollectionChanged(Object sender, CollectionChangeEventArgs e)
        {
            ToolBoxCategory tbc = e.Element as ToolBoxCategory;

            if (e.Action == CollectionChangeAction.Add)
            {
                tbc.Items.ItemChanged += new CollectionChangeEventHandler(OnCategoryItemChanged);
            }
            else if (e.Action == CollectionChangeAction.Remove)
            {
                tbc.Items.ItemChanged -= new CollectionChangeEventHandler(OnCategoryItemChanged);
            }
            Invalidate();
        }