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); } } }
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(); Pixmap.Layer 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()); }
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; }
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)))); } } }
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); } } }
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); }
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); }
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); } } }
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; }
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); }
protected override void OnDragEnter(DragEventArgs e) { base.OnDragEnter(e); DataObject data = e.Data as DataObject; var op = new ConvertOperation(data, ConvertOperation.Operation.All); if (op.CanPerform <Pixmap>()) { e.Effect = e.AllowedEffect; } else { e.Effect = DragDropEffects.None; } }
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); } } }
public override bool CanConvertFrom(ConvertOperation convert) { if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes)) { return(convert.CanPerform <AudioData>()); } if (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert)) { List <AudioData> availData = convert.Perform <AudioData>(ConvertOperation.Operation.Convert).ToList(); return(availData.Any(t => this.FindMatchingResources <AudioData, Sound>(t, IsMatch) .Any())); } return(false); }
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); } } }
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); } } }
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; }
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)))); } } }
public override bool CanConvertFrom(ConvertOperation convert) { return convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes) && convert.CanPerform<BatchInfo>(); }
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(); }
public override bool CanConvertFrom(ConvertOperation convert) { return convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateObj) && convert.CanPerform<Material>(); }
public override bool CanConvertFrom(ConvertOperation convert) { return (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert) && convert.CanPerform <Texture>()); }
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); } } }
public override bool CanConvertFrom(ConvertOperation convert) { return (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes) && convert.CanPerform <BatchInfo>()); }
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(); }
public override bool CanConvertFrom(ConvertOperation convert) { return (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateObj) && convert.CanPerform <AtlasViewer.TabItemInfo>()); }
public override bool CanConvertFrom(ConvertOperation convert) { return convert.AllowedOperations.HasFlag(ConvertOperation.Operation.Convert) && convert.CanPerform<Texture>(); }
public override bool CanConvertFrom(ConvertOperation convert) { return (convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateObj) && convert.CanPerform <Material>()); }
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); }