예제 #1
0
파일: Form1.cs 프로젝트: CopyCat73/Pure-Dev
        public void ResetPublicationsFilter()
        {
            PublicationsFilter.DataSource    = _PurePublicationTypes;
            PublicationsFilter.DisplayMember = "Name";
            PublicationsFilter.ValueMember   = "Uri";

            _PublicationFilter_CheckedItems.Clear();

            for (int i = 0; i < PublicationsFilter.Items.Count; i++)
            {
                PublicationsFilter.SetItemChecked(i, true);
                PurePublicationType selectedType = (PurePublicationType)PublicationsFilter.Items[i];
                _PublicationFilter_CheckedItems.Add(selectedType.Uri);
            }
            this.PublicationsFilter.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.PublicationsFilter_ItemCheck);
        }
예제 #2
0
파일: Form1.cs 프로젝트: CopyCat73/Pure-Dev
        private void PublicationsFilter_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            _PureDownloadedPublicationsFiltered.Clear();
            PurePublicationType selectedType = (PurePublicationType)PublicationsFilter.Items[e.Index];

            if (e.NewValue == CheckState.Checked)
            {
                _PublicationFilter_CheckedItems.Add(selectedType.Uri);
            }
            else
            {
                _PublicationFilter_CheckedItems.Remove(selectedType.Uri);
            }

            foreach (PurePublication Pub in _PureDownloadedPublications)
            {
                if (_PublicationFilter_CheckedItems.Contains(Pub.Type))
                {
                    _PureDownloadedPublicationsFiltered.Add(Pub);
                }
            }
            ResetPublicationsList();
        }
예제 #3
0
파일: Form1.cs 프로젝트: CopyCat73/Pure-Dev
        private void parsePublicationsXSD()
        {
            _PurePublicationTypeTree.Clear();

            string fileContents;

            using (StreamReader streamReader = new StreamReader(Properties.Settings.Default.PublicationXSDLocation, Encoding.UTF8))
            {
                fileContents = streamReader.ReadToEnd();
            }

            try
            {
                XmlReader           reader           = XmlReader.Create(new StringReader(fileContents));
                XElement            root             = XElement.Load(reader);
                XmlNameTable        nameTable        = reader.NameTable;
                XmlNamespaceManager namespaceManager = new XmlNamespaceManager(nameTable);
                namespaceManager.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");

                List <string>          AbstractElementList = new List <string>();
                List <string>          PublicationList     = new List <string>();
                IEnumerable <XElement> AbstractElements    = root.XPathSelectElements("//xs:complexType[@name='publicationType' and @abstract='true']/xs:sequence/xs:element", namespaceManager);
                foreach (XElement el in AbstractElements)
                {
                    if (el.Attribute("name") != null)
                    {
                        String Element = el.Attribute("name").Value;
                        AbstractElementList.Add(Element);
                    }
                    else if (el.Attribute("ref") != null)
                    {
                        String Element = el.Attribute("ref").Value;
                        AbstractElementList.Add(Element);
                    }
                }

                IEnumerable <XElement> PublicationTypes = root.XPathSelectElements("//xs:element[@name='publications']/xs:complexType/xs:choice/xs:element", namespaceManager);
                foreach (XElement el in PublicationTypes)
                {
                    String PubTypeName = el.Attribute("ref").Value;
                    PublicationList.Add(PubTypeName + "Type"); //eigenlijk opzoeken
                }

                IEnumerable <XElement> PublicationComplexTypes = root.XPathSelectElements("//xs:complexType", namespaceManager);
                foreach (XElement el in PublicationComplexTypes)
                {
                    if (el.Attribute("name") != null)
                    {
                        String PubTypeName = el.Attribute("name").Value;
                        if (PublicationList.Contains(PubTypeName))
                        {
                            PurePublicationType PubType = new PurePublicationType(PubTypeName, "");
                            PubType.AssociatedFields = new List <string>();
                            PubType.AssociatedFields.AddRange(AbstractElementList);
                            IEnumerable <XElement> PublicationFields = el.XPathSelectElements("/xs:scomplexContent/xs:extension/xs:sequence/xs:element", namespaceManager);
                            foreach (XElement fld in PublicationFields)
                            {
                                String PubField = fld.Attribute("name").Value;
                                PubType.AssociatedFields.Add(PubField);
                            }
                            _PurePublicationTypeTree.Add(PubType);
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                ShowMessage("Error:" + e1.Message);
            }
        }