Beispiel #1
0
        protected void AddTemplateLayoutMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
        {
            string containerType = "Diagram";

            if (containerBase.IsAnImplementationOf <IContainerNode>())
            {
                containerType = "Container";
            }

            IHasLayoutInfo selectedNode = Presenter.GetFirstSelected <IContainerNode>();

            if (selectedNode != null)
            {
                SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Apply Named Template to Selection...")
                                      .WithActionCommand(() => Presenter.ApplyLayoutTemplateToSelection()).AsGroupStarter());
            }
            else
            {
                SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Apply Named Template to " + containerType + "...")
                                      .WithActionCommand(() => Presenter.ApplyLayoutTemplate(containerBase, "", false)));
            }

            SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Apply Named Template to " + containerType + " Recursive...")
                                  .WithActionCommand(() => Presenter.ApplyLayoutTemplate(containerBase, "", true)));

            SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Save " + containerType + " as Named Template...")
                                  .WithActionCommand(() => Presenter.SaveContainerToXml(containerBase, "")));
        }
Beispiel #2
0
 protected override void Context()
 {
     _view       = A.Fake <IContextMenuView>();
     _parentView = A.Fake <IView>();
     _position   = new Point();
     sut         = new TestContextMenu(_view);
 }
        public ContextMenuPresenter(VerbSystem verbSystem)
        {
            IoCManager.InjectDependencies(this);

            _verbSystem = verbSystem;

            _contextMenuView = new ContextMenuView();
            _contextMenuView.OnKeyBindDownSingle   += OnKeyBindDownSingle;
            _contextMenuView.OnMouseEnteredSingle  += OnMouseEnteredSingle;
            _contextMenuView.OnMouseExitedSingle   += OnMouseExitedSingle;
            _contextMenuView.OnMouseHoveringSingle += OnMouseHoveringSingle;

            _contextMenuView.OnKeyBindDownStack  += OnKeyBindDownStack;
            _contextMenuView.OnMouseEnteredStack += OnMouseEnteredStack;

            _contextMenuView.OnExitedTree     += OnExitedTree;
            _contextMenuView.OnCloseRootMenu  += OnCloseRootMenu;
            _contextMenuView.OnCloseChildMenu += OnCloseChildMenu;

            _cfg.OnValueChanged(CCVars.ContextMenuGroupingType, _contextMenuView.OnGroupingContextMenuChanged, true);

            CommandBinds.Builder
            .Bind(ContentKeyFunctions.OpenContextMenu, new PointerInputCmdHandler(HandleOpenContextMenu))
            .Register <ContextMenuPresenter>();
        }
Beispiel #4
0
        protected override void SetModelMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node)
        {
            var container = Get <IContainer>(node.Id);

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.AddNew(ObjectTypes.Container))
                                        .WithCommandFor <AddNewCommandFor <IContainer, IContainer>, IContainer>(container)
                                        .WithIcon(ApplicationIcons.ContainerAdd));

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.AddExisting(ObjectTypes.Container))
                                        .WithCommandFor <AddExistingCommandFor <IContainer, IContainer>, IContainer>(container)
                                        .WithIcon(ApplicationIcons.ContainerLoad));

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.AddNew(ObjectTypes.Parameter))
                                        .WithCommandFor <AddNewCommandFor <IContainer, IParameter>, IContainer>(container)
                                        .WithIcon(ApplicationIcons.Parameters));

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.AddExisting(ObjectTypes.Parameter))
                                        .WithCommandFor <AddExistingCommandFor <IContainer, IParameter>, IContainer>(container)
                                        .WithIcon(ApplicationIcons.PKMLLoad));

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.AddNew(ObjectTypes.DistributedParameter))
                                        .WithCommandFor <AddNewCommandFor <IContainer, IDistributedParameter>, IContainer>(container)
                                        .WithIcon(ApplicationIcons.ParameterDistribution));

            base.SetModelMenuItems(contextMenuView, containerBase, node);

            if (container.ParentContainer == null) // container is TopContainer
            {
                contextMenuView.RemoveMenuItem(AppConstants.MenuNames.Delete);
                contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.Delete)
                                            .WithCommandFor <RemoveTopContainerCommand, IContainer>(Get <IContainer>(node.Id))
                                            .WithIcon(ApplicationIcons.Delete));
            }
        }
 protected override void SetLayoutMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
 {
     AddTemplateLayoutMenuItems(contextMenuView, containerBase);
     AddAutoLayoutMenuItems(contextMenuView, containerBase);
     contextMenuView.AddMenuItem(SubMenuLayout);
     contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("AutoLayout in layers")
                                 .WithActionCommand(() => Presenter.LayerLayout(containerBase)));
 }
