private void DrawPoint(DrawingContext drawingContext, CS2dPoint element) { Point p = TransformXY(new Point(element.X, element.Y)); double r = element.Size; Pen pen = element.Stroke == null ? null : new Pen(element.Stroke, 1); Brush brush = element.FillBrush; drawingContext.DrawEllipse(brush, pen, p, r, r); }
private void UpdateElements() { if (_elements == null) { return; } double xMin = double.MaxValue; double xMax = double.MinValue; double yMin = double.MaxValue; double yMax = double.MinValue; foreach (CS2dShape element in _elements) { if (element is CS2dPoint) { CS2dPoint t = element as CS2dPoint; if (xMin > t.X) { xMin = t.X; } if (xMax < t.X) { xMax = t.X; } if (yMin > t.Y) { yMin = t.Y; } if (yMax < t.Y) { yMax = t.Y; } } else if (element is CS2dPath) { foreach (Coast.Math.Vector2 v in ((CS2dPath)element).Segments) { if (xMin > v.X) { xMin = v.X; } if (xMax < v.X) { xMax = v.X; } if (yMin > v.Y) { yMin = v.Y; } if (yMax < v.Y) { yMax = v.Y; } } } else if (element is CS2dLine) { CS2dLine t = element as CS2dLine; if (xMin > t.StartPoint.X) { xMin = t.StartPoint.X; } if (xMax < t.StartPoint.X) { xMax = t.StartPoint.X; } if (yMin > t.StartPoint.Y) { yMin = t.StartPoint.Y; } if (yMax < t.StartPoint.Y) { yMax = t.StartPoint.Y; } if (xMin > t.EndPoint.X) { xMin = t.EndPoint.X; } if (xMax < t.EndPoint.X) { xMax = t.EndPoint.X; } if (yMin > t.EndPoint.Y) { yMin = t.EndPoint.Y; } if (yMax < t.EndPoint.Y) { yMax = t.EndPoint.Y; } } else if (element is CS2dCircle) { //CS2dCircle t = element as CS2dCircle; //if (xMin > t.CenterX - t.Radius) xMin = t.CenterX - t.Radius; //if (xMax < t.CenterX + t.Radius) xMax = t.CenterX + t.Radius; //if (yMin > t.CenterX - t.Radius) yMin = t.CenterX - t.Radius; //if (yMax < t.CenterX + t.Radius) yMax = t.CenterX + t.Radius; } } if (xMax - xMin <= 0) { Errored = true; } if (yMax - yMin <= 0) { Errored = true; } DisireXLowerRange = xMin - (xMax - xMin) * RangeExtensionRate; DisireXUpperRange = xMax + (xMax - xMin) * RangeExtensionRate; DisireYLowerRange = yMin - (yMax - yMin) * RangeExtensionRate; DisireYUpperRange = yMax + (yMax - yMin) * RangeExtensionRate; }