表示 ToolBar 控件中的单个项。
Example #1
0
 /// <summary>
 /// 引发 System.Windows.Forms.Form.MouseDown 事件。
 /// </summary>
 /// <param name="e">包含事件数据的 System.Windows.Forms.MouseEventArgs。</param>
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (!this.DesignMode)
     {
         Point point = e.Location;
         foreach (ToolItem item in this.Items)
         {
             if (item.Rectangle.Contains(point))
             {
                 if (item != this.SelectedItem)
                 {
                     this._selectedItem = item;
                     this.OnSelectedItemChanged(EventArgs.Empty);
                     this._selectedIndex = this.Items.GetIndexOfRange(item);
                     this.OnSelectedIndexChanged(EventArgs.Empty);
                     this.Invalidate();
                 }
             }
             else
             {
                 item.MouseState = EMouseState.Normal;
                 this.Invalidate(item.Rectangle);
             }
         }
     }
 }
Example #2
0
 /// <summary>
 /// 引发 System.Windows.Forms.Form.MouseDown 事件。
 /// </summary>
 /// <param name="e">包含事件数据的 System.Windows.Forms.MouseEventArgs。</param>
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (!this.DesignMode)
     {
         Point point = e.Location;
         foreach (ToolItem item in this.Items)
         {
             if (item.Rectangle.Contains(point))
             {
                 if (item != this.SelectedItem)
                 {
                     this._selectedItem = item;
                     this.OnSelectedItemChanged(EventArgs.Empty);
                     this._selectedIndex = this.Items.GetIndexOfRange(item);
                     this.OnSelectedIndexChanged(EventArgs.Empty);
                     this.Invalidate();
                 }
             }
             else
             {
                 item.MouseState = EMouseState.Normal;
                 this.Invalidate(item.Rectangle);
             }
         }
     }
 }