public void AddItem(string mainText, string content, object info) { MaskinListBoxItem mskitm = new MaskinListBoxItem(maskinListBoxItemLineColor, maskinListBoxItemOnLineColor, MaskinListBoxItemDownColor, mainText, content, info, Width - 19); Items.Add(H / 30 + 1, mskitm); Controls.Add(mskitm); mskitm.Location = new Point(1, H); H += 30; //新项目加入列表时的宽度 }
private int GetIDbyItem(MaskinListBoxItem m) { foreach (var item in Items) { if (item.Value.Equals(m)) { return(item.Key); } } return(-1); }
internal void ItemClked(MaskinListBoxItem msi) { if (!msi.Equals(selectedItem)) { msi.Selected = true; if (selectedItem != null) { selectedItem.Selected = false; } selectedItem = msi; } ItemClicked?.Invoke(new itemArgs(msi.MainText, msi.Content, msi.Info, GetIDbyItem(msi))); }
internal void ItemDoubleClked(MaskinListBoxItem msi) { ItemDoubleClicked?.Invoke(new itemArgs(msi.MainText, msi.Content, msi.Info, GetIDbyItem(msi))); }