private void timerFlashItem_Tick(object sender, EventArgs e) { this.flashDuration += (this.timerFlashItem.Interval / 1000.0f); this.flashIntensity = 1.0f - (this.flashDuration % 0.33f) / 0.33f; this.objectView.Invalidate(); if (this.flashDuration > 0.66f) { this.flashNode = null; this.flashIntensity = 0.0f; this.flashDuration = 0.0f; this.timerFlashItem.Enabled = false; } }
public bool SelectNode(NodeBase node, bool select = true) { if (node == null) return false; TreeNodeAdv viewNode = this.objectView.FindNode(this.objectModel.GetPath(node)); if (viewNode != null) { viewNode.IsSelected = select; if (select) this.objectView.EnsureVisible(viewNode); return true; } return false; }
public void FlashNode(NodeBase node) { if (node == null) return; this.flashNode = node; this.flashDuration = 0.0f; this.timerFlashItem.Enabled = true; this.objectView.EnsureVisible(this.objectView.FindNode(this.objectModel.GetPath(this.flashNode))); }
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(); }
private void nodeTextBoxName_EditorShowing(object sender, CancelEventArgs e) { if (e.Cancel) return; if (this.objectView.SelectedNode == null) { e.Cancel = true; return; } NodeBase node = this.objectView.SelectedNode.Tag as NodeBase; GameObjectNode objNode = node as GameObjectNode; if (objNode == null) { e.Cancel = true; } else { DesignTimeObjectData data = DesignTimeObjectData.Get(objNode.Obj); if (data.IsLocked) e.Cancel = true; } if (!e.Cancel) { this.lastEditedNode = node; this.objectView.ContextMenuStrip = null; } }
public static int Compare(NodeBase first, NodeBase second) { return(first.TypeSortIndex - second.TypeSortIndex); }
public static int Compare(NodeBase first, NodeBase second) { return first.TypeSortIndex - second.TypeSortIndex; }