Abstract base class for autocategorization schemes. Call PreProcess before any set of autocat operations. This is a preliminary form, and may change in future versions. Returning only true / false on a categorization attempt may prove too simplistic.
        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;
        }
        public override void SaveToAutoCat(AutoCat autocat)
        {
            AutoCatDevPub ac = autocat as AutoCatDevPub;
            if (ac == null) return;
            ac.Prefix = txtPrefix.Text;
            ac.OwnedOnly = chkOwnedOnly.Checked;
            ac.MinCount = (int)list_numScore.Value;
            ac.AllDevelopers = chkAllDevelopers.Checked;
            ac.AllPublishers = chkAllPublishers.Checked;

            ac.Developers.Clear();
            if (!chkAllDevelopers.Checked)
            {
                foreach (ListViewItem item in clbDevelopersSelected.CheckedItems)
                {
                    ac.Developers.Add(item.Tag.ToString());
                }
            }

            ac.Publishers.Clear();
            if (!chkAllPublishers.Checked)
            {
                foreach (ListViewItem item in clbPublishersSelected.CheckedItems)
                {
                    ac.Publishers.Add(item.Tag.ToString());
                }
            }
        }
        public override void SaveToAutoCat( AutoCat ac ) {
            AutoCatUserScore acScore = ac as AutoCatUserScore;
            if( ac == null ) return;

            acScore.Prefix = txtPrefix.Text;
            acScore.Rules = new List<UserScore_Rule>( ruleList );
        }
        public override void SaveToAutoCat( AutoCat ac ) {
            AutoCatHltb acHltb = ac as AutoCatHltb;
            if( acHltb == null ) return;

            acHltb.Prefix = txtPrefix.Text;
            acHltb.IncludeUnknown = chkIncludeUnknown.Checked;
            acHltb.UnknownText = txtUnknownText.Text;
            acHltb.Rules = new List<Hltb_Rule>( ruleList );
        }
        public override void LoadFromAutoCat( AutoCat autocat ) {
            AutoCatFlags ac = autocat as AutoCatFlags;
            if( ac == null ) return;

            txtPrefix.Text = ac.Prefix;

            foreach( ListViewItem item in lstIncluded.Items ) {
                item.Checked = ac.IncludedFlags.Contains( item.Text );
            }
        }
        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 );
                }
            }
        }
        public override void LoadFromAutoCat( AutoCat ac ) {
            AutoCatUserScore acScore = ac as AutoCatUserScore;
            if( ac == null ) return;

            txtPrefix.Text = acScore.Prefix;

            ruleList.Clear();
            foreach( UserScore_Rule rule in acScore.Rules ) {
                ruleList.Add( new UserScore_Rule( rule ) );
            }
            UpdateEnabledSettings();
        }
        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 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;
        }
        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 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;
            list_chkScoreSort.Checked = ac.ListScoreSort;

            FillTagsList( ac.IncludedTags );
        }
        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( Hltb_Rule rule in acHltb.Rules ) {
                ruleList.Add( new Hltb_Rule( rule ) );
            }
            UpdateEnabledSettings();
        }
Beispiel #13
0
        public DlgAutoCat( List<AutoCat> autoCats, GameList ownedGames, AutoCat selected, string profile ) {
            InitializeComponent();

            AutoCatList = new List<AutoCat>();

            profilePath = profile;

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

            this.ownedGames = ownedGames;
        }
        public override void SaveToAutoCat( AutoCat autocat ) {
            AutoCatTags ac = autocat as AutoCatTags;
            if( ac == null ) return;
            ac.Prefix = txtPrefix.Text;

            ac.MaxTags = (int)numMaxTags.Value;

            ac.IncludedTags = new HashSet<string>();
            foreach( ListViewItem i in lstIncluded.CheckedItems ) {
                ac.IncludedTags.Add( i.Tag as string );
            }

            ac.ListMinScore = (int)list_numMinScore.Value;
            ac.ListOwnedOnly = list_chkOwnedOnly.Checked;
            ac.ListTagsPerGame = (int)list_numTagsPerGame.Value;
            ac.ListWeightFactor = (float)list_numWeightFactor.Value;
            ac.ListExcludeGenres = list_chkExcludeGenres.Checked;
            ac.ListScoreSort = list_chkScoreSort.Checked;
        }
Beispiel #15
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 #16
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 (UserScore_Rule rule in acScore.Rules)
            {
                ruleList.Add(new UserScore_Rule(rule));
            }
            UpdateEnabledSettings();
        }
