Exemplo n.º 1
0
        //private void DrawLine(DrawingContext drawingContext, CS2dLine line)
        //{
        //    Point p0 = TransformXY(line.StartPoint);
        //    Point p1 = TransformXY(line.EndPoint);

        //    Pen stroke = line.Stroke == null ? null : new Pen(line.Stroke, line.Thickness);

        //    drawingContext.DrawLine(stroke, p0, p1);

        //}

        private void DrawLine(DrawingContext drawingContext, CS2dLine element)
        {
            Point p0 = TransformXY(new Point(XLowerRange, element.Value.GetY(XLowerRange)));
            Point p1 = TransformXY(new Point(XUpperRange, element.Value.GetY(XUpperRange)));

            Pen stroke = element.Stroke == null ? null : new Pen(element.Stroke, element.Thickness);

            drawingContext.DrawLine(stroke, p0, p1);
        }
Exemplo n.º 2
0
        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;
        }