Ejemplo n.º 1
0
		public override void Apply(IActionBuildingContext builder)
		{
			ActionPath path = new ActionPath(_pathHint, builder.ResourceResolver);
			builder.Action = new ActionPlaceholder(builder.ActionID, path, builder.ResourceResolver);
			builder.Action.Available = _initiallyAvailable;
			builder.Action.Persistent = true;
			builder.Action.Visible = false;
			builder.Action.Label = path.LastSegment.LocalizedText;
			builder.Action.GroupHint = new GroupHint(_groupHint ?? string.Empty);
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Constructs/initializes a <see cref="DropDownAction"/> via the given <see cref="IActionBuildingContext"/>.
		/// </summary>
		/// <remarks>For internal framework use only.</remarks>
		public override void Apply(IActionBuildingContext builder)
		{
			ActionPath path = new ActionPath(_path, builder.ResourceResolver);
			builder.Action = new DropDownAction(builder.ActionID, path, builder.ResourceResolver);
			builder.Action.Available = this.InitiallyAvailable;
			builder.Action.Persistent = true;
			builder.Action.Label = path.LastSegment.LocalizedText;

			((DropDownAction)builder.Action).SetMenuModelDelegate(
				CreateGetMenuModelDelegate(builder.ActionTarget, _menuModelPropertyName));
		}
Ejemplo n.º 3
0
		/// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="actionID">The logical action ID.</param>
        /// <param name="path">The action path.</param>
        /// <param name="resourceResolver">A resource resolver that will be used to resolve icons associated with this action.</param>
        protected Action(string actionID, ActionPath path, IResourceResolver resourceResolver)
        {
            _actionID = actionID;
            _path = path;
            _resourceResolver = resourceResolver;

            // smart defaults
            _enabled = true;
            _visible = true;
			_available = true;

			_persistent = false;

            FormerActionIDs = new List<string>();
        }
Ejemplo n.º 4
0
		private AbstractAction(string id, string path, IResourceResolver resourceResolver)
		{
			Platform.CheckForEmptyString(id, "id");
			Platform.CheckForEmptyString(path, "path");

			_resourceResolver = resourceResolver;
			_actionId = id;
            _formerActionIds = new List<string>();
			_path = new ActionPath(path, resourceResolver);
			_groupHint = new GroupHint(string.Empty);
			_label = string.Empty;
			_tooltip = string.Empty;
			_iconSet = null;
			_available = true;
			_permissible = false;
		}
Ejemplo n.º 5
0
		private static IAction CreateAction(
			string actionID,
			string path,
			WebBrowserComponent webBrowser)
		{
			string url = ExtractUrlFromFavourite(path);
			string menuPath = CreateMenuPath(path);

			// Create the menu action
			ActionPath actionPath = new ActionPath(menuPath, null);
			MenuAction action = new MenuAction(actionID, actionPath, ClickActionFlags.None, null);
			action.Label = actionPath.LastSegment.LocalizedText;

			// Set what we're supposed to do when the menu item is clicked
			action.SetClickHandler(
				delegate
				{
					// Navigate to the URL
					webBrowser.Url = url;
					webBrowser.Go();
				});

			return action;
		}
Ejemplo n.º 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;
						//}
                    }
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="actionID">The fully qualified action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="flags">Flags that control the style of the action.</param>
 /// <param name="resourceResolver">A resource resolver that will be used to resolve text and image resources.</param>
 public ClickAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resourceResolver)
     : base(actionID, path, resourceResolver)
 {
     _flags   = flags;
     _checked = false;
 }
Ejemplo n.º 8
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="actionID">The logical action ID.</param>
		/// <param name="path">The action path.</param>
		/// <param name="resourceResolver">A resource resolver that will be used to resolve resources associated with this action.</param>
		public DropDownAction(string actionID, ActionPath path, IResourceResolver resourceResolver)
			: base(actionID, path, resourceResolver)
		{
		}
Ejemplo n.º 9
0
		public ActionPlaceholder(string actionId, ActionPath path, IResourceResolver resourceResolver)
			: base(actionId, path, ClickActionFlags.None, resourceResolver) {}
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="actionID">The fully qualified action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="flags">Flags that control the style of the action.</param>
 /// <param name="resourceResolver">A resource resolver that will be used to resolve text and image resources.</param>
 public ButtonAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resourceResolver)
     : base(actionID, path, flags, resourceResolver)
 {
 }
Ejemplo n.º 11
0
 public ContextMenuAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resourceResolver) 
     : base(actionID, path, flags, resourceResolver)
 {
 }
