/// <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)); }
private void Btn_OnDelClick(object sender, EventArgs e) { //删除控件 ButtonWithDel btn = (ButtonWithDel)sender; RemoveButton(btn); //触发事件 OnCategoryChanged?.Invoke(this, new OnCategoryChangedEventArgs((Category)btn.Tag, true)); }
private void ChangeCategory(ENavigationCategory category) { CurrentCategory = category; OnCategoryChanged?.Invoke(category); }