예제 #1
0
        /// <summary>
        /// Invoked when an unhandled <see cref="E:System.Windows.Input.Mouse.MouseUp"/> routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. The event data reports that the mouse button was released.</param>
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            base.OnMouseUp(e);

            switch (e.ChangedButton)
            {
            case MouseButton.Right:
                var mousePosition       = System.Windows.Forms.Cursor.Position;
                var viewModel           = new ContextMenuViewModel();
                var currentEnabledState = ViewModel.Modification.GetComponent <EnabledComponent>().IsEnabled;
                viewModel.Items.Add(new ContextMenuItemViewModel {
                    Text = currentEnabledState ? "Disable" : "Enable", ClickedHandler = HandleEnabledClicked
                });
                viewModel.Items.Add(new ContextMenuItemViewModel {
                    Text = "Configure"
                });
                viewModel.Items.Add(new ContextMenuItemViewModel {
                    Text = "About"
                });
                var menu = new CustomContextMenu();
                menu.DataContext = viewModel;
                menu.WindowState = WindowState.Minimized;
                menu.WindowState = WindowState.Normal;
                menu.Left        = mousePosition.X;
                menu.Top         = mousePosition.Y;
                menu.Show();
                break;
            }
        }
예제 #2
0
 public ItemViewModel(ContextMenuViewModel parent, string value)
 {
     _parent       = parent;
     Value         = value;
     DeleteCommand = new ActionCommand <ItemViewModel>(s =>
     {
         _parent.Items.Remove(this);
     });
 }
예제 #3
0
        // Context menu
        protected override void AddContextMenuItems(ContextMenuItemCollection items)
        {
            base.AddContextMenuItems(items);

            var fixAllMenu = new ContextMenuViewModel("全部修复", FixAllCommand, false, false, false);

            items.Add(fixAllMenu);

            var rejectAllMenu = new ContextMenuViewModel("全部忽略", RejectAllCommand, true, _rejectAll, false);

            items.Add(rejectAllMenu);
        }
예제 #4
0
        protected override void AddContextMenuItems(ContextMenuItemCollection items)
        {
            base.AddContextMenuItems(items);
            var viewMenu = new ContextMenuViewModel("查看图形", ViewCommand, false, false, false);

            items.Add(viewMenu);

            var fixMenu = new ContextMenuViewModel("修复", FixCommand, false, false, false);

            items.Add(fixMenu);

            // Seperator
            items.Add(null);

            var isChecked  = CheckResult.Status == Status.Rejected;
            var rejectMenu = new ContextMenuViewModel("忽略", RejectCommand, true, isChecked, false);

            items.Add(rejectMenu);
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IAssemblyAnalysisService analysisService, IWindowService windowService, IApplicationControlService appCtrlService)
        {
            if (IsInDesignMode)
            {
                return;
            }

            this.analysisService = analysisService;
            this.windowService   = windowService;
            this.appCtrlService  = appCtrlService;

            this.contextMenuVM = new ContextMenuViewModel(this, appCtrlService);

            DropAssemblyCommand = new RelayCommand <DragEventArgs>(AnalyzeDroppedAssembly);

            ToggleTitleBarVisibilityCommand = contextMenuVM.ToggleTitleBarVisibilityCommand;
            CloseApplicationCommand         = contextMenuVM.CloseApplicationCommand;
            AnalyzeAssemblyCommand          = contextMenuVM.AnalyzeAssemblyCommand;
            AnalyzeFolderCommand            = contextMenuVM.AnalyzeFolderCommand;
        }
예제 #6
0
 public void ShowContextMenu(IList <IDiiagramrCommand> commands, Point position)
 {
     ContextMenuViewModel.ShowContextMenu(commands, position);
 }