Пример #1
0
        /// <summary>
        /// TODOにひとつ追加する
        /// </summary>
        /// <param name="key"></param>
        /// <param name="intent"></param>
        /// <returns></returns>
        public static void Add(string key, ITodoIntent intent)
        {
            // 同じ識別子が複数登録されたら、後のほうをキャンセルする
            foreach (ToolStripItem tsi in _tar.DropDownItems)
            {
                if (tsi.Tag is KeyIntentPair ki)
                {
                    if (key == ki.Key)
                    {
                        return;
                    }
                }
            }
            var db = new ToolStripDropDownButton(key)
            {
                Tag                = new KeyIntentPair(key, intent),
                AutoSize           = true,
                AutoToolTip        = true,
                Alignment          = ToolStripItemAlignment.Left,
                AllowDrop          = false,
                Available          = true,
                DisplayStyle       = ToolStripItemDisplayStyle.Text,
                DoubleClickEnabled = false,
                Enabled            = true,
                TextAlign          = System.Drawing.ContentAlignment.MiddleLeft,
                TextDirection      = ToolStripTextDirection.Inherit,
                TextImageRelation  = TextImageRelation.ImageBeforeText
            };

            db.Click += new EventHandler(todo_assist_click);

            _tar.DropDownItems.Add(db);
            _tar.Enabled   = true;
            _tar.BackColor = Color.Yellow;
        }
Пример #2
0
 public KeyIntentPair(string key, ITodoIntent intent)
 {
     Key    = key;
     Intent = intent;
 }