本文整理汇总了C#中Behaviac.Design.NodeViewData类的典型用法代码示例。如果您正苦于以下问题:C# NodeViewData类的具体用法?C# NodeViewData怎么用?C# NodeViewData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeViewData类属于Behaviac.Design命名空间,在下文中一共展示了NodeViewData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNodeViewData
public override NodeViewData CreateNodeViewData(NodeViewData parent, BehaviorNode rootBehavior)
{
NodeViewData nvd = base.CreateNodeViewData(parent, rootBehavior);
nvd.ChangeShape(NodeShape.Ellipse);
return nvd;
}
示例2: CreateNodeViewData
public override NodeViewData CreateNodeViewData(NodeViewData parent, BehaviorNode rootBehavior)
{
NodeViewData nvd = base.CreateNodeViewData(parent, rootBehavior);
nvd.ChangeShape(this.IsEndState ? NodeShape.RoundedRectangle : NodeShape.Rectangle);
return nvd;
}
示例3: CreateNodeViewData
public override NodeViewData CreateNodeViewData(NodeViewData parent, Behaviac.Design.Nodes.BehaviorNode rootBehavior)
{
NodeViewData nvd = base.CreateNodeViewData(parent, rootBehavior);
nvd.ChangeShape(NodeShape.Rectangle);
return nvd;
}
示例4: CreateNodeViewData
public override NodeViewData CreateNodeViewData(NodeViewData parent, Behaviac.Design.Nodes.BehaviorNode rootBehavior)
{
NodeViewDataStyled nvd = new NodeViewDataStyled(parent, rootBehavior, this, null, __defaultBackgroundBrush, _label, _description);
nvd.ChangeShape(NodeShape.Rectangle);
return nvd;
}
示例5: NodeLayoutManager
/// <summary>
/// Creates a new NodeLayoutManager.
/// </summary>
/// <param name="edgePen">The pen which is used to draw the edges connecting the nodes.</param>
/// <param name="edgePenSubReferenced">The pen which is used to draw the edges connecting sub-referenced nodes.</param>
/// <param name="skipLabels">Defines if labels are drawn or not.</param>
/// <param name="rootNode">The root of the nodes shown in the view.</param>
internal NodeLayoutManager(NodeViewData rootNode, Pen edgePen, Pen edgePenHighlight, Pen edgePenUpdate, Pen edgePenSubReferenced, bool skipLabels)
{
_rootNodeLayout = rootNode;
_edgePen = edgePen;
_edgePenHighLight = edgePenHighlight;
_edgePenUpdate = edgePenUpdate;
_edgePenReadOnly = edgePenSubReferenced;
_skipLabels = skipLabels;
}
示例6: Draw
public override void Draw(Graphics graphics, NodeViewData nvd, RectangleF boundingBox) {
Attach evnt = (Attach)_attachment;
//// use a different brush depending on if the event is reacted to or blocked.
//_labelBrush= evnt.BlockEvent ? Brushes.Orange : Brushes.White;
_labelBrush = Brushes.White;
base.Draw(graphics, nvd, boundingBox);
}
示例7: NodeViewDataStyled
public NodeViewDataStyled(NodeViewData parent, BehaviorNode rootBehavior, Node node, Pen borderPen, Brush backgroundBrush, Brush draggedBackgroundBrush, string label, string description, int minWidth = 120, int minHeight = 35) :
base(parent, rootBehavior, node,
NodeShape.RoundedRectangle,
new Style(backgroundBrush, null, Brushes.White),
new Style(null, DefaultCurrentBorderPen, null),
new Style(null, __defaultSelectedBorderPen, null),
new Style(draggedBackgroundBrush, null, null),
new Style(null, __highlightedBorderPen, null),
new Style(null, __updatedBorderPen, null),
new Style(null, __prefabBorderPen, null),
label, __defaultLabelFont, __profileLabelFont, __profileLabelBoldFont, minWidth, minHeight, description) {
}
示例8: BehaviorTreeView_DragDrop
/// <summary>
/// Handles when dropping a tree node on the view.
/// </summary>
private void BehaviorTreeView_DragDrop(object sender, DragEventArgs e) {
// make sure the view is focused
Focus();
// drag the property or method into the node
string dragItem = (string)e.Data.GetData(DataFormats.Text);
if (!string.IsNullOrEmpty(dragItem) && _dragTargetNode != null && _dragTargetNode.Node != null) {
if (_dragTargetNode.Node.SetDefaultPropertyByDragAndDrop(dragItem)) {
if (ClickNode != null) {
ClickNode(_dragTargetNode);
}
UndoManager.Save(this.RootNode);
LayoutChanged();
}
return;
}
// get source node
TreeNode sourceNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
if (sourceNode == null) {
return;
}
NodeTag sourceNodeTag = (NodeTag)sourceNode.Tag;
// keep the current node position
//KeepNodePosition(_dragTargetNode);
bool bDragBTOverNode = !((Node)this.RootNode).IsFSM && sourceNodeTag.Type == NodeTagType.Behavior && _dragTargetNode is Behaviac.Design.NodeViewData;
// check if we are dropping an attach
// or if we are dropping a bt to a node and the indicator is not left/right/up/bottom/center
if (_dragAttachMode == NodeAttachMode.Attachment ||
(bDragBTOverNode && (_dragAttachMode == NodeAttachMode.None || _dragAttachMode == NodeAttachMode.Attachment))) {
Attachments.Attachment attach = null;
// when we attach a behaviour we must create a special referenced behaviour node
if (bDragBTOverNode) {
//drag an event(a bt) to a node
if (!File.Exists(sourceNodeTag.Filename))
{
MainWindow.Instance.SaveBehavior(sourceNodeTag.Defaults as Nodes.BehaviorNode, false);
}
if (File.Exists(sourceNodeTag.Filename)) {
// get the behavior we want to reference
BehaviorNode behavior = _behaviorTreeList.LoadBehavior(sourceNodeTag.Filename);
Behavior rootB = _rootNodeView.RootBehavior as Behavior;
Behavior b = behavior as Behavior;
if (!b.CanBeAttached || !IsCompatibleAgentType(rootB, b))
return;
attach = Behaviac.Design.Attachments.Attachment.Create(typeof(Behaviac.Design.Attachments.Event), _dragTargetNode.Node);
Behaviac.Design.Attachments.Event evt = (Behaviac.Design.Attachments.Event)attach;
evt.ReferencedBehavior = behavior;
}
} else if (_dragTargetNode != null) {
Debug.Check(_dragAttachMode == NodeAttachMode.Attachment);
// add the attach to the target node
attach = Behaviac.Design.Attachments.Attachment.Create(sourceNodeTag.NodeType, _dragTargetNode.Node);
}
if (_dragTargetNode != null && attach != null && _dragTargetNode.Node.AcceptsAttachment(attach))
{
attach.OnPropertyValueChanged(false);
attach.ResetId();
_dragTargetNode.Node.AddAttachment(attach);
NodeViewData.SubItemAttachment sub = attach.CreateSubItem();
_dragTargetNode.AddSubItem(sub);
SelectedNode = _dragTargetNode;
SelectedNode.SelectedSubItem = sub;
// call the ClickEvent event handler
if (ClickEvent != null) {
ClickEvent(SelectedNode);
}
UndoManager.Save(this.RootNode);
LayoutChanged();
}
}
//else if (_dragAttachMode != NodeAttachMode.None)
else {
// attach a new node to the target node
//.........这里部分代码省略.........
示例9: CenterNode
/// <summary>
/// Centres the given node in the view.
/// </summary>
/// <param name="node">The node which will be centred.</param>
internal void CenterNode(NodeViewData node) {
_maintainNodePosition = node;
// we use the existing maintain position stuff for that
RectangleF bbox = node.IsFSM ? node.GetTotalBoundingBox() : node.BoundingBox;
float width = bbox.Width <= 0.0f ? node.MinWidth : bbox.Width;
float height = bbox.Height <= 0.0f ? node.MinHeight : bbox.Height;
// Scale the whole graph to the suitable size in the view.
float viewWidth = ClientSize.Width - 30;
float viewHeight = ClientSize.Height - 30;
bool isWidthScale = false;
if (viewWidth > 0 && viewHeight > 0) {
SizeF totalSize = node.GetTotalSize(_nodeLayoutManager.Padding.Width, int.MaxValue);
float scale = 1.0f;
if (totalSize.Width / totalSize.Height < viewWidth / viewHeight) {
scale = viewHeight / totalSize.Height;
isWidthScale = false;
}
else {
scale = viewWidth / totalSize.Width;
isWidthScale = true;
}
const float MinScale = 0.1f;
const float MaxScale = 2.0f;
if (scale < MinScale) {
_nodeLayoutManager.Scale = MinScale;
}
else if (scale > MaxScale) {
_nodeLayoutManager.Scale = MaxScale;
}
else {
_nodeLayoutManager.Scale = scale;
}
}
if (node.IsFSM)
{
if (isWidthScale)
_graphOrigin = new PointF(0.0f, ClientSize.Height * 0.5f - height * 0.5f * _nodeLayoutManager.Scale);
else
_graphOrigin = new PointF(ClientSize.Width * 0.5f - width * 0.5f * _nodeLayoutManager.Scale, 0.0f);
}
else
{
_graphOrigin = new PointF(20.0f, ClientSize.Height * 0.5f - height * 0.5f);
}
Invalidate();
}
示例10: BehaviorTreeView_DragOver
/// <summary>
/// Handles when a tree node is dragged on the view.
/// </summary>
private void BehaviorTreeView_DragOver(object sender, DragEventArgs e) {
// get the node we are dragging over
Point pt = PointToClient(new Point(e.X, e.Y));
NodeViewData nodeFound = _rootNodeView.GetInsideNode(new PointF(pt.X, pt.Y));
// update last know mouse position
_lastMousePosition = new PointF(pt.X, pt.Y);
// update the current node
if (nodeFound != _currentNode) {
_currentNode = nodeFound;
Invalidate();
}
// when we are moving on a node we must keep drawing as the ttach ode might change but not the node
else if (nodeFound != null) {
Invalidate();
}
// store the target node
_dragTargetNode = _currentNode;
// deny drop by default
e.Effect = DragDropEffects.None;
// process dragging the property and method string value from the Meta Browser
string dragItem = (string)e.Data.GetData(DataFormats.Text);
if (!string.IsNullOrEmpty(dragItem) &&
_dragTargetNode != null && _dragTargetNode.Node != null &&
_dragTargetNode.Node.AcceptDefaultPropertyByDragAndDrop()) {
e.Effect = DragDropEffects.Move;
_dragAttachMode = NodeAttachMode.None;
return;
}
// make sure the correct drag attach mode is set
if (_dragTargetNode != null) {
if (_dragNodeDefaults is Nodes.Node && _dragAttachMode == NodeAttachMode.Attachment) {
_dragAttachMode = NodeAttachMode.None;
} else if (_dragNodeDefaults is Attachments.Attachment && _dragAttachMode != NodeAttachMode.Attachment) {
_dragAttachMode = NodeAttachMode.Attachment;
}
}
// check if we are trying to drop a node on another one
if (_dragTargetNode != null && (e.KeyState & 1/*left mouse button*/) > 0) {
if (_dragNodeDefaults != null &&
(_dragNodeDefaults is Nodes.Node && (_dragAttachMode != NodeAttachMode.None || !(_dragNodeDefaults is Nodes.BehaviorNode) || !(_dragTargetNode.Node is Nodes.BehaviorNode)) ||
_dragNodeDefaults is Attachments.Attachment && _dragTargetNode.Node.AcceptsAttachment(_dragNodeDefaults))) {
e.Effect = DragDropEffects.Move;
}
}
// If this is an empty node, no effect for it.
if (_dragTargetNode == null || _dragTargetNode.Node == null || _dragNodeDefaults == null ||
_dragAttachMode == NodeAttachMode.None && !_dragTargetNode.Node.AcceptsAttachment(_dragNodeDefaults))
{
e.Effect = DragDropEffects.None;
}
if (_rootNodeView.IsFSM || _rootNodeView.Children.Count == 0) { // fsm or empty behavior
if (_dragNodeDefaults != null) {
if (_dragNodeDefaults is Node) {
Node dragNode = _dragNodeDefaults as Node;
if (dragNode.IsFSM || dragNode is Behavior) {
if (_dragTargetNode == null) {
e.Effect = DragDropEffects.Move;
}
//else if (_dragNodeDefaults is Nodes.BehaviorNode) {
// e.Effect = DragDropEffects.None;
//}
}
} else if (_dragNodeDefaults is Attachments.Attachment) {
Attachments.Attachment dragAttachment = _dragNodeDefaults as Attachments.Attachment;
if (dragAttachment.IsFSM) {
if (_dragTargetNode != null && !(_dragTargetNode.Node is Nodes.BehaviorNode) &&
_dragTargetNode.Node.AcceptsAttachment(dragAttachment)) {
e.Effect = DragDropEffects.Move;
}
else {
e.Effect = DragDropEffects.None;
}
}
}
}
}
}
示例11: Draw
public override void Draw(Graphics graphics, NodeViewData nvd, RectangleF boundingBox) {
// render background
DrawBackground(graphics, nvd, this.BackgroundBrush);
// render the label
PointF center = new PointF(boundingBox.Left + boundingBox.Width * 0.5f, boundingBox.Top + boundingBox.Height * 0.5f);
SizeF labelSize = MeasureDisplayStringWidth(graphics, this.DisplayLabel, _labelFont);
// draw text
switch (_alignment) {
case (Alignment.Left):
graphics.DrawString(this.DisplayLabel, _labelFont, _labelBrush, boundingBox.Left + 6.0f, center.Y - labelSize.Height * 0.5f);
break;
case (Alignment.Center):
graphics.DrawString(this.DisplayLabel, _labelFont, _labelBrush, center.X - labelSize.Width * 0.5f, center.Y - labelSize.Height * 0.5f);
break;
case (Alignment.Right):
graphics.DrawString(this.DisplayLabel, _labelFont, _labelBrush, boundingBox.Right - labelSize.Width - 6.0f, center.Y - labelSize.Height * 0.5f);
break;
}
}
示例12: MoveSubItem
private bool MoveSubItem(NodeViewData sourceNvd, NodeViewData targetNvd, NodeViewData.SubItemAttachment sourceAttachment, NodeViewData.SubItemAttachment targetAttachment, bool insertPreviously, bool isCopied) {
if (sourceNvd != null && targetNvd != null && sourceAttachment != null &&
sourceNvd.SetSubItem(targetNvd, sourceAttachment, targetAttachment, insertPreviously, isCopied)) {
// set the prefab dirty for the node
if (!string.IsNullOrEmpty(sourceNvd.Node.PrefabName)) {
sourceNvd.Node.HasOwnPrefabData = true;
}
if (!string.IsNullOrEmpty(targetNvd.Node.PrefabName)) {
targetNvd.Node.HasOwnPrefabData = true;
}
SelectedNode = targetNvd;
// call the ClickEvent event handler
if (ClickEvent != null) {
ClickEvent(SelectedNode);
}
UndoManager.Save(this.RootNode);
LayoutChanged();
return true;
}
return false;
}
示例13: control_ClickEvent
private void control_ClickEvent(NodeViewData node)
{
if (node == null)
return;
// if there is no subitem selected, use the properties of the node
if (node.SelectedSubItem == null || node.SelectedSubItem.SelectableObject == null)
{
PropertiesDock.InspectObject(node.RootBehavior, node.Node);
}
// publish the properties of the subitem's selection object
else
{
PropertiesDock.InspectObject(node.RootBehavior, node.SelectedSubItem.SelectableObject);
}
}
示例14: OnPaint
/// <summary>
/// Handles the drawing and updating of the graph.
/// </summary>
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
// calculate the mouse position in the graph
PointF graphMousePos = _nodeLayoutManager.ViewToGraph(_lastMousePosition);
// when the layout was changed it needs to be recalculated
bool layoutChanged = _nodeLayoutManager.LayoutChanged;
if (layoutChanged) {
_nodeLayoutManager.UpdateLayout(e.Graphics, _forceChangeLayout);
_forceChangeLayout = false;
}
// center the root behaviour if requested
if (_pendingCenterBehavior) {
_pendingCenterBehavior = false;
CenterNode(_rootNodeView);
}
// select the pending node
if (_selectedNodePending != null) {
if (_selectedNodePendingParent != null) {
if (_selectedNodePendingParent.CanBeExpanded() && !_selectedNodePendingParent.IsExpanded) {
_selectedNodePendingParent.IsExpanded = true;
LayoutChanged();
}
SelectedNode = _selectedNodePendingParent.GetChild(_selectedNodePending);
} else {
SelectedNode = RootNodeView.FindNodeViewData(_selectedNodePending);
}
if (SelectedNode != null) {
if (SelectedNode.CanBeExpanded() && !SelectedNode.IsExpanded) {
SelectedNode.IsExpanded = true;
LayoutChanged();
}
SelectedNode.SelectedSubItem = SelectedNode.GetSubItem(_selectedAttachmentPending);
ShowNode(SelectedNode);
}
_selectedNodePending = null;
_selectedNodePendingParent = null;
_selectedAttachmentPending = null;
if (ClickEvent != null) {
ClickEvent(SelectedNode);
}
}
// check if we must keep the original position of the mouse
if (_maintainMousePosition) {
_maintainMousePosition = false;
// move the graph so that _graphOrigin is at the same position in the view as it was before
float mouseX = (graphMousePos.X - _graphOrigin.X) * _nodeLayoutManager.Scale + _nodeLayoutManager.Offset.X;
float mouseY = (graphMousePos.Y - _graphOrigin.Y) * _nodeLayoutManager.Scale + _nodeLayoutManager.Offset.Y;
_nodeLayoutManager.Offset = new PointF(mouseX, mouseY);
}
// check if we must keep the original position of _maintainNodePosition
else if (_maintainNodePosition != null) {
// move the graph so that _graphOrigin is at the same position in the view as it was before
RectangleF bbox = _maintainNodePosition.IsFSM ? _maintainNodePosition.GetTotalBoundingBox() : _maintainNodePosition.BoundingBox;
PointF viewpos = new PointF(bbox.X * _nodeLayoutManager.Scale, bbox.Y * _nodeLayoutManager.Scale);
_nodeLayoutManager.Offset = new PointF(_graphOrigin.X - viewpos.X, _graphOrigin.Y - viewpos.Y);
}
// reset the node whose position we want to keep
_maintainNodePosition = null;
// draw the graph to the view
_nodeLayoutManager.DrawGraph(e.Graphics, graphMousePos, _currentNode, SelectedNode, _highlightedNodeIds, _updatedNodeIds, _highlightedTransitionIds, _highlightBreakPoint, _profileInfos);
// check if we are currently dragging a node and we must draw additional data
if (_dragTargetNode != null && _dragAttachment == null && (KeyCtrlIsDown && _movedNode != null || _dragTargetNode.Node != _movedNode)) {
if (_dragAttachMode == NodeAttachMode.Attachment) {
// we could draw some stuff for attachements here
} else {
// draw the arrows for the attach modes
// get the bounding box of the node
RectangleF bbox = _dragTargetNode.BoundingBox;
// get the bounding box of the connector
_dragTargetConnector = null;
// the depth of the area for the mouse
const float offset = 12.0f;
// the distance of the arrow from the border and its height
const float innerOffset = 2.0f;
//.........这里部分代码省略.........
示例15: OnKeyUp
/// <summary>
/// Handles when a key is released.
/// </summary>
protected override void OnKeyUp(KeyEventArgs e) {
switch (e.KeyCode) {
case (Keys.Enter):
if (SelectedNode != null) {
if (KeyCtrlIsDown) {
SelectedNode.ExpandAll(!SelectedNode.IsExpanded);
}
else {
SelectedNode.IsExpanded = !SelectedNode.IsExpanded;
}
LayoutChanged();
e.Handled = true;
}
break;
// store when the shift key is released
case (Keys.ShiftKey):
// update the drawn graph for dragging and duplicating
if (_movedNodeGraph != null) {
_movedNodeGraph.RenderDepth = 0;
Invalidate();
}
break;
// paste from clipboard
case (Keys.V):
PasteSelectedNode();
_clipboardPasteMode = false;
// reset all the drag data
_copiedNode = null;
_movedNode = null;
_dragTargetNode = null;
_dragNodeDefaults = null;
_movedNodeGraph = null;
// redraw the graph
Invalidate();
break;
case (Keys.Left):
case (Keys.Right):
case (Keys.Up):
case (Keys.Down):
if (e.Control)
{
break;
}
if (SelectedNode == null) {
SelectedNode = this.RootNodeView;
if (ClickNode != null) {
ClickNode(SelectedNode);
}
LayoutChanged();
break;
}
switch (e.KeyCode) {
case (Keys.Left):
if (SelectedNode != null && SelectedNode.Parent != null) {
SelectedNode = SelectedNode.Parent;
if (ClickNode != null) {
ClickNode(SelectedNode);
}
LayoutChanged();
}
break;
case (Keys.Right):
if (SelectedNode != null && SelectedNode.Children.Count > 0) {
SelectedNode = SelectedNode.Children[0] as NodeViewData;
if (ClickNode != null) {
ClickNode(SelectedNode);
}
LayoutChanged();
}
break;
case (Keys.Up):
if (SelectedNode != null) {
if (!KeyShiftIsDown || !SwitchSelection()) {
//.........这里部分代码省略.........