public DTextLabel(DObject parentPar, DrawingLabel label) : base(parentPar, label) { }
public DLabel(DObject parentPar, DrawingLabel label, FrameworkElement content) : base(parentPar) { DrawingLabel = label; if (parentPar != null) { label.Owner = parentPar.DrawingObject; if (label.GeometryLabel != null) { label.GeometryLabel.GeometryParent = parentPar.DrawingObject.GeometryObject; } if (parentPar.DrawingObject.GeometryObject is IGeometryLabeledObject) { ((IGeometryLabeledObject)parentPar.DrawingObject.GeometryObject).Label = label.GeometryLabel; } } if (ParentObject is IHavingDLabel) { ((IHavingDLabel)ParentObject).Label = this; } Content = content; if ((label.Owner is Node) && ((label.Owner as DrawingNode).GeometryObject as GeometryNode).BoundaryCurve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingNode).GeometryObject as GeometryNode).Center; MakeVisual(); } else if ((label.Owner is Edge) && ((label.Owner as DrawingEdge).GeometryObject as GeometryEdge).Curve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingEdge).GeometryObject as GeometryEdge).BoundingBox.Center; MakeVisual(); } }
internal static void AddStyleForPen(DObject dObj, Brush myPen, MsaglStyle style) { if (style == MsaglStyle.Dashed) { throw new NotImplementedException(); /* * myPen.DashStyle = DashStyle.Dash; * * if (dObj.DashPatternArray == null) * { * float f = dObj.DashSize(); * dObj.DashPatternArray = new[] { f, f }; * } * myPen.DashPattern = dObj.DashPatternArray; * * myPen.DashOffset = dObj.DashPatternArray[0]; */ } else if (style == MsaglStyle.Dotted) { throw new NotImplementedException(); /* * myPen.DashStyle = DashStyle.Dash; * if (dObj.DashPatternArray == null) * { * float f = dObj.DashSize(); * dObj.DashPatternArray = new[] { 1, f }; * } * myPen.DashPattern = dObj.DashPatternArray; */ } }
public DLabel(DObject parentPar, DrawingLabel label, FrameworkElement content) : base(parentPar) { DrawingLabel = label; if (parentPar != null) { label.Owner = parentPar.DrawingObject; if (label.GeometryLabel != null) label.GeometryLabel.GeometryParent = parentPar.DrawingObject.GeometryObject; if (parentPar.DrawingObject.GeometryObject is IGeometryLabeledObject) ((IGeometryLabeledObject)parentPar.DrawingObject.GeometryObject).Label = label.GeometryLabel; } if (ParentObject is IHavingDLabel) ((IHavingDLabel)ParentObject).Label = this; Content = content; if ((label.Owner is Node) && ((label.Owner as DrawingNode).GeometryObject as GeometryNode).BoundaryCurve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingNode).GeometryObject as GeometryNode).Center; MakeVisual(); } else if ((label.Owner is Edge) && ((label.Owner as DrawingEdge).GeometryObject as GeometryEdge).Curve != null) { Label.GeometryLabel.Center = ((Label.Owner as DrawingEdge).GeometryObject as GeometryEdge).BoundingBox.Center; MakeVisual(); } }
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); }
public bool IsAncestorOf(DObject obj) { if (obj == null) { return(false); } return(obj.ParentObject == this || IsAncestorOf(obj.ParentObject)); }
public DNestedGraphLabel(DObject parentPar, FrameworkElement content) : base(parentPar, content) { Graphs = new List <DGraph>(); if (content is DGraph) { Graphs.Add(content as DGraph); (content as DGraph).ParentObject = this; } }
public DNestedGraphLabel(DObject parentPar, FrameworkElement content) : base(parentPar, content) { Graphs = new List<DGraph>(); if (content is DGraph) { Graphs.Add(content as DGraph); (content as DGraph).ParentObject = this; } }
internal Geometry(DObject dObject) { this.dObject = dObject; DNode dNode = dObject as DNode; if (dNode != null) bBox = dNode.DrawingNode.BoundingBox; else { DLabel dLabel = dObject as DLabel; if (dLabel != null) bBox = dLabel.Label.BoundingBox; } }
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); }
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 Geometry(DObject dObject) { this.dObject = dObject; DNode dNode = dObject as DNode; if (dNode != null) { bBox = dNode.DrawingNode.BoundingBox; } else { DLabel dLabel = dObject as DLabel; if (dLabel != null) { bBox = dLabel.Label.BoundingBox; } } }
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 Line(DObject tag, MsaglPoint start, MsaglPoint end, double lw) : base(tag) { lineWidth = lw; MsaglPoint dir = end - start; if (lineWidth < 0) { lineWidth = 1; } double len = dir.Length; if (len > ApproximateComparer.IntersectionEpsilon) { dir /= (len / (lineWidth / 2)); dir = dir.Rotate(Math.PI / 2); } else { dir.X = 0; dir.Y = 0; } this.bBox = new Rectangle(start + dir); this.bBox.Add(start - dir); this.bBox.Add(end + dir); this.bBox.Add(end - dir); this.start = start; this.end = end; if (this.bBox.LeftTop.X == this.bBox.RightBottom.X) { bBox.LeftTop = bBox.LeftTop + new MsaglPoint(-0.05f, 0); bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0.05f, 0); } if (this.bBox.LeftTop.Y == this.bBox.RightBottom.Y) { bBox.LeftTop = bBox.LeftTop + new MsaglPoint(0, -0.05f); bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0, 0.05f); } }
/// <summary> /// first and count denine the segment needed to be split into two groups /// </summary> /// <param name="first"></param> /// <param name="count"></param> /// <returns></returns> BBNode ProcessGroup(int first, int count) { if (count > 1) { int seed0; MsaglRectangle b0; int seed1; FindSeeds(first, count, out seed0, out b0, out seed1); MsaglRectangle b1; int count0; int count1; SplitOnGroups(first, count, seed0, ref b0, seed1, out b1, out count0, out count1); BBNode node = new BBNode(); node.bBox = new MsaglRectangle(b0, b1); node.left = ProcessGroup(first, count0); node.left.parent = node; node.right = ProcessGroup(first + count0, count1); node.right.parent = node; return(node); } if (count == 1) { Geometry geom = geometries[first] as Geometry; if (geom != null) { BBNode node = new BBNode(); node.geometry = geom; return(node); } DObject dObject = geometries[first] as DObject; if (dObject != null) { return(dObject.BBNode); } } return(null); }
void DObject_MouseMove(object sender, MouseEventArgs e) { if (e != m_CurrentEvent) { m_CurrentEvent = e; m_LastObjectSet = null; } if (m_LastObjectSet == null) { DObject obj = this; if (obj is DLabel && !(obj.ParentObject is DEdge)) { obj = obj.ParentObject; } if (obj is DGraph) { obj = null; } m_LastObjectSet = ParentGraph.ObjectUnderMouseCursor = obj; } }
internal Line(DObject tag, MsaglPoint start, MsaglPoint end, double lw) : base(tag) { lineWidth = lw; MsaglPoint dir = end - start; if (lineWidth < 0) lineWidth = 1; double len = dir.Length; if (len > ApproximateComparer.IntersectionEpsilon) { dir /= (len / (lineWidth / 2)); dir = dir.Rotate(Math.PI / 2); } else { dir.X = 0; dir.Y = 0; } this.bBox = new Rectangle(start + dir); this.bBox.Add(start - dir); this.bBox.Add(end + dir); this.bBox.Add(end - dir); this.start = start; this.end = end; if (this.bBox.LeftTop.X == this.bBox.RightBottom.X) { bBox.LeftTop = bBox.LeftTop + new MsaglPoint(-0.05f, 0); bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0.05f, 0); } if (this.bBox.LeftTop.Y == this.bBox.RightBottom.Y) { bBox.LeftTop = bBox.LeftTop + new MsaglPoint(0, -0.05f); bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0, 0.05f); } }
private void DefaultBeginContentEdit(DObject obj) { if (m_EditingLabel) return; FrameworkElement fe = ContentEditorProvider.GetNewGUIInstance(obj); if (fe != null) { DecorateObjectForDragging(obj); m_LabelEditor = new LabelEditor() { EditControl = fe, EditTarget = obj, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; m_LabelEditor.Closed += (sender, args) => { RemoveObjDraggingDecorations(obj); if (m_LabelEditor.OK) ContentEditorProvider.UpdateLabel(fe, obj); m_EditingLabel = false; LayoutRoot.Children.Remove(m_LabelEditor); m_LabelEditor = null; }; m_EditingLabel = true; LayoutRoot.Children.Add(m_LabelEditor); SynchronizationContext.Current.Post(o => ContentEditorProvider.FocusGUI(fe, obj), null); } }
public DLabel(DObject parentPar, FrameworkElement content) : this(parentPar, new DrawingLabel(), content) { }
static BBNode BuildBBHierarchyUnderDObject(DObject dObject) { var dNode = dObject as DNode; if (dNode != null) return BuildBBHierarchyUnderDNode(dNode); var dedge = dObject as DEdge; if (dedge != null) { return BuildBBHierarchyUnderDEdge(dedge); } var dLabel = dObject as DLabel; if (dLabel != null) return BuildBBHierarchyUnderDLabel(dLabel); var dGraph = dObject as DGraph; if (dGraph != null) { dGraph.BBNode.bBox = dGraph.DrawingGraph.BoundingBox; return dGraph.BBNode; } throw new InvalidOperationException(); }
protected DObject(DObject parent) : this() { ParentObject = parent; Canvas.SetZIndex(this, parent == null ? 0 : Canvas.GetZIndex(parent) + 1); }
public DTextLabel(DObject parentPar) : this(parentPar, new DrawingLabel()) { }
static void RebuildBBHierarchyUnderObject(DObject dObj) { BBNode oldNode = dObj.BBNode; BBNode newNode = BuildBBHierarchyUnderDObject(dObj); if (newNode != null) { //now copy all fields, except the parent oldNode.left = newNode.left; oldNode.right = newNode.right; oldNode.geometry = newNode.geometry; oldNode.bBox = newNode.bBox; } else oldNode.bBox = Microsoft.Msagl.Core.Geometry.Rectangle.CreateAnEmptyBox(); }
static void InvalidateBBNodesAbove(DObject dObj) { for (BBNode node = dObj.BBNode; node != null; node = node.parent) node.bBox.Width = -1; //this will make the box empty }
public virtual void FocusGUI(FrameworkElement guiElement, DObject obj) { (guiElement as TextBox).Focus(); }
protected DObject(DObject parent) { ParentObject = parent; }
internal DCluster(DObject parent, DrawingCluster drawingCluster) : base(parent, drawingCluster) { Node.Attr.FillColor = Drawing.Color.White; }
public bool IsAncestorOf(DObject obj) { if (obj == null) return false; return obj.ParentObject == this || IsAncestorOf(obj.ParentObject); }
private void DefaultBeginContentEdit(DObject obj) { if (m_EditingLabel) return; DTextLabel clicked = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel; DObject labelOwner = obj is DTextLabel ? (obj as DTextLabel).ParentObject : obj; if (clicked != null /*&& clicked != m_EditingLabel*/) { //EndContentEdit(); DTextLabel editingLabel = clicked; FrameworkElement fe = null; bool isMine = false; if (GetNewEditControlDelegate != null) fe = GetNewEditControlDelegate(labelOwner); else { isMine = true; fe = new TextBox() { MinWidth = 50.0, Text = editingLabel.Text, SelectionStart = 0, SelectionLength = editingLabel.Text.Length, AcceptsReturn = true }; } if (fe != null) { DecorateObjectForDragging(obj); m_LabelEditor = new LabelEditor() { EditControl = fe, EditTarget = obj, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; if (isMine) { fe.KeyDown += (sender, args) => { if (System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.None) { if (args.Key == System.Windows.Input.Key.Enter) m_LabelEditor.Close(true); else if (args.Key == System.Windows.Input.Key.Escape) m_LabelEditor.Close(false); } }; } m_LabelEditor.Closed += (sender, args) => { RemoveObjDraggingDecorations(obj); if (m_LabelEditor.OK) { if (GetTextFromEditControlDelegate != null) editingLabel.Text = GetTextFromEditControlDelegate(labelOwner, fe); else editingLabel.Text = (fe as TextBox).Text; BuildBBHierarchy(); } m_EditingLabel = false; LayoutRoot.Children.Remove(m_LabelEditor); m_LabelEditor = null; }; m_EditingLabel = true; LayoutRoot.Children.Add(m_LabelEditor); if (isMine) (fe as TextBox).Focus(); } } }
internal Geometry(DObject dObject, MsaglRectangle box) { this.dObject = dObject; this.bBox = box; }
public DLabel(DObject parentPar, DrawingLabel label) : this(parentPar, label, null) { }
private IEnumerable<DObject> RelatedObjs(DObject dObj) { yield return dObj; var dNode = dObj as DNode; if (dNode != null) { foreach (DEdge e in dNode.OutEdges) yield return e; foreach (DEdge e in dNode.InEdges) yield return e; foreach (DEdge e in dNode.SelfEdges) yield return e; } else { var dEdge = dObj as DEdge; if (dEdge != null) { yield return dEdge.Source; yield return dEdge.Target; if (dEdge.Label != null) yield return dEdge.Label; } } }
public DTextLabel(DObject parentPar, string text) : this(parentPar) { Text = text; }
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; }
internal static void AddStyleForPen(DObject dObj, Brush myPen, MsaglStyle style) { if (style == MsaglStyle.Dashed) { throw new NotImplementedException(); /* myPen.DashStyle = DashStyle.Dash; if (dObj.DashPatternArray == null) { float f = dObj.DashSize(); dObj.DashPatternArray = new[] { f, f }; } myPen.DashPattern = dObj.DashPatternArray; myPen.DashOffset = dObj.DashPatternArray[0]; */ } else if (style == MsaglStyle.Dotted) { throw new NotImplementedException(); /* myPen.DashStyle = DashStyle.Dash; if (dObj.DashPatternArray == null) { float f = dObj.DashSize(); dObj.DashPatternArray = new[] { 1, f }; } myPen.DashPattern = dObj.DashPatternArray; */ } }