Beispiel #17
0
        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);
                }
            }
        }
        public override void SaveToAutoCat(AutoCat autoCat)
        {
            AutoCatLanguage ac = autoCat as AutoCatLanguage;

            if (ac == null)
            {
                return;
            }

            ac.Prefix = txtPrefix.Text;

            ac.IncludeTypePrefix = chkIncludeTypePrefix.Checked;
            ac.TypeFallback      = chkTypeFallback.Checked;

            ac.IncludedLanguages.Interface.Clear();
            ac.IncludedLanguages.Subtitles.Clear();
            ac.IncludedLanguages.FullAudio.Clear();

            foreach (ListViewItem i in lstInterface.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedLanguages.Interface.Add(i.Text);
                }
            }

            foreach (ListViewItem i in lstSubtitles.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedLanguages.Subtitles.Add(i.Text);
                }
            }

            foreach (ListViewItem i in lstFullAudio.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedLanguages.FullAudio.Add(i.Text);
                }
            }
        }
Beispiel #19
0
        public DlgAutoCat(List <AutoCat> autoCats, GameList ownedGames, AutoCat selected, string profile)
        {
            InitializeComponent();

            AutoCatList = new List <AutoCat>();

            profilePath = profile;

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

            this.ownedGames = ownedGames;
        }
        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;
            list_chkScoreSort.Checked     = ac.ListScoreSort;

            FillTagsList(ac.IncludedTags);
        }
        public override void SaveToAutoCat(AutoCat autoCat)
        {
            AutoCatCurator ac = autoCat as AutoCatCurator;

            if (ac == null)
            {
                return;
            }

            ac.CategoryName = txtCategoryName.Text;
            ac.CuratorUrl   = txtCuratorUrl.Text;

            ac.IncludedRecommendations.Clear();
            foreach (ListViewItem i in lstIncluded.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedRecommendations.Add((CuratorRecommendation)Enum.Parse(typeof(CuratorRecommendation), i.Tag.ToString()));
                }
            }
        }
Beispiel #22
0
        private void lstAutoCats_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.current != null)
            {
                SaveToAutoCat();
            }
            current = lstAutoCats.SelectedItem as 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;
            }
        }
        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 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 (Hltb_Rule rule in acHltb.Rules)
            {
                ruleList.Add(new Hltb_Rule(rule));
            }
            UpdateEnabledSettings();
        }
        public override void SaveToAutoCat(AutoCat autocat)
        {
            AutoCatVrSupport ac = autocat as AutoCatVrSupport;

            if (ac == null)
            {
                return;
            }

            ac.Prefix = txtPrefix.Text;

            ac.IncludedVrSupportFlags.Headsets.Clear();
            ac.IncludedVrSupportFlags.Input.Clear();
            ac.IncludedVrSupportFlags.PlayArea.Clear();

            foreach (ListViewItem i in lstVrHeadsets.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedVrSupportFlags.Headsets.Add(i.Text);
                }
            }

            foreach (ListViewItem i in lstVrInput.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedVrSupportFlags.Input.Add(i.Text);
                }
            }

            foreach (ListViewItem i in lstVrPlayArea.Items)
            {
                if (i.Checked)
                {
                    ac.IncludedVrSupportFlags.PlayArea.Add(i.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);
                }
            }
        }
Beispiel #27
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> CloneAutoCatList(List <string> acList, Filter filter)
        {
            List <AutoCat> newList = new List <AutoCat>();

            foreach (string s in acList)
            {
                // find the AutoCat based on name
                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 clone = ac.Clone();
                    if (filter != null)
                    {
                        clone.Filter = filter.Name;
                    }
                    newList.Add(clone);
                }
            }
            return(newList);
        }
Beispiel #28
0
        private void RenameAutoCat(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();
        }
        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;
        }
        public override void SaveToAutoCat(AutoCat autocat)
        {
            AutoCatTags ac = autocat as AutoCatTags;

            if (ac == null)
            {
                return;
            }
            ac.Prefix = txtPrefix.Text;

            ac.MaxTags = (int)numMaxTags.Value;

            ac.IncludedTags = new HashSet <string>();
            foreach (ListViewItem i in lstIncluded.CheckedItems)
            {
                ac.IncludedTags.Add(i.Tag as string);
            }

            ac.List_MinScore      = (int)list_numMinScore.Value;
            ac.List_OwnedOnly     = list_chkOwnedOnly.Checked;
            ac.List_TagsPerGame   = (int)list_numTagsPerGame.Value;
            ac.List_WeightFactor  = (float)list_numWeightFactor.Value;
            ac.List_ExcludeGenres = list_chkExcludeGenres.Checked;
        }
        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;
        }
