Example #1
0
		public override void Process(Configuration config)
		{
			var tables = GetTables(config);

			// create a resource resolver that will scan all plugins
			// TODO: we should only scan plugins that are tied to the specified PersistentStore, but there is currently no way to know this
			IResourceResolver resolver = new ResourceResolver(
				CollectionUtils.Map(Platform.PluginManager.Plugins, (PluginInfo pi) => pi.Assembly).ToArray());

			// find all dbi resources
			var rx = new Regex("dbi.xml$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
			var dbiFiles = resolver.FindResources(rx);

			foreach (var dbiFile in dbiFiles)
			{
				using (var stream = resolver.OpenResource(dbiFile))
				{
					var xmlDoc = new XmlDocument();
					xmlDoc.Load(stream);
					var indexElements = xmlDoc.SelectNodes("indexes/index");
					if (indexElements == null)
						continue;

					foreach (XmlElement indexElement in indexElements)
					{
						ProcessIndex(indexElement, tables);
					}
				}
			}

		}
Example #2
0
		public TableView()
        {
			SuppressSelectionChangedEvent = false;
			InitializeComponent();

            // if we allow the framework to generate columns, there seems to be a bug with 
            // setting the minimum column width > 100 pixels
            // therefore, turn off the auto-generate and create the columns ourselves
            _dataGridView.AutoGenerateColumns = false;

            _rowHeight = this.DataGridView.RowTemplate.Height;
            this.DataGridView.RowPrePaint += SetCustomBackground;
            this.DataGridView.RowPostPaint += DisplayCellSubRows;
            this.DataGridView.RowPostPaint += OutlineCell;
            this.DataGridView.RowPostPaint += SetLinkColor;

			// System.Component.DesignMode does not work in control constructors
			if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
			{
				// Use a DelayedEventPublisher to make fixes for bugs 386 and 8032 a little clearer.  Previously used a Timer directly
				// to delay the events
				_delayedSelectionChangedPublisher = new DelayedEventPublisher((sender, args) => NotifySelectionChanged(), 50);
			}

			try
			{
				var resolver = new ResourceResolver(typeof (TableView), false);
				using (var s = resolver.OpenResource("checkmark.png"))
				{
					_checkmarkBitmap = new Bitmap(s);
				}
			}
			catch (Exception) {}
        }
Example #3
0
        public ActionBuildingContext(string actionID, object actionTarget)
        {
            _actionID = actionID;
            _actionTarget = actionTarget;

            _resolver = new ActionResourceResolver(_actionTarget);
        }
Example #4
0
		public static void TestConfigResourceToFile(string fileName)
		{
			ResourceResolver resolver = new ResourceResolver(typeof(SettingsMigrationTests).Assembly);
			using (Stream resourceStream = resolver.OpenResource("TestPreviousConfiguration.config"))
			{
				StreamToFile(resourceStream, fileName);
				resourceStream.Close();
			}
		}
Example #5
0
        /// <summary>
        /// Translates the name of the specified property on the specified domain class.
        /// </summary>
        /// <param name="domainClass"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        public static string Translate(Type domainClass, string propertyName)
        {
            IResourceResolver resolver = new ResourceResolver(domainClass.Assembly);

            string key = domainClass.Name + propertyName;
            string localized = resolver.LocalizeString(key);
            if (localized == key)
                localized = resolver.LocalizeString(propertyName);

            return localized;
        }
Example #6
0
		protected ImageExporter(string identifier, string description, string[] fileExtensions)
		{
			Platform.CheckForEmptyString(identifier, "identifier");
			Platform.CheckForEmptyString(description, "description");
			Platform.CheckForNullReference(fileExtensions, "fileExtension");
			if (fileExtensions.Length == 0)
				throw new ArgumentException("The exporter must have at least one associated file extension.");

			IResourceResolver resolver = new ResourceResolver(this.GetType().Assembly);
			_identifier = identifier;
			_description = resolver.LocalizeString(description);
			_fileExtensions = fileExtensions;
		}
        public override IActionSet GetExportedActions(string site, ClearCanvas.ImageViewer.InputManagement.IMouseInformation mouseInformation)
        {
            IResourceResolver resolver = new ResourceResolver(GetType(), true);
            var @namespace = GetType().FullName;
            var hideAction = new MenuAction(@namespace + ":toggle", new ActionPath(site + "/MenuSetMarkupColorForUser", resolver), ClickActionFlags.None, resolver);
            hideAction.Label = "Set User Markup Color";
            hideAction.Persistent = true;
            hideAction.SetClickHandler(OpenAimMarkupColorOptions);

            IActionSet actions = new ActionSet(new IAction[] { hideAction });
            var other = base.GetExportedActions(site, mouseInformation);
            if (other != null)
                actions = actions.Union(other);

            return actions;
        }
Example #8
0
        public AlertNotificationForm(DesktopForm owner, string title)
        {
            InitializeComponent();

			this.Text = title;
        	this.Owner = owner;

            _maxOpacity = 1.0;
            _minOpacity = 0.3;

        	var resolver = new ResourceResolver(typeof (AlertNotificationForm).Assembly);
			using (var s = resolver.OpenResource("close.bmp"))
			{
				_closeButtonBitmap = new Bitmap(s);
			}

			owner.Move += OwnerFormMoved;
        	owner.Resize += OwnerFormResized;
        }
        private IActionSet CreateActions()
        {
            List<IAction> actions = new List<IAction>();
            Type thisType = this.GetType();
            IResourceResolver resolver = new ResourceResolver(thisType.Assembly);
            foreach (ITableColumn tableColumn in this.Context.Columns)
            {
                string columnName = tableColumn.Name;
                string escapedColumnName = SecurityElement.Escape(columnName);
                string actionName = columnName.Replace("&", "").Replace("<", "_").Replace(">", "_").Replace("\"", "").Replace("'", "").Replace(' ', '_');
                ButtonAction buttonAction = new ButtonAction(
                    string.Format("{0}:toggle_{1}", thisType.FullName, actionName),
                    new ActionPath(string.Format("{0}/{1}", TOGGLE_DROPDOWN_SITE, actionName),
                                   resolver), ClickActionFlags.CheckAction, resolver);
                buttonAction.Label = columnName;
                buttonAction.Checked = !SearchSettings.Default.AimSearchHiddenColumns.Contains(escapedColumnName);
                TableColumnBase<AIMSearchResult> column = (TableColumnBase<AIMSearchResult>) tableColumn;
                buttonAction.SetClickHandler(delegate
                                             	{
                                             		bool wasChecked = buttonAction.Checked;
                                             		buttonAction.Checked = !wasChecked;
                                             		column.Visible = !wasChecked;
                                             		if (buttonAction.Checked)
                                             		{
                                             			while (SearchSettings.Default.AimSearchHiddenColumns.IndexOf(escapedColumnName) != -1)
                                             				SearchSettings.Default.AimSearchHiddenColumns.Remove(escapedColumnName);
                                             		}
                                             		else
                                             		{
                                             			SearchSettings.Default.AimSearchHiddenColumns.Add(escapedColumnName);
                                             		}
                                             		SearchSettings.Default.Save();
                                             	});

                actions.Add(buttonAction);
            }

            return new ActionSet(actions);
        }
Example #10
0
		public List<StoredDisplaySetCreationSetting> GetStoredSettings()
		{
			XmlDocument document = this.DisplaySetCreationSettingsXml;
			if (document == null)
			{
				document = new XmlDocument();
				Stream stream = new ResourceResolver(this.GetType(), false).OpenResource("DisplaySetCreationSettingsDefaults.xml");
				document.Load(stream);
				stream.Close();
			}

			XmlNodeList settingsNodes = document.SelectNodes("//display-set-creation-settings/setting");
			if (settingsNodes== null || settingsNodes.Count == 0)
			{
				document = new XmlDocument();
				Stream stream = new ResourceResolver(this.GetType(), false).OpenResource("DisplaySetCreationSettingsDefaults.xml");
				document.Load(stream);
				stream.Close();
				settingsNodes = document.SelectNodes("//display-set-creation-settings/setting");
			}

			List<string> missingModalities = new List<string>(StandardModalities.Modalities);
			List<StoredDisplaySetCreationSetting> storedDisplaySetSettings = new List<StoredDisplaySetCreationSetting>();

			foreach (XmlElement settingsNode in settingsNodes)
			{
				XmlAttribute attribute = settingsNode.Attributes["modality"];
				string modality = "";
				if (attribute != null)
				{
					modality = attribute.Value ?? "";
					missingModalities.Remove(modality);
				}

				if (!String.IsNullOrEmpty(modality))
				{
					XmlNodeList optionNodes = settingsNode.SelectNodes("options/option");
					StoredDisplaySetCreationSetting setting = new StoredDisplaySetCreationSetting(modality);
					SetOptions(setting, optionNodes);
					storedDisplaySetSettings.Add(setting);

					XmlNode presentationIntentNode = settingsNode.SelectSingleNode("presentation-intent");
					if (presentationIntentNode != null)
					{
						attribute = presentationIntentNode.Attributes["show-grayscale-inverted"];
						if (attribute != null)
							setting.ShowGrayscaleInverted = (attribute.Value == "True");
					}
				}
			}

			foreach (string missingModality in missingModalities)
				storedDisplaySetSettings.Add(new StoredDisplaySetCreationSetting(missingModality));

			return storedDisplaySetSettings;
		}
Example #11
0
		private void Initialize(bool reloadSettings)
		{
			lock (_syncLock)
			{
				if (Document != null && !reloadSettings)
					return;

				AnnotationLayoutStoreSettings.Default.Reload();
				if (Document != null)
					return;

				try
				{
					XmlDocument document = new XmlDocument();
					ResourceResolver resolver = new ResourceResolver(this.GetType().Assembly);
					using (Stream stream = resolver.OpenResource("AnnotationLayoutStoreDefaults.xml"))
					{
						document.Load(stream);
						Document = document;
					}
				}
				catch (Exception e)
				{
					Platform.Log(LogLevel.Debug, e);
					Clear();
				}
			}
		}
Example #12
0
 /// <summary>
 /// Translates the name of the specified domain class.
 /// </summary>
 /// <param name="domainClass"></param>
 /// <returns></returns>
 public static string Translate(Type domainClass)
 {
     IResourceResolver resolver = new ResourceResolver(domainClass.Assembly);
     return resolver.LocalizeString(domainClass.Name);
 }
Example #13
0
		public void Test()
		{
			List<IAnnotationItem> annotationItems = new List<IAnnotationItem>();

			AnnotationLayoutStore.Instance.Clear();

			IList<StoredAnnotationLayout> layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(0, layouts.Count);

			AnnotationLayoutStore.Instance.Update(this.CreateLayout("testLayout1"));
			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(1, layouts.Count);

			layouts = new List<StoredAnnotationLayout>();
			layouts.Clear();
			layouts.Add(CreateLayout("testLayout1"));
			layouts.Add(CreateLayout("testLayout2"));
			layouts.Add(CreateLayout("testLayout3"));
			layouts.Add(CreateLayout("testLayout4"));

			AnnotationLayoutStore.Instance.Update(layouts);

			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(4, layouts.Count);

			ResourceResolver resolver = new ResourceResolver(this.GetType().Assembly);
			using (Stream stream = resolver.OpenResource("AnnotationLayoutStoreDefaults.xml"))
			{
				AnnotationLayoutStoreSettings.Default.LayoutSettingsXml = new XmlDocument();
				AnnotationLayoutStoreSettings.Default.LayoutSettingsXml.Load(stream);
			}

			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			int xmlLayoutCount = layouts.Count;

			StoredAnnotationLayout layout = AnnotationLayoutStore.Instance.GetLayout("Dicom.OT", annotationItems);
			layout = CopyLayout(layout, "Dicom.OT.Copied");

			AnnotationLayoutStore.Instance.Update(layout);
			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(xmlLayoutCount + 1, layouts.Count);

			layout = AnnotationLayoutStore.Instance.GetLayout("Dicom.OT.Copied", annotationItems);
			Assert.IsNotNull(layout);
			
			AnnotationLayoutStore.Instance.RemoveLayout("Dicom.OT.Copied");
			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(xmlLayoutCount, layouts.Count);

			layout = AnnotationLayoutStore.Instance.GetLayout("Dicom.OT.Copied", annotationItems);
			Assert.IsNull(layout);

			layout = AnnotationLayoutStore.Instance.GetLayout("Dicom.OT", annotationItems);
			Assert.IsNotNull(layout);

			layouts = new List<StoredAnnotationLayout>(); 
			layouts.Clear();
			layouts.Add(CreateLayout("testLayout1"));
			layouts.Add(CreateLayout("testLayout2"));
			layouts.Add(CreateLayout("testLayout3"));
			layouts.Add(CreateLayout("testLayout4"));

			AnnotationLayoutStore.Instance.Update(layouts);

			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(xmlLayoutCount + 4, layouts.Count);

			AnnotationLayoutStore.Instance.RemoveLayout("testLayout1");
			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(xmlLayoutCount + 3, layouts.Count);

			AnnotationLayoutStore.Instance.RemoveLayout("testLayout2");
			layouts = AnnotationLayoutStore.Instance.GetLayouts(annotationItems);
			Assert.AreEqual(xmlLayoutCount + 2, layouts.Count);

			layout = AnnotationLayoutStore.Instance.GetLayout("Dicom.OT", annotationItems);
			Assert.IsNotNull(layout);

			layout = AnnotationLayoutStore.Instance.GetLayout("testLayout3", annotationItems); 
			Assert.AreEqual(1, layout.AnnotationBoxGroups.Count);

			layout = AnnotationLayoutStore.Instance.GetLayout("Dicom.OT", annotationItems);
			layout = CopyLayout(layout, "testLayout3");
			AnnotationLayoutStore.Instance.Update(layout);
			layout = AnnotationLayoutStore.Instance.GetLayout("testLayout3", annotationItems);
			Assert.AreEqual(5, layout.AnnotationBoxGroups.Count);
		}
Example #14
0
		protected void Initialize(string xmlResourceName)
		{
			using (Stream stream = new ResourceResolver(typeof(SopClassLegacyConfigurationElementCollection).Assembly).OpenResource(xmlResourceName))
			{
				XmlDocument document = new XmlDocument();
				document.Load(stream);
				foreach (XmlElement sopClass in document.SelectNodes("//sop-class"))
					Add(sopClass.Attributes["uid"].InnerText, sopClass.Attributes["description"].InnerText);

				stream.Close();
			}
		}
Example #15
0
		/// <summary>
		/// Gets the display name for the specified worklist class, obtained either from
		/// the <see cref="WorklistClassDisplayNameAttribute"/>, otherwise via the
		/// <see cref="TerminologyTranslator"/> class.
		/// </summary>
		/// <param name="worklistClass"></param>
		/// <returns></returns>
		public static string GetDisplayName(Type worklistClass)
		{
			var a = AttributeUtils.GetAttribute<WorklistClassDisplayNameAttribute>(worklistClass, true);

			if (a == null)
				return TerminologyTranslator.Translate(worklistClass);

			var resolver = new ResourceResolver(worklistClass, true);
			return resolver.LocalizeString(a.DisplayName);
		}
Example #16
0
		private void AddAssemblyIconToImage(Assembly pluginAssembly)
		{
			object[] pluginAttributes = pluginAssembly.GetCustomAttributes(typeof(PluginAttribute), false);

			foreach (PluginAttribute pluginAttribute in pluginAttributes)
			{
				if (!string.IsNullOrEmpty(pluginAttribute.Icon))
				{
					try
					{
						IResourceResolver resolver = new ResourceResolver(pluginAssembly);
						Bitmap icon = new Bitmap(resolver.OpenResource(pluginAttribute.Icon));

						// Burn the icon into the background image
						Graphics g = Graphics.FromImage(this.BackgroundImage);

						int positionX = _nextIconPositionX;
						int positionY = _nextIconPositionY;

						g.DrawImage(icon, positionX, positionY, IconWidth, IconHeight);

						// Burn the icon's name and version into the background image
						string pluginName = pluginAttribute.Name;
						string pluginVersion = string.Empty;
						try
						{
							FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(pluginAssembly.Location);
							pluginVersion = versionInfo.ProductVersion;
						}
						catch
						{
						}

						Font font = new Font("Tahoma", 10F, GraphicsUnit.Pixel);
						Brush brush = new SolidBrush(Color.FromArgb(50, 50, 50));

						StringFormat format = new StringFormat();
						format.Alignment = StringAlignment.Center;

						Rectangle layoutRect = new Rectangle(positionX - IconPaddingX / 2, positionY + IconHeight, IconWidth + IconPaddingX, IconTextHeight);

						g.DrawString(pluginName + "\n" + pluginVersion, font, brush, layoutRect, format);

						font.Dispose();
						brush.Dispose();

						g.Dispose();

						// Advance to the next icon position within the plugin rectangle
						_nextIconPositionX += (IconWidth + IconPaddingX);
						if (_nextIconPositionX + IconWidth + IconPaddingX / 2 > _pluginIconsRectangle.Right)
						{
							_nextIconPositionX = _pluginIconsRectangle.Left + IconPaddingX / 2;
							_nextIconPositionY += IconPaddingY + IconHeight + IconTextHeight;
						}

						this.Invalidate();
					}
					catch
					{
					}
				}
			}
		}
		public void Test()
		{
			DicomFilteredAnnotationLayoutStore.Instance.Clear();

			IList<DicomFilteredAnnotationLayout> layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(0, layouts.Count);

			DicomFilteredAnnotationLayoutStore.Instance.Update(CreateLayout("testLayout1", "Dicom.MR", "MR"));
			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(1, layouts.Count);

			layouts = new List<DicomFilteredAnnotationLayout>();
			layouts.Clear();
			layouts.Add(CreateLayout("testLayout1", "Dicom.MR", "MR"));
			layouts.Add(CreateLayout("testLayout2", "Dicom.MG", "MG"));
			layouts.Add(CreateLayout("testLayout3", "Dicom.CT", "CT"));
			layouts.Add(CreateLayout("testLayout4", "Dicom.PT", "PT"));

			DicomFilteredAnnotationLayoutStore.Instance.Update(layouts);

			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(4, layouts.Count);

			ResourceResolver resolver = new ResourceResolver(this.GetType().Assembly);
			using (Stream stream = resolver.OpenResource("DicomFilteredAnnotationLayoutStoreDefaults.xml"))
			{
				StreamReader reader = new StreamReader(stream);
				DicomFilteredAnnotationLayoutStoreSettings.Default.FilteredLayoutSettingsXml = reader.ReadToEnd();
			}

			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml, layouts.Count);

			DicomFilteredAnnotationLayout layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.MR");
			layout = CopyLayout(layout, "Dicom.Filtered.RT");
			layout.Filters[0] = new KeyValuePair<string,string>("Modality", "RT");

			DicomFilteredAnnotationLayoutStore.Instance.Update(layout);
			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 1, layouts.Count);

			layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.RT");
			Assert.IsNotNull(layout);

			DicomFilteredAnnotationLayoutStore.Instance.RemoveFilteredLayout("Dicom.Filtered.RT");
			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml, layouts.Count);

			layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.RT");
			Assert.IsNull(layout);

			layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.MR");
			Assert.IsNotNull(layout);

			layouts = new List<DicomFilteredAnnotationLayout>();
			layouts.Clear();
			layouts.Add(CreateLayout("Dicom.Filtered.RT", "Dicom.RT", "RT"));
			layouts.Add(CreateLayout("Dicom.Filtered.SC", "Dicom.SC", "SC"));
			layouts.Add(CreateLayout("Dicom.Filtered.US", "Dicom.US", "US"));
			layouts.Add(CreateLayout("Dicom.Filtered.ES", "Dicom.ES", "ES"));

			DicomFilteredAnnotationLayoutStore.Instance.Update(layouts);

			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 4, layouts.Count);

			DicomFilteredAnnotationLayoutStore.Instance.RemoveFilteredLayout("Dicom.Filtered.RT");
			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 3, layouts.Count);

			DicomFilteredAnnotationLayoutStore.Instance.RemoveFilteredLayout("Dicom.Filtered.SC");
			layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
			Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 2, layouts.Count);

			layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.AllMatch");
			Assert.IsNotNull(layout);
			Assert.AreEqual(0, layout.Filters.Count);

			layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.MR");
			Assert.AreEqual(1, layout.Filters.Count);
		}
