//decides which options need to be enabled and disabled
        private void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ContextMenuStrip strip = sender as ContextMenuStrip;

            if (strip == null)
            {
                return;
            }

            foreach (var menuItem in strip.Items)
            {
                ToolStripMenuItem item = menuItem as ToolStripMenuItem;
                if (item == null)
                {
                    continue;
                }
                if (item.Text.ToLower().Contains("selected"))
                {
                    item.Enabled = _selectedObjects != null && _selectedObjects.Count > 0;
                    if (item.Text.ToLower().Contains("delete"))
                    {
                        TagButton tagBtn = GetTagButton(strip.SourceControl.Text, false);
                        item.Enabled = item.Enabled && tagBtn.IsObjectSelected;
                    }
                }
            }

            e.Cancel = false;
        }
        private void AddNewTagButton(TagButton tagBtn)
        {
            var btn = GetNewUITagButton(tagBtn.TagName, tagBtn.State);

            btn.MouseClick               += Tag_Click_Toggle;
            btn.ContextMenuStrip          = TagContextMenu;
            btn.ContextMenuStrip.Opening += ContextMenuStrip_Opening;
            this.pnlTagContainer.Controls.Add(btn);
        }
Beispiel #3
0
        /// <summary>
        /// updates the state of an individual tag
        /// </summary>
        /// <param name="name">name of the tag to be updated</param>
        /// <param name="state">state of the tag</param>
        /// <param name="updateUI">specify whether or not to update the UI to reflect this update</param>
        public void UpdateTag(string name, TagButtonState state = TagButtonState.INACTIVE, bool updateUI = false)
        {
            TagButton btn = GetTagButton(name);

            btn.State     = state;
            TagDict[name] = btn;
            if (updateUI)
            {
                ResetUI();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Either returns an exisiting TagButton object with the given name, or creates a new one and adds it to the dictionary
        /// </summary>
        /// <param name="name">name of the tag</param>
        /// <param name="createNew">
        /// Set this to false if you don't want to create a new tag in case one with the
        /// provided name doesn't already exist, in which case, null will be returned;
        /// </param>
        /// <returns>
        /// Returns an exisitng tag button, or if one doesn't exist with the given name creates a new one,
        /// adds it to the dicionary and returns it. If createNew is set to false and a tag with the name cannot be found, null is returned.
        /// </returns>
        public TagButton GetTagButton(string name, bool createNew = true)
        {
            TagButton tag;

            if (!TagDict.TryGetValue(name, out tag))
            {
                if (!createNew)
                {
                    return(null);
                }
                tag = new TagButton(name);
                TagDict.Add(name, tag);
            }
            return(tag);
        }
Beispiel #5
0
 public static void SetCurrentDocumentTags(List <string> tags, bool merge = false)
 {
     if (!merge)
     {
         Panel_TagManager.TagDict = new Dictionary <string, TagButton>();
     }
     foreach (string tag in tags)
     {
         TagButton btn = new TagButton(tag, TagButtonState.INACTIVE);
         if (Panel_TagManager.TagDict.ContainsKey(tag))
         {
             Panel_TagManager.TagDict[tag] = btn;
         }
         else
         {
             Panel_TagManager.TagDict.Add(tag, btn);
         }
     }
     //updating the UI if the panel is loaded
     TagManager?.ResetUI();
 }
 private void UpdateUIButton(ref Button btn, TagButton tagBtn)
 {
     btn.Text = tagBtn.TagName;
     StyleButton(ref btn, tagBtn.State);
     btn.FlatAppearance.BorderSize = tagBtn.IsObjectSelected ? 2 : 0;
 }
Beispiel #7
0
 public void UpdateTag(TagButton tagBtn, bool updateUI = false)
 {
     UpdateTag(tagBtn.TagName, tagBtn.State, updateUI);
 }