private static void SetOptions(StoredDisplaySetCreationSetting setting, XmlNodeList optionNodes)
        {
            if (optionNodes != null)
            {
                foreach (XmlNode optionNode in optionNodes)
                {
                    XmlAttribute identifierAttribute = optionNode.Attributes["identifier"];
                    if (identifierAttribute != null)
                    {
                        XmlAttribute valueAttribute;
                        XmlAttribute showOriginalAttribute;

                        switch (identifierAttribute.Value)
                        {
                        case "CreateSingleImageDisplaySets":
                            if (setting.CreateSingleImageDisplaySetsEnabled)
                            {
                                valueAttribute = optionNode.Attributes["value"];
                                if (valueAttribute != null)
                                {
                                    setting.CreateSingleImageDisplaySets = valueAttribute.Value == "True";
                                }
                            }
                            break;

                        case "CreateAllImagesDisplaySet":
                            if (setting.CreateAllImagesDisplaySetEnabled)
                            {
                                valueAttribute = optionNode.Attributes["value"];
                                if (valueAttribute != null)
                                {
                                    setting.CreateAllImagesDisplaySet = valueAttribute.Value == "True";
                                }
                            }
                            break;

                        case "ShowOriginalSeries":
                            if (setting.ShowOriginalSeriesEnabled)
                            {
                                valueAttribute = optionNode.Attributes["value"];
                                if (valueAttribute != null)
                                {
                                    setting.ShowOriginalSeries = valueAttribute.Value == "True";
                                }
                            }
                            break;

                        case "SplitEchos":
                            if (setting.SplitMultiEchoSeriesEnabled)
                            {
                                valueAttribute = optionNode.Attributes["value"];
                                if (valueAttribute != null)
                                {
                                    setting.SplitMultiEchoSeries = (valueAttribute.Value == "True");
                                }

                                showOriginalAttribute = optionNode.Attributes["show-original"];
                                if (showOriginalAttribute != null)
                                {
                                    setting.ShowOriginalMultiEchoSeries = showOriginalAttribute.Value == "True";
                                }
                            }
                            break;

                        case "SplitMixedMultiframes":
                            if (setting.SplitMixedMultiframesEnabled)
                            {
                                valueAttribute = optionNode.Attributes["value"];
                                if (valueAttribute != null)
                                {
                                    setting.SplitMixedMultiframes = (valueAttribute.Value == "True");
                                }

                                showOriginalAttribute = optionNode.Attributes["show-original"];
                                if (showOriginalAttribute != null)
                                {
                                    setting.ShowOriginalMixedMultiframeSeries = showOriginalAttribute.Value == "True";
                                }
                            }
                            break;

                        default: break;
                        }
                    }
                }
            }
        }
        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);
        }