internal void EditingFile_ItemRemoved(MotionItemBase item, MotionFolderItem parentFolder) { MotionItemBaseView view = DataToViewDict[item]; if (view.ParentItem != null) { view.ParentItem.ChildItemCollection.Remove(view); view.ParentItem = null; } //Remove from collection itemList.Remove(item); DataToViewDict.Remove(item); if (item.IsRoot) { MotionTreeView.ChildItemCollection.Remove(view); RootFolderView = null; } //Unregister events //어차피 삭제이후 사용되지 않으므로 참조가 어려운 이벤트는 생략한다. item.NameChanged -= view.Data_NameChanged; EditorContext.MarkUnsaved(); }
//Events internal void EditingFile_ItemCreated(MotionItemBase item, MotionFolderItem parentFolder) { if (item == null) { return; } MotionItemBaseView view = null; switch (item.Type) { case MotionItemType.Motion: MotionItemView motionView = new MotionItemView(EditorContext, (MotionItem)item); view = motionView; motionView.UpdatePreviewGraph(); break; case MotionItemType.Folder: MotionFolderItemView folderView = new MotionFolderItemView(EditorContext, (MotionFolderItem)item); view = folderView; if (parentFolder == null) { //Create root folderView.SetRootFolder(); RootFolderView = folderView; MotionTreeView.ChildItemCollection.Add(folderView); MotionTreeView.ManualRootFolder = folderView; } //Register events MotionFolderItem folderItem = (MotionFolderItem)item; folderItem.ChildInserted += Data_ChildInserted; folderItem.ChildRemoved += Data_ChildRemoved; void Data_ChildInserted(int index, MotionItemBase childItem) { MotionItemBaseView childItemView = DataToViewDict[childItem]; folderView.ChildItemCollection.Insert(index, childItemView); } void Data_ChildRemoved(MotionItemBase childItem) { MotionItemBaseView childItemView = DataToViewDict[childItem]; folderView.ChildItemCollection.Remove(childItemView); } break; } if (parentFolder != null) { view.ParentItem = (MotionFolderItemView)DataToViewDict[parentFolder]; } //Register events item.NameChanged += view.Data_NameChanged; //Add to collection itemList.Add(item); DataToViewDict.Add(item, view); EditorContext.MarkUnsaved(); }