Example #1
0
        /// <summary>
        /// 添加类型到
        /// </summary>
        /// <param name="c"></param>
        public override void AddCategory(Category category)
        {
            if (category == null ||
                this.Categories.Find(c => c.ICId == category.ICId) != null)
            {
                return;
            }

            ButtonWithDel btn = new ButtonWithDel();

            btn.AllowDrop = true;
            btn.Tag       = category;
            btn.Text      = category.CCategoryName;
            btn.BackColor = colors[rd.Next(colors.Count)];
            //btn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            btn.BackColor = colors[rd.Next(colors.Count)];
            //btn.Width = (int)(category.CCategoryName.Length * btn.Font.Size * 2) + 8;

            //事件
            btn.OnButtonClick += Btn_Click;
            btn.OnDelClick    += Btn_OnDelClick;

            this.Controls.Add(btn);

            //触发事件
            OnCategoryChanged?.Invoke(this, new OnCategoryChangedEventArgs(category, false));
        }
Example #2
0
        private void Btn_OnDelClick(object sender, EventArgs e)
        {
            //删除控件
            ButtonWithDel btn = (ButtonWithDel)sender;

            RemoveButton(btn);

            //触发事件
            OnCategoryChanged?.Invoke(this, new OnCategoryChangedEventArgs((Category)btn.Tag, true));
        }
Example #3
0
 private void ChangeCategory(ENavigationCategory category)
 {
     CurrentCategory = category;
     OnCategoryChanged?.Invoke(category);
 }