Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        public JObject ToJObject()
        {
            JObject jFile = new JObject();

            jFile.Add("Version", SystemInfo.Version);

            AddItemRecursive(jFile, rootFolder);

            void AddItemRecursive(JObject jParent, MotionItemBase item)
            {
                JObject jItem = new JObject();

                jParent.Add(item.IsRoot ? RootFolderName : item.Name, jItem);
                jItem.Add("Type", item.Type.ToString());

                if (item.Type == MotionItemType.Motion)
                {
                    JObject jData = new JObject();
                    jItem.Add("Data", jData);

                    SaveMotion(jData, item as MotionItem);
                }
                else
                {
                    JObject jItems = new JObject();
                    jItem.Add("Items", jItems);

                    SaveFolder(jItems, item as MotionFolderItem);
                }
            }

            void SaveMotion(JObject jData, MotionItem motion)
            {
                JArray jPoints = new JArray();

                jData.Add("Point", jPoints);

                for (int pointI = 0; pointI < motion.pointList.Count; ++pointI)
                {
                    JArray jPoint = new JArray();
                    jPoints.Add(jPoint);

                    MotionPoint point = motion.pointList[pointI];
                    jPoint.Add(point.MainPoint.ToString());
                    jPoint.Add(point.SubPoints[0].ToString());
                    jPoint.Add(point.SubPoints[1].ToString());
                }
            }

            void SaveFolder(JObject jData, MotionFolderItem folder)
            {
                for (int i = 0; i < folder.childList.Count; ++i)
                {
                    MotionItemBase childItem = folder.childList[i];
                    AddItemRecursive(jData, childItem);
                }
            }

            return(jFile);
        }
Esempio n. 3
0
        public void DuplicateSelectedMotion()
        {
            if (!IsSelectedItemCopyable)
            {
                return;
            }

            MotionItemBase   latestNewItem = null;
            MotionFolderItem parentFolder  = SelectedItemParent;

            foreach (MotionItemBaseView refItem in MotionTreeView.SelectedItemSet)
            {
                if (refItem.Type == MotionItemType.Motion)
                {
                    MotionItem refMotionItem = (MotionItem)refItem.Data;
                    //Create motion
                    MotionItem newItem = EditingFile.CreateMotionEmpty(parentFolder);
                    latestNewItem = newItem;

                    //Copy points
                    foreach (MotionPoint refPoint in refMotionItem.pointList)
                    {
                        MotionPoint point = new MotionPoint();
                        newItem.AddPoint(point);

                        point.SetMainPoint(refPoint.MainPoint);
                        for (int i = 0; i < refPoint.SubPoints.Length; ++i)
                        {
                            point.SetSubPoint(i, refPoint.SubPoints[i]);
                        }
                    }

                    ((MotionItemView)DataToViewDict[newItem]).UpdatePreviewGraph();

                    //Set name
                    const string CopyPostfix = "_Copy";
                    string       name        = refItem.Data.Name;
                    for (; ;)
                    {
                        if (EditingFile.itemDict.ContainsKey(name))
                        {
                            name += CopyPostfix;
                        }
                        else
                        {
                            break;
                        }
                    }
                    newItem.SetName(name);
                }
            }
            if (latestNewItem != null)
            {
                MotionTreeView.SelectedItemSet.SetSelectedItem(DataToViewDict[latestNewItem]);
            }
        }
Esempio n. 4
0
        private void MotionListView_ItemMoved(ITreeItem item, ITreeFolder oldParent, ITreeFolder newParent, int index)
        {
            MotionItemBase       itemData            = ((MotionItemBaseView)item).Data;
            MotionFolderItemView newParentFolderView = (MotionFolderItemView)newParent;

            if (oldParent != null)
            {
                MotionFolderItemView oldParentFolderView = (MotionFolderItemView)oldParent;
                oldParentFolderView.Data.RemoveChild(itemData);
            }
            newParentFolderView.Data.InsertChild(index, itemData);
        }
Esempio n. 5
0
        public MotionItem GetMotion(string motionId)
        {
            if (motionId == null)
            {
                throw new Exception("motionId is Null.");
            }
            if (!itemDict.ContainsKey(motionId))
            {
                throw new KeyNotFoundException("Not exist motion.");
            }
            MotionItemBase item = itemDict[motionId];

            if (item.Type != MotionItemType.Motion)
            {
                throw new TypeLoadException("Item isn't Motion type.");
            }
            return(item as MotionItem);
        }
Esempio n. 6
0
        public void RemoveItem(MotionItemBase item)
        {
            if (item.Type == MotionItemType.Folder)
            {
                //메세지 띄우기

                MotionFolderItem folderItem = (MotionFolderItem)item;
                foreach (MotionItemBase childItem in folderItem.childList.ToList())
                {
                    RemoveItem(childItem);
                }
            }

            MotionFolderItem parentFolder = item.Parent;

            item.Parent.childList.Remove(item);
            itemDict.Remove(item.Name);

            ItemRemoved?.Invoke(item, parentFolder);
        }
Esempio n. 7
0
 public MoveOrder(MotionItemBase target, Direction direction)
 {
     this.target    = target;
     this.direction = direction;
 }
Esempio n. 8
0
 public MoveOrder(MotionItemBase target)
 {
     this.target = target;
 }
Esempio n. 9
0
        //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();
        }