예제 #1
0
        public static AutoCatGenre LoadFromXmlElement(XmlElement xElement)
        {
            string name        = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Name], TypeIdString);
            string filter      = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Filter], null);
            int    maxCats     = XmlUtil.GetIntFromNode(xElement[XmlName_MaxCats], 0);
            bool   remOther    = XmlUtil.GetBoolFromNode(xElement[XmlName_RemOther], false);
            bool   tagFallback = XmlUtil.GetBoolFromNode(xElement[XmlName_TagFallback], true);
            string prefix      = XmlUtil.GetStringFromNode(xElement[Serialization.Constants.Prefix], null);

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

            XmlElement  ignoreListElement = xElement[XmlName_IgnoreList];
            XmlNodeList ignoreNodes       = ignoreListElement?.SelectNodes(XmlName_IgnoreItem);

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

            AutoCatGenre result = new AutoCatGenre(name, filter, prefix, maxCats, remOther, tagFallback, ignore);

            return(result);
        }
예제 #2
0
 protected AutoCatGenre(AutoCatGenre other) : base(other)
 {
     Filter            = other.Filter;
     MaxCategories     = other.MaxCategories;
     RemoveOtherGenres = other.RemoveOtherGenres;
     TagFallback       = other.TagFallback;
     Prefix            = other.Prefix;
     IgnoredGenres     = new List <string>(other.IgnoredGenres);
     Selected          = other.Selected;
 }
예제 #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);
            }
        }
        public override void LoadFromAutoCat(AutoCat autoCat)
        {
            AutoCatGenre ac = autoCat as AutoCatGenre;

            if (ac == null)
            {
                return;
            }

            chkRemoveExisting.Checked = ac.RemoveOtherGenres;
            chkTagFallback.Checked    = ac.TagFallback;
            numMaxCats.Value          = ac.MaxCategories;
            txtPrefix.Text            = ac.Prefix;

            foreach (ListViewItem item in lstIgnore.Items)
            {
                item.Checked = !ac.IgnoredGenres.Contains(item.Text);
            }
        }
        public override void SaveToAutoCat(AutoCat autoCat)
        {
            AutoCatGenre ac = autoCat as AutoCatGenre;

            if (ac == null)
            {
                return;
            }

            ac.Prefix            = txtPrefix.Text;
            ac.MaxCategories     = (int)numMaxCats.Value;
            ac.RemoveOtherGenres = chkRemoveExisting.Checked;
            ac.TagFallback       = chkTagFallback.Checked;

            ac.IgnoredGenres.Clear();
            foreach (ListViewItem i in lstIgnore.Items)
            {
                if (!i.Checked)
                {
                    ac.IgnoredGenres.Add(i.Text);
                }
            }
        }