コード例 #1
0
 public void AddMenu(string menuKey, string menuText)
 {
     menuKey = menuKey.Trim().ToLower();
     if (this._menulist[menuKey] == null)
     {
         RecentUseMenuCollection item = new RecentUseMenuCollection {
             UseCount = 1,
             UseTime  = DateTime.Now,
             MenuKey  = menuKey,
             MenuText = menuText
         };
         this._menulist.Add(item);
     }
     else if (this._menulist[menuKey].UseCount < 2147483637)
     {
         this._menulist[menuKey].UseCount++;
         this._menulist[menuKey].UseTime = DateTime.Now;
     }
     else
     {
         int num = this._maxRecentMenuCount;
         for (int i = 0; i < this._menulist.Count; i++)
         {
             this._menulist[i].UseCount = num;
             num--;
             if (i >= 15)
             {
                 this._menulist.Remove(this._menulist[i]);
             }
         }
     }
     this._menulist.Sort();
     this.LoadMenu();
 }
コード例 #2
0
 public RecentUseMenu(ContextMenuStrip menu, EventHandler menuEvent, Dictionary <string, ToolStripMenuItem> allowUseMenu)
 {
     this._menu         = menu;
     this._menuEvent    = menuEvent;
     this._allowUseMenu = allowUseMenu;
     this._menulist     = new RecentUseMenuCollection();
     this.ReadMenu();
 }
コード例 #3
0
 private void ReadMenu()
 {
     if (Settings.Default.RecentUseMenu.Trim().Length > 0)
     {
         try
         {
             Dictionary <string, string> dictionary = SerializableHelper.DeSerialize <Dictionary <string, string> >(Settings.Default.RecentUseMenu);
             if ((dictionary != null) && dictionary.ContainsKey(Variable.sUserId))
             {
                 Action <RecentUseMenuCollection> action = null;
                 string fi = dictionary[Variable.sUserId];
                 RecentUseMenuCollection temp = SerializableHelper.DeSerialize <RecentUseMenuCollection>(fi);
                 if (temp != null)
                 {
                     if ((this._allowUseMenu == null) || (this._allowUseMenu.Count == 0))
                     {
                         temp.Clear();
                     }
                     else
                     {
                         List <RecentUseMenuCollection> list = new List <RecentUseMenuCollection>();
                         foreach (RecentUseMenuCollection menus in temp)
                         {
                             if (!this._allowUseMenu.ContainsKey(menus.MenuKey.ToLower() + "1"))
                             {
                                 list.Add(menus);
                             }
                         }
                         if (action == null)
                         {
                             action = obj => temp.Remove(obj);
                         }
                         list.ForEach(action);
                     }
                     this._menulist = temp;
                 }
             }
         }
         catch
         {
         }
     }
 }