/// <summary>
 /// Resets the child control.
 /// </summary>
 public void ResetChildControl()
 {
     if (isExpand)
     {
         if (selectItem != null)
         {
             try
             {
                 ControlHelper.FreezeControl(this, true);
                 this.panChilds.Controls.Clear();
                 if (selectItem.ShowControl != null)
                 {
                     HZH_Controls.Controls.UCSplitLine_H split = new UCSplitLine_H();
                     split.BackColor = Color.FromArgb(50, 197, 197, 197);
                     split.Dock      = DockStyle.Top;
                     this.panChilds.Controls.Add(split);
                     split.BringToFront();
                     this.panChilds.Controls.Add(selectItem.ShowControl);
                     selectItem.ShowControl.Dock = DockStyle.Fill;
                 }
             }
             finally
             {
                 ControlHelper.FreezeControl(this, false);
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Shows the more menu.
        /// </summary>
        /// <param name="lbl">The label.</param>
        private void ShowMoreMenu(Label lbl)
        {
            var menu = (NavigationMenuItem)lbl.Tag;

            if (CheckShow(menu))
            {
                if (menu.Items != null && menu.Items.Length > 0)
                {
                    Panel panel = new Panel();
                    panel.BackColor = Color.White;
                    panel.Paint    += panel_Paint;
                    panel.Padding   = new System.Windows.Forms.Padding(1);
                    Size size   = GetItemsSize(menu.Items);
                    var  height = size.Height * menu.Items.Length + 2;
                    height += menu.Items.Count(p => p.HasSplitLintAtTop);//分割线
                    if (size.Width < lbl.Width)
                    {
                        size.Width = lbl.Width;
                    }
                    panel.Size = new Size(size.Width, height);

                    foreach (var item in menu.Items)
                    {
                        if (item.HasSplitLintAtTop)
                        {
                            UCSplitLine_H line = new UCSplitLine_H();
                            line.Dock = DockStyle.Top;
                            panel.Controls.Add(line);
                            line.BringToFront();
                        }
                        Label _lbl = new Label();
                        _lbl.Font      = Font;
                        _lbl.ForeColor = this.BackColor;
                        _lbl.AutoSize  = false;
                        _lbl.TextAlign = ContentAlignment.MiddleCenter;
                        _lbl.Height    = size.Height;
                        _lbl.Text      = item.Text;
                        _lbl.Dock      = DockStyle.Top;
                        _lbl.BringToFront();
                        _lbl.Paint      += lbl_Paint;
                        _lbl.MouseEnter += lbl_MouseEnter;
                        _lbl.Tag         = item;
                        _lbl.Click      += lbl_Click;
                        _lbl.Size        = new System.Drawing.Size(size.Width, size.Height);
                        panel.Controls.Add(_lbl);
                        _lbl.BringToFront();
                    }
                    Point point = Point.Empty;

                    if (menu.ParentItem != null)
                    {
                        Point p = lbl.Parent.PointToScreen(lbl.Location);
                        if (p.X + lbl.Width + panel.Width > Screen.PrimaryScreen.Bounds.Width)
                        {
                            point = new Point(-1 * panel.Width - 2, -1 * lbl.Height);
                        }
                        else
                        {
                            point = new Point(panel.Width + 2, -1 * lbl.Height);
                        }
                    }
                    m_lstAnchors[menu]              = new FrmAnchor(lbl, panel, point);
                    m_lstAnchors[menu].FormClosing += UCNavigationMenu_FormClosing;
                    m_lstAnchors[menu].Show(this);
                    m_lstAnchors[menu].Size = new Size(size.Width, height);
                }
            }
        }