Esempio n. 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 (UIToolBarItem 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 = MouseOperate.Normal;
                 this.Invalidate(item.Rectangle);
             }
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 跳到选择项
 /// </summary>
 /// <param name="index">索引</param>
 public void SelectIndex(int index)
 {
     if (index >= this._items.Count || index < 0)
     {
         return;
     }
     this._selectedItem  = _items[index];
     this._selectedIndex = index;
     this.Invalidate();
     this.OnSelectedIndexChanged(EventArgs.Empty);
 }