Ejemplo n.º 12
0
 /// <summary>.
 /// Constructor
 /// </summary>
 /// <param name="actionID">The fully qualified action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="flags">Flags that control the style of the action.</param>
 /// <param name="resourceResolver">A resource resolver that will be used to resolve text and image resources.</param>
 public MenuAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resourceResolver)
     : base(actionID, path, flags, resourceResolver)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates the <see cref="KeyboardAction"/> represented by this attribute.
 /// </summary>
 /// <param name="actionID">The logical action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="flags">Flags that specify the click behaviour of the action.</param>
 /// <param name="resolver">The object used to resolve the action path and icons.</param>
 protected override ClickAction CreateAction(string actionID, ActionPath path, ClickActionFlags flags, ClearCanvas.Common.Utilities.IResourceResolver resolver)
 {
     return(new KeyboardAction(actionID, path, flags, resolver));
 }
        public static bool StartAimAnnotationTool(IImageViewer currentImageViewer)
        {
            if (currentImageViewer == null)
                return false;

            var actionPath = new ActionPath(BUTTON_ACTION_PATH, new ResourceResolver(typeof(AimAnnotationTool), true));
            IActionSet actionSet = currentImageViewer.ExportedActions.Select(action => action.Path.LocalizedPath == actionPath.LocalizedPath);
            if (actionSet != null)
            {
                foreach (IAction action in actionSet)
                {
                    ClickAction clickAction = action as ClickAction;
                    if (clickAction != null)
                    {
                        clickAction.Click();
                        return true;
                    }
                }
            }

            return false;
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="actionID"></param>
 /// <param name="path"></param>
 /// <param name="resourceResolver"></param>
 public TextBoxAction(string actionID, ActionPath path, IResourceResolver resourceResolver)
     : base(actionID, path, resourceResolver)
 {
 }
Ejemplo n.º 16
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="actionID"></param>
		/// <param name="path"></param>
		/// <param name="resourceResolver"></param>
		public TextBoxAction(string actionID, ActionPath path, IResourceResolver resourceResolver)
			: base(actionID, path, resourceResolver) {}
Ejemplo n.º 17
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="actionID">The logical action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="resourceResolver">A resource resolver that will be used to resolve resources associated with this action.</param>
 public DropDownAction(string actionID, ActionPath path, IResourceResolver resourceResolver)
     : base(actionID, path, resourceResolver)
 {
 }
Ejemplo n.º 18
0
		/// <summary>
		/// Creates the <see cref="ClickAction"/> represented by this attribute.
		/// </summary>
		/// <param name="actionID">The logical action ID.</param>
		/// <param name="path">The action path.</param>
		/// <param name="flags">Flags that specify the click behaviour of the action.</param>
		/// <param name="resolver">The object used to resolve the action path and icons.</param>
        protected abstract ClickAction CreateAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resolver);
Ejemplo n.º 19
0
		/// <summary>
		/// Applies this attribute to an <see cref="IAction"/> instance, via the specified <see cref="IActionBuildingContext"/>.
    	/// </summary>
    	/// <remarks>
    	/// Because this action is an <see cref="ActionInitiatorAttribute"/>, this method actually
    	/// creates the associated <see cref="ClickAction"/>.  <see cref="ActionDecoratorAttribute"/>s
    	/// merely modify the properties of the action.
    	/// </remarks>
    	public override void Apply(IActionBuildingContext builder)
        {
            // assert _action == null
            ActionPath path = new ActionPath(this.Path, builder.ResourceResolver);
            builder.Action = CreateAction(builder.ActionID, path, this.Flags, builder.ResourceResolver);
			builder.Action.Available = this.InitiallyAvailable;
            builder.Action.Persistent = true;
            ((ClickAction)builder.Action).KeyStroke = this.KeyStroke;
            builder.Action.Label = path.LastSegment.LocalizedText;

            if (!string.IsNullOrEmpty(_clickHandler))
            {
                // check that the method exists, etc
                ValidateClickHandler(builder.ActionTarget, _clickHandler);

                ClickHandlerDelegate clickHandler =
                    (ClickHandlerDelegate)Delegate.CreateDelegate(typeof(ClickHandlerDelegate), builder.ActionTarget, _clickHandler);
                ((ClickAction)builder.Action).SetClickHandler(clickHandler);
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="actionID">The fully qualified action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="flags">Flags that control the style of the action.</param>
 /// <param name="resourceResolver">A resource resolver that will be used to resolve text and image resources.</param>
 public ClickAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resourceResolver)
     : base(actionID, path, resourceResolver)
 {
     _flags = flags;
     _checked = false;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Factory method to instantiate the action.
 /// </summary>
 /// <param name="actionID">The logical action identifier to associate with this action.</param>
 /// <param name="path">The path to the action in the toolbar model.</param>
 /// <param name="flags">Flags specifying how the button should respond to being clicked.</param>
 /// <param name="resolver">The action resource resolver used to resolve the action path and icons.</param>
 /// <returns>A <see cref="ClickAction"/>.</returns>
 protected override ClickAction CreateAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resolver)
 {
     return(new ButtonAction(actionID, path, flags, resolver));
 }
Ejemplo n.º 22
0
    	/// <summary>
		/// Creates the <see cref="KeyboardAction"/> represented by this attribute.
    	/// </summary>
    	/// <param name="actionID">The logical action ID.</param>
    	/// <param name="path">The action path.</param>
    	/// <param name="flags">Flags that specify the click behaviour of the action.</param>
    	/// <param name="resolver">The object used to resolve the action path and icons.</param>
    	protected override ClickAction CreateAction(string actionID, ActionPath path, ClickActionFlags flags, ClearCanvas.Common.Utilities.IResourceResolver resolver)
        {
            return new KeyboardAction(actionID, path, flags, resolver);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Creates the <see cref="ClickAction"/> represented by this attribute.
 /// </summary>
 /// <param name="actionID">The logical action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="flags">Flags that specify the click behaviour of the action.</param>
 /// <param name="resolver">The object used to resolve the action path and icons.</param>
 protected abstract ClickAction CreateAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resolver);
Ejemplo n.º 24
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="actionId">The fully qualified action ID.</param>
 /// <param name="path">The action path.</param>
 /// <param name="flags">Flags that control the style of the action.</param>
 /// <param name="resolver">A resource resolver that will be used to resolve text and image resources.</param>
 public DropDownButtonAction(string actionId, ActionPath path, ClickActionFlags flags, IResourceResolver resolver)
     : base(actionId, path, flags, resolver)
 {
 }
Ejemplo n.º 25
0
    	/// <summary>
		/// Creates the <see cref="MenuAction"/> represented by this attribute.
    	/// </summary>
    	/// <param name="actionID">The logical action ID.</param>
    	/// <param name="path">The action path.</param>
    	/// <param name="flags">Flags that specify the click behaviour of the action.</param>
    	/// <param name="resolver">The object used to resolve the action path and icons.</param>
    	protected override ClickAction CreateAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resolver)
        {
            return new MenuAction(actionID, path, flags, resolver);
        }
Ejemplo n.º 26
0
		private AbstractAction(IAction concreteAction)
		{
			Platform.CheckForNullReference(concreteAction, "concreteAction");
			Platform.CheckTrue(concreteAction.Persistent, "Action must be persistent.");

			_resourceResolver = concreteAction.ResourceResolver;
			_actionId = concreteAction.ActionID;
		    _formerActionIds = new List<string>(concreteAction.FormerActionIDs);
			_path = new ActionPath(concreteAction.Path.ToString(), concreteAction.ResourceResolver);
			_groupHint = new GroupHint(concreteAction.GroupHint.Hint);
			_label = concreteAction.Label;
			_tooltip = concreteAction.Tooltip;
			_iconSet = concreteAction.IconSet;
			_available = concreteAction.Available;
			_permissible = concreteAction.Permissible;
		}
            public SegmentationActionContainer(SegmentationTool ownerTool, SegmentationMenuInfo info, int index)
            {
                _ownerTool = ownerTool;
                _info = info;

                StringBuilder pathStringBuilder = new StringBuilder();
                pathStringBuilder.AppendFormat("{0}/", ImageViewerComponent.ContextMenuSite);
                // Multiple patients
                if (_ownerTool.Context.Viewer.StudyTree.Studies.Any(study => study.ParentPatient.PatientId != info.PatientId))
                {
                    pathStringBuilder.AppendFormat("{0} · {1}/", info.PatientsName, info.PatientId);
                }
                // Multiple Studies
                if (_ownerTool.Context.Viewer.StudyTree.Studies.Any(study => study.StudyInstanceUid != info.StudyInstanceUid))
                {
                    // We are trying to replicate what ImageSetDescriptior.GetName() does here:
                    string modalitiesInStudy = StringUtilities.Combine(CollectionUtils.Sort(
                        _ownerTool.Context.Viewer.StudyTree.Studies.First(
                        study => study.StudyInstanceUid == info.StudyInstanceUid).ModalitiesInStudy), ", ");

                    DateTime studyDate;
                    DateParser.Parse(info.StudyDate, out studyDate);
                    DateTime studyTime;
                    TimeParser.Parse(info.StudyTime, out studyTime);

                    pathStringBuilder.AppendFormat("{0} {1}", studyDate.ToString(Format.DateFormat), studyTime.ToString(Format.TimeFormat));
                    if (!string.IsNullOrEmpty(info.StudyAccessionNumber))
                        pathStringBuilder.AppendFormat(", A#: {0}", info.StudyAccessionNumber);
                    pathStringBuilder.AppendFormat(", [{0}] {1}/", modalitiesInStudy ?? "", info.StudyDescription);
                }
                pathStringBuilder.AppendFormat("SEG{0}", index);

                string actionId = String.Format("{0}:apply{1}", typeof (SegmentationTool).FullName, index);
                var actionPath = new ActionPath(pathStringBuilder.ToString(), _ownerTool._resolver);
                _action = new MenuAction(actionId, actionPath, ClickActionFlags.None, _ownerTool._resolver);
                _action.GroupHint = new GroupHint("DisplaySets");

                _action.Label = String.Format("{0} SEG: {1}", _info.SeriesNumber, _info.DisplayLabel);
                _action.SetClickHandler(Apply);
            }