Exemplo n.º 1
0
 private static void OnMenuClicked(ToolStripMenuItem menuItem)
 {
     if (MenuTable.ContainsKey(menuItem) && CommandTable.ContainsKey(menuItem))
     {
         TaskbarIcon TaskbarIcon = MenuTable[menuItem];
         if (CommandTable[menuItem] is RoutedCommand Command && TaskbarIcon.Target != null)
         {
             Command.Execute(TaskbarIcon, TaskbarIcon.Target);
         }
     }
 }
Exemplo n.º 2
0
        // Read line then Try to parse to int; if exception is thrown call InvalidSelection(); otherwise call Action<int> handler for the menuID given in selector
        static void ReadSelection()
        {
            Console.Write("Selector: ");
            string input    = Console.ReadLine();
            int    selector = -1;

            try {
                Int32.TryParse(input, out selector);
            }
            catch {
                InvalidSelection();
            }
            if (MenuTable.ContainsKey(selector))
            {
                MenuTable[selector].Item2(selector);
                ShowMenu();
            }
            else
            {
                InvalidSelection();
            }
        }