コード例 #1
0
        public PresetVoiLutGroupCollection GetPresetGroups()
        {
            if (_presetGroups != null)
            {
                return(_presetGroups);
            }

            _presetGroups = new PresetVoiLutGroupCollection();

            XmlDocument document = new XmlDocument();

            document.LoadXml(this.SettingsXml);

            XmlNodeList groupNodes = document.SelectNodes("//group");

            foreach (XmlElement groupNode in groupNodes)
            {
                PresetVoiLutGroup group = DeserializeGroup(groupNode);
                if (group != null && !_presetGroups.Contains(group))
                {
                    _presetGroups.Add(group);
                }
            }

            return(_presetGroups);
        }
コード例 #2
0
        public override void Start()
        {
            InitializeAddFactories();
            _selectedAddFactory = new PresetFactoryDescriptor(PresetVoiLutOperationFactories.GetFactory(LinearPresetVoiLutOperationFactory.FactoryName));

            _voiLutPresets = new Table <PresetVoiLut>();

            _availableModalities = new List <string>(StandardModalities.Modalities);
            _availableModalities.Sort();

            _presetVoiLutGroups = PresetVoiLutSettings.DefaultInstance.GetPresetGroups().Clone();

            foreach (string modality in _availableModalities)
            {
                if (!_presetVoiLutGroups.Contains(new PresetVoiLutGroup(modality)))
                {
                    _presetVoiLutGroups.Add(new PresetVoiLutGroup(modality));
                }
            }

            _presetVoiLutGroups.Sort();

            _selectedPresetVoiLutGroup = _presetVoiLutGroups[0];

            InitializeMenuAndToolbar();
            InitializeTable();
            PopulateTable();

            Selection = null;

            base.Start();
        }
コード例 #3
0
        public PresetVoiLutGroupCollection Clone()
        {
            PresetVoiLutGroupCollection clone = new PresetVoiLutGroupCollection();

            foreach (PresetVoiLutGroup group in _groups)
            {
                clone.Add(group.Clone());
            }

            return(clone);
        }
コード例 #4
0
        public void SetPresetGroups(PresetVoiLutGroupCollection groups)
        {
            try
            {
                XmlDocument document    = new XmlDocument();
                XmlElement  rootElement = document.CreateElement("preset-voi-luts");
                document.AppendChild(rootElement);

                foreach (PresetVoiLutGroup group in groups)
                {
                    if (group.Presets.Count == 0)
                    {
                        continue;
                    }

                    XmlElement groupNode = document.CreateElement("group");
                    if (!String.IsNullOrEmpty(group.Modality))
                    {
                        groupNode.SetAttribute("modality", group.Modality);
                    }

                    rootElement.AppendChild(groupNode);

                    XmlElement presetsElement = document.CreateElement("presets");
                    groupNode.AppendChild(presetsElement);

                    foreach (PresetVoiLut preset in group.Presets)
                    {
                        XmlElement presetElement = document.CreateElement("preset");
                        presetsElement.AppendChild(presetElement);

                        if (preset.KeyStroke != XKeys.None)
                        {
                            presetElement.SetAttribute("keystroke", preset.KeyStroke.ToString());
                        }

                        PresetVoiLutConfiguration configuration = preset.Operation.GetConfiguration();

                        presetElement.SetAttribute("factory", configuration.FactoryName);

                        XmlElement configurationElement = document.CreateElement("configuration");
                        presetElement.AppendChild(configurationElement);

                        foreach (KeyValuePair <string, string> configurationItem in configuration)
                        {
                            if (String.IsNullOrEmpty(configurationItem.Key) || String.IsNullOrEmpty(configurationItem.Value))
                            {
                                continue;
                            }

                            XmlElement configurationItemElement = document.CreateElement("item");
                            configurationItemElement.SetAttribute("key", configurationItem.Key);
                            configurationItemElement.SetAttribute("value", configurationItem.Value);

                            configurationElement.AppendChild(configurationItemElement);
                        }
                    }
                }

                _presetGroups = null;
                string currentSettings = this.SettingsXml;

                this.SettingsXml = document.OuterXml;
                this.Save();
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e);
            }
        }