コード例 #1
0
 public void AddToSubMenus(MenuContainerLevelTwo subMenu)
 {
     subMenus.Add(subMenu);
 }
コード例 #2
0
        public MenuButton(List <Connections.AtiranAccModel.Menu> menuData_, Connections.AtiranAccModel.Menu self_, MenuContainer parent_)
        {
            this.Margin = new Padding(0);
            menuData    = menuData_;
            self        = self_;
            children    = menuData.Where(md => md.ParentMenuID == self.MenuID).OrderBy(i => i.order).ToList();
            parent      = parent_;
            parent.AddItem(this);
            tlp                = new ToolTip();
            tlp.OwnerDraw      = true;
            tlp.Draw          += Tlp_Draw;
            tlp.Popup         += Tlp_Popup;
            this.FlowDirection = FlowDirection.RightToLeft;

            rightSpace = new Panel();

            rightSpace.Height = this.Height;
            rightSpace.Margin = new Padding(0);
            this.Controls.Add(rightSpace);

            title = new Label();
            if (children.Count > 0)
            {
                title.Image      = ResourceManager.GetResourceManager().GetObject("sort_down_green") as Image;
                title.ImageAlign = ContentAlignment.MiddleLeft;
                title.Padding    = new Padding(5, 0, 0, 0);
            }
            title.TextAlign = ContentAlignment.MiddleRight;
            title.Text      = (self_.Titel.Length > title.Width) ? " ... " + self_.Titel.Remove(self_.Titel.LastIndexOf(' ')).ToString() : self_.Titel;
            title.Tag       = self_.MenuID;
            title.Height    = this.Height;
            title.Margin    = new Padding(0);

            this.Controls.Add(title);

            this.ControlAdded += MenuButton_ControlAdded;
            this.Enter        += MenuButton_Enter;
            childContainer     = new MenuContainerLevelTwo((Atiran.UI.WindowsForms.UIElements.Form) this.Parent.Parent, (MenuContainer)this.parent, this);
            ((Atiran.UI.WindowsForms.UIElements.Form) this.Parent.Parent).AddToSubMenus(childContainer);
            childContainer.Visible = false;

            if (children != null && children.Count > 0)
            {
                foreach (Connections.AtiranAccModel.Menu c in children)
                {
                    MenuButtonLevelTwo mb = new MenuButtonLevelTwo(menuData, c, childContainer);
                }
            }
            childContainer.Top = this.Top + 69;

            //childContainer.Left = this.parent.Left - 200;
            this.BackColor              = Color.FromArgb(56, 79, 99);
            this.ForeColor              = Color.FromArgb(255, 255, 255);
            this.title.MouseMove       += MenuButtonMouseMove;
            this.title.MouseLeave      += MenuButton_MouseLeave;
            this.title.MouseEnter      += MenuButton_MouseEnter;
            this.title.Click           += MenuButton_Click;
            this.rightSpace.MouseMove  += MenuButtonMouseMove;
            this.rightSpace.MouseLeave += MenuButton_MouseLeave;
            this.rightSpace.MouseEnter += MenuButton_MouseEnter;
            this.rightSpace.Click      += MenuButton_Click;
            this.MouseHover            += MenuButton_MouseHover;
        }