private Image GetOverlayIcon(IconSize iconSize) { var resourceResolver = new ApplicationThemeResourceResolver(GetType().Assembly); var overlayIconSet = GrayMode ? _grayIconSet : _redIconSet; return(overlayIconSet.CreateIcon(iconSize, resourceResolver)); }
private void UpdateIcons() { var resourceResolver = new ApplicationThemeResourceResolver(GetType(), false); _searchButton.Image = resourceResolver.OpenImage(@"Resources.SearchToolSmall.png"); _clearButton.Image = resourceResolver.OpenImage(@"Resources.ClearFilterSmall.png"); }
private void UpdateIcons() { var resourceResolver = new ApplicationThemeResourceResolver(GetType(), false); _searchButton.Image = resourceResolver.OpenImage(@"Icons.Search.png"); _searchTodayButton.Image = resourceResolver.OpenImage(@"Icons.Today.png"); _searchLastWeekButton.Image = resourceResolver.OpenImage(@"Icons.Last7Days.png"); _clearButton.Image = resourceResolver.OpenImage(@"Icons.Clear.png"); }
/// <summary> /// Gets a statically cached image resource. /// </summary> internal static Image GetImageResource(string resourceName) { // simple static resource caching - the progress bar graphical elements only total about 6 kilobytes if (!_cachedImageResources.ContainsKey(resourceName)) { var resourceResolver = new ApplicationThemeResourceResolver(Assembly.GetExecutingAssembly()); var image = Image.FromStream(resourceResolver.OpenResource(resourceName)); _cachedImageResources.Add(resourceName, image); } return(_cachedImageResources[resourceName]); }
/// <summary> /// Gets the appropriate icon overlay resource name to indicate an unavailable action. /// </summary> /// <param name="iconSize">The desired version of the icon overlay.</param> /// <returns>The requested icon overlay as an <see cref="Image"/>.</returns> private Image GetOverlayIcon(IconSize iconSize) { var resourceResolver = new ApplicationThemeResourceResolver(GetType().Assembly); switch (iconSize) { case IconSize.Small: return new Bitmap(resourceResolver.OpenResource("Icons.UnavailableToolOverlaySmall.png")); case IconSize.Medium: return new Bitmap(resourceResolver.OpenResource("Icons.UnavailableToolOverlayMedium.png")); case IconSize.Large: default: return new Bitmap(resourceResolver.OpenResource("Icons.UnavailableToolOverlayLarge.png")); } }
/// <summary> /// Gets a set of exported <see cref="IAction"/>s. /// </summary> /// <param name="site">The action model site at which the actions should reside.</param> /// <param name="mouseInformation">The mouse input when the action model was requested, such as in response to a context menu request.</param> /// <returns>A set of exported <see cref="IAction"/>s.</returns> public override IActionSet GetExportedActions(string site, IMouseInformation mouseInformation) { IResourceResolver resolver = new ApplicationThemeResourceResolver(this.GetType(), true); string @namespace = typeof(RoiCalloutGraphic).FullName; List <IAction> actions = new List <IAction>(); MenuAction hideAction = new MenuAction(@namespace + ":toggle", new ActionPath(site + "/MenuShowAnalysis", resolver), ClickActionFlags.None, resolver); hideAction.GroupHint = new GroupHint("Tools.Measurements.Display"); hideAction.Label = SR.MenuShowAnalysis; hideAction.Checked = this.ShowAnalysis; hideAction.Persistent = true; hideAction.SetClickHandler(this.ToggleShowAnalysis); actions.Add(hideAction); if (AllowRename) { MenuAction renameAction = new MenuAction(@namespace + ":rename", new ActionPath(site + "/MenuRename", resolver), ClickActionFlags.None, resolver); renameAction.GroupHint = new GroupHint("Tools.Measurements.Properties"); renameAction.Label = SR.MenuRename; renameAction.Persistent = true; renameAction.SetClickHandler(this.Rename); actions.Add(renameAction); } IActionSet actionSet = new ActionSet(actions); if (this.ShowAnalysis) { var analyzerActionSets = GetAnalyzersExportedActions(site, mouseInformation); if (analyzerActionSets != null) { foreach (var set in analyzerActionSets) { actionSet = actionSet.Union(set); } } } IActionSet other = base.GetExportedActions(site, mouseInformation); if (other != null) { actionSet = actionSet.Union(other); } return(actionSet); }
public Rotate3DTool() : base(SR.TooltipRotate3D) { CursorToken = new CursorToken("Icons.Rotate3DToolSmall.png", GetType().Assembly); _operation = new SpatialTransform3DImageOperation(Apply); const string graphicName = "Icons.NoSpineLabeling.png"; var iconSet = new UnavailableActionIconSet(new IconSet("Icons.Rotate3DToolSmall.png", "Icons.Rotate3DToolMedium.png", "Icons.Rotate3DToolLarge.png")); var resolver = new ApplicationThemeResourceResolver(GetType(), false); _flashOverlayController = new FlashOverlayController(iconSet, resolver) { FlashSpeed = 1500 }; }
/// <summary> /// Gets a set of exported <see cref="IAction"/>s. /// </summary> /// <param name="site">The action model site at which the actions should reside.</param> /// <param name="mouseInformation">The mouse input when the action model was requested, such as in response to a context menu request.</param> /// <returns>A set of exported <see cref="IAction"/>s.</returns> public override IActionSet GetExportedActions(string site, IMouseInformation mouseInformation) { if (!HitTest(mouseInformation.Location)) { return(new ActionSet()); } IResourceResolver resolver = new ApplicationThemeResourceResolver(this.GetType(), true); string @namespace = typeof(TextEditControlGraphic).FullName; MenuAction action = new MenuAction(@namespace + ":edit", new ActionPath(site + "/MenuEditText", resolver), ClickActionFlags.None, resolver); action.GroupHint = new GroupHint("Tools.Graphics.Edit"); action.Label = SR.MenuEditText; action.Persistent = true; action.SetClickHandler(delegate { this.StartEdit(); }); return(base.GetExportedActions(site, mouseInformation).Union(new ActionSet(new IAction[] { action }))); }
/// <summary> /// Gets the appropriate icon overlay resource name to indicate an unavailable action. /// </summary> /// <param name="iconSize">The desired version of the icon overlay.</param> /// <returns>The requested icon overlay as an <see cref="Image"/>.</returns> private Image GetOverlayIcon(IconSize iconSize) { var resourceResolver = new ApplicationThemeResourceResolver(GetType().Assembly); switch (iconSize) { case IconSize.Small: return(new Bitmap(resourceResolver.OpenResource("Icons.UnavailableToolOverlaySmall.png"))); case IconSize.Medium: return(new Bitmap(resourceResolver.OpenResource("Icons.UnavailableToolOverlayMedium.png"))); case IconSize.Large: default: return(new Bitmap(resourceResolver.OpenResource("Icons.UnavailableToolOverlayLarge.png"))); } }
private void InitializeMenuAndToolbar() { ResourceResolver resolver = new ApplicationThemeResourceResolver(this.GetType().Assembly); _toolbarModel = new SimpleActionModel(resolver); _toolbarModel.AddAction("add", SR.LabelAdd, "AddToolSmall.png", OnAdd); _toolbarModel.AddAction("edit", SR.LabelEdit, "EditToolSmall.png", OnEditSelected); _toolbarModel.AddAction("delete", SR.LabelDelete, "DeleteToolSmall.png", OnDeleteSelected); _contextMenuModel = new SimpleActionModel(resolver); _contextMenuModel.AddAction("add", SR.LabelAdd, "AddToolSmall.png", OnAdd); _contextMenuModel.AddAction("edit", SR.LabelEdit, "EditToolSmall.png", OnEditSelected); _contextMenuModel.AddAction("delete", SR.LabelDelete, "DeleteToolSmall.png", OnDeleteSelected); _toolbarModel["add"].Visible = !HasMultipleFactories; _contextMenuModel["add"].Visible = !HasMultipleFactories; UpdateButtonStates(); }
/// <summary> /// Gets a set of exported <see cref="IAction"/>s. /// </summary> /// <param name="site">The action model site at which the actions should reside.</param> /// <param name="mouseInformation">The mouse input when the action model was requested, such as in response to a context menu request.</param> /// <returns>A set of exported <see cref="IAction"/>s.</returns> public override IActionSet GetExportedActions(string site, IMouseInformation mouseInformation) { IActionSet actions = base.GetExportedActions(site, mouseInformation); _lastContextMenuPoint = mouseInformation.Location; if (!_canAddRemoveVertices) { return(actions); } if (!base.Subject.HitTest(Point.Round(_lastContextMenuPoint))) { return(actions); } int count = this.Subject.Points.Count; bool hit = base.ControlPoints.HitTest(Point.Round(_lastContextMenuPoint)); IResourceResolver resolver = new ApplicationThemeResourceResolver(this.GetType(), true); string @namespace = typeof(VerticesControlGraphic).FullName; MenuAction insertAction = new MenuAction(@namespace + ":insert", new ActionPath(site + "/MenuInsertVertex", resolver), ClickActionFlags.None, resolver); insertAction.GroupHint = new GroupHint("Tools.Graphics.Edit"); insertAction.Label = SR.MenuInsertVertex; insertAction.Persistent = true; insertAction.SetClickHandler(this.PerformInsertVertex); MenuAction deleteAction = new MenuAction(@namespace + ":delete", new ActionPath(site + "/MenuDeleteVertex", resolver), ClickActionFlags.None, resolver); deleteAction.GroupHint = new GroupHint("Tools.Graphics.Edit"); deleteAction.Label = SR.MenuDeleteVertex; deleteAction.Visible = hit && count > 1; deleteAction.Persistent = true; deleteAction.SetClickHandler(this.PerformDeleteVertex); return(actions.Union(new ActionSet(new IAction[] { insertAction, deleteAction }))); }
public AbstractActionModelTreeLeafAction(IAction action) : base(action.Path.LastSegment) { Platform.CheckForNullReference(action, "action"); Platform.CheckTrue(action.Persistent, "Action must be persistent."); // this allows us to keep a "clone" that is independent of the live action objects // that might (probably are) in use or cached in some tool or component somewhere. _action = AbstractAction.Create(action); CheckState = _action.Available ? CheckState.Checked : CheckState.Unchecked; IconSet iconSet; if (action.IconSet == null || action.ResourceResolver == null) { iconSet = new IconSet("Icons.ActionModelNullSmall.png", "Icons.ActionModelNullMedium.png", "Icons.ActionModelNullLarge.png"); ResourceResolver = new ApplicationThemeResourceResolver(typeof(AbstractActionModelTreeLeafAction).Assembly, action.ResourceResolver); } else { iconSet = _action.IconSet; ResourceResolver = _action.ResourceResolver; } if (_action.Permissible) { IconSet = iconSet; } else { IconSet = new UnavailableActionIconSet(iconSet); Description = SR.TooltipActionNotPermitted; Tooltip = String.IsNullOrEmpty(CanonicalLabel) ? SR.TooltipActionNotPermitted : String.Format(SR.TooltipFormatActionNotPermitted, CanonicalLabel); } }
public AbstractActionModelTreeLeafAction(IAction action) : base(action.Path.LastSegment) { Platform.CheckForNullReference(action, "action"); Platform.CheckTrue(action.Persistent, "Action must be persistent."); // this allows us to keep a "clone" that is independent of the live action objects // that might (probably are) in use or cached in some tool or component somewhere. _action = AbstractAction.Create(action); CheckState = _action.Available ? CheckState.Checked : CheckState.Unchecked; IconSet iconSet; if (action.IconSet == null || action.ResourceResolver == null) { iconSet = new IconSet("Icons.ActionModelNullSmall.png", "Icons.ActionModelNullMedium.png", "Icons.ActionModelNullLarge.png"); ResourceResolver = new ApplicationThemeResourceResolver(typeof(AbstractActionModelTreeLeafAction).Assembly, action.ResourceResolver); } else { iconSet = _action.IconSet; ResourceResolver = _action.ResourceResolver; } if (_action.Permissible) { IconSet = iconSet; } else { IconSet = new UnavailableActionIconSet(iconSet); Description = SR.TooltipActionNotPermitted; Tooltip = String.IsNullOrEmpty(CanonicalLabel) ? SR.TooltipActionNotPermitted : String.Format(SR.TooltipFormatActionNotPermitted, CanonicalLabel); } }
private Image GetOverlayIcon(IconSize iconSize) { var resourceResolver = new ApplicationThemeResourceResolver(GetType().Assembly); var overlayIconSet = GrayMode ? _grayIconSet : _redIconSet; return overlayIconSet.CreateIcon(iconSize, resourceResolver); }