Exemplo n.º 1
0
        public void LoadContextMenu()
        {
            var results = PluginManager.GetContextMenusForPlugin(Result);

            ContextMenuItems.Clear();
            foreach (var r in results)
            {
                ContextMenuItems.Add(new ContextMenuItemViewModel()
                {
                    PluginName           = r.PluginName,
                    Title                = r.Title,
                    Glyph                = r.Glyph,
                    FontFamily           = r.FontFamily,
                    AcceleratorKey       = r.AcceleratorKey,
                    AcceleratorModifiers = r.AcceleratorModifiers,
                    Command              = new RelayCommand(_ =>
                    {
                        bool hideWindow =
                            r.Action != null &&
                            r.Action(
                                new ActionContext
                        {
                            SpecialKeyState = KeyboardHelper.CheckModifiers(),
                        });

                        if (hideWindow)
                        {
                            // TODO - Do we hide the window
                            // MainWindowVisibility = Visibility.Collapsed;
                        }
                    }),
                });
            }
        }
Exemplo n.º 2
0
        // copy the task list into an observable collection of list names
        private void UpdateView(int newSelection = 0)
        {
            Log.Instance.LogDebug(string.Format("MainViewModel.UpdateView {0}", newSelection));

            TaskLists.Clear();
            ContextMenuItems.Clear();

            if (TaskListGroup != null)
            {
                for (int i = 0; i < TaskListGroup.NumLists; i++)
                {
                    Log.Instance.LogDebug(string.Format("MainViewModel.Adding Task List {0}", TaskListGroup.ListName(i)));

                    TaskLists.Add(new TaskListView(TaskListGroup.ListName(i)));
                    ContextMenuItems.Add(new ContextMenuItem(TaskListGroup.ListName(i), new CustomCommandHandler(i, OnMoveItem)));
                }
            }
            else
            {
                Log.Instance.LogDebug(string.Format("MainViewModel.UpdateView - TaskListGroup is null, skipping"));
            }

            RaisePropertyChanged("TaskLists");
            RaisePropertyChanged("ContextMenuItems");

            SelectedTaskList = newSelection;

            PropertyDataGridViewModel = new DataGridViewModel(TaskListGroup, SelectedTaskList);
        }
Exemplo n.º 3
0
Arquivo: MainVM.cs Projeto: t9mike/ADK
        private void MapRightClick(PointF point)
        {
            map.SelectedObject = map.FindObject(point);
            map.Invalidate();

            ContextMenuItems.Clear();

            ContextMenuItems.Add(new MenuItemVM()
            {
                Header           = "Info",
                Command          = MapDoubleClickCommand,
                CommandParameter = point,
                IsEnabled        = map.SelectedObject != null
            });

            ContextMenuItems.Add(null);

            ContextMenuItems.Add(new MenuItemVM()
            {
                Header           = "Center",
                Command          = CenterOnPointCommand,
                CommandParameter = point
            });
            ContextMenuItems.Add(new MenuItemVM()
            {
                Header  = "Search object...",
                Command = SearchObjectCommand
            });
            ContextMenuItems.Add(new MenuItemVM()
            {
                Header = "Go to point..."
            });

            ContextMenuItems.Add(null);

            ContextMenuItems.Add(new MenuItemVM()
            {
                Header           = "Ephemerides",
                IsEnabled        = map.SelectedObject != null && sky.GetEphemerisCategories(map.SelectedObject).Any(),
                Command          = GetObjectEphemerisCommand,
                CommandParameter = map.SelectedObject
            });

            // dynamic menu items from plugins
            foreach (var configItem in contextMenuItemsConfig)
            {
                ContextMenuItems.Add(new MenuItemVM()
                {
                    Header      = configItem.Text,
                    IsEnabled   = configItem.EnabledCondition(),
                    IsCheckable = configItem.CheckedCondition != null,
                    IsChecked   = configItem.CheckedCondition != null ? configItem.CheckedCondition() : false,
                    Command     = new Command(configItem.Action)
                });
            }

            ContextMenuItems.Add(null);

            ContextMenuItems.Add(new MenuItemVM()
            {
                Header           = map.LockedObject != null ? (map.SelectedObject != null && map.SelectedObject != map.LockedObject ? "Lock" : "Unlock") : "Lock",
                IsEnabled        = map.LockedObject != null || map.SelectedObject != null,
                Command          = LockOnObjectCommand,
                CommandParameter = map.SelectedObject
            });

            NotifyPropertyChanged(nameof(ContextMenuItems));
        }