예제 #1
0
        public static void BuildMenu(MenuShell menu, ActionModelNode node)
        {
            if (node.PathSegment != null)
            {
                MenuItem menuItem;
                if (node.Action != null)
                {
                    // this is a leaf node (terminal menu item)
                    menuItem = new ActiveMenuItem((IClickAction)node.Action);
                }
                else
                {
                    // this menu item has a sub menu
                    string menuText = node.PathSegment.LocalizedText.Replace('&', '_');
                    menuItem         = new MenuItem(menuText);
                    menuItem.Submenu = new Menu();
                }

                menu.Append(menuItem);
                menu = (MenuShell)menuItem.Submenu;
            }

            foreach (ActionModelNode child in node.ChildNodes)
            {
                BuildMenu(menu, child);
            }
        }
예제 #2
0
        private void OnContextMenuStripOpening(object sender, CancelEventArgs e)
        {
            if (_tileController == null || _tileController.ContextMenuProvider == null)
            {
                e.Cancel = true;
                return;
            }

            if (_tileController.ContextMenuEnabled)
            {
                ActionModelNode menuModel = _tileController.ContextMenuProvider.GetContextMenuModel(_tileController);
                if (menuModel != null && menuModel.ChildNodes.Count > 0)
                {
                    ToolStripBuilder.Clear(_contextMenuStrip.Items);
                    ToolStripBuilder.BuildMenu(_contextMenuStrip.Items, menuModel.ChildNodes);

                    // filter unavailable items out of list since they wreck the display of the overflow and scroll portions of the menu dropdown
                    // (ClearCanvas Ticket #4775, Microsoft Connect Issue #136061)
                    FilterUnavailableItems(_contextMenuStrip.Items);

                    // cancel list if, after filtering, no items are left to display.
                    e.Cancel = (_contextMenuStrip.Items.Count == 0);
                }
                else
                {
                    e.Cancel = true;
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
예제 #3
0
        /// <summary>
        /// Gets the cursor token associated with the tool.
        /// </summary>
        /// <param name="point">The point in destination (view) coordinates.</param>
        /// <returns>a <see cref="CursorToken"/> object that is used to construct the cursor in the view.</returns>
        public bool GetCheckedSync()
        {
            ImageViewerComponent view = this.ImageViewer as ImageViewerComponent;
            ActionModelNode      node = view.ToolbarModel;

            ActionModelNode tempNode = null;

            IAction[] action = null;
            foreach (ActionModelNode tempnode in node.ChildNodes)
            {
                if (tempnode.PathSegment.ResourceKey == "ToolbarSynchronizeStackingLinkStudies")
                {
                    tempNode = tempnode;
                    break;
                }
            }
            if (tempNode != null)
            {
                action = tempNode.GetActionsInOrder();
            }
            if ((action != null))
            {
                ButtonAction ac = action[0] as ButtonAction;
                return(ac.Checked);
            }
            return(false);
        }
예제 #4
0
 private static void BuildActionModelTree(ActionModelNode actionModel, AbstractActionModelTreeBranch abstractActionModelTreeBranch)
 {
     foreach (ActionModelNode childNode in actionModel.ChildNodes)
     {
         if (childNode is ActionNode)
         {
             ActionNode actionNode = (ActionNode)childNode;
             if (actionNode.Action.Persistent)
             {
                 if (actionNode.Action is IClickAction)
                 {
                     abstractActionModelTreeBranch.AppendChild(new AbstractActionModelTreeLeafClickAction((IClickAction)actionNode.Action));
                 }
                 else
                 {
                     abstractActionModelTreeBranch.AppendChild(new AbstractActionModelTreeLeafAction(actionNode.Action));
                 }
             }
         }
         else if (childNode is SeparatorNode)
         {
             abstractActionModelTreeBranch.AppendChild(new AbstractActionModelTreeLeafSeparator());
         }
         else if (childNode is BranchNode)
         {
             AbstractActionModelTreeBranch treeBranch = new AbstractActionModelTreeBranch(childNode.PathSegment);
             BuildActionModelTree(childNode, treeBranch);
             abstractActionModelTreeBranch.AppendChild(treeBranch);
         }
     }
 }
예제 #5
0
 private static void BuildFlatActionModelTree(ActionModelNode actionModel, AbstractActionModelTreeBranch abstractActionModelTreeBranch)
 {
     foreach (ActionModelNode childNode in actionModel.GetLeafNodesInOrder())
     {
         if (childNode is ActionNode)
         {
             ActionNode actionNode = (ActionNode)childNode;
             if (actionNode.Action.Persistent)
             {
                 if (actionNode.Action is IClickAction)
                 {
                     abstractActionModelTreeBranch.AppendChild(new AbstractActionModelTreeLeafClickAction((IClickAction)actionNode.Action));
                 }
                 else
                 {
                     abstractActionModelTreeBranch.AppendChild(new AbstractActionModelTreeLeafAction(actionNode.Action));
                 }
             }
         }
         else if (childNode is SeparatorNode)
         {
             abstractActionModelTreeBranch.AppendChild(new AbstractActionModelTreeLeafSeparator());
         }
     }
 }
예제 #6
0
        private void NavigatingEventHandler(object sender, System.Windows.Forms.WebBrowserNavigatingEventArgs e)
        {
            // default page - allow navigation to proceed
            if (e.Url.OriginalString == "about:blank")
            {
                return;
            }

            if (e.Url.OriginalString.StartsWith("action:"))
            {
                e.Cancel = true;    // cancel the webbrowser navigation

                ActionModelNode embeddedActionModel = GetEmbeddedActionModel();
                if (embeddedActionModel != null)
                {
                    // need to find the action in the model that matches the uri path
                    // TODO clean this up - this is a bit of hack right now
                    ActionPath uriPath = new ActionPath(e.Url.LocalPath, null);
                    foreach (ActionModelNode child in embeddedActionModel.ChildNodes)
                    {
                        // not currently used
                        //if(child.Action.Path.LastSegment.ResourceKey == uriPath.LastSegment.ResourceKey)
                        //{
                        //    ((IClickAction)child.Action).Click();
                        //    break;
                        //}
                    }
                }
            }
        }
예제 #7
0
        private void Select()
        {
            if (!this.Selected)
            {
                //Platform.CheckMemberIsSet(this.DisplaySet, "ImageBox.DisplaySet");
                Platform.CheckMemberIsSet(this.ParentPhysicalWorkspace, "ImageBox.ParentPhysicalWorkspace");
                Platform.CheckMemberIsSet(this.ImageViewer, "ImageBox.ImageViewer");

                this.Selected = true;
                _parentPhysicalWorkspace.SelectedImageBox = this;
                this.ImageViewer.EventBroker.OnImageBoxSelected(new ImageBoxSelectedEventArgs(this));

                if (_displaySet != null)
                {
                    _displaySet.Selected = true;
                }
            }
            try
            {
                ImageViewerComponent view = this.ImageViewer as ImageViewerComponent;

                ActionModelNode node = view.ToolbarModel;

                ActionModelNode tempNode = null;
                IAction[]       action   = null;
                foreach (ActionModelNode tempnode in node.ChildNodes)
                {
                    if (tempnode.PathSegment.ResourceKey == "ToolbarSynchronizeStacking")
                    {
                        tempNode = tempnode;
                        break;
                    }
                }
                if (tempNode != null)
                {
                    action = tempNode.GetActionsInOrder();
                }
                if ((action != null) && (action.Count() > 0))
                {
                    ButtonAction ac  = action[0] as ButtonAction;
                    ImageSop     sop = ((IImageSopProvider)this.TopLeftPresentationImage).ImageSop;
                    if (sop.Modality == "DX" || sop.Modality == "CR" || sop.Modality == "RF")
                    {
                        ac.Checked = false;
                    }
                    else
                    {
                        ac.Checked = true;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void OnDropDownOpening(object sender, EventArgs e)
        {
            ToolStripBuilder.Clear(this.DropDownItems);

            ActionModelNode model = ((IDropDownAction)_action).DropDownMenuModel;

            if (model != null)
            {
                ToolStripBuilder.BuildMenu(this.DropDownItems, model.ChildNodes);
            }
        }
예제 #9
0
 private static void ShowContextMenu(ContextMenuStrip contextMenuStrip, ActionModelNode actionModel, Point screenPoint, int minWidth, bool alignRight)
 {
     ToolStripBuilder.Clear(contextMenuStrip.Items);
     if (actionModel != null)
     {
         ToolStripBuilder.BuildMenu(contextMenuStrip.Items, actionModel.ChildNodes);
         if (alignRight)
         {
             screenPoint.Offset(-contextMenuStrip.Width, 0);
         }
         contextMenuStrip.Show(screenPoint);
     }
 }
예제 #10
0
        /// <summary>
        /// Updates the view's title, menu and toolbars.
        /// </summary>
        internal void UpdateView()
        {
            if (this.DesktopWindowView != null)
            {
                this.Title = MakeTitle(_baseTitle, _workspaces.ActiveWorkspace);

                _menuModel    = BuildActionModel(_menuActionSite);
                _toolbarModel = BuildActionModel(_toolbarActionSite);

                this.DesktopWindowView.SetMenuModel(_menuModel);
                this.DesktopWindowView.SetToolbarModel(_toolbarModel);
            }
        }
예제 #11
0
 private void DataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         if (_contextActionModelDelegate != null)
         {
             ActionModelNode actionModel = _contextActionModelDelegate(-1, e.ColumnIndex);
             Rectangle       r           = base.DataGridView.GetColumnDisplayRectangle(e.ColumnIndex, true);
             ShowContextMenu(_contextMenuStrip, actionModel,
                             base.DataGridView.PointToScreen(new Point(e.Location.X + r.Left, e.Location.Y + r.Top)),
                             0, false);
         }
     }
 }
예제 #12
0
        private void DisposeTools()
        {
            // if column is removed from an owner, dispose any tools which are hanging on
            if (_actionModel != null)
            {
                _actionModel = null;
            }

            if (_tools != null)
            {
                _tools.Dispose();
                _tools = null;
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="component"></param>
        public ApplicationComponentUserControl(IApplicationComponent component)
        {
            InitializeComponent();

            _errorProvider.DataSource           = component;
            component.ValidationVisibleChanged += ValidationVisibleChangedEventHandler;

            if (component is ApplicationComponent)
            {
                ActionModelNode menuModel = ((ApplicationComponent)component).MetaContextMenuModel;
                if (menuModel != null)
                {
                    ToolStripBuilder.BuildMenu(_contextMenu.Items, menuModel.ChildNodes);
                }
            }
        }
예제 #14
0
 public static void BuildToolbar(Toolbar toolbar, Tooltips tooltips, ActionModelNode node, int depth)
 {
     if (node.Action != null)
     {
         // create the tool button
         ToolButton button = new ActiveToolbarButton((IClickAction)node.Action, tooltips);
         toolbar.Insert(button, toolbar.NItems);
     }
     else
     {
         foreach (ActionModelNode child in node.ChildNodes)
         {
             BuildToolbar(toolbar, tooltips, child, depth + 1);
         }
     }
 }
예제 #15
0
        private void ProcessExplicitContextMenuRequest(Point?location, ActionModelNode actionModel)
        {
            //Force a handler with capture to release.
            if (this.CaptureHandler != null)
            {
                ReleaseCapture(true);
            }

            //When we show the context menu, reset the active button and start count,
            //because the user is going to have to start over again with a new click.
            _activeButton = 0;
            _startCount   = 0;

            if (!location.HasValue || !TileClientRectangle.Contains(location.Value))
            {
                location = _currentMousePoint;
            }

            if (actionModel == null)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                //Get all the mouse button handlers that provide a context menu.
                foreach (var handlerGraphic in GetHandlerGraphics(sceneGraph).OfType <IContextMenuProvider>())
                {
                    var actionSet = handlerGraphic.GetContextMenuModel(this);
                    if (actionSet != null && actionSet.ChildNodes.Count > 0)
                    {
                        ContextMenuProvider = handlerGraphic;
                        break;
                    }
                }
            }
            else
            {
                ContextMenuProvider = new ActionModelProvider(actionModel);
            }

            //Request the context menu.
            _contextMenuEnabled = true;
            EventsHelper.Fire(_contextMenuRequested, this, new ItemEventArgs <Point>(location.Value));

            ContextMenuProvider = null;
        }
예제 #16
0
        /// <summary>
        /// Searches <paramref name="actionNode"/> and returns the action (represented as HTML) whose label matches
        /// <paramref name="labelSearch"/>.
        /// </summary>
        /// <param name="actionNode">The node to be searched.</param>
        /// <param name="labelSearch">The label to match on.</param>
        /// <param name="actionLabel">The new label to be applied to the action in the returned HTML.</param>
        /// <returns>The found action represented as HTML, otherwise an empty string.</returns>
        public string GetHTML(ActionModelNode actionNode, string labelSearch, string actionLabel)
        {
            IAction[] actions = actionNode.GetActionsInOrder();
            if (actions.Length == 0)
            {
                return("");
            }

            // find the action corresponding to the action label, if exist
            foreach (var action in actions)
            {
                if (action.Label == labelSearch)
                {
                    return(GetHTML(action.Path.LocalizedPath, actionLabel));
                }
            }

            return("");
        }
예제 #17
0
        private void AppendActionModel(TableView table, ActionModelNode model)
        {
            if (table.ToolbarModel == null)
            {
                table.ToolbarModel = model;
            }
            else
            {
                table.ToolbarModel.Merge(model);
            }

            if (table.MenuModel == null)
            {
                table.MenuModel = model;
            }
            else
            {
                table.MenuModel.Merge(model);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public BiographyOrderReportsComponentControl(BiographyOrderReportsComponent component)
            : base(component)
        {
            _component = component;
            InitializeComponent();

            Control reportPreview = (Control)_component.ReportPreviewComponentHost.ComponentView.GuiElement;

            reportPreview.Dock = DockStyle.Fill;
            _reportPreviewPanel.Controls.Add(reportPreview);

            _reports.DataSource = _component.Reports;
            _reports.DataBindings.Add("Value", _component, "SelectedReport", true, DataSourceUpdateMode.OnPropertyChanged);
            _reports.Format += delegate(object sender, ListControlConvertEventArgs e) { e.Value = _component.FormatReportListItem(e.ListItem); };

            _toolbarActionModel = _component.ActionModel;
            ToolStripBuilder.BuildToolbar(_toolstrip.Items, _toolbarActionModel.ChildNodes);

            _component.AllPropertiesChanged += AllPropertiesChangedEventHandler;
        }
예제 #19
0
        ////TODO (CR May 2010): We should add in the capability for handler extensions,
        /// much like the applicationcomponent views.
        public static ActionNodeEntityHandler Create(ActionModelNode modelNode)
        {
            if (modelNode is ActionNode)
            {
                IAction action = ((ActionNode)modelNode).Action;
                if (action is DropDownButtonAction)
                {
                    IEntityHandler handler = Create <DropDownButtonActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
                if (action is DropDownAction)
                {
                    IEntityHandler handler = Create <DropDownActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
                if (action is LayoutChangerAction)
                {
                    IEntityHandler handler = Create <LayoutChangerActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
                if (action is IClickAction)
                {
                    IEntityHandler handler = Create <ClickActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
            }
            else if (modelNode.ChildNodes.Count > 0)
            {
                IEntityHandler handler = Create <BranchActionEntityHandler>();
                handler.SetModelObject(modelNode);
                return((ActionNodeEntityHandler)handler);
            }

            //TODO (CR May 2010): although we won't get here, if we did, we should throw
            return(null);
        }
예제 #20
0
        private void FireContextMenuEvent()
        {
            if (_tileController.ContextMenuProvider != null && _tileController.ContextMenuEnabled)
            {
                ActionModelNode actionModelNode = _tileController.ContextMenuProvider.GetContextMenuModel(_tileController);
                if (_contextMenu != null)
                {
                    _contextMenu.Dispose();
                }

                _contextMenu = new ContextMenuContainer(actionModelNode);

                ApplicationContext.FireEvent(new ContextMenuEvent
                {
                    Identifier      = Guid.NewGuid(),
                    SenderId        = Identifier,
                    ActionModelRoot = new WebActionNode {
                        Children = _contextMenu.GetWebActions()
                    }
                });
            }
        }
예제 #21
0
        /// <summary>
        /// Constructs a <see cref="GalleryComponent"/> with the specified data source, automatically adding the actions of
        /// <see cref="GalleryToolExtensionPoint"/>s at the specified action sites.
        /// </summary>
        /// <param name="dataSource">An <see cref="IBindingList"/> of <see cref="IGalleryItem"/>s.</param>
        /// <param name="toolbarSite">The site for toolbar actions.</param>
        /// <param name="contextMenuSite">The site for context menu actions.</param>
        public GalleryComponent(IBindingList dataSource, string toolbarSite, string contextMenuSite)
        {
            _dataSource = dataSource;

            if (toolbarSite != null || contextMenuSite != null)
            {
                GalleryToolExtensionPoint xp = new GalleryToolExtensionPoint();
                ToolContext context          = new ToolContext(this);
                ToolSet     ts = new ToolSet(xp, context);

                if (contextMenuSite != null)
                {
                    _menuModel = ActionModelRoot.CreateModel(typeof(GalleryComponent).FullName, contextMenuSite, ts.Actions);
                }
                if (toolbarSite != null)
                {
                    _toolbarModel = ActionModelRoot.CreateModel(typeof(GalleryComponent).FullName, toolbarSite, ts.Actions);
                }

                _toolSet = ts;
            }
        }
예제 #22
0
        public void PrintFilm()
        {
            ActionModelNode node = ContextMenuModel;

            ActionModelNode tempNode = null;

            IAction[] action = null;
            foreach (ActionModelNode tempnode in node.ChildNodes)
            {
                Platform.Log(LogLevel.Error, "the source is " + tempnode.PathSegment.ResourceKey);
                if (tempnode.PathSegment.ResourceKey == "MenuThirdPrint" || tempnode.PathSegment.ResourceKey == "MenuPrintChooseDisplaySet")
                {
                    tempNode = tempnode;
                    break;
                }
            }

            if (tempNode != null)
            {
                action = tempNode.GetActionsInOrder();
            }
            if ((action != null) && (action.Count() > 0))
            {
                MenuAction ac = action[1] as MenuAction;
                ac.Click();
            }

            //foreach (ITool tool in _toolSet.Tools)
            //{
            //    string strname = tool.GetType().FullName;
            //    if (strname == "ClearCanvas.ImageViewer.Tools.Standard.ThirdPrintTool")
            //    {

            //    }
            //}
        }
예제 #23
0
        //private static void AdvanceImage(int increment, IImageBox selectedImageBox)
        private void AdvanceImage(int increment, IImageBox selectedImageBox)
        {
            if (increment > 0)
            {
                GlobalData.direct = 1;
            }
            else
            {
                GlobalData.direct = -1;
            }

            int prevTopLeftPresentationImageIndex = selectedImageBox.TopLeftPresentationImageIndex;

            selectedImageBox.TopLeftPresentationImageIndex += increment;


            if (selectedImageBox.TopLeftPresentationImageIndex != prevTopLeftPresentationImageIndex)
            {
                selectedImageBox.Draw();
            }

            else
            {
                ImageViewerComponent view = this.ImageViewer as ImageViewerComponent;
                ActionModelNode      node = view.ToolbarModel;

                ActionModelNode tempNode = null;
                IAction []      action   = null;
                foreach (ActionModelNode tempnode in node.ChildNodes)
                {
                    if (tempnode.PathSegment.ResourceKey == "ToolbarSynchronizeStacking")
                    {
                        tempNode = tempnode;
                        break;
                    }
                }
                if (tempNode != null)
                {
                    action = tempNode.GetActionsInOrder();
                }
                if ((action != null) && (action.Count() > 0))
                {
                    ButtonAction ac = action[0] as ButtonAction;
                    if (ac.Checked == true)
                    {
                        return;
                    }
                }
                if (selectedImageBox.TopLeftPresentationImage == null)
                {
                    return;
                }
#if SUINING
                ImageSop sop = ((IImageSopProvider)selectedImageBox.TopLeftPresentationImage).ImageSop;
                if (sop.Modality == "CT" || sop.Modality == "MR")
                {
                    return;
                }
#endif
                if (increment > 0)
                {
                    AdvanceDisplaySet(1);
                }
                else
                {
                    AdvanceDisplaySet(-1);
                }
            }
        }
예제 #24
0
 public void ShowContextMenu(Point? tileLocation, ActionModelNode actionModel)
 {
     EventsHelper.Fire(_contextMenuRequested, this, new TileContextMenuRequestEventArgs(tileLocation, actionModel));
 }
예제 #25
0
 public TileContextMenuRequestEventArgs(Point? location, ActionModelNode actionModel)
 {
     Location = location;
     ActionModel = actionModel;
 }
예제 #26
0
 public ItemTag(ActionModelNode node, IActionView view)
 {
     _node = node;
     _view = view;
 }
예제 #27
0
 /// <summary>
 /// Sets the toolbar model, causing the toolbar displayed on the screen to be updated.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="model"></param>
 public virtual void SetToolbarModel(ActionModelNode model)
 {
 }
예제 #28
0
 /// <summary>
 /// Sets the menu model, causing the menu displayed on the screen to be updated.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="model"></param>
 public virtual void SetMenuModel(ActionModelNode model)
 {
 }
예제 #29
0
 public static void BuildToolbar(Toolbar toolbar, Tooltips tooltips, ActionModelNode node)
 {
     BuildToolbar(toolbar, tooltips, node, 0);
 }
예제 #30
0
        /// <summary>
        /// Called to build menus and toolbars.  Override this method to customize menu and toolbar building.
        /// </summary>
        /// <remarks>
        /// The default implementation simply clears and re-creates the toolstrip using methods on the
        /// utility class <see cref="ToolStripBuilder"/>.
        /// </remarks>
        /// <param name="kind"></param>
        /// <param name="toolStrip"></param>
        /// <param name="actionModel"></param>
        protected virtual void BuildToolStrip(ToolStripBuilder.ToolStripKind kind, ToolStrip toolStrip, ActionModelNode actionModel)
        {
            // avoid flicker
            toolStrip.SuspendLayout();
            // very important to clean up the existing ones first
            ToolStripBuilder.Clear(toolStrip.Items);

            if (actionModel != null)
            {
                if (actionModel.ChildNodes.Count > 0)
                {
                    // Toolstrip should only be visible if there are items on it
                    if (kind == ToolStripBuilder.ToolStripKind.Toolbar)
                    {
                        ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes, ToolStripBuilder.ToolStripBuilderStyle.GetDefault(), ToolStripSettings.Default.IconSize);
                    }
                    else
                    {
                        ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes);
                    }
                }
            }

            toolStrip.ResumeLayout();
        }