Exemplo n.º 1
0
        public void SetDefaultItem(CompareItem newDefaultItem)
        {
            DefaultItem = newDefaultItem;

            foreach (CompareItem item in Items)
            {
                item.Status = (item == DefaultItem ? CompareItemStatus.Base : CompareItemStatus.Unknown);
                item.CompareResult.Clear();
            }
        }
Exemplo n.º 2
0
        public void LoadFromXML(string xmlPath)
        {
            Console.WriteLine("Loading data from XML");
            Groups.Clear();

            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(xmlPath);
                XmlNodeList xmlGroups = xmlDoc.SelectNodes("/groups/group");

                // Dohvaćamo grupe
                foreach (XmlNode xmlGroup in xmlGroups)
                {
                    CompareGroup newGroup = new CompareGroup();
                    newGroup.Name = xmlGroup.SelectSingleNode("name").InnerText;

                    // Dohvaćamo iteme
                    XmlNodeList xmlItems = xmlGroup.SelectNodes("items/item");

                    foreach (XmlNode xmlItem in xmlItems)
                    {
                        CompareItem newItem = new CompareItem();
                        newItem.Group = newGroup;
                        newItem.Name  = xmlItem.SelectSingleNode("name").InnerText;
                        newItem.Path  = xmlItem.SelectSingleNode("path").InnerText;

                        XmlNode defaultItem = xmlItem.SelectSingleNode("default");
                        newItem.Default = (defaultItem != null) && (Convert.ToBoolean(defaultItem.InnerText));

                        if (newItem.Default)
                        {
                            newGroup.SetDefaultItem(newItem);

                            newItem.Status = CompareItemStatus.Base;
                        }
                        else
                        {
                            newItem.Status = CompareItemStatus.Unknown;
                        }

                        newGroup.Items.Add(newItem);
                    }

                    Groups.Add(newGroup);
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }