예제 #1
0
        private int addedTags = 0;                      // Counter to know when to unregister listener
        #endregion

        #region Startup and Shutdown
        /// <summary>
        /// Set defaults and bind grid
        /// </summary>
        /// <param name="mp3File">mp3file is used only for tags</param>
        public Mp3FileDialogue(Mp3File mp3File)
        {
            InitializeComponent();
            this.mp3File = mp3File;
            Text         = Path.GetFileName(mp3File.AbsolutePath);
            exposedTags  = ExposedTagsConfiguration.ExposedTagsConfigurationInstance.ExposedTags;
            tags         = new BindingList <TagProcessing>(mp3File.DirtyTags);
            TagsGrid.AutoGenerateColumns = false;
            TagsGrid.DataSource          = tags;
        }
예제 #2
0
 /// <summary>
 /// Initialization called only once by the exposedTagsConfigurationInstance
 /// </summary>
 private ExposedTagsConfiguration( ) :
     base("ExposedTagsFilePath", "ExposedTagsFileName", "ExposedTags.xml", out Program.obj, typeof(ExposedTags))
 {
     exposedTags = Program.obj as ExposedTags;
     if (exposedTags == null)
     {
         exposedTags = new ExposedTags();
         exposedTags.CreateDefault();
     }
 }
예제 #3
0
        /// <summary>
        /// Lookup for preexisting value if present
        /// </summary>
        private void TagsGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var tagNameValue = TagsGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

            if (tagNameValue != null && !string.IsNullOrEmpty(tagNameValue.ToString()))
            {
                string tmp;
                mp3File.TryReadValue(tagNameValue.ToString(), ExposedTags.IsPrivateOrUserFrame(tagNameValue.ToString()), out tmp);
                TagsGrid.Rows[e.RowIndex].Cells["TagValueOld"].Value    = tmp;
                TagsGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly = true;
                addedTags--;
                if (addedTags == 0)
                {
                    TagsGrid.CellEndEdit -= TagsGrid_CellEndEdit;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Changes will persist to disk after serialization, for now change singleton
        /// </summary>
        private void SaveCurrentAsDefaultsButton_Click(object sender, EventArgs e)
        {
            exposedTags.Tags.Clear();
            foreach (var tag in tags)
            {
                var name = tag.tagName;

                if (ExposedTags.IsPrivateOrUserFrame(name))
                {
                    exposedTags.Tags.Add(new ExposedTags.Tag(name, true));
                }
                else
                {
                    exposedTags.Tags.Add(new ExposedTags.Tag(name));
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Figure out what kind of frame it is, then try to write to it
 /// </summary>
 /// <param name="name">Name of frame</param>
 /// <param name="privateOrUserFrame">How to look for the frame</param>
 /// <param name="value">Value to write</param>
 /// <returns>True on success, false on failure</returns>
 private bool TryWriteValue(string name, string value)
 {
     if (!ExposedTags.IsPrivateOrUserFrame(name))
     {
         return(TryWritePropertyValue(name, value));
     }
     else
     {
         string garbage;
         if (TryReadUserFrame(name, out garbage))
         {
             return(TryWriteUserFrame(name, value));
         }
         else
         {
             return(TryWritePrivateFrame(name, value));
         }
     }
 }