示例#1
0
 /// <summary>
 /// UI callback: remove selected entry
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRemoveEntry_Click(object sender, RoutedEventArgs e)
 {
     if (SelectedLibraryEntry != null)
     {
         Library.RemoveEntry(SelectedLibraryEntry);
         SelectedLibraryEntry = null;
     }
 }
        /// <summary>
        /// Constructor which initializes the dialog with a library entry
        /// </summary>
        /// <param name="entry">Entry for initialization</param>
        public EditEntryWindow(AudioEntry entry)
        {
            InitializeComponent();
            PopulateCategories();

            this.DataContext = this;

            if (entry != null)
            {
                Path       = entry.Path;
                Category   = entry.Category;
                AudioName  = entry.Name;
                RecordDate = entry.RecordDate;

                EnumeratedTags = entry.GetTags();
            }
        }
        /// <summary>
        /// Modify an existing library entry with dialog entries
        /// </summary>
        /// <param name="entry">(ref) Existing audio entry</param>
        /// <returns>True if created successful</returns>
        public bool ModifyEntry(ref AudioEntry entry)
        {
            if (entry == null)
            {
                return(false);
            }

            try
            {
                entry.Name       = AudioName;
                entry.Path       = Path;
                entry.RecordDate = RecordDate;
                entry.Category   = Category;

                string[] tags = EnumeratedTags.Trim().Split(';');

                if (tags != null && tags.Length > 0)
                {
                    foreach (string s in tags)
                    {
                        if (s.Trim().Length > 0)
                        {
                            entry.Tags.Add(s.Trim());
                        }
                    }
                }
                else
                {
                    entry.Tags.Clear();
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }