本文整理汇总了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
//.........这里部分代码省略.........