예제 #1
0
        private void AddItems(List <Json.DataObject> objs, int index, bool select, bool report = true)
        {
            IList list = CurrentList;

            if (objs.Count == 0 || list == null)
            {
                return;
            }

            CreateEditAction action = new CreateEditAction(true, Index.RemoveNext(), Index.RemoveNext());

            foreach (Json.DataObject item in objs)
            {
                CurrentList.Insert(index, item);
                listBoxList.Items.Insert(index, SafeName(item));
                action.objects.Add(index, item);
                index++;
            }
            index--;
            if (select)
            {
                listBoxList.SelectedIndices.Clear();
                this.listBoxList.SelectedIndex = index;
            }
            action.Index1.itemIndex = index;
            if (report && OnObjectEdited != null)
            {
                OnObjectEdited(this, action);
            }
        }
예제 #2
0
        private void DeleteItems(List <int> toRemove, bool select, bool report = true)
        {
            IList list = CurrentList;

            if (toRemove.Count == 0 || list == null)
            {
                return;
            }

            CreateEditAction action = new CreateEditAction(false, Index.RemoveNext(), Index.RemoveNext());

            toRemove.Sort();
            for (int i = toRemove.Count - 1; i >= 0; i--)
            {
                int    index = toRemove[i];
                object item  = list[index];
                action.objects.Add(index, (Json.DataObject)item);

                list.RemoveAt(index);
                listBoxList.Items.RemoveAt(index);
            }
            int startIndex = toRemove[0];

            if (startIndex > list.Count - 1)
            {
                startIndex--;
            }
            if (select)
            {
                listBoxList.SelectedIndices.Clear();
                listBoxList.SelectedIndex = startIndex;
            }
            action.Index1.itemIndex = startIndex;
            if (report && OnObjectEdited != null)
            {
                OnObjectEdited(this, action);
            }
        }