internal PresetVoiLut GetPresetVoiLut()
        {
            PresetVoiLut preset = new PresetVoiLut(ContainedComponent.GetOperation());

            preset.KeyStroke = _selectedKeyStroke.KeyStroke;
            return(preset);
        }
コード例 #2
0
        private List <PresetVoiLut> GetApplicablePresets()
        {
            List <PresetVoiLut> presets = new List <PresetVoiLut>();

            if (this.SelectedPresentationImage is IImageSopProvider)
            {
                //Only temporary until we enable the full functionality in the presets.
                PresetVoiLut autoPreset = new PresetVoiLut(new AutoPresetVoiLutOperationComponent());
                autoPreset.KeyStroke = XKeys.F2;
                presets.Add(autoPreset);

                ImageSop sop = ((IImageSopProvider)this.SelectedPresentationImage).ImageSop;

                PresetVoiLutGroupCollection groups = PresetVoiLutSettings.DefaultInstance.GetPresetGroups();
                PresetVoiLutGroup           group  = CollectionUtils.SelectFirst(groups,
                                                                                 delegate(PresetVoiLutGroup testGroup)
                {
                    return(testGroup.AppliesTo(sop));
                });
                if (group != null)
                {
                    foreach (PresetVoiLut preset in group.Clone().Presets)
                    {
                        if (preset.Operation.AppliesTo(this.SelectedPresentationImage))
                        {
                            presets.Add(preset);
                        }
                    }
                }

                presets.Sort(new PresetVoiLutComparer());
            }

            return(presets);
        }
コード例 #3
0
			public PresetVoiLutActionContainer(WindowLevelTool ownerTool, string actionSite, PresetVoiLut preset, int index)
			{
				_ownerTool = ownerTool;
				_preset = preset;

				string actionId = String.Format("apply{0}", _preset.Operation.Name);

				ActionPlaceholder actionPlaceholder = ownerTool.FindActionPlaceholder(actionSite);
				_action = actionPlaceholder.CreateMenuAction(actionId, string.Format("presetLut{0}", index), ClickActionFlags.None, ownerTool._resolver);
				_action.Label = _preset.Operation.Name;
				_action.KeyStroke = _preset.KeyStroke;
				_action.SetClickHandler(this.Apply);
			}
コード例 #4
0
            public PresetVoiLutActionContainer(WindowLevelTool ownerTool, string actionSite, PresetVoiLut preset, int index)
            {
                _ownerTool = ownerTool;
                _preset    = preset;

                string actionId = String.Format("apply{0}", _preset.Operation.Name);

                ActionPlaceholder actionPlaceholder = ownerTool.FindActionPlaceholder(actionSite);

                _action           = actionPlaceholder.CreateMenuAction(actionId, string.Format("presetLut{0}", index), ClickActionFlags.None, ownerTool._resolver);
                _action.Label     = _preset.Operation.Name;
                _action.KeyStroke = _preset.KeyStroke;
                _action.SetClickHandler(this.Apply);
            }
コード例 #5
0
        private List<PresetVoiLut> GetApplicablePresets()
        {
            List<PresetVoiLut> presets = new List<PresetVoiLut>();

            if (this.SelectedPresentationImage is IImageSopProvider)
            {
                //Only temporary until we enable the full functionality in the presets.
                PresetVoiLut autoPreset = new PresetVoiLut(new AutoPresetVoiLutOperationComponent());
                autoPreset.KeyStroke = XKeys.F2;
                presets.Add(autoPreset);

                ImageSop sop = ((IImageSopProvider) this.SelectedPresentationImage).ImageSop;

                PresetVoiLutGroupCollection groups = PresetVoiLutSettings.Default.GetPresetGroups();
                PresetVoiLutGroup group = CollectionUtils.SelectFirst(groups,
                                                                      delegate(PresetVoiLutGroup testGroup)
                                                                          {
                                                                              return testGroup.AppliesTo(sop);
                                                                          });
                if (group != null)
                {
                    foreach (PresetVoiLut preset in group.Clone().Presets)
                    {
                        if (preset.Operation.AppliesTo(this.SelectedPresentationImage))
                            presets.Add(preset);
                    }
                }

                presets.Sort(new PresetVoiLutComparer());
            }

            return presets;
        }
コード例 #6
0
		private void DeserializeGroupPresets(PresetVoiLutCollection presets, XmlNodeList presetNodes)
		{
			foreach (XmlElement presetNode in presetNodes)
			{
				string keyStrokeAttribute = presetNode.GetAttribute("keystroke");
				XKeys keyStroke = XKeys.None;
				if (!String.IsNullOrEmpty(keyStrokeAttribute))
					keyStroke = (XKeys)_xkeysConverter.ConvertFromInvariantString(keyStrokeAttribute);

				string factoryName = presetNode.GetAttribute("factory");

				IPresetVoiLutOperationFactory factory = PresetVoiLutOperationFactories.GetFactory(factoryName);
				if (factory == null)
					continue;

				PresetVoiLutConfiguration configuration = PresetVoiLutConfiguration.FromFactory(factory);

				XmlNodeList configurationItems = presetNode.SelectNodes("configuration/item");
				foreach (XmlElement configurationItem in configurationItems)
					configuration[configurationItem.GetAttribute("key")] = configurationItem.GetAttribute("value");

				try 
				{
					IPresetVoiLutOperation operation = factory.Create(configuration);
					PresetVoiLut preset = new PresetVoiLut(operation);
					preset.KeyStroke = keyStroke;
					presets.Add(preset);
				}
				catch(Exception e)
				{
					Platform.Log(LogLevel.Error, e);
					continue;
				}
			}
		}