Example #1
0
        private void SetPopupLocation(MenuRelation menuItem)
        {
            var location = GetRealLocation(this);
            menuItem.Popup.Top = location.Y + this.Height-1;
            menuItem.Popup.Left = location.X  + buttonLayout.Left + menuItem.Button.Left;

            //popup��Menu��Anchor����һ�£��������������Сʱ���²��֣���Ӱ��Popup������λ��
            menuItem.Popup.Anchor = this.Anchor;
        }
Example #2
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 (buttonLayout.Controls.Count > 0)
            {
                var lastControl = buttonLayout.Controls[buttonLayout.Controls.Count - 1];
                var left = lastControl.Left + lastControl.Width + 2;
                btn.Left = left;
            }
            else
            {
                btn.Left = 15;
            }
            buttonLayout.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}',300,'{1}');", popup.ID, showHide[0])+showAction ;

            hideAction = string.Format("vwg_hideMenu('{0}',250,'{1}',200);", 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();
        }
Example #3
0
        private void SetPopupLocation(MenuRelation menuItem)
        {
            var location = GetRealLocation(this);
            menuItem.Popup.Top = location.Y + this.Height - 1;
            menuItem.Popup.Left = location.X + menuItem.Button.Left;

            //popup和Menu的Anchor属性一致,当调整浏览器大小时重新布局,不影响Popup弹出的位置
            menuItem.Popup.Anchor = this.Anchor;
        }