private void UpdateTagsBox(ITagsDBReadByLanguage tagsRead) { tagsBox.BeginUpdate(); tagsBox.Items.Clear(); if (m_SelectedCategoryId >= 0) { m_Tags = tagsRead.GetAllTags(m_SelectedCategoryId); } else { IList <TagInfoForLanguage> allTags = tagsRead.GetAllTags(); m_Tags = new List <TagForLanguage>(allTags.Count); foreach (TagInfoForLanguage tagInfo in allTags) { m_Tags.Add(new TagForLanguage() { Name = tagInfo.Name, Id = tagInfo.Id }); } } foreach (TagForLanguage tag in m_Tags) { tagsBox.Items.Add(tag.Name); if (m_SelectedTags.Contains(tag.Id)) { tagsBox.SetItemCheckState(tagsBox.Items.Count - 1, CheckState.Checked); } } tagsBox.EndUpdate(); }
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 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 UpdateTagsBox(ITagsDBReadByLanguage tagsRead) { tagsBox.BeginUpdate(); tagsBox.Items.Clear(); if (m_SelectedCategoryId >= 0) { m_Tags = tagsRead.GetAllTags(m_SelectedCategoryId); } else { IList <TagInfoForLanguage> allTags = tagsRead.GetAllTags(); m_Tags = new List <TagForLanguage>(allTags.Count); foreach (TagInfoForLanguage tagInfo in allTags) { m_Tags.Add(new TagForLanguage() { Name = tagInfo.Name, Id = tagInfo.Id }); } } try { var readIf = Ares.Tags.TagsModule.GetTagsDB().ReadInterface; foreach (TagForLanguage tag in m_Tags) { tagsBox.Items.Add(tag.Name); if (m_Files != null && m_Files.Count > 0) { HashSet <int> tagsSet = new HashSet <int>(); tagsSet.Add(tag.Id); var files = readIf.GetAllFilesWithAnyTag(tagsSet); bool allFilesHaveTag = true; bool anyFileHasTag = false; foreach (String file in m_Files) { if (files.Contains(file, StringComparer.InvariantCultureIgnoreCase)) { anyFileHasTag = true; if (!allFilesHaveTag) { break; } } else { allFilesHaveTag = false; if (anyFileHasTag) { break; } } } if (anyFileHasTag) { tagsBox.SetItemCheckState(tagsBox.Items.Count - 1, allFilesHaveTag ? CheckState.Checked : CheckState.Indeterminate); } } } } catch (Ares.Tags.TagsDbException ex) { MessageBox.Show(this, String.Format(StringResources.TagsDbError, ex.Message), StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); } tagsBox.EndUpdate(); }
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; }