当前位置: 首页>>代码示例>>C#>>正文


C# ConvertOperation.Res方法代码示例

本文整理汇总了C#中ConvertOperation.Res方法的典型用法代码示例。如果您正苦于以下问题:C# ConvertOperation.Res方法的具体用法?C# ConvertOperation.Res怎么用?C# ConvertOperation.Res使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConvertOperation的用法示例。


在下文中一共展示了ConvertOperation.Res方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: folderView_DragDrop

        private void folderView_DragDrop(object sender, DragEventArgs e)
        {
            this.folderView.BeginUpdate();

            bool effectMove = (e.Effect & DragDropEffects.Move) != DragDropEffects.None;
            bool effectCopy = (e.Effect & DragDropEffects.Copy) != DragDropEffects.None;

            NodeBase baseTarget = this.DragDropGetTargetBaseNode();
            ResourceNode targetResNode = baseTarget as ResourceNode;
            DirectoryNode targetDirNode = baseTarget as DirectoryNode;
            this.tempDropBasePath = this.GetInsertActionTargetBasePath(baseTarget);
            DataObject data = e.Data as DataObject;
            ConvertOperation.Operation convOp = data.GetAllowedConvertOp();
            if (data != null)
            {
                // Dropping files
                if (data.ContainsFileDropList())
                {
                    IEnumerable<string> incomingFiles = data.GetFileDropList().OfType<string>();

                    // Handle file import operations and filter out files that have been handled that way.
                    incomingFiles = this.HandleFileImport(this.tempDropBasePath, incomingFiles);

                    // Filter out non-Resource files that might have been dropped accidentally into the data directory
                    incomingFiles = incomingFiles.Where(path => Resource.IsResourceFile(path) || Directory.Exists(path));

                    // If there's anything left, proceed with a regular file drop operation
                    if (incomingFiles.Any())
                    {
                        this.tempFileDropList = incomingFiles.ToList();

                        // Display context menu if both moving and copying are availabled
                        if (effectMove && effectCopy)
                            this.contextMenuDragMoveCopy.Show(this, this.PointToClient(new Point(e.X, e.Y)));
                        else if (effectCopy)
                            this.copyHereToolStripMenuItem_Click(this, null);
                        else if (effectMove)
                            this.moveHereToolStripMenuItem_Click(this, null);
                    }
                }
                // Dropping GameObject to Prefab
                else if (
                    e.Effect.HasFlag(DragDropEffects.Link) &&
                    data.ContainsGameObjectRefs() &&
                    targetResNode != null &&
                    targetResNode.ResLink.Is<Duality.Resources.Prefab>() &&
                    data.GetGameObjectRefs().Length == 1)
                {
                    Prefab prefab = targetResNode.ResLink.Res as Prefab;
                    if (prefab != null)
                    {
                        GameObject draggedObj = data.GetGameObjectRefs()[0];

                        UndoRedoManager.BeginMacro();
                        // Prevent recursion
                        UndoRedoManager.Do(new BreakPrefabLinkAction(draggedObj.ChildrenDeep.Where(c => c.PrefabLink != null && c.PrefabLink.Prefab == prefab)));
                        // Inject GameObject to Prefab & Establish PrefabLink
                        UndoRedoManager.Do(new ApplyToPrefabAction(draggedObj, prefab));
                        UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromLast);
                    }
                }
                // See if we can retrieve Resources from data
                else if (
                    (baseTarget == null || !baseTarget.ReadOnly) &&
                    (effectCopy || effectMove) &&
                    (convOp.HasFlag(ConvertOperation.Operation.CreateRes) || convOp.HasFlag(ConvertOperation.Operation.CreateObj)))
                {
                    var resQuery = new ConvertOperation(data, ConvertOperation.Operation.All).Perform<IContentRef>();
                    if (resQuery != null)
                    {
                        // Save or move generated Resources
                        List<Resource> resList = resQuery.Res().ToList();
                        this.folderView.ClearSelection();
                        foreach (Resource res in resList)
                        {
                            string desiredName = null;
                            if (string.IsNullOrEmpty(desiredName))
                                desiredName = res.Name;
                            if (string.IsNullOrEmpty(desiredName) && res.AssetInfo != null)
                                desiredName = res.AssetInfo.NameHint;
                            if (string.IsNullOrEmpty(desiredName))
                                desiredName = res.GetType().Name;

                            bool pointsToFile = !res.IsDefaultContent && !res.IsRuntimeResource;
                            string basePath = this.GetInsertActionTargetBasePath(targetDirNode);
                            string nameExt = Resource.GetFileExtByType(res.GetType());
                            string resPath = Path.Combine(basePath, desiredName) + nameExt;
                            if (!pointsToFile || Path.GetFullPath(resPath) != Path.GetFullPath(res.Path))
                                resPath = PathHelper.GetFreePath(Path.Combine(basePath, desiredName), nameExt);
                            resPath = PathHelper.MakeFilePathRelative(resPath);

                            if (pointsToFile && File.Exists(res.Path))
                                File.Move(res.Path, resPath);
                            else
                                res.Save(resPath);

                            this.ScheduleSelect(resPath);
                        }

                        // If we happened to generate a Prefab, link possible existing GameObjects to it
//.........这里部分代码省略.........
开发者ID:priyanshus1,项目名称:duality,代码行数:101,代码来源:ProjectFolderView.cs


注:本文中的ConvertOperation.Res方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。