示例#1
0
 private void InternalSelectTool(IToolboxObject tool)
 {
     IToolboxObject previouslySelected = this.LastSelectedTool;
     if (tool is Item && !((Item) tool).Enabled) {
         tool = null;
     }
     this._lastSelectedTool = tool;
     if (previouslySelected != null && previouslySelected != this.LastSelectedTool) {
         if (previouslySelected is Tab) {
             ((Tab) previouslySelected).Selected = false;
         } else if (previouslySelected is Item) {
             ((Item) previouslySelected).Selected = false;
         }
     }
     if (this.LastSelectedTool != null) {
         Tab tab = this.LastSelectedTool as Tab;
         if (tab != null) {
             tab.Selected = true;
             return;
         }
         Item item = this.LastSelectedTool as Item;
         if (item != null) {
             if (this.LastSelectedItem != item) {
                 if (this.LastSelectedItem != null) {
                     this.LastSelectedItem.Selected = false;
                 }
                 this._lastSelectedItem = item;
             }
             item.Selected = true;
             if (item.Category != null && !item.Category.Opened) {
                 item.Category.Opened = true;
             }
             this.OnSelectItem(new ItemSelectionEventArgs(item));
             return;
         }
     }
 }
示例#2
0
 /// <summary>
 /// Selects a specified <paramref name="tool"/> on the <see cref="Toolbox"/>.
 /// </summary>
 /// <param name="tool">A <see cref="IToolboxObject"/> object to select.</param>
 protected virtual void SelectTool(IToolboxObject tool)
 {
     if (tool == null) {
         throw new ArgumentNullException("tool");
     }
     if (!tool.Visible) {
         throw new ArgumentException(Resources.ToolboxSelectNonVisibleTool);
     }
     if (tool is Item && !((Item) tool).Enabled) {
         throw new ArgumentException(Resources.ToolboxSelectDisabledItem);
     }
     this.InternalSelectTool(tool);
 }
示例#3
0
 internal HitTestInfo(Point location, HitArea area, IToolboxObject tool)
 {
     this._hitPoint = location;
     this._hitArea  = area;
     this._hitTool  = tool;
 }
示例#4
0
 /// <summary>
 /// Overriden.
 /// </summary>
 protected override void OnMouseDown(MouseEventArgs e)
 {
     this.InternalSelectTool(this.HitTest(e.Location).Tool);
     if (this.LastSelectedTool != null) {
         this._draggedTool = this.LastSelectedTool;
         Size dragSize = SystemInformation.DragSize;
         this._dragBoxFromMouseDown =
             new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize);
         Tab tab = this.LastSelectedTool as Tab;
         if (tab != null) {
             tab.InternalMouseDown(e);
         }
         Item item = this.LastSelectedTool as Item;
         if (item != null) {
             item.InternalMouseDown(e);
         }
     } else {
         this._dragBoxFromMouseDown = Rectangle.Empty;
     }
     base.OnMouseDown(e);
 }
 internal HitTestInfo(Point location, HitArea area, IToolboxObject tool)
 {
     this._hitPoint = location;
     this._hitArea = area;
     this._hitTool = tool;
 }