public override void SaveToAutoCat(AutoCat autoCat)
        {
            AutoCatManual ac = autoCat as AutoCatManual;

            if (ac == null)
            {
                return;
            }

            ac.Prefix = txtPrefix.Text;
            ac.RemoveAllCategories = chkRemoveAll.Checked;

            ac.RemoveCategories.Clear();
            if (!chkRemoveAll.Checked)
            {
                foreach (ListViewItem item in clbRemoveSelected.CheckedItems)
                {
                    ac.RemoveCategories.Add(item.Name);
                }
            }

            ac.AddCategories.Clear();
            foreach (ListViewItem item in clbAddSelected.CheckedItems)
            {
                ac.AddCategories.Add(item.Name);
            }
        }
Ejemplo n.º 2
0
 protected AutoCatManual(AutoCatManual other) : base(other)
 {
     Filter = other.Filter;
     Prefix = other.Prefix;
     RemoveAllCategories = other.RemoveAllCategories;
     RemoveCategories    = new List <string>(other.RemoveCategories);
     AddCategories       = new List <string>(other.AddCategories);
     Selected            = other.Selected;
 }
Ejemplo n.º 3
0
        public static AutoCat LoadACFromXmlElement(XmlElement xElement)
        {
            string type = xElement.Name;

            switch (type)
            {
            case AutoCatGenre.TypeIdString:
                return(AutoCatGenre.LoadFromXmlElement(xElement));

            case AutoCatFlags.TypeIdString:
                return(AutoCatFlags.LoadFromXmlElement(xElement));

            case AutoCatTags.TypeIdString:
                return(AutoCatTags.LoadFromXmlElement(xElement));

            case AutoCatYear.TypeIdString:
                return(AutoCatYear.LoadFromXmlElement(xElement));

            case AutoCatUserScore.TypeIdString:
                return(AutoCatUserScore.LoadFromXmlElement(xElement));

            case AutoCatHltb.TypeIdString:
                return(AutoCatHltb.LoadFromXmlElement(xElement));

            case AutoCatManual.TypeIdString:
                return(AutoCatManual.LoadFromXmlElement(xElement));

            case AutoCatDevPub.TypeIdString:
                return(AutoCatDevPub.LoadFromXmlElement(xElement));

            case AutoCatGroup.TypeIdString:
                return(AutoCatGroup.LoadFromXmlElement(xElement));

            case AutoCatName.TypeIdString:
                return(AutoCatName.LoadFromXmlElement(xElement));

            case AutoCatVrSupport.TypeIdString:
                return(AutoCatVrSupport.LoadFromXmlElement(xElement));

            case AutoCatLanguage.TypeIdString:
                return(AutoCatLanguage.LoadFromXmlElement(xElement));

            case AutoCatCurator.TypeIdString:
                return(LoadFromXmlElement(xElement, typeof(AutoCatCurator)));

            case AutoCatPlatform.TypeIdString:
                return(LoadFromXmlElement(xElement, typeof(AutoCatPlatform)));

            case AutoCatHoursPlayed.TypeIdString:
                return(AutoCatHoursPlayed.LoadFromXmlElement(xElement));

            default:
                return(null);
            }
        }
Ejemplo n.º 4
0
        public static AutoCatManual LoadFromXmlElement(XmlElement xElement)
        {
            string name      = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Name], TypeIdString);
            string filter    = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Filter], null);
            bool   removeAll = XmlUtil.GetBoolFromNode(xElement[XmlName_RemoveAll], false);
            string prefix    = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Prefix], null);

            List <string> remove = new List <string>();

            XmlElement  removeListElement = xElement[XmlName_RemoveList];
            XmlNodeList removeNodes       = removeListElement?.SelectNodes(XmlName_RemoveItem);

            if (removeNodes != null)
            {
                foreach (XmlNode node in removeNodes)
                {
                    if (XmlUtil.TryGetStringFromNode(node, out string s))
                    {
                        remove.Add(s);
                    }
                }
            }

            List <string> add = new List <string>();

            XmlElement  addListElement = xElement[XmlName_AddList];
            XmlNodeList addNodes       = addListElement?.SelectNodes(XmlName_AddItem);

            if (addNodes != null)
            {
                foreach (XmlNode node in addNodes)
                {
                    if (XmlUtil.TryGetStringFromNode(node, out string s))
                    {
                        add.Add(s);
                    }
                }
            }

            AutoCatManual result = new AutoCatManual(name, filter, prefix, removeAll, remove, add);

            return(result);
        }
        public override void LoadFromAutoCat(AutoCat autoCat)
        {
            AutoCatManual ac = autoCat as AutoCatManual;

            if (ac == null)
            {
                return;
            }

            chkRemoveAll.Checked = ac.RemoveAllCategories;
            txtPrefix.Text       = ac.Prefix;

            lstRemove.BeginUpdate();

            List <string> found = new List <string>();

            foreach (ListViewItem item in lstRemove.Items)
            {
                item.Checked = ac.RemoveCategories.Contains(item.Name);
                found.Add(item.Name);
            }

            lstRemove.EndUpdate();

            foreach (string s in ac.RemoveCategories)
            {
                if (!found.Contains(s))
                {
                    ListViewItem l = new ListViewItem
                    {
                        Text = s,
                        Name = s
                    };
                    clbRemoveSelected.Items.Add(l, true);
                }
            }

            lstAdd.BeginUpdate();
            found = new List <string>();
            foreach (ListViewItem item in lstAdd.Items)
            {
                item.Checked = ac.AddCategories.Contains(item.Name);
                found.Add(item.Name);
            }

            lstAdd.EndUpdate();

            foreach (string s in ac.AddCategories)
            {
                if (!found.Contains(s))
                {
                    ListViewItem l = new ListViewItem
                    {
                        Text = s,
                        Name = s
                    };
                    clbAddSelected.Items.Add(l, true);
                }
            }

            UpdateRemoveCount();
            UpdateAddCount();

            loaded = true;
        }