// Done! public void DrawExits(Graphics g, WorkAreaState was) { if (ConcreteNode.Exits.Count == 0) { return; } var gpe = this.Visuals.ExitPath; //var gpc = this.Visuals.ExitCrossPath; gpe.Reset(); //gpc.Reset(); var size = new Size(Visuals.ExitSize, Visuals.ExitSize); for (int i = 0; i < ConcreteNode.Exits.Count; ++i) { Point v = Vector.Transform(ConcreteNode.Exits[i + 0].Location, was.Scale, was.DeltaX, was.DeltaY); gpe.AddRectangle(new Rectangle(v, size)); if (ConcreteNode.Exits[i] != null) { //gpc.StartFigure(); //gpc.AddLine(v.X, v.Y, v.X + size.Width, v.Y + size.Height); //gpc.AddLine(v.X + size.Width, v.Y, v.X, v.Y + size.Height); //gpc.CloseFigure(); } } g.FillPath(Visuals.ExitFill, gpe); g.DrawPath(Visuals.ExitBorder, gpe); //g.DrawPath(Visuals.ExitCross, gpc); }
// Done! public static void DrawPath(Graphics g, WorkAreaState was) { if (was.ShowPath == false && was.Path == null || was.Path.Count == 0) { return; } GraphicsPath gpd = new GraphicsPath(); GraphicsPath gpl = new GraphicsPath(); const int size = 10; const int os = size / 2; for (int i = 0; i < was.Path.Count; ++i) { var c = Vector.Transform(was.Path[i + 0].Location, was.Scale, was.DeltaX, was.DeltaY, was.DeltaZ); gpd.AddEllipse(new RectangleF(c.X - os, c.Y - os, size, size)); if (i < was.Path.Count - 1) { var n = Vector.Transform(was.Path[i + 1].Location, was.Scale, was.DeltaX, was.DeltaY, was.DeltaZ); gpl.AddLine((PointF)c, (PointF)n); } } g.DrawPath(new Pen(Color.Blue, 3f), gpl); g.FillPath(Brushes.Blue, gpd); }
// Done! public static void DrawSelectedExit(Graphics g, WorkAreaState was) { var vmn = was.SelectedShape; var v = was.SelectedExit.Location; var p1 = Vector.Transform(new Vector(v.X, v.Y), was.Scale, was.DeltaX, was.DeltaY); DrawSquare(g, Brushes.Green, Pens.RosyBrown, p1, vmn.Visuals.ExitSize); }
// Done! #region Static Methods public static WorkAreaState LowQuality(WorkAreaState was) { return(new WorkAreaState { Width = was.Width, Height = was.Height, IsMouseDown = was.IsMouseDown, SelectedAnchor = was.SelectedAnchor, LastSelectedAnchor = was.LastSelectedAnchor, SelectedShape = was.SelectedShape, LastSelectedShape = was.LastSelectedShape, SelectedExit = was.SelectedExit, LastSelectedExit = was.LastSelectedExit, SelectedArtifact = was.SelectedArtifact, LastSelectedArtifact = was.LastSelectedArtifact, LastMousePosition = was.LastMousePosition, SlopeVector0 = was.SlopeVector0, SlopeVector1 = was.SlopeVector1, PersistAnchor = false, PersistExit = false, PersistShape = false, PersistExtraInfo = false, ShowSlopes = false, Scale = was.Scale, DeltaX = was.DeltaX, DeltaY = was.DeltaY, DeltaZ = was.DeltaZ, CloseGeometry = true, Normalize = false, ShowZCoordinate = false, ShowAnchorLabels = false, ShowAnchors = false, ShowExitLabels = false, ShowExits = false, ShowExitConnectors = false, ShowExitSources = false, ShowExtraDetails = false, ShowAngles = false, ShowImageGuide = false, ShowShapeName = false, ShowMST = false, BackgroundColor = was.BackgroundColor, IsSaved = was.IsSaved, ShowOnlyConnectors = was.ShowOnlyConnectors, IsAnchorOnTop = was.IsAnchorOnTop, Action = was.Action, IsDirty = was.IsDirty, HighQuality = false, ShowBounds = false, Redraw = true, Backup = was, ShowShapeSelection = was.ShowShapeSelection, TweakAgentView = was.TweakAgentView, ShowMoveSelection = was.ShowMoveSelection, }); }
// Done! public static void DrawBounds(Graphics g, WorkAreaState was) { var vmn = was.SelectedShape; var s = vmn.Visuals.AnchorSize; var p1 = Vector.Transform(new Vector(vmn.Min.X, vmn.Min.Y), was.Scale, was.DeltaX, was.DeltaY); var p2 = Vector.Transform(new Vector(vmn.Max.X, vmn.Max.Y), was.Scale, was.DeltaX, was.DeltaY); var r = new RectangleF(p1.X, p1.Y, p2.X - p1.X + s, p2.Y - p1.Y + s); DrawRectangle(g, Brushes.Transparent, Pens.RosyBrown, new Vector(r.X, r.Y), new SizeF(r.Width, r.Height)); }
// Done! public static void DrawSelectedAnchor(Graphics g, WorkAreaState was) { //var node = was.SelectedShape; //DrawSquare(g, node.Visuals.ExitFill, node.Visuals.ExitBorder, was.SelectedAnchor, node.Visuals.AnchorSize); var vmn = was.SelectedShape; var v = was.SelectedAnchor; var p1 = Vector.Transform(new Vector(v.X, v.Y), was.Scale, was.DeltaX, was.DeltaY); DrawSquare(g, Brushes.Green, Pens.RosyBrown, p1, vmn.Visuals.ExitSize); }
// Done! private static void DrawGeneralGeometry(Graphics g, VisualMapNode vmn, WorkAreaState was, GraphicsPath gp1, GraphicsPath gp2, bool active) { var node = vmn.ConcreteNode; if (node.Geometry == null || node.Geometry.Count == 0) { return; } gp1.Reset(); gp2.Reset(); // Create Geometry! for (int i = 0; i < node.Geometry.Count - 1; ++i) { Point c = Vector.Transform(node.Geometry[i + 0], was.Scale, was.DeltaX, was.DeltaY); Point n = Vector.Transform(node.Geometry[i + 1], was.Scale, was.DeltaX, was.DeltaY); gp1.AddLine(c.X, c.Y, n.X, n.Y); } // Close Geometry! if (was.CloseGeometry && node.Geometry.Count > 2) { Vector c = Vector.Transform(node.Geometry[node.Geometry.Count - 1], was.Scale, was.DeltaX, was.DeltaY); Vector n = Vector.Transform(node.Geometry[0], was.Scale, was.DeltaX, was.DeltaY); gp1.AddLine(c.X, c.Y, n.X, n.Y); } // Show Name if (was.ShowShapeName == true && string.IsNullOrEmpty(node.Name) == false) { var center = Vector.Transform(Vector.Average(node.Geometry), was.Scale, was.DeltaX, was.DeltaY); var ci = CultureInfo.InvariantCulture; var f = vmn.Visuals.AnchorFont; string info = GenerateInfo(node, ci, was.ShowMST); gp2.AddString(info, new FontFamily(f.Name), (int)f.Style, f.Size, (PointF)(center + OffSet1), StringFormat.GenericDefault); } if (vmn.FillShape == true) { g.FillPath(vmn.Visuals.GeometryFill, gp1); } if (vmn.FillShapePath == true) { g.FillPath(vmn.Visuals.GeometryPathFill, gp1); } g.DrawPath(active ? vmn.Visuals.ActiveGeometry : vmn.Visuals.Geometry, gp1); if (active == false) { g.DrawPath(vmn.Visuals.NameLabel, gp2); } }
// Todo: Review! public void DrawExitConnections(Graphics g, WorkAreaState was) { if (ConcreteNode.Exits.Count == 0) { return; } var gp1 = this.Visuals.ExitSourceConnectorsPath; //var gp2 = this.Visuals.ExitConnectorPath; gp1.Reset(); //gp2.Reset(); var c = Vector.Transform(Vector.Average(ConcreteNode.Geometry), was.Scale, was.DeltaX, was.DeltaY); for (int i = 0; i < ConcreteNode.Exits.Count; ++i) { var e = ConcreteNode.Exits[i]; Point p = Vector.Transform(e.Location, was.Scale, was.DeltaX, was.DeltaY); if (was.ShowExitSources == true) { gp1.StartFigure(); gp1.AddLine(p.X, p.Y, c.X, c.Y); gp1.CloseFigure(); } if (was.ShowExitConnectors == true && ConcreteNode.Exits[i].Exits.Count > 0 && ConcreteNode.Exits[i].Exits[0] != null) { var gp2 = this.Visuals.ExitConnectorPath; gp2.Reset(); Point n = Vector.Transform(Vector.Average(ConcreteNode.Exits[i].Exits[0].Geometry), was.Scale, was.DeltaX, was.DeltaY); gp2.StartFigure(); gp2.AddLine(p.X, p.Y, n.X, n.Y); gp2.CloseFigure(); if (was.ShowConnectorColors == true) { const float factor = 3; const float factor2 = 100000; var constraint = e.Exits[0].Constraints; var width = Math.Abs(constraint.Memory.Value) * factor + constraint.Speed.Value * factor + constraint.Transitable.Value * factor + 1; var color = Color.FromArgb(0xff, Color.FromArgb((int)(Math.Abs(constraint.Memory.Value) * factor2 + constraint.Speed.Value * factor2 + constraint.Transitable.Value * factor2 + 1))); g.DrawPath(new Pen(color, width), gp2); } else { g.DrawPath(Visuals.ExitConnectors, gp2); } } } g.DrawPath(Visuals.ExitSourceConnectors, gp1); //g.DrawPath(Visuals.ExitConnectors, gp2); }
// Done! #region Draw // Done! #region Helpers // Done! private static string DetermineCoordinateFormat(WorkAreaState was, Vector v) { Vector s = was.Normalize ? v.Normalize(was.Width, was.Height, Math.Max(was.Width, was.Height)) : v; CultureInfo ci = CultureInfo.InvariantCulture; if (was.Normalize) { return(was.ShowZCoordinate ? string.Format(ci, "({0:0.000}|{1:0.000}|{2:0.000})", s.X, s.Y, s.Z) : string.Format(ci, "({0:0.000}|{1:0.000})", s.X, s.Y)); } return(was.ShowZCoordinate ? string.Format(ci, "({0}|{1}|{2})", s.X, s.Y, s.Z) : string.Format(ci, "({0}|{1})", s.X, s.Y)); }
// Done! public void DrawExitLabels(Graphics g, WorkAreaState was) { if (ConcreteNode.Exits.Count == 0) { return; } var gp = this.Visuals.ExitLabelPath; gp.Reset(); for (int i = 0; i < ConcreteNode.Exits.Count; ++i) { var f = this.Visuals.AnchorFont; var v = (Point)Vector.Transform(ConcreteNode.Exits[i].Location, was.Scale, was.DeltaX, was.DeltaY, was.DeltaZ); var coords = DetermineCoordinateFormat(was, ConcreteNode.Exits[i].Location); gp.AddString(coords, new FontFamily(f.Name), (int)f.Style, f.Size, (PointF)(v + OffSet2), StringFormat.GenericDefault); } g.DrawPath(this.Visuals.ExitLabel, gp); }
// Done! public void DrawAnchors(Graphics g, WorkAreaState wae) { if (ConcreteNode.Geometry.Count == 0) { return; } var gp = this.Visuals.AnchorPath; gp.Reset(); var size = new Size(Visuals.AnchorSize, Visuals.AnchorSize); for (int i = 0; i < ConcreteNode.Geometry.Count; ++i) { gp.AddRectangle(new Rectangle(Vector.Transform(ConcreteNode.Geometry[i], wae.Scale, wae.DeltaX, wae.DeltaY), size)); } g.FillPath(Visuals.AnchorFill, gp); g.DrawPath(Visuals.AnchorBorder, gp); }
// Done! public static void DrawSelectedGeometry(Graphics g, WorkAreaState was) { var ss = was.SelectedShape; DrawGeneralGeometry(g, was.SelectedShape, was, ss.Visuals.GeometryPath, ss.Visuals.GeometryNamePath, true); }
// Done! #region Instance Methods // Done! public void DrawGeometry(Graphics g, WorkAreaState was) { DrawGeneralGeometry(g, this, was, this.Visuals.GeometryPath, this.Visuals.GeometryNamePath, false); }