public UITagGroup(string title, bool singleSelection, bool hasText, TagChanged_Delegate onTagChanged, params string[] tags) { InitializeComponent(); SuspendLayout(); lblTitle.Text = title; this.onTagChanged = onTagChanged; single = singleSelection; this.hasText = hasText; // add all of the tags. for (int i = 0; i < tags.Length; ++i) { string tag = tags[i]; if (PrefixWithTag) { tag = "Tag" + tag; } // Get shortcut key from the tag. int mneIndex = tag.IndexOf('&'); Keys shortcut = Keys.None; if (mneIndex > -1) { shortcut = (Keys)Enum.Parse(typeof(Keys), tag.Substring(mneIndex + 1, 1), true); if (shortcutDuplcate.Contains(shortcut)) { MessageBox.Show("Shortcut :" + shortcut.ToString() + " is a duplicate!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } shortcutDuplcate.Add(shortcut); tag = tag.Remove(mneIndex, 1); } if (hasText) { ImageInfo.TextTags.Add(tag); } var c = new CheckBox(); c.Text = tags[i]; c.Height = 20; c.Top = lblTitle.Bottom + 5 + (c.Height * i); c.Tag = tag; c.CheckStateChanged += tag_CheckStateChanged; Controls.Add(c); TextBox t = null; if (hasText) { t = new TextBox(); t.Top = c.Top; t.Left = c.Right; t.Height = c.Height; t.Tag = tag; t.TextChanged += tag_TextChanged; t.KeyDown += tag_TextBox_KeyDown; Controls.Add(t); } this.tags[tag] = new tagInfo(c, t); if (shortcut != Keys.None) { shortcuts[shortcut] = this.tags[tag]; } } ResumeLayout(true); }
public UITagGroup(string title, bool singleSelection, bool hasText, TagChanged_Delegate onTagChanged, params string[] tags) : this(title, singleSelection, hasText, true, onTagChanged, tags) { }