Exemplo n.º 1
0
        private bool SelectedMenuItem(Predicate <ServerMenuEntry> predicate)
        {
            for (int i = 0; i < MenuListBox.Items.Count; i++)
            {
                ServerMenuEntry serverMenuEntry = (ServerMenuEntry)MenuListBox.Items[i];

                if (predicate(serverMenuEntry))
                {
                    MenuListBox.SelectedIndex = i;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private void MenuListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            ServerMenuEntry currentEntry = (ServerMenuEntry)e.AddedItems[0];

            if (currentEntry.TargetTabType != null)
            {
                SelectTab(currentEntry.TargetTabType);
            }

            if (currentEntry.TargetAction.HasValue)
            {
                ActionDictionary[currentEntry.TargetAction.Value]();
            }
        }