private void RenameAutoCat(AutoCat.AutoCat ac)
        {
            if (ac == null)
            {
                return;
            }

            bool         good = true;
            DialogResult res;
            string       name;

            do
            {
                GetStringDlg dlg = new GetStringDlg(ac.Name, GlobalStrings.DlgAutoCat_RenameBoxTitle,
                                                    GlobalStrings.DlgAutoCat_RenameBoxLabel, GlobalStrings.DlgAutoCat_RenameBoxButton);
                res  = dlg.ShowDialog();
                name = dlg.Value;
                if (string.IsNullOrEmpty(name))
                {
                    MessageBox.Show(GlobalStrings.DlgAutoCat_MustHaveName);
                    good = false;
                }
                else if (NameExists(name))
                {
                    MessageBox.Show(GlobalStrings.DlgAutoCat_NameInUse);
                    good = false;
                }
            } while (res == DialogResult.OK && !good);
            if (res == DialogResult.OK)
            {
                ac.Name = name;
            }
            AutoCatList.Sort();
            FillAutocatList();
        }
 private void RemoveAutoCat(AutoCat.AutoCat ac)
 {
     if (ac == null)
     {
         return;
     }
     lstAutoCats.Items.Remove(ac);
     AutoCatList.Remove(ac);
 }
Exemple #3
0
        public DlgAutoCatSelect(List <AutoCat.AutoCat> autoCats, string name)
        {
            InitializeComponent();

            AutoCatList   = new List <AutoCat.AutoCat>();
            originalGroup = name;

            foreach (AutoCat.AutoCat c in autoCats)
            {
                AutoCat.AutoCat clone = c.Clone();
                clone.Selected = false;
                AutoCatList.Add(clone);
            }
        }
        private void CreateNewAutoCat()
        {
            string       name = string.Empty;
            AutoCatType  t    = AutoCatType.None;
            bool         good = true;
            DialogResult res;

            do
            {
                DlgAutoCatCreate dlg = new DlgAutoCatCreate();
                res = dlg.ShowDialog();
                if (res == DialogResult.OK)
                {
                    good = true;
                    name = dlg.SelectedName;
                    t    = dlg.SelectedType;
                    if (string.IsNullOrEmpty(name))
                    {
                        MessageBox.Show(GlobalStrings.DlgAutoCat_MustHaveName);
                        good = false;
                    }
                    else if (NameExists(name))
                    {
                        MessageBox.Show(GlobalStrings.DlgAutoCat_NameInUse);
                        good = false;
                    }
                    else if (t == AutoCatType.None)
                    {
                        MessageBox.Show(GlobalStrings.DlgAutoCat_SelectValidType);
                        good = false;
                    }
                }
            } while (res == DialogResult.OK && !good);
            AutoCat.AutoCat newAutoCat = null;
            if (res == DialogResult.OK)
            {
                newAutoCat = AutoCat.AutoCat.Create(t, name);
                if (newAutoCat != null)
                {
                    AutoCatList.Add(newAutoCat);
                }
            }
            AutoCatList.Sort();
            FillAutocatList();
            if (newAutoCat != null)
            {
                lstAutoCats.SelectedItem = newAutoCat;
            }
        }
        public override void SaveToAutoCat(AutoCat autocat)
        {
            AutoCatFlags ac = autocat as AutoCatFlags;

            if (ac == null)
            {
                return;
            }

            ac.Prefix = txtPrefix.Text;

            ac.IncludedFlags.Clear();
            foreach (ListViewItem i in lstIncluded.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedFlags.Add(i.Text);
                }
            }
        }
Exemple #6
0
        public override void LoadFromAutoCat(AutoCat ac)
        {
            AutoCatUserScore acScore = ac as AutoCatUserScore;

            if (ac == null)
            {
                return;
            }

            txtPrefix.Text            = acScore.Prefix;
            chkUseWilsonScore.Checked = acScore.UseWilsonScore;

            ruleList.Clear();
            foreach (UserScoreRule rule in acScore.Rules)
            {
                ruleList.Add(new UserScoreRule(rule));
            }

            UpdateEnabledSettings();
        }
        public DlgAutoCat(List <AutoCat.AutoCat> autoCats, GameList ownedGames, AutoCat.AutoCat selected, string profile)
        {
            InitializeComponent();

            AutoCatList = new List <AutoCat.AutoCat>();

            profilePath = profile;

            foreach (AutoCat.AutoCat c in autoCats)
            {
                AutoCat.AutoCat clone = c.Clone();
                AutoCatList.Add(clone);
                if (c.Equals(selected))
                {
                    initial = clone;
                }
            }

            this.ownedGames = ownedGames;
        }
        private void lstAutoCats_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (current != null)
            {
                SaveToAutoCat();
            }
            current = lstAutoCats.SelectedItem as AutoCat.AutoCat;
            RecreateConfigPanel();
            FillConfigPanel();

            if (lstAutoCats.SelectedItem != null)
            {
                btnUp.Enabled   = (lstAutoCats.SelectedIndex == 0) ? false : true;
                btnDown.Enabled = (lstAutoCats.SelectedIndex == (lstAutoCats.Items.Count - 1)) ? false : true;
            }
            else
            {
                btnUp.Enabled   = false;
                btnDown.Enabled = false;
            }
        }
Exemple #9
0
        public static AutoCatConfigPanel CreatePanel(AutoCat ac, GameList ownedGames, List <AutoCat> autocats)
        {
            AutoCatType t = ac.AutoCatType;

            switch (t)
            {
            case AutoCatType.Genre:
                return(new AutoCatConfigPanel_Genre());

            case AutoCatType.Flags:
                return(new AutoCatConfigPanel_Flags());

            case AutoCatType.Tags:
                return(new AutoCatConfigPanel_Tags(ownedGames));

            case AutoCatType.Year:
                return(new AutoCatConfigPanel_Year());

            case AutoCatType.UserScore:
                return(new AutoCatConfigPanel_UserScore());

            case AutoCatType.Hltb:
                return(new AutoCatConfigPanel_Hltb());

            case AutoCatType.Manual:
                return(new AutoCatConfigPanel_Manual(ownedGames));

            case AutoCatType.DevPub:
                return(new AutoCatConfigPanel_DevPub(ownedGames));

            case AutoCatType.Group:
                return(new AutoCatConfigPanel_Group(autocats));

            case AutoCatType.Name:
                return(new AutoCatConfigPanel_Name());

            default:
                return(null);
            }
        }
        public override void LoadFromAutoCat(AutoCat autocat)
        {
            AutoCatTags ac = autocat as AutoCatTags;

            if (ac == null)
            {
                return;
            }

            txtPrefix.Text   = ac.Prefix == null ? string.Empty : ac.Prefix;
            numMaxTags.Value = ac.MaxTags;

            list_numMinScore.Value        = ac.ListMinScore;
            list_numTagsPerGame.Value     = ac.ListTagsPerGame;
            list_chkOwnedOnly.Checked     = ac.ListOwnedOnly;
            list_numWeightFactor.Value    = (decimal)ac.ListWeightFactor;
            list_chkExcludeGenres.Checked = ac.ListExcludeGenres;

            FillTagsList(ac.IncludedTags);

            loaded = true;
        }
Exemple #11
0
        // using a list of AutoCat names (strings), return a cloned list of AutoCats replacing the filter with a new one if a new filter is provided.
        // This is used to help process AutoCatGroup.
        public List <AutoCat.AutoCat> CloneAutoCatList(List <string> acList, Filter filter)
        {
            List <AutoCat.AutoCat> newList = new List <AutoCat.AutoCat>();

            foreach (string s in acList)
            {
                // find the AutoCat based on name
                AutoCat.AutoCat ac = GetAutoCat(s);
                if (ac != null)
                {
                    // add a cloned copy of the Autocat and replace the filter if one is provided.
                    // a cloned copy is used so that the selected property can be assigned without effecting lvAutoCatType on the Main form.
                    AutoCat.AutoCat clone = ac.Clone();
                    if (filter != null)
                    {
                        clone.Filter = filter.Name;
                    }
                    newList.Add(clone);
                }
            }
            return(newList);
        }
