Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UCNavigationMenu"/> class.
 /// </summary>
 public UCNavigationMenu()
 {
     InitializeComponent();
     items = new NavigationMenuItem[0];
     if (ControlHelper.IsDesignMode())
     {
         items = new NavigationMenuItem[4];
         for (int i = 0; i < 4; i++)
         {
             items[i] = new NavigationMenuItem()
             {
                 Text        = "菜单" + (i + 1),
                 AnchorRight = i >= 2
             };
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Handles the Click 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_Click(object sender, EventArgs e)
        {
            Label lbl = sender as Label;

            if (lbl.Tag != null)
            {
                var menu = (NavigationMenuItem)lbl.Tag;
                if (menu.Items == null || menu.Items.Length <= 0)
                {
                    selectItem = menu;

                    while (m_lstAnchors.Count > 0)
                    {
                        try
                        {
                            foreach (var item in m_lstAnchors)
                            {
                                item.Value.Close();
                                m_lstAnchors.Remove(item.Key);
                            }
                        }
                        catch { }
                    }

                    if (ClickItemed != null)
                    {
                        ClickItemed(this, e);
                    }
                }
                else
                {
                    CloseList(menu);
                    if (m_lstAnchors.ContainsKey(menu))
                    {
                        if (m_lstAnchors[menu] != null && !m_lstAnchors[menu].IsDisposed)
                        {
                            m_lstAnchors[menu].Close();
                        }
                        m_lstAnchors.Remove(menu);
                    }
                    ShowMoreMenu(lbl);
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Closes the list.
 /// </summary>
 /// <param name="menu">The menu.</param>
 private void CloseList(NavigationMenuItem menu)
 {
     if (menu.Items != null)
     {
         foreach (var item in menu.Items)
         {
             CloseList(item);
             if (m_lstAnchors.ContainsKey(item))
             {
                 if (m_lstAnchors[item] != null && !m_lstAnchors[item].IsDisposed)
                 {
                     m_lstAnchors[item].Close();
                     m_lstAnchors[item] = null;
                     m_lstAnchors.Remove(item);
                 }
             }
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Checks the show.
 /// </summary>
 /// <param name="menu">The menu.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 private bool CheckShow(NavigationMenuItem menu)
 {
     //检查已经打开的节点
     if (m_lstAnchors.ContainsKey(menu))
     {
         CloseList(menu);
         return(false);
     }
     if (HasInCacheChild(menu))
     {
         if (m_lstAnchors.ContainsKey(menu.ParentItem))
         {
             CloseList(menu.ParentItem);
             return(true);
         }
         return(false);
     }
     else
     {
         for (int i = 0; i < 1;)
         {
             try
             {
                 foreach (var item in m_lstAnchors)
                 {
                     if (m_lstAnchors[item.Key] != null && !m_lstAnchors[item.Key].IsDisposed)
                     {
                         m_lstAnchors[item.Key].Close();
                     }
                 }
             }
             catch
             {
                 continue;
             }
             i++;
         }
         m_lstAnchors.Clear();
         return(true);
     }
 }
Пример #5
0
 /// <summary>
 /// Determines whether [has in cache child] [the specified menu].
 /// </summary>
 /// <param name="menu">The menu.</param>
 /// <returns><c>true</c> if [has in cache child] [the specified menu]; otherwise, <c>false</c>.</returns>
 private bool HasInCacheChild(NavigationMenuItem menu)
 {
     foreach (var item in m_lstAnchors)
     {
         if (item.Key == menu)
         {
             return(true);
         }
         else
         {
             if (item.Key.Items != null)
             {
                 if (item.Key.Items.Contains(menu))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }