public void SetFiles(List <String> files) { m_Files = files; m_FileTags.Clear(); m_AddedTags.Clear(); m_RemovedTags.Clear(); try { ITagsDBReadByLanguage dbRead = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId); foreach (String file in m_Files) { IList <TagInfoForLanguage> tagsForFile = dbRead.GetTagsForFile(file); foreach (TagInfoForLanguage tagInfo in tagsForFile) { if (m_FileTags.ContainsKey(tagInfo.Id)) { m_FileTags[tagInfo.Id]++; } else { m_FileTags[tagInfo.Id] = 1; } } } m_OriginalFileTags = new Dictionary <int, int>(m_FileTags); UpdateControls(); } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void categoriesBox_SelectedIndexChanged(object sender, EventArgs e) { if (!m_Listen) { return; } if (categoriesBox.SelectedIndex == categoriesBox.Items.Count - 1) { m_SelectedCategoryId = -2; } else { m_SelectedCategoryId = m_Categories[categoriesBox.SelectedIndex].Id; } m_Listen = false; try { ITagsDBReadByLanguage tagsRead = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId); UpdateTagsBox(tagsRead); } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } m_Listen = true; }
private void UpdateControls() { if (m_TagsByCategory == null) { return; } m_Listen = false; try { ITagsDBReadByLanguage tagsRead = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId); m_Categories = tagsRead.GetAllCategories(); categoriesBox.BeginUpdate(); categoriesBox.Items.Clear(); int selIndex = -1; foreach (CategoryForLanguage category in m_Categories) { categoriesBox.Items.Add(category.Name); if (category.Id == m_SelectedCategoryId) { selIndex = categoriesBox.Items.Count - 1; } } categoriesBox.Items.Add(StringResources.All); if (selIndex == -1) { selIndex = 0; if (m_Categories.Count > 0) { m_SelectedCategoryId = m_Categories[0].Id; } else { m_SelectedCategoryId = -2; } } categoriesBox.SelectedIndex = selIndex; categoriesBox.EndUpdate(); UpdateTagsBox(tagsRead); } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } m_Listen = true; }
private void clearTagsButton_Click(object sender, EventArgs e) { m_Listen = false; Ares.Editor.Actions.Actions.Instance.AddNew(new Ares.Editor.Actions.RemoveAllTagsFromMusicByTagsAction(m_Element), m_Project); try { ITagsDBReadByLanguage tagsRead = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId); UpdateTagsBox(tagsRead); } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } m_Listen = true; }
private void button1_Click(object sender, EventArgs e) { m_SelectedTags.Clear(); m_TagsByCategory.Clear(); m_Listen = false; try { ITagsDBReadByLanguage tagsRead = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId); UpdateTagsBox(tagsRead); } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } m_Listen = true; }
private void AddTag(String category, String tagName) { try { bool hasChanges = false; int categoryId = -1; CategoryForLanguage existing = m_Categories.FirstOrDefault((categoryForLanguage) => { return(categoryForLanguage.Name.Equals(category, StringComparison.OrdinalIgnoreCase)); }); if (existing == null) { // the category is new hasChanges = true; categoryId = TagsModule.GetTagsDB().GetWriteInterfaceByLanguage(m_LanguageId).AddCategory(category); } else { categoryId = existing.Id; IList <TagForLanguage> tags = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId).GetAllTags(categoryId); TagForLanguage existingTag = tags.FirstOrDefault((tagForLanguage) => { return(tagForLanguage.Name.Equals(tagName, StringComparison.OrdinalIgnoreCase)); }); if (existingTag == null) { hasChanges = true; } } if (hasChanges) { // either category or tag inside the category is new int tagId = TagsModule.GetTagsDB().GetWriteInterfaceByLanguage(m_LanguageId).AddTag(categoryId, tagName); m_FileTags[tagId] = m_Files.Count; m_AddedTags.Add(tagId); UpdateControls(); Ares.Editor.Actions.TagChanges.Instance.FireTagsDBChanged(this); } } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateControls() { m_Listen = false; tagCategoryCombinationBox.Enabled = m_Element != null; tagCategoryCombinationBox.SelectedIndex = (m_Element != null) ? (int)m_Element.TagCategoryCombination : 0; fadeUpDown.Enabled = m_Element != null; fadeUpDown.Value = m_Element != null ? m_Element.FadeTime : 0; try { ITagsDBReadByLanguage tagsRead = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId); languageBox.BeginUpdate(); languageBox.Items.Clear(); m_Languages = tagsRead.GetAllLanguages(); int selIndex = -1; foreach (LanguageForLanguage language in m_Languages) { languageBox.Items.Add(language.Name); if (language.Id == m_LanguageId) { selIndex = languageBox.Items.Count - 1; } } if (selIndex != -1) { languageBox.SelectedIndex = selIndex; } languageBox.EndUpdate(); m_Categories = tagsRead.GetAllCategories(); categoriesBox.BeginUpdate(); categoriesBox.Items.Clear(); selIndex = -1; foreach (CategoryForLanguage category in m_Categories) { categoriesBox.Items.Add(category.Name); if (category.Id == m_SelectedCategoryId) { selIndex = categoriesBox.Items.Count - 1; } } categoriesBox.Items.Add(StringResources.All); if (selIndex == -1) { selIndex = 0; if (m_Categories.Count > 0) { m_SelectedCategoryId = m_Categories[0].Id; } else { m_SelectedCategoryId = -2; } } categoriesBox.SelectedIndex = selIndex; categoriesBox.EndUpdate(); UpdateTagsBox(tagsRead); } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } m_Listen = true; }
private void UpdateControls() { bool hasFiles = (m_Files != null && m_Files.Count > 0); tagsBox.Enabled = hasFiles; shareButton.Enabled = hasFiles; downloadButton.Enabled = hasFiles; id3Button.Enabled = hasFiles; musicBrainzButton.Enabled = hasFiles; addTagButton.Enabled = hasFiles; confirmButton.Enabled = hasFiles; m_Listen = false; try { ITagsDBReadByLanguage tagsRead = TagsModule.GetTagsDB().GetReadInterfaceByLanguage(m_LanguageId); m_Categories = tagsRead.GetAllCategories(); categoriesBox.BeginUpdate(); categoriesBox.Items.Clear(); int selIndex = -1; foreach (CategoryForLanguage category in m_Categories) { categoriesBox.Items.Add(category.Name); if (category.Id == m_SelectedCategoryId) { selIndex = categoriesBox.Items.Count - 1; } } categoriesBox.Items.Add(StringResources.All); if (m_SelectedCategoryId == -2) { selIndex = categoriesBox.Items.Count - 1; } if (selIndex == -1) { selIndex = 0; if (m_Categories.Count > 0) { m_SelectedCategoryId = m_Categories[0].Id; } else { m_SelectedCategoryId = -2; } } categoriesBox.SelectedIndex = selIndex; categoriesBox.EndUpdate(); UpdateTagsBox(tagsRead); languageBox.BeginUpdate(); languageBox.Items.Clear(); m_Languages = tagsRead.GetAllLanguages(); selIndex = -1; foreach (LanguageForLanguage language in m_Languages) { languageBox.Items.Add(language.Name); if (language.Id == m_LanguageId) { selIndex = languageBox.Items.Count - 1; } } if (selIndex != -1) { languageBox.SelectedIndex = selIndex; } languageBox.EndUpdate(); if (confirmButton.Enabled) { confirmButton.Enabled = Ares.Tags.TagsModule.GetTagsDB().WriteInterface.CanConfirmTags(m_Files); } } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } m_Listen = true; }