Exemplo 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;
 }
Exemplo 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);            
        }
Exemplo n.º 3
0
        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);
        }        
Exemplo n.º 4
0
 private void tags_ItemChanging(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e)
 {
 }        
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 private void tags_ItemRemoving(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e)
 {
     // Empty. Logic inside ItemRemoved
 }
Exemplo n.º 7
0
        // ********************************************************************************* //
        #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("*");
        }        
Exemplo n.º 8
0
        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);
        }                
Exemplo n.º 9
0
 private void tags_ItemRemoved(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e)
 {
     // Unregister the tag's ValueChanging event            
     e.Item.ValueChanging -= this.tag_ValueChanging;
 }        
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
 private void tags_ItemAdding(RaisingEventsList<FileTag> sender, RaisingEventsList<FileTag>.RaisingEventsListEventArgs e)
 {
     if (this.currentAction == DatabaseAction.Idle)
         throw new InvalidOperationException("This object is read-only");
 }