public IRevertable Revert(EditorSceneBase scene) { uint var = 0; IDictionary[] dicts = new IDictionary[infos.Length + singleInfos.Length]; int i_dicts = 0; //Revert Lists RevertableDictDeletion.DeleteInDictInfo[] deleteInfos = new RevertableDictDeletion.DeleteInDictInfo[infos.Length]; int i_deleteInfos = 0; foreach (AddInDictInfo info in infos) { deleteInfos[i_deleteInfos] = new RevertableDictDeletion.DeleteInDictInfo(new RevertableDictDeletion.DeleteInfo[info.infos.Length], info.dict); int i_info = 0; for (int i = info.infos.Length - 1; i >= 0; i--) { deleteInfos[i_deleteInfos].infos[i_info++] = new RevertableDictDeletion.DeleteInfo(info.infos[i].obj, info.infos[i].key); info.dict.Remove(info.infos[i].key); (info.infos[i].obj as IEditableObject)?.DeselectAll(scene.control); } dicts[i_dicts++] = info.dict; i_deleteInfos++; } //Revert Singles RevertableDictDeletion.SingleDeleteInDictInfo[] deleteSingleInfos = new RevertableDictDeletion.SingleDeleteInDictInfo[singleInfos.Length]; i_deleteInfos = 0; foreach (SingleAddInDictInfo info in singleInfos) { deleteSingleInfos[i_deleteInfos++] = new RevertableDictDeletion.SingleDeleteInDictInfo(info.obj, info.key, info.dict); info.dict.Remove(info.key); dicts[i_dicts++] = info.dict; (info.obj as IEditableObject)?.DeselectAll(scene.control); } scene.UpdateSelection(var); scene.DictChanged?.Invoke(this, new DictChangedEventArgs(dicts)); return(new RevertableDictDeletion(deleteInfos, deleteSingleInfos)); }
public IRevertable Revert(EditorSceneBase scene) //Remove added objects from their lists { uint var = 0; IList[] lists = new IList[infos.Length + singleInfos.Length]; int i_lists = 0; //Revert Lists RevertableDeletion.DeleteInListInfo[] deleteInfos = new RevertableDeletion.DeleteInListInfo[infos.Length]; int i_deleteInfos = 0; foreach (AddInListInfo info in infos) { deleteInfos[i_deleteInfos] = new RevertableDeletion.DeleteInListInfo(new RevertableDeletion.DeleteInfo[info.objs.Length], info.list); int i_info = 0; for (int i = 0; i < info.objs.Length; i++) { deleteInfos[i_deleteInfos].infos[i_info++] = new RevertableDeletion.DeleteInfo(info.objs[i], info.list.IndexOf(info.objs[i])); info.list.Remove(info.objs[i]); (info.objs[i] as IEditableObject)?.DeselectAll(scene.control); } lists[i_lists++] = info.list; i_deleteInfos++; } //Revert Singles RevertableDeletion.SingleDeleteInListInfo[] deleteSingleInfos = new RevertableDeletion.SingleDeleteInListInfo[singleInfos.Length]; i_deleteInfos = 0; foreach (SingleAddInListInfo info in singleInfos) { deleteSingleInfos[i_deleteInfos++] = new RevertableDeletion.SingleDeleteInListInfo(info.obj, info.list.IndexOf(info.obj), info.list); info.list.Remove(info.obj); lists[i_lists++] = info.list; (info.obj as IEditableObject)?.DeselectAll(scene.control); } scene.UpdateSelection(var); scene.ListChanged?.Invoke(this, new ListChangedEventArgs(lists)); return(new RevertableDeletion(deleteInfos, deleteSingleInfos)); }