public ResolveGenres(Dictionary <string, string> genreIssueList, Title title) { InitializeComponent(); _title = title; if (TitleCollectionManager.GetAllGenreMetaDatas().Count() > 0) { String[] arrGenre = (from gmd in TitleCollectionManager.GetAllGenreMetaDatas() select gmd.Name).ToArray(); _genreList.AddRange(arrGenre); } foreach (string key in genreIssueList.Keys) { if (String.IsNullOrEmpty(genreIssueList[key])) { _genreMapping.Add(new GenreMapping() { SourceGenre = key, DestinationGenre = string.Empty, Action = MapActionEnum.Ignore }); } else { _genreMapping.Add(new GenreMapping() { SourceGenre = key, DestinationGenre = genreIssueList[key], Action = MapActionEnum.Map }); } } RenderGenreMapping(); }
public void SetMRULists() { if (this.Text == "Genres") { cbeItem.Properties.Items.AddRange(TitleCollectionManager.GetAllGenreMetaDatas().ToArray()); } else if ((this.Text == "Tags")) { cbeItem.Properties.Items.AddRange(TitleCollectionManager.GetAllTagsList().ToArray()); } }
private void cbeItem_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Kind == ButtonPredefines.Plus) { if (_list.Contains(cbeItem.Text)) { return; } if (this.Text == "Genres") { var genre = from gmd in TitleCollectionManager.GetAllGenreMetaDatas() where gmd.Name == cbeItem.Text select gmd; if (genre.Count() == 0) { DialogResult result = XtraMessageBox.Show("You are attempting to add a genre that is not defined. Click Yes to add it to the list.", "Allowed Genre Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question); switch (result) { case DialogResult.Yes: break; default: return; } } } _list.Add(cbeItem.Text); (this.BindingContext[_list] as CurrencyManager).Refresh(); lbItems.Refresh(); cbeItem.Text = ""; } else if ((this.Text == "Tags")) { //cbeItem.Properties.Items.AddRange(OMLEngine.Settings.OMLSettings.Tags.Split('|')); } }
private void ApplyGenreMappings(Title title, bool removeUnknownGenres) { List <String> genreList = new List <String>(); int genreCount = TitleCollectionManager.GetAllGenreMetaDatas().Count(); if (genreCount > 0) { genreList.AddRange(from gm in TitleCollectionManager.GetAllGenreMetaDatas() select gm.Name); Dictionary <string, string> genreIssuesList = new Dictionary <string, string>(); Dictionary <string, string> genreChanges = new Dictionary <string, string>(); foreach (string genre in title.Genres) { string newGenre = genre.Trim(); if (!genreList.Contains(newGenre)) { // Genre doesn't exists if (OMLEngine.Settings.SettingsManager.GenreMap_GetMapping(newGenre) != null) { // Mapping already exists for genre genreChanges[genre] = OMLEngine.Settings.SettingsManager.GenreMap_GetMapping(newGenre); } else { // Mapping doesn't exists for genre, try trimming off 'film' from the end just incase if (newGenre.EndsWith("Film", true, CultureInfo.InvariantCulture)) { newGenre = newGenre.Replace(" Film", ""); } if (genreList.Contains(newGenre)) { genreIssuesList[genre] = newGenre; } else { string match = genreList.FirstOrDefault(s => s.Split(' ').Intersect(newGenre.Split(' ')).Count() != 0); genreIssuesList[genre] = match; } } } } foreach (string genre in genreChanges.Keys) { title.RemoveGenre(genre); // Mapping contains empty string when user wants a specific genre ignored. if (!String.IsNullOrEmpty(genreChanges[genre]) && !title.Genres.Contains(genreChanges[genre])) { title.AddGenre(genreChanges[genre]); } } if (genreIssuesList.Keys.Count > 0) { if (!removeUnknownGenres) { foreach (string genre in genreIssuesList.Keys) { if (title.Genres.Contains(genre)) { title.RemoveGenre(genre); } } } } } }