Example #18
0
		/// <summary>
		/// Gets the category for the specified worklist class, as specified by
		/// the <see cref="WorklistCategoryAttribute"/>, or null if not specified.
		/// </summary>
		/// <param name="worklistClass"></param>
		/// <returns></returns>
		public static string GetCategory(Type worklistClass)
		{
			var a = AttributeUtils.GetAttribute<WorklistCategoryAttribute>(worklistClass, true);
			if (a == null)
				return null;

			var resolver = new ResourceResolver(worklistClass, true);
			return resolver.LocalizeString(a.Category);
		}
Example #19
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <remarks>
		/// The resource is resolved using the calling assembly (from <see cref="System.Reflection.Assembly.GetCallingAssembly"/>).
		/// </remarks>
		/// <param name="resourceName">The resource name of the cursor.</param>
		public CursorToken(string resourceName)
		{
			Platform.CheckForEmptyString(resourceName, "resourceName");

			_resourceName = resourceName;
			_resolver = new ApplicationThemeResourceResolver(Assembly.GetCallingAssembly());
		}
Example #20
0
		/// <summary>
		/// Gets the icon for the <see cref="ApplicationTheme"/>.
		/// </summary>
		/// <returns>A new <see cref="Stream"/> for the icon.</returns>
		/// <seealso cref="Icon"/>
		public Stream GetIcon()
		{
			if (string.IsNullOrEmpty(_providers[0].Icon))
				return null;

			var resourceResolver = new ResourceResolver(_providers[0].GetType(), false);
			return resourceResolver.OpenResource(_providers[0].Icon);
		}
		private static PaletteColorLut CreateFromColorPaletteSopInstanceXml(string resourceName)
		{
			try
			{
				var resourceResolver = new ResourceResolver(Assembly.GetExecutingAssembly());
				using (var xmlStream = resourceResolver.OpenResource(resourceName))
				{
					var xmlDocument = new XmlDocument();
					xmlDocument.Load(xmlStream);
					var docRootNode = CollectionUtils.FirstElement(xmlDocument.GetElementsByTagName("ClearCanvasColorPaletteDefinition")) as XmlElement;
					if (docRootNode != null)
					{
						var instanceNode = CollectionUtils.FirstElement(docRootNode.GetElementsByTagName("Instance")) as XmlElement;
						if (instanceNode != null)
						{
							var instanceXml = new InstanceXml(instanceNode, null);
							return Create(instanceXml.Collection);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Platform.Log(LogLevel.Debug, ex, "Failed to load embedded standard color palette SOP from resource {0}", resourceName);
			}
			return null;
		}
Example #22
0
		/// <summary>
		/// Constructor
		/// </summary>
		protected Folder()
		{
			// establish default resource resolver on this assembly (not the assembly of the derived class)
			_resourceResolver = new ResourceResolver(typeof(Folder).Assembly);

			// Initialize folder Path
			var pathAttrib = AttributeUtils.GetAttribute<FolderPathAttribute>(this.GetType());
			if (pathAttrib != null)
			{
				_folderPath = new Path(pathAttrib.Path, _resourceResolver);
				_startExpanded = pathAttrib.StartExpanded;
			}

			// Initialize tooltip
			var attrib = AttributeUtils.GetAttribute<FolderDescriptionAttribute>(this.GetType());
			if (attrib != null)
			{
				var resolver = new ResourceResolver(this.GetType(), true);
				this.Tooltip = resolver.LocalizeString(attrib.Description);
			}
		}
Example #23
0
		protected override void InitializeDefault()
		{
			using (Stream stream = new ResourceResolver(typeof(SopClassLegacyConfigurationElementCollection).Assembly).OpenResource("TransferSyntaxes.xml"))
			{
				XmlDocument document = new XmlDocument();
				document.Load(stream);
				foreach (XmlElement transferSyntax in document.SelectNodes("//transfer-syntax"))
					Add(transferSyntax.Attributes["uid"].InnerText, transferSyntax.Attributes["description"].InnerText);
			}
		}
		private EnumerationInfo ReadSoftEnum(Type enumValueClass, Table table)
		{
			// look for an embedded resource that matches the enum class
			string res = string.Format("{0}.enum.xml", enumValueClass.FullName);
			IResourceResolver resolver = new ResourceResolver(enumValueClass.Assembly);
			try
			{
				using (Stream xmlStream = resolver.OpenResource(res))
				{
					XmlDocument xmlDoc = new XmlDocument();
					xmlDoc.Load(xmlStream);
					int displayOrder = 1;

					return new EnumerationInfo(enumValueClass.FullName, table.Name, false,
						CollectionUtils.Map<XmlElement, EnumerationMemberInfo>(xmlDoc.GetElementsByTagName("enum-value"),
							delegate(XmlElement enumValueElement)
							{
								XmlElement valueNode = CollectionUtils.FirstElement<XmlElement>(enumValueElement.GetElementsByTagName("value"));
								XmlElement descNode = CollectionUtils.FirstElement<XmlElement>(enumValueElement.GetElementsByTagName("description"));

								return new EnumerationMemberInfo(
									enumValueElement.GetAttribute("code"),
									valueNode != null ? valueNode.InnerText : null,
									descNode != null ? descNode.InnerText : null,
									displayOrder++,
									false);
							}));
				}
			}
			catch (Exception)
			{
				// no embedded resource found - no values defined
				return new EnumerationInfo(enumValueClass.FullName, table.Name, false, new List<EnumerationMemberInfo>());
			}
		}
Example #25
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="systemCursor">The system cursor to show in the view.</param>
		public CursorToken(SystemCursors systemCursor)
		{
			_resourceName = systemCursor.ToString();
			_resolver = null;
		}
 private IActionSet GetContextMenuActionSet()
 {
     var aimUserGraphics = GetAimUserGraphics();
     var actionsList = new List<IAction>();
     const string path = "imageviewer-contextmenu/Visible AIM Users/";
     var resolver = new ResourceResolver(GetType(), true);
     foreach (var aimUser in aimUserGraphics.Keys)
     {
         if (aimUserGraphics.Count > 0)
         {
             var user = aimUser;
             var action = new MenuAction(aimUser, new ActionPath(path + aimUser, resolver), ClickActionFlags.CheckAction, resolver);
             action.Checked = aimUserGraphics[aimUser][0].Visible;
             action.Enabled = true;
             action.Persistent = false;
             action.Label = aimUser;
             actionsList.Add(action);
             action.SetClickHandler(
                 delegate
                 {
                     var visible = !action.Checked;
                     _displayMarkupPerUser[user] = visible;
                     action.Checked = visible;
                     SelectedPresentationImage.Draw();
                 });
         }
     }
     return new ActionSet(actionsList);
 }
Example #27
0
		/// <summary>
		/// Gets the description for the specified worklist class, as specified by
		/// the <see cref="WorklistCategoryAttribute"/>, or null if not specified.
		/// </summary>
		/// <param name="worklistClass"></param>
		/// <returns></returns>
		public static string GetDescription(Type worklistClass)
		{
			var a = AttributeUtils.GetAttribute<WorklistClassDescriptionAttribute>(worklistClass, true);
			if (a == null)
				return null;

			var resolver = new ResourceResolver(worklistClass, true);
			return resolver.LocalizeString(a.Description);
		}
		/// <summary>
		/// Translates the default value for a settings class given the raw value.
		/// </summary>
		/// <remarks>
		/// If the specified raw value is the name of an embedded resource (embedded in the same
		/// assembly as the specified settings class), the contents of the resource are returned.
		/// Otherwise, the raw value is simply returned.
		/// </remarks>
		public static string TranslateDefaultValue(Type settingsClass, string rawValue)
		{
			// short circuit if nothing translatable
			if (string.IsNullOrEmpty(rawValue))
				return rawValue;

			// does the raw value look like it could be an embedded resource?
			if (Regex.IsMatch(rawValue, @"^([\w]+\.)+\w+$"))
			{
				try
				{
					// try to open the resource
					IResourceResolver resolver = new ResourceResolver(settingsClass.Assembly);
					using (var resourceStream = resolver.OpenResource(rawValue))
					{
						var r = new StreamReader(resourceStream);
						return r.ReadToEnd();
					}
				}
				catch (MissingManifestResourceException)
				{
					// guess it was not an embedded resource, so return the raw value
					return rawValue;
				}
			}
			return rawValue;
		}
		// [Test]
		internal void ExportDefaultLayoutConfigurationData()
		{
			// this method exports the default layout in EnterpriseServer format

			var configBodyData = new StringBuilder();
			using (var configBodyDataWriter = new StringWriter(configBodyData))
			{
				var configBody = new XmlDocument();
				{
					var sbValue = new StringBuilder();
					using (var writer = new StringWriter(sbValue))
					{
						var resourceResolver = new ResourceResolver(typeof (AnnotationLayoutStoreTests).Assembly);
						var defaultLayout = new XmlDocument();
						defaultLayout.Load(resourceResolver.OpenResource("AnnotationLayoutStoreDefaults.xml"));
						defaultLayout.Save(writer);
					}

					var cdata = configBody.CreateCDataSection(sbValue.ToString());

					var value = configBody.CreateElement("value");
					value.AppendChild(cdata);

					var setting = configBody.CreateElement("setting");
					setting.SetAttribute("name", "LayoutSettingsXml");
					setting.AppendChild(value);

					var settings = configBody.CreateElement("settings");
					settings.AppendChild(setting);

					configBody.AppendChild(settings);
				}
				configBody.Save(configBodyDataWriter);
			}

			var configDocument = new XmlDocument();

			var nameElement = configDocument.CreateElement("Name");
			nameElement.InnerText = typeof (AnnotationLayoutStoreSettings).FullName ?? string.Empty;

			var versionElement = configDocument.CreateElement("Version");
			versionElement.InnerText = string.Format("{0:00000}.{1:00000}", ProductInformation.Version.Major, ProductInformation.Version.Minor);

			var bodyElement = configDocument.CreateElement("Body");
			bodyElement.InnerText = configBodyData.ToString();

			var configItem = configDocument.CreateElement("item");
			configItem.AppendChild(nameElement);
			configItem.AppendChild(versionElement);
			configItem.AppendChild(bodyElement);

			var rootConfigurations = configDocument.CreateElement("Configurations");
			rootConfigurations.SetAttribute("type", "array");
			rootConfigurations.AppendChild(configItem);

			configDocument.AppendChild(rootConfigurations);
			configDocument.Save(string.Format("{0}.xml", typeof (AnnotationLayoutStoreSettings).FullName));
		}
Example #30
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="resourceName">The resource name of the cursor.</param>
		/// <param name="resourceAssembly">The assembly where the cursor resource resides.</param>
		public CursorToken(string resourceName, Assembly resourceAssembly)
		{
			Platform.CheckForEmptyString(resourceName, "resourceName");
			Platform.CheckForNullReference(resourceAssembly, "resourceAssembly");

			_resourceName = resourceName;
			_resolver = new ApplicationThemeResourceResolver(resourceAssembly);
		}