コード例 #1
0
ファイル: MenuStrip.cs プロジェクト: WardBenjamin/gwen-dotnet
 /// <summary>
 /// Add item handler.
 /// </summary>
 /// <param name="item">Item added.</param>
 protected override void OnAddItem(MenuItem item)
 {
     item.Dock = Pos.Left;
     item.TextPadding = new Padding(5, 0, 5, 0);
     item.Padding = new Padding(10, 0, 10, 0);
     item.SizeToContents();
     item.IsOnStrip = true;
     item.HoverEnter += OnHoverItem;
 }
コード例 #2
0
ファイル: ComboBox.cs プロジェクト: AreonDev/NoWayOut
        /// <summary>
        /// Internal handler for item selected event.
        /// </summary>
        /// <param name="control">Event source.</param>
		protected virtual void OnItemSelected(Base control, ItemSelectedEventArgs args)
        {
            if (!IsDisabled)
            {
                //Convert selected to a menu item
                MenuItem item = control as MenuItem;
                if (null == item) return;

                m_SelectedItem = item;
                Text = m_SelectedItem.Text;
                m_Menu.IsHidden = true;

                if (ItemSelected != null)
                    ItemSelected.Invoke(this, args);

                Focus();
                Invalidate();
            }
        }
コード例 #3
0
ファイル: ComboBox.cs プロジェクト: WardBenjamin/gwen-dotnet
        /// <summary>
        /// Internal handler for item selected event.
        /// </summary>
        /// <param name="control">Event source.</param>
        protected virtual void OnItemSelected(ControlBase control)
        {
            //Convert selected to a menu item
            MenuItem item = control as MenuItem;
            if (null == item) return;

            m_SelectedItem = item;
            Text = m_SelectedItem.Text;
            m_Menu.IsHidden = true;

            if (ItemSelected != null)
                ItemSelected.Invoke(this);

            Focus();
            Invalidate();
        }
コード例 #4
0
ファイル: Menu.cs プロジェクト: jcsnider/GWEN.Net-Unity
        /// <summary>
        /// Add item handler.
        /// </summary>
        /// <param name="item">Item added.</param>
        protected virtual void OnAddItem(MenuItem item)
        {
            item.TextPadding = new Padding(IconMarginDisabled ? 0 : 24, 0, 16, 0);
            item.Dock = Pos.Top;
            item.SizeToContents();
            item.Alignment = Pos.CenterV | Pos.Left;
            item.HoverEnter += OnHoverItem;

            // Do this here - after Top Docking these values mean nothing in layout
            int w = item.Width + 10 + 32;
            if (w < Width) w = Width;
            SetSize(w, Height);
        }
コード例 #5
0
ファイル: Menu.cs プロジェクト: jcsnider/GWEN.Net-Unity
        /// <summary>
        /// Adds a new menu item.
        /// </summary>
        /// <param name="text">Item text.</param>
        /// <param name="iconName">Icon texture name.</param>
        /// <param name="accelerator">Accelerator for this item.</param>
        /// <returns>Newly created control.</returns>
        public virtual MenuItem AddItem(string text, string iconName, string accelerator = "")
        {
            MenuItem item = new MenuItem(this);
            item.Padding = Padding.Four;
            item.SetText(text);
            item.SetImage(iconName);
            item.SetAccelerator(accelerator);

            OnAddItem(item);

            return item;
        }
コード例 #6
0
ファイル: ComboBox.cs プロジェクト: Sprunth/gwen-dotnet
 /// <summary>
 /// Selects the first menu item with the given user data it finds.
 /// If a menu item can not be found that matches input, nothing happens.
 /// </summary>
 /// <param name="userdata">The UserData to look for. The equivalency check uses "param.Equals(item.UserData)".
 /// If null is passed in, it will look for null/unset UserData.</param>
 public void SelectByUserData(object userdata)
 {
     foreach (var item in m_Menu.Children.Cast<MenuItem>())
     {
         if (userdata == null)
         {
             if (item.UserData == null)
             {
                 SelectedItem = item;
                 return;
             }
         }
         else if (userdata.Equals(item.UserData))
         {
             SelectedItem = item;
             return;
         }
     }
 }
コード例 #7
0
ファイル: ComboBox.cs プロジェクト: Sprunth/gwen-dotnet
 /// <summary>
 /// Selects the first menu item with the given text it finds. 
 /// If a menu item can not be found that matches input, nothing happens.
 /// </summary>
 /// <param name="text">The label to look for, this is what is shown to the user.</param>
 public void SelectByText(string text)
 {
     foreach (var item in m_Menu.Children.Cast<MenuItem>().Where(item => item.Text == text))
     {
         SelectedItem = item;
         return;
     }
 }
コード例 #8
0
ファイル: ComboBox.cs プロジェクト: Sprunth/gwen-dotnet
 /// <summary>
 /// Selects the first menu item with the given internal name it finds.
 /// If a menu item can not be found that matches input, nothing happens.
 /// </summary>
 /// <param name="name">The internal name to look for. To select by what is displayed to the user, use "SelectByText".</param>
 public void SelectByName(string name)
 {
     foreach (var item in m_Menu.Children.Cast<MenuItem>().Where(item => item.Name == name))
     {
         SelectedItem = item;
         return;
     }
 }