예제 #1
0
        private static DicomFilteredAnnotationLayout DeserializeFilteredLayout(XmlElement dicomFilteredLayoutNode)
        {
            string matchingLayoutId = dicomFilteredLayoutNode.GetAttribute("matching-layout-id");
            string filteredLayoutId = dicomFilteredLayoutNode.GetAttribute("id");

            DicomFilteredAnnotationLayout filteredLayout = new DicomFilteredAnnotationLayout(filteredLayoutId, matchingLayoutId);

            foreach (XmlElement filterNode in dicomFilteredLayoutNode.SelectNodes("filters/filter"))
            {
                string key = filterNode.GetAttribute("key");
                if (String.IsNullOrEmpty(key))
                {
                    continue;
                }

                string filterValue = filterNode.GetAttribute("value");
                if (String.IsNullOrEmpty(filterValue))
                {
                    continue;
                }

                filteredLayout.Filters.Add(new KeyValuePair <string, string>(key, filterValue));
            }

            return(filteredLayout);
        }
예제 #2
0
        public string GetMatchingStoredLayoutId(List <KeyValuePair <string, string> > filterCandidates)
        {
            lock (_syncLock)
            {
                Initialize(false);

                string      xPath = "dicom-filtered-annotation-layout-configuration/dicom-filtered-annotation-layouts/dicom-filtered-annotation-layout";
                XmlNodeList filteredLayoutNodes = _document.SelectNodes(xPath);
                foreach (XmlElement filteredLayoutNode in filteredLayoutNodes)
                {
                    DicomFilteredAnnotationLayout filteredAnnotationLayout = DeserializeFilteredLayout(filteredLayoutNode);
                    if (filteredAnnotationLayout.IsMatch(filterCandidates))
                    {
                        return(filteredAnnotationLayout.MatchingLayoutIdentifier);
                    }
                }
            }

            return("");
        }
예제 #3
0
        public void Update(DicomFilteredAnnotationLayout filteredLayout)
        {
            Platform.CheckForNullReference(filteredLayout, "filteredLayout");
            Platform.CheckForEmptyString(filteredLayout.MatchingLayoutIdentifier, "filteredLayout.MatchingLayoutIdentifier");

            lock (_syncLock)
            {
                Initialize(false);

                try
                {
                    SerializeFilteredLayout(_document, filteredLayout);
                    SaveSettings(_document.OuterXml);
                }
                catch
                {
                    Initialize(true);
                    throw;
                }
            }
        }
예제 #4
0
        private static void SerializeFilteredLayout(XmlDocument document, DicomFilteredAnnotationLayout dicomFilteredAnnotationLayout)
        {
            string     xPath = "dicom-filtered-annotation-layout-configuration/dicom-filtered-annotation-layouts";
            XmlElement filteredLayoutsNode = (XmlElement)document.SelectSingleNode(xPath);

            if (filteredLayoutsNode == null)
            {
                throw new InvalidDataException(String.Format(SR.ExceptionInvalidFilteredAnnotationLayoutXml, "'dicom-filtered-annotation-layouts' node does not exist"));
            }

            XmlElement newFilteredLayoutNode = document.CreateElement("dicom-filtered-annotation-layout");

            newFilteredLayoutNode.SetAttribute("id", dicomFilteredAnnotationLayout.Identifier);
            newFilteredLayoutNode.SetAttribute("matching-layout-id", dicomFilteredAnnotationLayout.MatchingLayoutIdentifier);

            XmlElement filtersNode = document.CreateElement("filters");

            newFilteredLayoutNode.AppendChild(filtersNode);

            foreach (KeyValuePair <string, string> keyValuePair in dicomFilteredAnnotationLayout.Filters)
            {
                XmlElement newFilterNode = document.CreateElement("filter");
                newFilterNode.SetAttribute("key", keyValuePair.Key);
                newFilterNode.SetAttribute("value", keyValuePair.Value);
                filtersNode.AppendChild(newFilterNode);
            }

            xPath = String.Format("dicom-filtered-annotation-layout[@id='{0}']", dicomFilteredAnnotationLayout.Identifier);
            XmlElement existingNode = (XmlElement)filteredLayoutsNode.SelectSingleNode(xPath);

            if (existingNode != null)
            {
                filteredLayoutsNode.ReplaceChild(newFilteredLayoutNode, existingNode);
            }
            else
            {
                filteredLayoutsNode.AppendChild(newFilteredLayoutNode);
            }
        }