Ejemplo n.º 1
0
 void TagsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     //if (e.Action == NotifyCollectionChangedAction.Remove)
     //{
     //	foreach (object o in e.OldItems)
     //	{
     //		TokenizedTagItem tag = (TokenizedTagItem)o;
     //		if (tag != null)
     //		{
     //			Note.Tags.Remove(tag.Text);
     //		}
     //	}
     //}
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         foreach (object o in e.NewItems)
         {
             TokenizedTagItem tag = (TokenizedTagItem)o;
             if (tag != null)
             {
                 tag.PropertyChanged += Tag_PropertyChanged;
                 //Note.Tags.Add(tag.Text);
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Raises the TagDoubleClick event
        /// </summary>
        internal void RaiseTagDoubleClick(TokenizedTagItem tag)
        {
            //if (this.IsSelectable)
            //    this.SelectedItem = tag;

            UpdateAllTagsProperty();
            tag.IsEditing = true;
        }
Ejemplo n.º 3
0
 public TokenizedTagEventArgs(TokenizedTagItem item)
 {
     this.Item = item;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Raises the TagClick event
 /// </summary>
 internal void RaiseTagApplied(TokenizedTagItem tag)
 {
     /*
     if (this.IsSelectable)
         this.SelectedItem = tag;
     */
     if (this.TagApplied != null)
     {
         TagApplied(this, new TokenizedTagEventArgs(tag));
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes a tag from the collection
        /// </summary>
        internal void RemoveTag(TokenizedTagItem tag, bool cancelEvent = false)
        {
            if (this.ItemsSource != null)
            {
                ((IList)this.ItemsSource).Remove(tag); // assume IList for convenience
                this.Items.Refresh();
                //UpdateAllTagsProperty();

                if (TagRemoved != null && !cancelEvent)
                {
                    TagRemoved(this, new TokenizedTagEventArgs(tag));
                }

                // select the last item
                if (this.SelectedItem == null && this.Items.Count > 0)
                {
                    //TokenizedTagItem itemToSelect = this.Items.GetItemAt(0) as TokenizedTagItem;
                    TokenizedTagItem itemToSelect = Items.GetItemAt(Items.Count - 1) as TokenizedTagItem;
                    if (!object.ReferenceEquals(itemToSelect, null))
                    {
                        RaiseTagClick(itemToSelect);
                        if (this.IsSelectable)
                            this.SelectedItem = itemToSelect;
                    }
                    //this.SelectedItem = this.Items.CurrentItem;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a tag to the collection
        /// </summary>
        internal void AddTag(TokenizedTagItem tag)
        {
            TokenizedTagItem itemToSelect = null;
            if (this.SelectedItem == null && this.Items.Count > 0)
            {
                 itemToSelect = (TokenizedTagItem)this.SelectedItem;
            }
            ((IList)this.ItemsSource).Add(tag); // assume IList for convenience
            this.Items.Refresh();

            // select the previous item
            if (!object.ReferenceEquals(itemToSelect, null))
            {
                // && !object.ReferenceEquals(TagApplied, null)
                //TagApplied.Invoke(this, new TokenizedTagEventArgs(appliedTag));
                RaiseTagClick(itemToSelect);
                if (this.IsSelectable)
                    this.SelectedItem = itemToSelect;
            }

            // update values
            //UpdateAllTagsProperty();

            if (TagAdded != null)
                TagAdded(this, new TokenizedTagEventArgs(tag));
        }
Ejemplo n.º 7
0
        internal TokenizedTagItem InitializeNewTag(bool suppressEditing = false)
        {
            var newItem = new TokenizedTagItem() { IsEditing = !suppressEditing };
            AddTag(newItem);
            UpdateAllTagsProperty();
            this.IsEditing = !suppressEditing;

            return newItem;
        }
Ejemplo n.º 8
0
        public void OnApplyTemplate(TokenizedTagItem appliedTag = null)
        {
            Button createBtn = this.GetTemplateChild("PART_CreateTagButton") as Button;
            if (createBtn != null)
            {
                createBtn.Click -= createBtn_Click;
                createBtn.Click += createBtn_Click;
                //createBtn.Focus();
                // nixin - focuses
                //createBtn_Click(createBtn, null);
            }

            base.OnApplyTemplate();

            if (appliedTag != null && !object.ReferenceEquals(TagApplied, null))
            {
                TagApplied.Invoke(this, new TokenizedTagEventArgs(appliedTag));
            }
        }