/// <summary>
        /// </summary>
        /// <param name="xElement"></param>
        /// <returns></returns>
        public static AutoCatGenre LoadFromXmlElement(XmlElement xElement)
        {
            string name        = XmlUtil.GetStringFromNode(xElement[XmlNameName], TypeIdString);
            string filter      = XmlUtil.GetStringFromNode(xElement[XmlNameFilter], null);
            int    maxCats     = XmlUtil.GetIntFromNode(xElement[XmlNameMaxCats], 0);
            bool   remOther    = XmlUtil.GetBoolFromNode(xElement[XmlNameRemOther], false);
            bool   tagFallback = XmlUtil.GetBoolFromNode(xElement[XmlNameTagFallback], true);
            string prefix      = XmlUtil.GetStringFromNode(xElement[XmlNamePrefix], null);

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

            XmlElement ignoreListElement = xElement[XmlNameIgnoreList];

            XmlNodeList ignoreNodes = ignoreListElement?.SelectNodes(XmlNameIgnoreItem);

            if (ignoreNodes != null)
            {
                for (int i = 0; i < ignoreNodes.Count; i++)
                {
                    XmlNode node = ignoreNodes[i];
                    if (XmlUtil.TryGetStringFromNode(node, out string s))
                    {
                        ignore.Add(s);
                    }
                }
            }

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

            return(result);
        }
 /// <summary>
 /// </summary>
 /// <param name="other"></param>
 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;
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        /// <summary>
        /// </summary>
        /// <param name="xElement"></param>
        /// <returns></returns>
        public static AutoCat LoadAutoCatFromXmlElement(XmlElement xElement)
        {
            switch (xElement.Name)
            {
            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));

            default:
                return(null);
            }
        }
Beispiel #5
0
        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);
                }
            }
        }