本文整理汇总了C#中ConvertOperation.CanPerform方法的典型用法代码示例。如果您正苦于以下问题:C# ConvertOperation.CanPerform方法的具体用法?C# ConvertOperation.CanPerform怎么用?C# ConvertOperation.CanPerform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConvertOperation
的用法示例。
在下文中一共展示了ConvertOperation.CanPerform方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanDeserializeFromData
protected override bool CanDeserializeFromData(DataObject data)
{
ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
if (convert.CanPerform(this.editedCmpType)) return true;
if (convert.CanPerform(typeof(GameObject)))
{
GameObject obj = convert.Perform<GameObject>().FirstOrDefault();
return obj != null && obj.GetComponent(this.editedCmpType) != null;
}
return false;
}
示例2: DeserializeFromData
protected override void DeserializeFromData(DataObject data)
{
ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
if (convert.CanPerform(this.editedCmpType))
{
var refQuery = convert.Perform(this.editedCmpType);
if (refQuery != null)
{
Component[] refArray = refQuery.Cast<Component>().ToArray();
this.component = (refArray != null && refArray.Length > 0) ? refArray[0] : null;
this.PerformSetValue();
this.PerformGetValue();
this.OnEditingFinished(FinishReason.LeapValue);
}
}
else if (convert.CanPerform(typeof(GameObject)))
{
GameObject obj = convert.Perform<GameObject>().FirstOrDefault();
Component cmp = obj != null ? obj.GetComponent(this.editedCmpType) : null;
if (cmp != null)
{
this.component = cmp;
this.PerformSetValue();
this.PerformGetValue();
this.OnEditingFinished(FinishReason.LeapValue);
}
}
}
示例3: CanConvertFrom
public override bool CanConvertFrom(ConvertOperation convert)
{
if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
{
return convert.CanPerform<Pixmap>();
}
if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
{
List<Pixmap> availData = convert.Perform<Pixmap>(ConvertOperation.Operation.Convert).ToList();
return availData.Any(t => this.FindMatch(t) != null);
}
return false;
}
示例4: DeserializeFromData
protected override void DeserializeFromData(DataObject data)
{
ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.Convert);
if (convert.CanPerform(typeof(GameObject)))
{
var refQuery = convert.Perform(typeof(GameObject));
if (refQuery != null)
{
GameObject[] refArray = refQuery.Cast<GameObject>().ToArray();
this.gameObj = (refArray != null && refArray.Length > 0) ? refArray[0] : null;
this.PerformSetValue();
this.PerformGetValue();
this.OnEditingFinished(FinishReason.LeapValue);
}
}
}
示例5: CanConvertFrom
public override bool CanConvertFrom(ConvertOperation convert)
{
if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
{
return convert.CanPerform<Texture>();
}
if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert))
{
List<Texture> availData = convert.Perform<Texture>(ConvertOperation.Operation.Convert).ToList();
return availData.Any(t =>
this.FindMatchingResources<Texture,Material>(t, IsMatch)
.Any());
}
return false;
}
示例6: OnDragDrop
protected override void OnDragDrop(DragEventArgs e)
{
// Check children first. Only accept the drop if they don't
e.Effect = DragDropEffects.None;
base.OnDragDrop(e);
if (e.Effect != DragDropEffects.None) return;
DataObject dragDropData = e.Data as DataObject;
if (!this.ReadOnly && dragDropData != null)
{
ConvertOperation convert = new ConvertOperation(dragDropData, ConvertOperation.Operation.All);
if (convert.CanPerform<Sound>())
{
// Accept drop
e.Effect = e.AllowedEffect;
UndoRedoManager.Do(new CreateSoundEmitterSourceAction(
this.GetValue().Cast<SoundEmitter>(),
convert.Perform<Sound>().Select(s => new SoundEmitter.Source(s))));
}
}
}
示例7: CanConvertFrom
public override bool CanConvertFrom(ConvertOperation convert)
{
return
convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateObj) &&
convert.CanPerform<Material>();
}
示例8: objectView_DragDrop
private void objectView_DragDrop(object sender, DragEventArgs e)
{
this.objectView.BeginUpdate();
bool effectMove = (e.Effect & DragDropEffects.Move) != DragDropEffects.None;
bool effectCopy = (e.Effect & DragDropEffects.Copy) != DragDropEffects.None;
DataObject data = e.Data as DataObject;
if (data != null)
{
ConvertOperation convertOp = new ConvertOperation(data, ConvertOperation.Operation.All);
this.tempDropTarget = this.DragDropGetTargetNode();
if (data.ContainsGameObjectRefs())
{
this.tempDropData = data.GetGameObjectRefs();
// 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);
}
else if (data.ContainsComponentRefs())
{
this.tempDropData = data.GetComponentRefs();
// 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);
}
else if (this.tempDropTarget != null && convertOp.CanPerform<Component>())
{
GameObject dropObj = null;
if (this.tempDropTarget is GameObjectNode)
dropObj = (this.tempDropTarget as GameObjectNode).Obj;
else
dropObj = (this.tempDropTarget as ComponentNode).Component.GameObj;
var componentQuery = convertOp.Perform<Component>();
if (componentQuery != null)
{
// Create Components
CreateComponentAction createAction = new CreateComponentAction(dropObj, componentQuery.Where(c => c.GameObj == null));
UndoRedoManager.BeginMacro();
UndoRedoManager.Do(new DeleteComponentAction(componentQuery.Select(c => dropObj.GetComponent(c.GetType())).NotNull()));
UndoRedoManager.Do(createAction);
UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromLast);
bool selCleared = false;
foreach (Component newComponent in createAction.Result)
{
NodeBase dataNode = this.FindNode(newComponent);
if (dataNode == null) continue;
TreeNodeAdv viewNode = this.objectView.FindNode(this.objectModel.GetPath(dataNode));
if (viewNode == null) continue;
if (!selCleared)
{
this.objectView.ClearSelection();
selCleared = true;
}
viewNode.IsSelected = true;
this.objectView.EnsureVisible(viewNode);
}
}
}
else if (convertOp.CanPerform<GameObject>())
{
GameObject dropObj = (this.tempDropTarget is GameObjectNode) ? (this.tempDropTarget as GameObjectNode).Obj : null;
var gameObjQuery = convertOp.Perform<GameObject>();
if (gameObjQuery != null)
{
CreateGameObjectAction action = new CreateGameObjectAction(dropObj, gameObjQuery);
UndoRedoManager.Do(action);
bool selCleared = false;
foreach (GameObject newObj in action.Result)
{
NodeBase dataNode = this.FindNode(newObj);
if (dataNode == null) continue;
TreeNodeAdv viewNode = this.objectView.FindNode(this.objectModel.GetPath(dataNode));
if (viewNode == null) continue;
if (!selCleared)
{
this.objectView.ClearSelection();
selCleared = true;
}
viewNode.IsSelected = true;
this.objectView.EnsureVisible(viewNode);
}
}
}
}
this.objectView.EndUpdate();
}
示例9: OnKeyDown
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.C && e.Control)
{
DataObject data = new DataObject();
data.SetBatchInfos(new[] { this.DisplayedValue as BatchInfo });
Clipboard.SetDataObject(data);
e.Handled = true;
}
else if (e.KeyCode == Keys.V && e.Control)
{
DataObject data = Clipboard.GetDataObject() as DataObject;
ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
IEnumerable<BatchInfo> refQuery = null;
if (convert.CanPerform<BatchInfo>() && (refQuery = convert.Perform<BatchInfo>()) != null)
{
this.SetValue(refQuery.FirstOrDefault());
this.PerformGetValue();
this.OnEditingFinished(FinishReason.LeapValue);
}
else
System.Media.SystemSounds.Beep.Play();
e.Handled = true;
}
base.OnKeyDown(e);
}
示例10: CanConvertFrom
public override bool CanConvertFrom(ConvertOperation convert)
{
return
convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes) &&
convert.CanPerform<BatchInfo>();
}
示例11: CanConvertFrom
public override bool CanConvertFrom(ConvertOperation convert)
{
return
convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert) &&
convert.CanPerform<Texture>();
}
示例12: DeserializeFromData
protected override void DeserializeFromData(DataObject data)
{
ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
if (convert.CanPerform(this.editedResType))
{
var refQuery = convert.Perform(this.editedResType);
if (refQuery != null)
{
Resource[] refArray = refQuery.Cast<Resource>().ToArray();
this.contentPath = (refArray != null && refArray.Length > 0) ? refArray[0].Path : null;
this.PerformSetValue();
this.PerformGetValue();
this.OnEditingFinished(FinishReason.LeapValue);
}
}
}
示例13: GetPreviewHash
protected override int GetPreviewHash()
{
if (this.contentPath == null) return 0;
IContentRef contentRef = new ContentRef<Resource>(null, this.contentPath);
if (!contentRef.IsAvailable) return 0;
ConvertOperation convOp = new ConvertOperation(new[] { contentRef.Res }, ConvertOperation.Operation.Convert);
if (convOp.CanPerform<Pixmap>())
{
Pixmap basePx = convOp.Perform<Pixmap>().FirstOrDefault();
PixelData basePxLayer = basePx != null ? basePx.MainLayer : null;
return basePxLayer != null ? basePxLayer.GetHashCode() : 0;
}
else if (convOp.CanPerform<AudioData>())
{
AudioData audioData = convOp.Perform<AudioData>().FirstOrDefault();
return (audioData != null && audioData.OggVorbisData != null) ? audioData.OggVorbisData.GetHashCode() : 0;
}
return this.contentPath.GetHashCode();
}
示例14: DeserializeFromData
protected override void DeserializeFromData(DataObject data)
{
ConvertOperation convert = new ConvertOperation(data, ConvertOperation.Operation.All);
if (convert.CanPerform(this.editedResType))
{
var refQuery = convert.Perform(this.editedResType);
if (refQuery != null)
{
Resource[] refArray = refQuery.Cast<Resource>().ToArray();
UpdateContentPath((refArray != null && refArray.Length > 0) ? refArray[0].Path : null);
}
}
}