Beispiel #6
0
        protected void AddAutoLayoutMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
        {
            if (containerBase == null)
            {
                return;
            }

            SubMenuLayout.AddItem(CreateMenuButton.WithCaption("AutoLayout Children").AsGroupStarter().WithActionCommand(() => Presenter.Layout(containerBase, AppConstants.Diagram.Base.LayoutDepthChildren, null)));
        }
        protected override void SetLayoutMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
        {
            AddTemplateLayoutMenuItems(contextMenuView, containerBase);

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("Apply current Layouts from Structure and Reactions")
                                        .WithActionCommand(askAndApplySpaceReactionLayout));

            AddAutoLayoutMenuItems(contextMenuView, containerBase);
            contextMenuView.AddMenuItem(SubMenuLayout);
        }
        protected override void SetSelectionMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node)
        {
            if (!Presenter.IsReactionNode(node))
            {
                return;
            }

            contextMenuView.AddMenuItem(CreateMenuCheckButton.WithCaption("Connect Educts right")
                                        .WithChecked(Presenter.DisplayEductsRight(node))
                                        .WithCheckedAction(displayRight => Presenter.SetDisplayEductsRightForDiagramSelection(displayRight)));

            base.SetSelectionMenuItems(contextMenuView, containerBase, node);
        }
 private void createRemoveCommandFor(IContextMenuView contextMenuView, T entity)
 {
     if (entity.IsAnImplementationOf <IReactionBuilder>())
     {
         contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.Delete)
                                     .WithRemoveCommand(Presenter.Subject.DowncastTo <IMoBiReactionBuildingBlock>(), entity).WithIcon(ApplicationIcons.Delete));
     }
     else
     {
         contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.Delete)
                                     .WithRemoveCommand(entity.ParentContainer, entity).WithIcon(ApplicationIcons.Delete));
     }
 }
Beispiel #10
0
        protected virtual void SetSelectionMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node)
        {
            contextMenuView.AddMenuItem(SubMenuSelect);

            if (containerBase != null)
            {
                SubMenuSelect.AddItem(CreateMenuButton.WithCaption("All Children")
                                      .WithActionCommand(() => Presenter.SelectChildren(containerBase)));
            }

            if (Presenter.SelectionContains <IBaseNode>())
            {
                SubMenuSelect.AddItem(CreateMenuButton.WithCaption("Visible Linked nodes")
                                      .WithActionCommand(() => Presenter.SelectVisibleLinkedNodesForDiagramSelection()));
                if (node != null)
                {
                    SubMenuSelect.AddItem(CreateMenuButton.WithCaption("Invert Selection")
                                          .WithActionCommand(() => Presenter.InvertSelection(node.GetParent())));
                }

                IHasLayoutInfo selectedNode = Presenter.GetFirstSelected <IHasLayoutInfo>();
                if (selectedNode != null)
                {
                    SubMenuDiagram.AddItem(CreateMenuCheckButton.WithCaption("Location Fixed").AsGroupStarter()
                                           .WithChecked(selectedNode.LocationFixed)
                                           .WithCheckedAction(locationFixed => Presenter.SetLocationFixedForDiagramSelection(locationFixed)));
                }

                contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("Hide Selection").WithActionCommand(() => Presenter.HideSelection()));
            }

            if (Presenter.SelectionContains <IElementBaseNode>())
            {
                var subMenuNodeSize = CreateSubMenu.WithCaption("Nodesize")
                                      .WithItem(CreateMenuButton.WithCaption("Large").WithActionCommand(() => Presenter.SetNodeSizeForDiagramSelection(NodeSize.Large)))
                                      .WithItem(CreateMenuButton.WithCaption("Middle").WithActionCommand(() => Presenter.SetNodeSizeForDiagramSelection(NodeSize.Middle)))
                                      .WithItem(CreateMenuButton.WithCaption("Small").WithActionCommand(() => Presenter.SetNodeSizeForDiagramSelection(NodeSize.Small)));
                contextMenuView.AddMenuItem(subMenuNodeSize);
            }

            // Shows all children (e.g. after hiding a selection)

            if (containerBase != null)
            {
                contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("Show All Children").WithActionCommand(() => Presenter.ShowChildren(containerBase)));
            }
        }
        protected override void SetModelMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node)
        {
            var parent   = Presenter.Subject as IMoBiSpatialStructure;
            var menuItem = CreateMenuButton.WithCaption(AppConstants.MenuNames.AddNew("Top Container"))
                           .WithCommandFor <AddNewTopContainerCommand, IMoBiSpatialStructure>(parent)
                           .WithIcon(ApplicationIcons.ContainerAdd);

            contextMenuView.AddMenuItem(menuItem);

            var menuItem2 = CreateMenuButton.WithCaption(AppConstants.MenuNames.AddExisting("Top Container"))
                            .WithCommand <AddExistingTopContainerCommand>()
                            .WithIcon(ApplicationIcons.ContainerLoad);

            contextMenuView.AddMenuItem(menuItem2);

            base.SetModelMenuItems(contextMenuView, containerBase, node);
        }
        protected override void SetModelMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node)
        {
            var entity = Get <T>(node.Id);

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.Rename)
                                        .WithCommandFor <RenameObjectCommand <T>, T>(entity).WithIcon(ApplicationIcons.Rename));

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.Edit)
                                        .WithCommandFor <EditCommandFor <T>, T>(entity).WithIcon(ApplicationIcons.Edit));

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.SaveAsPKML)
                                        .WithCommandFor <SaveUICommandFor <T>, T>(entity).WithIcon(ApplicationIcons.SaveIconFor(typeof(T).Name)));

            createRemoveCommandFor(contextMenuView, entity);

            base.SetModelMenuItems(contextMenuView, containerBase, node);
        }
        protected override void SetModelMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node)
        {
            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.RibbonButtonNames.NewMolecule)
                                        .WithActionCommand(() => Presenter.AddMoleculeNode())
                                        .WithIcon(ApplicationIcons.MoleculeAdd));

            var parent = Presenter.Subject as IMoBiReactionBuildingBlock;

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.AddNew(ObjectTypes.Reaction))
                                        .WithCommandFor <AddNewCommandFor <IMoBiReactionBuildingBlock, IReactionBuilder>, IMoBiReactionBuildingBlock>(parent)
                                        .WithIcon(ApplicationIcons.ReactionAdd));

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption(AppConstants.MenuNames.AddExisting(ObjectTypes.Reaction))
                                        .WithCommandFor <AddExistingCommandFor <IMoBiReactionBuildingBlock, IReactionBuilder>, IMoBiReactionBuildingBlock>(parent)
                                        .WithIcon(ApplicationIcons.ReactionLoad));

            base.SetModelMenuItems(contextMenuView, containerBase, node);
        }
Beispiel #14
0
        protected virtual void SetDiagramMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
        {
            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("Refresh").WithActionCommand(() => Presenter.Refresh()).WithIcon(ApplicationIcons.Refresh).AsGroupStarter());

            contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("Undo Diagram Layout Change").WithActionCommand(() => Presenter.Undo()).WithIcon(ApplicationIcons.Undo));

            if (Presenter.SelectionContains <IBaseNode>())
            {
                SubMenuDiagram.AddItem(CreateMenuButton.WithCaption("To Front").AsGroupStarter().WithActionCommand(() => Presenter.MoveDiagramSelectionToFront()).WithIcon(ApplicationIcons.Forward));
                SubMenuDiagram.AddItem(CreateMenuButton.WithCaption("To Back").WithActionCommand(() => Presenter.MoveDiagramSelectionToBack()).WithIcon(ApplicationIcons.Back));
            }


            SubMenuDiagram.AddItem(CreateMenuButton.WithCaption("Zoom In").AsGroupStarter().WithCommand <ZoomInCommand>().WithIcon(ApplicationIcons.ZoomIn));
            SubMenuDiagram.AddItem(CreateMenuButton.WithCaption("Zoom Out").WithCommand <ZoomOutCommand>().WithIcon(ApplicationIcons.ZoomOut));
            SubMenuDiagram.AddItem(CreateMenuButton.WithCaption("Fit into Window").WithCommand <FitToPageCommand>().WithIcon(ApplicationIcons.FitToPage));
            SubMenuDiagram.AddItem(CreateMenuButton.WithCaption("Copy Image to Clipboard").AsGroupStarter().WithActionCommand(() => Presenter.CopyBitmapToClipboard(containerBase)));
            SubMenuDiagram.AddItem(CreateMenuButton.WithCaption("Save Image...").WithActionCommand(() => Presenter.SaveBitmapToFile(containerBase)));

            contextMenuView.AddMenuItem(SubMenuDiagram);
        }
