public virtual FrameworkElement GetNewGUIInstance(DObject obj) { DTextLabel editingLabel = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel; if (editingLabel == null) { return(null); } var tb = new TextBox() { MinWidth = 50.0, Text = editingLabel.Text, SelectionStart = 0, SelectionLength = editingLabel.Text.Length, AcceptsReturn = true }; tb.KeyDown += (sender, args) => { if (System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.None) { if (args.Key == System.Windows.Input.Key.Enter) { Owner.LabelEditor.Close(true); } else if (args.Key == System.Windows.Input.Key.Escape) { Owner.LabelEditor.Close(false); } } }; return(tb); }
internal DNode(DGraph graph, DrawingNode drawingNode) : base(graph) { this.DrawingNode = drawingNode; _OutEdges = new List<DEdge>(); _InEdges = new List<DEdge>(); _SelfEdges = new List<DEdge>(); PortsToDraw = new Set<Port>(); if (drawingNode.Label != null) Label = new DTextLabel(this, drawingNode.Label); }
internal DNode(DGraph graph, DrawingNode drawingNode) : base(graph) { this.DrawingNode = drawingNode; _OutEdges = new List <DEdge>(); _InEdges = new List <DEdge>(); _SelfEdges = new List <DEdge>(); PortsToDraw = new Set <Port>(); if (drawingNode.Label != null) { Label = new DTextLabel(this, drawingNode.Label); } }
internal DNode(DObject graph, DrawingNode drawingNode) : base(graph) { this.DrawingNode = drawingNode; _OutEdges = new List<DEdge>(); _InEdges = new List<DEdge>(); _SelfEdges = new List<DEdge>(); PortsToDraw = new Set<Port>(); if (drawingNode.Label != null && drawingNode.Label.GeometryLabel != null) Label = new DTextLabel(this, drawingNode.Label); if (!(this is DCluster)) Canvas.SetZIndex(this, 10000); }
internal DNode(DObject graph, DrawingNode drawingNode) : base(graph) { this.DrawingNode = drawingNode; _OutEdges = new List <DEdge>(); _InEdges = new List <DEdge>(); _SelfEdges = new List <DEdge>(); PortsToDraw = new Set <Port>(); if (drawingNode.Label != null && drawingNode.Label.GeometryLabel != null) { Label = new DTextLabel(this, drawingNode.Label); } if (!(this is DCluster)) { Canvas.SetZIndex(this, 10000); } }
internal static void SetNodeBoundaryCurve(DrawingGraph drawingGraph, DrawingNode drawingNode, DLabel existingLabel) { // Create the boundary curve. Note that a delegate may be allowed to create the curve (or replace it, if it already exists). GeometryNode geomNode = drawingNode.GeometryNode; if (geomNode == null) return; ICurve curve; if (drawingNode.NodeBoundaryDelegate == null || (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) == null) { // I need to know the node size, which may depend on a label. double width = 0.0; double height = 0.0; if (existingLabel != null) { //existingLabel.MakeVisual(); width = existingLabel.Label.Width; height = existingLabel.Label.Height; width += 2 * drawingNode.Attr.LabelMargin; height += 2 * drawingNode.Attr.LabelMargin; } else if (drawingNode.Label != null && drawingNode.Label.GeometryLabel != null) { // Measure the label's size (the only safe way is to instantiate it). var dLabel = new DTextLabel(null, drawingNode.Label); dLabel.MakeVisual(); width = dLabel.Label.Width; height = dLabel.Label.Height; // Add node label margin. width += 2 * drawingNode.Attr.LabelMargin; height += 2 * drawingNode.Attr.LabelMargin; } // Apply lower cap to node size if (width < drawingGraph.Attr.MinNodeWidth) width = drawingGraph.Attr.MinNodeWidth; if (height < drawingGraph.Attr.MinNodeHeight) height = drawingGraph.Attr.MinNodeHeight; curve = NodeBoundaryCurves.GetNodeBoundaryCurve(drawingNode, width, height); } if (geomNode.BoundaryCurve != null) curve.Translate(geomNode.BoundingBox.Center); geomNode.BoundaryCurve = curve; }
public virtual void UpdateLabel(FrameworkElement guiElement, DObject obj) { DTextLabel editingLabel = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel; editingLabel.Text = (guiElement as TextBox).Text; }