Example #1
0
 /// <summary>
 /// 获取菜单位于树中的路径
 /// </summary>
 public static string GetLocation(MenuItem cmi)
 {
     if (cmi == null)
     {
         return(string.Empty);
     }
     if (cmi.Parent != null)
     {
         return(MenuItem.GetLocation(cmi.Parent) + "." + cmi.Caption);
     }
     return(cmi.Caption);
 }
Example #2
0
 /// <summary>
 /// 输出当前菜单到控制台
 /// </summary>
 public virtual void Output()
 {
     this.Writer.W(ConsoleColor.Gray, "\n当前位置:");
     this.Writer.W(ConsoleColor.White, "{0}\n\n", MenuItem.GetLocation(this));
     if (!string.IsNullOrEmpty(this._intro))
     {
         this.Writer.W(ConsoleColor.Cyan, "{0}\n\n", this._intro);
     }
     foreach (var m in this.SubMenus)
     {
         var isVisible = m.DoCheckVisible();
         if (isVisible == null)
         {
             Writer.W(ConsoleColor.DarkGreen, " {0}\t:", GetShortCutKeyDisplay(m.ShortCutKey));
             Writer.W(ConsoleColor.Gray, " {0}\n", m.Caption);
         }
         else if (isVisible.Value)
         {
             Writer.W(ConsoleColor.Green, " {0}\t:", GetShortCutKeyDisplay(m.ShortCutKey));
             Writer.W(ConsoleColor.White, " {0}\n", m.Caption);
         }
     }
     this.Writer.W(ConsoleColor.DarkYellow, "\n请按键:");
 }