示例#1
0
        public void Add(MenuItemInfo itemInfo)
        {
            var creator = new MenuItem();
            var btn = creator.GetButton(itemInfo.ButtonText);
            var popup = creator.GetPopup(itemInfo.MenuContent);

            btn.Width = itemInfo.Width;
            btn.RenderRunClientMouseLeave = true;

            btn.Top = 5;
            if (this.Controls.Count > 0)
            {
                var lastControl = this.Controls[this.Controls.Count - 1];
                var left = lastControl.Left + lastControl.Width + 2;
                btn.Left = left;
            }
            else
            {
                btn.Left = 15;
            }
            this.Controls.Add(btn);

            string showAction = creator.GetButtonScript(true);
            string hideAction = creator.GetButtonScript(false);

            popup.DisplayMode = VWG.DisplayMode.Hidden;
            this.Form.Controls.Add(popup);
            popup.BringToFront();

            var showHide = Animate.Split(',');
            showAction = string.Format("vwg_showMenu('{0}',200,'{1}');", popup.ID, showHide[0]) + showAction;

            hideAction = string.Format("vwg_hideMenu('{0}',200,'{1}',120);", popup.ID, showHide[1]) + hideAction;
            btn.OnClientMouseOver = showAction;
            btn.OnClientMouseLeave = hideAction;

            popup.OnClientMouseOver = showAction;
            popup.OnClientMouseLeave = hideAction;
            popup.RenderRunClientMouseLeave = false;

            Items.Add(itemInfo);

            var relationItem = new MenuRelation() { Button = btn, Popup = popup };
            this._menuRelations.Add(relationItem);
            //SetPopupLocation(relationItem);

            creator.Dispose();
        }