Beispiel #32
0
 protected AutoCat(AutoCat other)
 {
     Name   = other.Name;
     Filter = other.Filter;
 }
 public override void LoadFromAutoCat( AutoCat autocat ) {
     AutoCatGroup ac = autocat as AutoCatGroup;
     current = autocat;
     if (ac == null) return;
     FillAutocatList(ac.Autocats);
 }
Beispiel #34
0
        private void lstAutoCats_SelectedIndexChanged( object sender, EventArgs e ) {
            if( this.current != null ) {
                SaveToAutoCat();
            }
            current = lstAutoCats.SelectedItem as 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;
            }
        }
Beispiel #35
0
 private void RemoveAutoCat( AutoCat ac ) {
     if( ac == null ) return;
     lstAutoCats.Items.Remove( ac );
     AutoCatList.Remove( ac );
 }
Beispiel #36
0
        private bool IsGroup(string find)
        {
            AutoCat test = GetAutoCat(find);

            return((test.AutoCatType == AutoCatType.Group) ? true : false);
        }
Beispiel #37
0
        public static Profile Load(string path)
        {
            Logger.Info(GlobalStrings.Profile_LoadingProfile, path);
            Profile profile = new Profile();

            profile.FilePath = path;

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(path);
            }
            catch (Exception e)
            {
                Logger.Warn(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
                long 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
                profile.AutoUpdate = XmlUtil.GetBoolFromNode(profileVersion < 3 ? profileNode[XmlName_Old_AutoDownload] : 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.LoadACFromXmlElement(autocatElement);
                            if (autocat != null)
                            {
                                profile.AutoCats.Add(autocat);
                            }
                        }
                    }
                }
                else
                {
                    GenerateDefaultAutoCatSet(profile.AutoCats);
                }

                //profile.AutoCats.Sort();
            }

            Logger.Info(GlobalStrings.MainForm_ProfileLoaded);

            return(profile);
        }
 public override void SaveToAutoCat( AutoCat autocat ) {
     AutoCatGroup ac = autocat as AutoCatGroup;
     if (ac == null) return;
     ac.Autocats = GetGroup();
 }
        private void Autocategorize( bool selectedOnly, AutoCat autoCat )
        {
            if( autoCat == null ) return;

            // Get a list of games to update
            List<GameInfo> gamesToUpdate = new List<GameInfo>();

            if( selectedOnly ) {
                foreach( ListViewItem item in lstGames.SelectedItems ) {
                    GameInfo g = item.Tag as GameInfo;
                    if( ( g != null ) && ( g.Id > 0 ) ) {
                        gamesToUpdate.Add( g );
                    }
                }
            } else {
                foreach( GameInfo g in gameData.Games.Values ) {
                    if( ( g != null ) && ( g.Id > 0 ) ) {
                        gamesToUpdate.Add( g );
                    }
                }
            }

            int updated = 0;

            // List of games not found in database, so we can try to scrape data for them
            List<GameInfo> notFound = new List<GameInfo>();

            autoCat.PreProcess( currentProfile.GameData, Program.GameDB );

            foreach( GameInfo g in gamesToUpdate ) {
                AutoCatResult res = autoCat.CategorizeGame( g );
                if( res == AutoCatResult.Success ) {
                    updated++;
                } else if( res == AutoCatResult.NotInDatabase ) {
                    notFound.Add( g );
                }
            }

            if( notFound.Count > 0 ) {
                if( MessageBox.Show( string.Format( GlobalStrings.MainForm_GamesNotFoundInGameDB, notFound.Count ), GlobalStrings.DBEditDlg_Confirm, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 )
                        == System.Windows.Forms.DialogResult.Yes ) {

                    Queue<int> jobs = new Queue<int>();
                    foreach( GameInfo g in notFound ) jobs.Enqueue( g.Id );

                    DbScrapeDlg scrapeDlg = new DbScrapeDlg( jobs );
                    DialogResult scrapeRes = scrapeDlg.ShowDialog();

                    if( scrapeRes == System.Windows.Forms.DialogResult.Cancel ) {
                        AddStatus( string.Format( GlobalStrings.MainForm_CanceledDatabaseUpdate ) );
                    } else {
                        AddStatus( string.Format( GlobalStrings.MainForm_UpdatedDatabaseEntries, scrapeDlg.JobsCompleted ) );
                        foreach( GameInfo g in notFound ) {
                            AutoCatResult res = autoCat.CategorizeGame( g );
                            if( res == AutoCatResult.Success ) {
                                updated++;
                            }
                        }
                    }
                }
            }
            autoCat.DeProcess();
            AddStatus( string.Format( GlobalStrings.MainForm_UpdatedCategories, updated ) );
            if( gamesToUpdate.Count > updated ) AddStatus( string.Format( GlobalStrings.MainForm_FailedToUpdate, gamesToUpdate.Count - updated ) );
            if( updated > 0 ) MakeChange( true );
            FullListRefresh();
        }
Beispiel #40
0
        /// <summary>
        /// Creates an Edit AutoCats dialog for the user
        /// </summary>
        private void EditAutoCats(AutoCat selected)
        {
            if (!ProfileLoaded) return;
            DlgAutoCat dlg = new DlgAutoCat(currentProfile.AutoCats, currentProfile.GameData, selected, currentProfile.FilePath);

            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                currentProfile.AutoCats = dlg.AutoCatList;
                MakeChange(true);
                FillAutoCatLists();
            }
        }
Beispiel #41
0
 protected AutoCat( AutoCat other ) {
     Name = other.Name;
 }
Beispiel #42
0
 public virtual void SaveToAutoCat(AutoCat autoCat)
 {
 }
Beispiel #43
0
 public virtual void LoadFromAutoCat(AutoCat autoCat)
 {
 }
        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);
            }
        }
Beispiel #45
0
 protected AutoCat(AutoCat other)
 {
     Name = other.Name;
 }
Beispiel #46
0
        public static Profile Load(string path)
        {
            Logger.Info(GlobalStrings.Profile_LoadingProfile, path);
            Profile profile = new Profile
            {
                FilePath = path
            };

            XmlDocument doc = new XmlDocument();

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

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

            if (profileNode != null)
            {
                // Get the 64-bit Steam ID
                long accId = XmlUtil.GetInt64FromNode(profileNode[XmlNameSteamId], 0);
                if (accId == 0)
                {
                    string oldAcc = XmlUtil.GetStringFromNode(profileNode[XmlNameOldSteamIdShort], null);
                    if (oldAcc != null)
                    {
                        accId = ToSteamId64(oldAcc);
                    }
                }

                profile.SteamID64 = accId;

                // Get other attributes
                profile.AutoUpdate = XmlUtil.GetBoolFromNode(profileNode[XmlNameAutoUpdate], profile.AutoUpdate);

                profile.AutoImport = XmlUtil.GetBoolFromNode(profileNode[XmlNameAutoImport], profile.AutoImport);
                profile.AutoExport = XmlUtil.GetBoolFromNode(profileNode[XmlNameAutoExport], profile.AutoExport);

                profile.LocalUpdate = XmlUtil.GetBoolFromNode(profileNode[XmlNameLocalUpdate], profile.LocalUpdate);
                profile.WebUpdate   = XmlUtil.GetBoolFromNode(profileNode[XmlNameWebUpdate], profile.WebUpdate);

                profile.IncludeUnknown       = XmlUtil.GetBoolFromNode(profileNode[XmlNameIncludeUnknown], profile.IncludeUnknown);
                profile.BypassIgnoreOnImport = XmlUtil.GetBoolFromNode(profileNode[XmlNameBypassIgnoreOnImport], profile.BypassIgnoreOnImport);

                profile.ExportDiscard       = XmlUtil.GetBoolFromNode(profileNode[XmlNameExportDiscard], profile.ExportDiscard);
                profile.AutoIgnore          = XmlUtil.GetBoolFromNode(profileNode[XmlNameAutoIgnore], profile.AutoIgnore);
                profile.OverwriteOnDownload = XmlUtil.GetBoolFromNode(profileNode[XmlNameOverwriteNames], profile.OverwriteOnDownload);

                profile.IncludeShortcuts = XmlUtil.GetBoolFromNode(profileNode[XmlNameIncludeShortcuts], profile.IncludeShortcuts);

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

                XmlNode     gameListNode = profileNode.SelectSingleNode(XmlNameGameList);
                XmlNodeList gameNodes    = gameListNode?.SelectNodes(XmlNameGame);
                if (gameNodes != null)
                {
                    foreach (XmlNode node in gameNodes)
                    {
                        AddGameFromNode(node, profile);
                    }
                }

                XmlNode     filterListNode = profileNode.SelectSingleNode(XmlNameFilterList);
                XmlNodeList filterNodes    = filterListNode?.SelectNodes(XmlNameFilter);
                if (filterNodes != null)
                {
                    foreach (XmlNode node in filterNodes)
                    {
                        AddFilterFromNode(node, profile);
                    }
                }

                XmlNode autocatListNode = profileNode.SelectSingleNode(XmlNameAutoCatList);
                if (autocatListNode != null)
                {
                    XmlNodeList autoCatNodes = autocatListNode.ChildNodes;
                    foreach (XmlNode node in autoCatNodes)
                    {
                        XmlElement autocatElement = node as XmlElement;
                        if (node == null)
                        {
                            continue;
                        }

                        AutoCat autocat = AutoCat.LoadACFromXmlElement(autocatElement);
                        if (autocat != null)
                        {
                            profile.AutoCats.Add(autocat);
                        }
                    }
                }
                else
                {
                    GenerateDefaultAutoCatSet(profile.AutoCats);
                }

                //profile.AutoCats.Sort();
            }

            Logger.Info(GlobalStrings.MainForm_ProfileLoaded);
            return(profile);
        }
Beispiel #47
0
        private void RenameAutoCat( 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 == System.Windows.Forms.DialogResult.OK ) {
                ac.Name = name;
            }
            AutoCatList.Sort();
            FillAutocatList();
        }
Beispiel #48
0
        /// <summary>
        /// Autocategorizes a set of games.
        /// </summary>
        /// <param name="selectedOnly">If true, runs on the selected games, otherwise, runs on all games.</param>
        /// <param name="autoCat">The autocat object to use.</param>
        private void Autocategorize(bool selectedOnly, AutoCat autoCat, bool scrape = true, bool refresh = true)
        {
            if (autoCat == null) return;

            Cursor.Current = Cursors.WaitCursor;

            // Get a list of games to update
            List<GameInfo> gamesToUpdate = new List<GameInfo>();

            if (selectedOnly && (autoCat.Filter == null))
            {
                foreach (GameInfo g in tlstGames.SelectedObjects)
                {
                    if (g.Id > 0)
                    {
                        gamesToUpdate.Add(g);
                    }
                }
            }
            else if ((tlstGames.Objects.Count > 0) && (autoCat.Filter == null))
            {
                foreach (GameInfo g in tlstGames.Objects)
                {
                    if (g.Id > 0)
                    {
                        gamesToUpdate.Add(g);
                    }
                }
            }
            else
            {
                foreach (GameInfo g in currentProfile.GameData.Games.Values)
                {
                    if ((g != null) && (g.Id > 0))
                    {
                        gamesToUpdate.Add(g);
                    }
                }
            }

            int updated = 0;

            // List of games not found in database, so we can try to scrape data for them
            Queue<int> notInDb = new Queue<int>();
            foreach (GameInfo game in gamesToUpdate)
            {
                if (game.Id > 0 && (!Program.GameDB.Contains(game.Id) || Program.GameDB.Games[game.Id].LastStoreScrape == 0))
                {
                    notInDb.Enqueue(game.Id);
                }
            }

            if ((notInDb.Count > 0) && scrape)
            {
                Cursor.Current = Cursors.Default;
                if (MessageBox.Show(string.Format(GlobalStrings.MainForm_GamesNotFoundInGameDB, notInDb.Count), GlobalStrings.DBEditDlg_Confirm, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
                        == System.Windows.Forms.DialogResult.Yes)
                {

                    DbScrapeDlg scrapeDlg = new DbScrapeDlg(notInDb);
                    DialogResult scrapeRes = scrapeDlg.ShowDialog();

                    if (scrapeRes == System.Windows.Forms.DialogResult.Cancel)
                    {
                        AddStatus(string.Format(GlobalStrings.MainForm_CanceledDatabaseUpdate));
                    }
                    else
                    {
                        AddStatus(string.Format(GlobalStrings.MainForm_UpdatedDatabaseEntries, scrapeDlg.JobsCompleted));
                        if (scrapeDlg.JobsCompleted > 0 && Settings.Instance.AutosaveDB)
                        {
                            SaveGameDB();
                        }
                    }
                }
                Cursor.Current = Cursors.WaitCursor;
            }

            autoCat.PreProcess(currentProfile.GameData, Program.GameDB);

            foreach (GameInfo g in gamesToUpdate)
            {
                AutoCatResult res = autoCat.CategorizeGame(g, currentProfile.GameData.GetFilter(autoCat.Filter));
                if (res == AutoCatResult.Success)
                {
                    updated++;
                }
            }

            autoCat.DeProcess();
            AddStatus(string.Format(GlobalStrings.MainForm_UpdatedCategories, updated));
            if (gamesToUpdate.Count > updated) AddStatus(string.Format(GlobalStrings.MainForm_FailedToUpdate, gamesToUpdate.Count - updated));
            if (updated > 0) MakeChange(true);
            if (refresh)
            {
                FillAllCategoryLists();
                FilterGamelist(true);
            }

            Cursor.Current = Cursors.Default;
        }
Beispiel #49
0
 protected AutoCat( AutoCat other )
 {
     Name = other.Name;
     Filter = other.Filter;
 }