Beispiel #15
0
        public ContextMenuPresenter(VerbSystem verbSystem)
        {
            IoCManager.InjectDependencies(this);

            _verbSystem = verbSystem;
            _verbSystem.ToggleContextMenu         += SystemOnToggleContextMenu;
            _verbSystem.ToggleContainerVisibility += SystemOnToggleContainerVisibility;

            _contextMenuView = new ContextMenuView();
            _contextMenuView.OnKeyBindDownSingle   += OnKeyBindDownSingle;
            _contextMenuView.OnMouseEnteredSingle  += OnMouseEnteredSingle;
            _contextMenuView.OnMouseExitedSingle   += OnMouseExitedSingle;
            _contextMenuView.OnMouseHoveringSingle += OnMouseHoveringSingle;

            _contextMenuView.OnKeyBindDownStack  += OnKeyBindDownStack;
            _contextMenuView.OnMouseEnteredStack += OnMouseEnteredStack;

            _contextMenuView.OnExitedTree     += OnExitedTree;
            _contextMenuView.OnCloseRootMenu  += OnCloseRootMenu;
            _contextMenuView.OnCloseChildMenu += OnCloseChildMenu;

            _cfg.OnValueChanged(CCVars.ContextMenuGroupingType, _contextMenuView.OnGroupingContextMenuChanged, true);
        }
Beispiel #16
0
 public MainWindow()
 {
     InitializeComponent();
     viewModel           = IoC.GetViewModel <MainViewModel>(this);
     _systemLogViewModel = IoC.GetViewModel <ISystemLogViewModel>(this);
     this.DataContext    = viewModel;
     taskOrderView       = new TaskOrderView();
     frame1.NavigateToPage(taskOrderView, false);
     lastView = taskOrderView;
     GlobalData.ErrMsgObject.ErrorMessageEvent += ErrorMessageEvent;//错误信息弹窗
     if (TagList.PLCGroups != null && TagList.PLCGroups.Count > 0)
     {
         if (TagList.PLCGroups[0].PlcDevice.IsConnected == false)
         {
             _systemLogViewModel.AddMewStatus("PLC连接失败,请检查设置!", LogTypeEnum.Error);
         }
     }
     TagList.GetTag("system_run", out runTag, "FxPLC");
     if (runTag != null)
     {
         runTag.PropertyChanged += RunTag_PropertyChanged;
         RunTag_PropertyChanged(runTag, null);
     }
 }
