private void TryAddButtons(MyButton btn, MyChildForm menuWindow)
 {
     IList<IButton> tsbs = menuWindow.GetCustomProperty(MenuWindowExtention.s_windowMenuButtonName) as IList<IButton>;
     if (tsbs == null)
     {
         tsbs = new List<IButton>();
         menuWindow.SetCustomProperty(MenuWindowExtention.s_windowMenuButtonName, tsbs);
     }
     tsbs.Add(btn);
 }
        public void AssociateButton(MyButton btn, IDisplayManager dm, string windowMenuName)
        {
            var windowMenuInfo = ADInfoBll.Instance.GetInfos<WindowMenuInfo>("Name = '" + windowMenuName + "'")[0];
            if (windowMenuInfo == null)
            {
                throw new ArgumentException("There is no WindowMenu of " + windowMenuName);
            }
            TryAddButtons(btn, this);

            btn.Text = windowMenuInfo.Text;
            btn.Tag = windowMenuInfo;
            btn.Click += new EventHandler((sender, e) =>
            {
                Button tsb = sender as Button;
                WindowMenuInfo info = tsb.Tag as WindowMenuInfo;

                MenuWindowExtention.OnButtonClick(info, tsb.FindForm());
            });

            dm.PositionChanged += new EventHandler((sender, e) =>
            {
                IDisplayManager dm2 = sender as IDisplayManager;

                if (dm2 == dm)
                {
                    MenuWindowExtention.SetMenuState(this);
                }
            });
        }
        public void AssociateButton(MyButton btn, IControlManager cm, string windowMenuName)
        {
            var windowMenuInfo = ADInfoBll.Instance.GetInfos<WindowMenuInfo>("Name = '" + windowMenuName + "'")[0];
            if (windowMenuInfo == null)
            {
                throw new ArgumentException("There is no WindowMenu of " + windowMenuName);
            }
            TryAddButtons(btn, this);
            btn.Text = windowMenuInfo.Text;
            btn.Tag = windowMenuInfo;
            btn.Click += new EventHandler((sender, e) =>
                {
                    Button tsb = sender as Button;
                    WindowMenuInfo info = tsb.Tag as WindowMenuInfo;

                    MenuWindowExtention.OnButtonClick(info, tsb.FindForm());
                    //UpdateContent(cm, gridName);
                });

            cm.DisplayManager.PositionChanged += new EventHandler((sender, e) =>
                {
                    IDisplayManager dm2 = sender as IDisplayManager;

                    if (dm2 == cm.DisplayManager)
                    {
                        MenuWindowExtention.SetMenuState(this);
                    }
                });
            cm.StateChanged += new EventHandler((sender, e) =>
            {
                IControlManager cm2 = sender as IControlManager;

                if (cm2 == cm)
                {
                    MenuWindowExtention.SetMenuState(this);
                }
            });

            cm.EditEnded += new EventHandler((sender, e) =>
            {
                IControlManager cm2 = sender as IControlManager;

                if (cm2 == cm)
                {
                    if (cm2.DisplayManager.InBatchOperation)
                    {
                        return;
                    }

                    MenuWindowExtention.SetMenuState(this);
                }
            });
        }
 private void InitializeComponent()
 {
     this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
     this.btnAdd = new Feng.Windows.Forms.MyButton();
     this.btnEdit = new Feng.Windows.Forms.MyButton();
     this.btnDelete = new Feng.Windows.Forms.MyButton();
     this.btnCancel = new Feng.Windows.Forms.MyButton();
     this.btnOK = new Feng.Windows.Forms.MyButton();
     this.flowLayoutPanel1.SuspendLayout();
     this.SuspendLayout();
     //
     // flowLayoutPanel1
     //
     this.flowLayoutPanel1.Controls.Add(this.btnAdd);
     this.flowLayoutPanel1.Controls.Add(this.btnEdit);
     this.flowLayoutPanel1.Controls.Add(this.btnDelete);
     this.flowLayoutPanel1.Controls.Add(this.btnCancel);
     this.flowLayoutPanel1.Controls.Add(this.btnOK);
     this.flowLayoutPanel1.Location = new System.Drawing.Point(2, 1);
     this.flowLayoutPanel1.Name = "flowLayoutPanel1";
     this.flowLayoutPanel1.Size = new System.Drawing.Size(373, 25);
     this.flowLayoutPanel1.TabIndex = 5;
     //
     // btnAdd
     //
     this.btnAdd.Location = new System.Drawing.Point(0, 0);
     this.btnAdd.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
     this.btnAdd.Name = "btnAdd";
     this.btnAdd.Size = new System.Drawing.Size(72, 21);
     this.btnAdd.TabIndex = 7;
     this.btnAdd.Text = "����";
     this.btnAdd.Click += new System.EventHandler(this.Button_Click);
     //
     // btnEdit
     //
     this.btnEdit.Location = new System.Drawing.Point(75, 0);
     this.btnEdit.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
     this.btnEdit.Name = "btnEdit";
     this.btnEdit.Size = new System.Drawing.Size(72, 21);
     this.btnEdit.TabIndex = 8;
     this.btnEdit.Text = "�޸�";
     this.btnEdit.Click += new System.EventHandler(this.Button_Click);
     //
     // btnDelete
     //
     this.btnDelete.Location = new System.Drawing.Point(150, 0);
     this.btnDelete.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
     this.btnDelete.Name = "btnDelete";
     this.btnDelete.Size = new System.Drawing.Size(72, 21);
     this.btnDelete.TabIndex = 9;
     this.btnDelete.Text = "ɾ��";
     this.btnDelete.Click += new System.EventHandler(this.Button_Click);
     //
     // btnCancel
     //
     this.btnCancel.Location = new System.Drawing.Point(225, 0);
     this.btnCancel.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
     this.btnCancel.Name = "btnCancel";
     this.btnCancel.Size = new System.Drawing.Size(72, 21);
     this.btnCancel.TabIndex = 6;
     this.btnCancel.Text = "ȡ��";
     this.btnCancel.Click += new System.EventHandler(this.Button_Click);
     //
     // btnOK
     //
     this.btnOK.Location = new System.Drawing.Point(300, 0);
     this.btnOK.Margin = new System.Windows.Forms.Padding(0);
     this.btnOK.Name = "btnOK";
     this.btnOK.Size = new System.Drawing.Size(72, 21);
     this.btnOK.TabIndex = 5;
     this.btnOK.Text = "ȷ��";
     this.btnOK.Click += new System.EventHandler(this.Button_Click);
     //
     // ActionButtons
     //
     this.Controls.Add(this.flowLayoutPanel1);
     this.Name = "ActionButtons";
     this.Size = new System.Drawing.Size(377, 24);
     this.flowLayoutPanel1.ResumeLayout(false);
     this.ResumeLayout(false);
 }