Ejemplo n.º 1
0
 private void tags_ItemRemoved(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e)
 {
     // Raise event
     if (this.TagRemoved != null)
     {
         FileWithTagsEventArgs e2 = new FileWithTagsEventArgs(e.Item);                
         this.TagRemoved(this, e2);
     }
     // Unregister the tag's ValueChanging event
     e.Item.ValueChanging -= this.tag_ValueChanging;
 }
Ejemplo n.º 2
0
        private void tags_ItemAdded(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e)
        {
            // Raise event
            if (this.TagAdded != null)
            {
                FileWithTagsEventArgs e2 = new FileWithTagsEventArgs(e.Item);
                this.TagAdded(this, e2);
            }

            // Subscribe to the ValueChanging event of the new tag
            e.Item.ValueChanging += new ValueChangingHandler(this.tag_ValueChanging);            
        }
Ejemplo n.º 3
0
 private void tag_ValueChanging(FileTag sender, FileTagEventArgs e)
 {
     FileTag newTag = new FileTag(e.NewValue);
     
     // Don't allow the tag to be change into a value that already exists
     if (this.tags.Exists(newTag.Compare))
     {
         e.Cancel = true;
         throw new InvalidOperationException(string.Format(
             "Can't change tag value from '{1}' to '{0}' because the tag '{0}' already exists in the file's tags list", 
             e.NewValue, e.OldValue));
     }
     
     // Raise event (removeTag and addTag)
     if (this.TagRemoved != null)
     {
         FileWithTagsEventArgs e2 = new FileWithTagsEventArgs(sender);
         this.TagRemoved(this, e2);
     }
     if (this.TagAdded != null)
     {
         FileWithTagsEventArgs e2 = new FileWithTagsEventArgs(newTag);
         this.TagAdded(this, e2);
     }
 }