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; }
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); }
public FileWithTags() { this.fileName = ""; this.tags = new RaisingEventsList<FileTag>(); // Subscribe to the tags list events this.tags.ItemAdding += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(this.tags_ItemAdding); this.tags.ItemAdded += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(this.tags_ItemAdded); this.tags.ItemRemoved += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(this.tags_ItemRemoved); this.tags.ItemRemoving += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(this.tags_ItemRemoving); this.tags.ItemChanging += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(this.tags_ItemChanging); }
private void tags_ItemChanging(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e) { }
private void tags_ItemAdding(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e) { // Don't allow duplicate tags to be added to the tags list if (this.tags.Exists(e.Item.Compare)) e.Cancel = true; }
private void tags_ItemRemoving(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e) { // Empty. Logic inside ItemRemoved }
// ********************************************************************************* // #endregion #region Constructor /// <summary> /// Constrauctor: Initialize new instance of "TagFilesDatabase" /// </summary> public TagFilesDatabase() { this.files = new RaisingEventsList<FileWithTags>(); this.files.ItemAdded += new RaisingEventsList<FileWithTags>.RaisingEventsListEventsHandler(files_ItemAdded); this.files.ItemRemoved += new RaisingEventsList<FileWithTags>.RaisingEventsListEventsHandler(files_ItemRemoved); this.tags = new RaisingEventsList<FileTag>(); this.tags.ItemAdding += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(tags_ItemAdding); this.tags.ItemAdded += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(tags_ItemAdded); this.tags.ItemRemoving += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(tags_ItemRemoving); this.tags.ItemRemoved += new RaisingEventsList<FileTag>.RaisingEventsListEventsHandler(tags_ItemRemoved); this.counters = new List<int>(); this.currentAction = DatabaseAction.Idle; this.groupsNames.Add("ללא קבוצה"); this.groupsKeys.Add("*"); }
private void files_ItemAdded(RaisingEventsList<FileWithTags> sender, RaisingEventsList<FileWithTags>.RaisingEventsListEventArgs e) { // Set the action of the database this.currentAction = DatabaseAction.AddingFile; // Add the file's tags FileWithTags file = e.Item; foreach (FileTag tag in file.Tags) { this.addTag(tag.Value); } // If the file has no tags, add the Empty tag if (file.Tags.Count == 0) { this.addTag(""); } // Set the ending of the current action this.currentAction = DatabaseAction.Idle; // Register to the file's events e.Item.TagAdded += new FileWithTags.FileWithTagsEventHandler(this.file_TagAdded); e.Item.TagRemoved += new FileWithTags.FileWithTagsEventHandler(this.file_TagRemoved); // Raise the DatabaseChange event this.raiseEvent(DatabaseAction.AddingFile, file, null); }
private void tags_ItemRemoved(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e) { // Unregister the tag's ValueChanging event e.Item.ValueChanging -= this.tag_ValueChanging; }
private void tags_ItemAdded(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e) { // Subscribe to the ValueChanging event of the new tag e.Item.ValueChanging += new ValueChangingHandler(this.tag_ValueChanging); }
private void tags_ItemAdding(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e) { if (this.currentAction == DatabaseAction.Idle) throw new InvalidOperationException("This object is read-only"); }