private void MoveUpMenuItem_Click(object sender, EventArgs e) { var indexes = SelectedIndices.ToList(); if (!indexes.Any() || indexes[0] == 0) { return; } foreach (var index in indexes) { var watch = _watches[index]; _watches.RemoveAt(index); _watches.Insert(index - 1, watch); } Changes(); var indices = indexes.Select(t => t - 1).ToList(); WatchListView.SelectedIndices.Clear(); foreach (var t in indices) { WatchListView.SelectItem(t, true); } WatchListView.ItemCount = _watches.Count; }
private void MoveItemUp(object obj) { ProductMasterItem item = obj as ProductMasterItem; if (item == null) { return; } int curIndex = WatchList.IndexOf(item); if (curIndex > 0) // if not first and found { WatchList.RemoveAt(curIndex); WatchList.Insert(curIndex - 1, item); ExtendedSchedule.Instance.Update(); } }
private void MoveItemDown(object obj) { ProductMasterItem item = obj as ProductMasterItem; if (item == null) { return; } int curIndex = WatchList.IndexOf(item); if (curIndex >= 0 && curIndex != WatchList.Count - 1) // if not last and found { WatchList.RemoveAt(curIndex); WatchList.Insert(curIndex + 1, item); ExtendedSchedule.Instance.Update(); } }
public void WatchListTriggersRemoveAt() { var wl = new WatchList<int>("carp"); bool triggered = false; wl.AddInternal(1); wl.AddInternal(2); wl.OnCollectionChanged += new CollectionChanged<int>(delegate(string name, IEnumerable<int> collection) { triggered = true; }); wl.RemoveAt(0); Assert.IsTrue(triggered); }