Exemple #12
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);
                }
            }
        }
        public override void LoadFromAutoCat(AutoCat ac)
        {
            AutoCatHltb acHltb = ac as AutoCatHltb;

            if (acHltb == null)
            {
                return;
            }

            txtPrefix.Text            = acHltb.Prefix;
            chkIncludeUnknown.Checked = acHltb.IncludeUnknown;
            txtUnknownText.Text       = acHltb.UnknownText == null ? string.Empty : acHltb.UnknownText;
            acHltb.IncludeUnknown     = chkIncludeUnknown.Checked;
            acHltb.UnknownText        = txtUnknownText.Text;

            ruleList.Clear();
            foreach (HltbRule rule in acHltb.Rules)
            {
                ruleList.Add(new HltbRule(rule));
            }

            UpdateEnabledSettings();
        }
Exemple #14
0
        public override void LoadFromAutoCat(AutoCat autocat)
        {
            AutoCatDevPub ac = autocat as AutoCatDevPub;

            if (ac == null)
            {
                return;
            }

            chkAllDevelopers.Checked = ac.AllDevelopers;
            chkAllPublishers.Checked = ac.AllPublishers;
            txtPrefix.Text           = ac.Prefix;
            list_numScore.Value      = ac.MinCount;
            chkOwnedOnly.Checked     = ac.OwnedOnly;

            FillDevList();
            FillPubList();

            lstDevelopers.BeginUpdate();
            foreach (ListViewItem item in lstDevelopers.Items)
            {
                item.Checked = ac.Developers.Contains(item.Tag.ToString());
            }

            lstDevelopers.EndUpdate();

            lstPublishers.BeginUpdate();
            foreach (ListViewItem item in lstPublishers.Items)
            {
                item.Checked = ac.Publishers.Contains(item.Tag.ToString());
            }

            lstPublishers.EndUpdate();

            loaded = true;
        }
Exemple #15
0
 public virtual void LoadFromAutoCat(AutoCat ac)
 {
 }
        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();
                    l.Text = s;
                    l.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();
                    l.Text = s;
                    l.Name = s;
                    clbAddSelected.Items.Add(l, true);
                }
            }

            UpdateRemoveCount();
            UpdateAddCount();

            loaded = true;
        }
Exemple #17
0
 private bool IsGroup(string find)
 {
     AutoCat.AutoCat test = GetAutoCat(find);
     return((test.AutoCatType == AutoCatType.Group) ? true : false);
 }
Exemple #18
0
        public int CompareTo(object other)
        {
            AutoCat cat = other as AutoCat;

            return(cat != null?string.CompareOrdinal(Name, cat.Name) : 1);
        }
Exemple #19
0
 /// <summary>
 /// </summary>
 /// <param name="other"></param>
 protected AutoCat(AutoCat other)
 {
     Name   = other.Name;
     Filter = other.Filter;
 }
Exemple #20
0
 public virtual void SaveToAutoCat(AutoCat ac)
 {
 }
Exemple #21
0
        public static Profile Load(string path)
        {
            Program.Logger.Write(LoggerLevel.Info, GlobalStrings.Profile_LoadingProfile, path);
            Profile profile = new Profile();

            profile.FilePath = path;

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(path);
            }
            catch (Exception e)
            {
                Program.Logger.Write(LoggerLevel.Warning, GlobalStrings.Profile_FailedToLoadProfile, e.Message);
                throw new ApplicationException(GlobalStrings.Profile_ErrorLoadingProfile + e.Message, e);
            }

            XmlNode profileNode = doc.SelectSingleNode("/" + XmlName_Profile);

            if (profileNode != null)
            {
                // Get the profile version that we're loading
                XmlAttribute versionAttr    = profileNode.Attributes[XmlName_Version];
                int          profileVersion = 0;
                if (versionAttr != null)
                {
                    if (!int.TryParse(versionAttr.Value, out profileVersion))
                    {
                        profileVersion = 0;
                    }
                }
                // Get the 64-bit Steam ID
                Int64 accId = XmlUtil.GetInt64FromNode(profileNode[XmlName_SteamID], 0);
                if (accId == 0)
                {
                    string oldAcc = XmlUtil.GetStringFromNode(profileNode[XmlName_Old_SteamIDShort], null);
                    if (oldAcc != null)
                    {
                        accId = DirNametoID64(oldAcc);
                    }
                }
                profile.SteamID64 = accId;

                // Get other attributes
                if (profileVersion < 3)
                {
                    profile.AutoUpdate =
                        XmlUtil.GetBoolFromNode(profileNode[XmlName_Old_AutoDownload], profile.AutoUpdate);
                }
                else
                {
                    profile.AutoUpdate = XmlUtil.GetBoolFromNode(profileNode[XmlName_AutoUpdate], profile.AutoUpdate);
                }

                profile.AutoImport = XmlUtil.GetBoolFromNode(profileNode[XmlName_AutoImport], profile.AutoImport);
                profile.AutoExport = XmlUtil.GetBoolFromNode(profileNode[XmlName_AutoExport], profile.AutoExport);

                profile.LocalUpdate = XmlUtil.GetBoolFromNode(profileNode[XmlName_LocalUpdate], profile.LocalUpdate);
                profile.WebUpdate   = XmlUtil.GetBoolFromNode(profileNode[XmlName_WebUpdate], profile.WebUpdate);

                profile.IncludeUnknown =
                    XmlUtil.GetBoolFromNode(profileNode[XmlName_IncludeUnknown], profile.IncludeUnknown);
                profile.BypassIgnoreOnImport = XmlUtil.GetBoolFromNode(profileNode[XmlName_BypassIgnoreOnImport],
                                                                       profile.BypassIgnoreOnImport);

                profile.ExportDiscard =
                    XmlUtil.GetBoolFromNode(profileNode[XmlName_ExportDiscard], profile.ExportDiscard);
                profile.AutoIgnore          = XmlUtil.GetBoolFromNode(profileNode[XmlName_AutoIgnore], profile.AutoIgnore);
                profile.OverwriteOnDownload =
                    XmlUtil.GetBoolFromNode(profileNode[XmlName_OverwriteNames], profile.OverwriteOnDownload);

                if (profileVersion < 2)
                {
                    bool ignoreShortcuts = false;
                    if (XmlUtil.TryGetBoolFromNode(profileNode[XmlName_Old_IgnoreExternal], out ignoreShortcuts))
                    {
                        profile.IncludeShortcuts = !ignoreShortcuts;
                    }
                }
                else
                {
                    profile.IncludeShortcuts =
                        XmlUtil.GetBoolFromNode(profileNode[XmlName_IncludeShortcuts], profile.IncludeShortcuts);
                }

                XmlNode exclusionListNode = profileNode.SelectSingleNode(XmlName_ExclusionList);
                if (exclusionListNode != null)
                {
                    XmlNodeList exclusionNodes = exclusionListNode.SelectNodes(XmlName_Exclusion);
                    foreach (XmlNode node in exclusionNodes)
                    {
                        int id;
                        if (XmlUtil.TryGetIntFromNode(node, out id))
                        {
                            profile.IgnoreList.Add(id);
                        }
                    }
                }

                XmlNode gameListNode = profileNode.SelectSingleNode(XmlName_GameList);
                if (gameListNode != null)
                {
                    XmlNodeList gameNodes = gameListNode.SelectNodes(XmlName_Game);
                    foreach (XmlNode node in gameNodes)
                    {
                        AddGameFromXmlNode(node, profile, profileVersion);
                    }
                }

                XmlNode filterListNode = profileNode.SelectSingleNode(XmlName_FilterList);
                if (filterListNode != null)
                {
                    XmlNodeList filterNodes = filterListNode.SelectNodes(XmlName_Filter);
                    foreach (XmlNode node in filterNodes)
                    {
                        AddFilterFromXmlNode(node, profile);
                    }
                }

                XmlNode autocatListNode = profileNode.SelectSingleNode(XmlName_AutoCatList);
                if (autocatListNode != null)
                {
                    XmlNodeList autoCatNodes = autocatListNode.ChildNodes;
                    foreach (XmlNode node in autoCatNodes)
                    {
                        XmlElement autocatElement = node as XmlElement;
                        if (node != null)
                        {
                            AutoCat.AutoCat autocat = AutoCat.AutoCat.LoadAutoCatFromXmlElement(autocatElement);
                            if (autocat != null)
                            {
                                profile.AutoCats.Add(autocat);
                            }
                        }
                    }
                }
                else
                {
                    GenerateDefaultAutoCatSet(profile.AutoCats);
                }
                //profile.AutoCats.Sort();
            }
            Program.Logger.Write(LoggerLevel.Info, GlobalStrings.MainForm_ProfileLoaded);
            return(profile);
        }