/// <summary> /// Handles the FormClosing event of the UCNavigationMenu control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="FormClosingEventArgs"/> instance containing the event data.</param> void UCNavigationMenu_FormClosing(object sender, FormClosingEventArgs e) { FrmAnchor frm = sender as FrmAnchor; if (m_lstAnchors.ContainsValue(frm)) { foreach (var item in m_lstAnchors) { if (item.Value == frm) { m_lstAnchors.Remove(item.Key); return; } } } }
/// <summary> /// Handles the MouseEnter event of the lbl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> void lbl_MouseEnter(object sender, EventArgs e) { Label lbl = sender as Label; var menu = lbl.Tag as NavigationMenuItemExt; foreach (var item in m_lstAnchors) { m_lstAnchors[item.Key].Hide(); } if (menu.ShowControl != null) { if (!m_lstAnchors.ContainsKey(menu)) { m_lstAnchors[menu] = new FrmAnchor(lbl, menu.ShowControl); } m_lstAnchors[menu].Show(this); m_lstAnchors[menu].Size = menu.ShowControl.Size; } }
/// <summary> /// Handles the MouseEnter event of the lbl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> void lbl_MouseEnter(object sender, EventArgs e) { if (!IsExpand) { Label lbl = sender as Label; var menu = lbl.Tag as NavigationMenuItemExt; foreach (var item in m_lstAnchors) { m_lstAnchors[item.Key].Hide(); } if (menu.ShowControl != null) { if (!m_lstAnchors.ContainsKey(menu)) { m_lstAnchors[menu] = new FrmAnchor(panMenu, menu.ShowControl, isNotFocus: false); } m_lstAnchors[menu].BackColor = this.BackColor; m_lstAnchors[menu].Show(this); m_lstAnchors[menu].Size = new Size(this.panChilds.Width, expandHeight - mainMenuHeight); } } }
/// <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); } } }