Beispiel #17
0
        protected void SetDetailedMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
        {
            var subMenuDetailed = CreateSubMenu.WithCaption("Expert Functions").AsGroupStarter();

            contextMenuView.AddMenuItem(subMenuDetailed);


            var subMenuShow = CreateSubMenu.WithCaption("Show / Hide");

            if (Presenter.SelectionContains <IBaseNode>())
            {
                subMenuDetailed.AddItem(subMenuShow);
            }

            subMenuShow.AddItem(
                CreateMenuButton.WithCaption("Hide not Linked Nodes").WithActionCommand(() => Presenter.HideNotLinkedNodes()));
            subMenuShow.AddItem(
                CreateMenuButton.WithCaption("Show Linked Nodes").WithActionCommand(() => Presenter.ShowLinkedNodes()));

            var subMenuExpand = CreateSubMenu.WithCaption("Expand / Collapse");

            subMenuDetailed.AddItem(subMenuExpand);

            subMenuExpand.AddItem(
                CreateMenuButton.WithCaption("Set Default Expansion").WithActionCommand(() => Presenter.SetDefaultExpansion()));
            subMenuExpand.AddItem(
                CreateMenuButton.WithCaption("Show Default Expansion")
                .WithActionCommand(() => Presenter.ShowDefaultExpansion()));

            if (Presenter.SelectionContains <IContainerNode>())
            {
                AddExpandMenuItems(subMenuExpand);
            }


            var subMenuDiagram = CreateSubMenu.WithCaption("Diagram");

            subMenuDetailed.AddItem(subMenuDiagram);

            subMenuDiagram.AddItem(
                CreateMenuButton.WithCaption("Copy clipping as Bitmap")
                .WithActionCommand(() => Presenter.CopyBitmapToClipboard(null)));
            subMenuDiagram.AddItem(
                CreateMenuButton.WithCaption("Print Preview...").WithActionCommand(() => Presenter.PrintDiagram()));

            var subMenuLayout = CreateSubMenu.WithCaption("Layout");

            if (containerBase != null)
            {
                subMenuDetailed.AddItem(subMenuLayout);
            }
            subMenuLayout.AddItem(
                CreateMenuButton.WithCaption("AutoLayout Grandchildren")
                .WithActionCommand(
                    () =>
                    Presenter.Layout(containerBase, AppConstants.Diagram.Base.LayoutDepthGrandChildren,
                                     null)));
            subMenuLayout.AddItem(
                CreateMenuButton.WithCaption("AutoLayout all Descendants")
                .WithActionCommand(
                    () => Presenter.Layout(containerBase, AppConstants.Diagram.Base.LayoutDepthAll, null)));
            if (_runOptions.IsDeveloperMode)
            {
                var subMenuDeveloper = CreateSubMenu.WithCaption("Developer Functions").AsGroupStarter()
                                       .WithItem(
                    CreateMenuButton.WithCaption("Position at 0")
                    .WithActionCommand(() => Presenter.Position0Selection()));
                subMenuDetailed.AddItem(subMenuDeveloper);
            }
        }
Beispiel #18
0
 private ContextMenuBase(IContextMenuView view)
 {
     _view = view;
 }
Beispiel #19
0
 protected ContextMenu(IContextMenuView view)
 {
     _view = view;
 }
Beispiel #20
0
 public TestContextMenu(IContextMenuView view)
     : base(view)
 {
 }
Beispiel #21
0
 protected virtual void SetLayoutMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
 {
     AddAutoLayoutMenuItems(contextMenuView, containerBase);
     contextMenuView.AddMenuItem(SubMenuLayout);
 }
Beispiel #22
0
 protected virtual void SetModelMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node)
 {
 }
Beispiel #23
0
 protected override void SetLayoutMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase)
 {
     AddTemplateLayoutMenuItems(contextMenuView, containerBase);
     AddAutoLayoutMenuItems(contextMenuView, containerBase);
     contextMenuView.AddMenuItem(SubMenuLayout);
 }
Beispiel #24
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            Control control = e.Source as Control;

            if (control == null || control.Tag == null)
            {
                return;
            }
            switch (control.Tag.ToString())
            {
            case "RFID":
                if (rfidView.Visibility != Visibility.Visible)
                {
                    rfidView.Show();
                }
                else
                {
                    rfidView.Activate();
                }
                break;

            case "TaskOrder":
                frame1.NavigateToPage(taskOrderView, false);
                lastView = taskOrderView;
                break;

            case "Report":
                frame1.NavigateToPage(reportView, false);
                lastView = null;
                break;

            case "Product":
                ProductParameterView productParameterView = new ProductParameterView();
                productParameterView.ShowDialog();
                break;

            case "SystemLog":
                SystemLogView systemLogView = new SystemLogView();
                systemLogView.ShowDialog();
                break;

            case "SystemInfo":
                SystemInfoView systemInfoView = new SystemInfoView();
                systemInfoView.ShowDialog();
                break;

            case "TagsView":
                TagsView tagsView = new TagsView();
                tagsView.ShowDialog();
                break;

            case "Start":
                runTag.Write(1);
                break;

            case "Stop":
                runTag.Write(0);
                break;

            case "New":
            case "Load":
            case "Edit":
            case "Delete":
            case "Finish":
            case "Download":
                if (lastView != null)
                {
                    lastView.ContextMenu_Click(control.Tag.ToString());
                }
                break;
            }
        }