public void UpdateChecks(string c) { updating = true; try { tSetting.Text = c; CustomItemListString = c; CustomItemList.Clear(); string[] v = c.Split('-'); int[] vi = new int[13]; if (v.Length != vi.Length) { CustomItemList.Add(-1); return; } for (int i = 0; i < 13; i++) { if (v[12 - i] != "") { vi[i] = Convert.ToInt32(v[12 - i], 16); } } for (int i = 0; i < 32 * 13; i++) { int j = i / 32; int k = i % 32; if (((vi[j] >> k) & 1) > 0) { if (i >= ItemUtils.AllLocations().Count()) { throw new IndexOutOfRangeException(); } CustomItemList.Add(i); } } foreach (ListViewItem l in lItems.Items) { if (CustomItemList.Contains(l.Index)) { l.Checked = true; } else { l.Checked = false; } } } catch { CustomItemList.Clear(); CustomItemList.Add(-1); } finally { updating = false; } }
private void lItems_ItemChecked(object sender, ItemCheckedEventArgs e) { if (updating) { return; } updating = true; if (e.Item.Checked) { CustomItemList.Add(e.Item.Index); } else { CustomItemList.Remove(e.Item.Index); } UpdateString(CustomItemList); updating = false; }