示例#1
0
 public IBounds Create(ICanvas canvas, IEllipse ellipse)
 {
     return new EllipseBounds(
         _nativeConverter,
         _canvasFactory,
         canvas,
         ellipse,
         0.0,
         7.5);
 }
示例#2
0
        public EllipseBounds(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            ICanvas canvas,
            IEllipse ellipse,
            double size,
            double offset)
        {
            _ellipse = ellipse;
            _size = size;
            _offset = offset;
            _canvas = canvas;

            _hitResult = HitResult.None;

            InitBounds(nativeConverter, canvasFactory);
        }
示例#3
0
文件: Wpf.cs 项目: 15831944/Sheet
 public void ToggleFill(IEllipse ellipse)
 {
     (ellipse.Native as Ellipse).Fill = (ellipse.Native as Ellipse).Fill == WpfBlockFactory.TransparentBrush ? WpfBlockFactory.NormalBrush : WpfBlockFactory.TransparentBrush;
 }
示例#4
0
文件: Wpf.cs 项目: 15831944/Sheet
 public ItemColor GetStroke(IEllipse ellipse)
 {
     return(GetItemColor((ellipse.Native as Ellipse).Stroke));
 }
示例#5
0
 private void Reset(IEllipse ellipse)
 {
     ellipse.Id = 0;
     Reset(ellipse.Point1);
     Reset(ellipse.Point2);
 }
示例#6
0
文件: Wpf.cs 项目: 15831944/Sheet
 public void Select(IEllipse ellipse)
 {
     (ellipse.Native as Ellipse).Stroke = WpfBlockFactory.SelectedBrush;
     (ellipse.Native as Ellipse).Fill   = (ellipse.Native as Ellipse).Fill == WpfBlockFactory.TransparentBrush ? WpfBlockFactory.TransparentBrush : WpfBlockFactory.SelectedBrush;
 }
示例#7
0
 public Ellipse1(IEllipse ell)
 {
     ellipse = ell;
 }
示例#8
0
 private void Process(IEllipse ellipse)
 {
     ellipse.Id = NextId();
     Process(ellipse.Point1);
     Process(ellipse.Point2);
 }
示例#9
0
        protected override void InitializationShapes()
        {
            RectangleTextCode = new RectangleText(
                new Size(400, 400),
                Brushes.Red,
                new Text()
            {
                Point    = new Point(LeftBorder.X + 350, LeftBorder.Y + 50),
                TextLine = UpdateTextCode()
            }
                );

            BeginEllipse = new Ellipse(
                new Point(LeftBorder.X, LeftBorder.Y + 25),
                new Size(200, 30),
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, LeftBorder.Y + 25), TextLine = "begin"
            }
                );

            InitializationIndex = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, BeginEllipse.GetDown().Y + 25),
                new Point(LeftBorder.X + 200, BeginEllipse.GetDown().Y + 25),
                new Point(LeftBorder.X + 200, BeginEllipse.GetDown().Y + 75),
                new Point(LeftBorder.X, BeginEllipse.GetDown().Y + 75)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, BeginEllipse.GetDown().Y + 30), TextLine = $"i := {StartCycleIndex}"
            }
                );

            ShapeSum = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, InitializationIndex.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, InitializationIndex.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, InitializationIndex.GetDown().Y + 100),
                new Point(LeftBorder.X, InitializationIndex.GetDown().Y + 100)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, InitializationIndex.GetDown().Y + 55), TextLine = "sum += i"
            }
                );

            ShapeIndex = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, ShapeSum.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, ShapeSum.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, ShapeSum.GetDown().Y + 100),
                new Point(LeftBorder.X, ShapeSum.GetDown().Y + 100)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, ShapeSum.GetDown().Y + 55), TextLine = "i += 1"
            }
                );

            ShapeСondition = new ClosedLine(
                new[]
            {
                new Point(ShapeIndex.GetLeft().X, ShapeIndex.GetLeft().Y + 75),
                new Point(ShapeIndex.GetDown().X, ShapeIndex.GetDown().Y + 25),
                new Point(ShapeIndex.GetRight().X, ShapeIndex.GetRight().Y + 75),
                new Point(ShapeIndex.GetDown().X, ShapeIndex.GetDown().Y + 75)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 60, ShapeIndex.GetDown().Y + 30), TextLine = $"i < {EndCycleIndex}"
            }
                );

            Result = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, ShapeСondition.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, ShapeСondition.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, ShapeСondition.GetDown().Y + 100),
                new Point(LeftBorder.X, ShapeСondition.GetDown().Y + 100)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, ShapeСondition.GetDown().Y + 55), TextLine = "sum"
            }
                );

            EndEllipse = new Ellipse(
                new Point(LeftBorder.X, Result.GetDown().Y + 50),
                new Size(200, 30),
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, Result.GetDown().Y + 50), TextLine = "end"
            }
                );
        }
        /*
         * function convertWGS84toOSGB36(p1) {
         * var p2 = convert(p1, e.WGS84, h.WGS84toOSGB36, e.Airy1830);
         * return p2;
         * }
         */

        public static LatLong convert(LatLong p1, IEllipse e1, IHelmert t, IEllipse e2)
        {
            // -- convert polar to cartesian coordinates (using ellipse 1)

            //Conver to radians
            p1.Lat = p1.Lat * Math.PI / 180;
            p1.Lon = p1.Lon * Math.PI / 180;

            double a = e1.a;
            double b = e1.b;

            double sinPhi    = Math.Sin(p1.Lat);
            double cosPhi    = Math.Cos(p1.Lat);
            double sinLambda = Math.Sin(p1.Lon);
            double cosLambda = Math.Cos(p1.Lon);
            double H         = p1.Height;

            double eSq = (a * a - b * b) / (a * a);
            double nu  = a / Math.Sqrt(1 - eSq * sinPhi * sinPhi);

            double x1 = (nu + H) * cosPhi * cosLambda;
            double y1 = (nu + H) * cosPhi * sinLambda;
            double z1 = ((1 - eSq) * nu + H) * sinPhi;


            // -- apply helmert transform using appropriate params

            double tx = t.tx;
            double ty = t.ty;
            double tz = t.tz;
            double rx = t.rx / 3600 * Math.PI / 180;  // normalise seconds to radians
            double ry = t.ry / 3600 * Math.PI / 180;
            double rz = t.rz / 3600 * Math.PI / 180;
            double s1 = t.s / 1e6 + 1;              // normalise ppm to (s+1)

            // apply transform
            double x2 = tx + x1 * s1 - y1 * rz + z1 * ry;
            double y2 = ty + x1 * rz + y1 * s1 - z1 * rx;
            double z2 = tz - x1 * ry + y1 * rx + z1 * s1;


            // -- convert cartesian to polar coordinates (using ellipse 2)

            a = e2.a;
            b = e2.b;
            double precision = 4 / a;  // results accurate to around 4 metres

            eSq = (a * a - b * b) / (a * a);
            double p = Math.Sqrt(x2 * x2 + y2 * y2);
            double phi = Math.Atan2(z2, p * (1 - eSq)), phiP = 2 * Math.PI;

            while (Math.Abs(phi - phiP) > precision)
            {
                nu   = a / Math.Sqrt(1 - eSq * Math.Sin(phi) * Math.Sin(phi));
                phiP = phi;
                phi  = Math.Atan2(z2 + eSq * nu * Math.Sin(phi), p);
            }
            double lambda = Math.Atan2(y2, x2);

            H = p / Math.Cos(phi) - nu;

            return(new LatLong(phi * 180 / Math.PI, lambda * 180 / Math.PI, H));
        }
示例#11
0
        private void DrawEllipse(XGraphics gfx, IEllipse ellipse)
        {
            double x = Math.Min(ellipse.Point1.X, ellipse.Point2.X);
            double y = Math.Min(ellipse.Point1.Y, ellipse.Point2.Y);
            double width = Math.Abs(ellipse.Point2.X - ellipse.Point1.X);
            double height = Math.Abs(ellipse.Point2.Y - ellipse.Point1.Y);

            if (ellipse.Fill.A > 0x00)
            {
                var pen = new XPen(
                    ToXColor(ellipse.Stroke),
                    X(ellipse.StrokeThickness));

                var brush = new XSolidBrush(ToXColor(ellipse.Fill));

                gfx.DrawEllipse(
                    pen,
                    brush,
                    X(x),
                    Y(y),
                    X(width),
                    Y(height));
            }
            else
            {
                var pen = new XPen(
                    ToXColor(ellipse.Stroke),
                    X(ellipse.StrokeThickness));

                gfx.DrawEllipse(
                    pen,
                    X(x),
                    Y(y),
                    X(width),
                    Y(height));
            }
        }
示例#12
0
文件: Wpf.cs 项目: monocraft/RxCanvas
        public WpfEllipse(IEllipse ellipse)
        {
            _xellipse = ellipse;

            _strokeBrush = new SolidColorBrush(_xellipse.Stroke.ToNativeColor());
            _strokeBrush.Freeze();
            _fillBrush = new SolidColorBrush(_xellipse.Fill.ToNativeColor());
            _fillBrush.Freeze();

            _nellipse = new Ellipse()
            {
                Stroke = _strokeBrush,
                StrokeThickness = ellipse.StrokeThickness,
                Fill = _fillBrush
            };

            Update();

            Native = _nellipse;
        }
示例#13
0
文件: Wpf.cs 项目: monocraft/RxCanvas
 public IEllipse Convert(IEllipse ellipse)
 {
     return new WpfEllipse(ellipse);
 }
示例#14
0
 public IEllipse Convert(IEllipse ellipse)
 {
     return ellipse;
 }
示例#15
0
        public XEllipseEditor(
            INativeConverter nativeConverter,
            ICanvasFactory canvasFactory,
            IBoundsFactory boundsFactory,
            ICanvas canvas)
        {
            _canvas = canvas;

            Name = "Ellipse";
            Key = "E";
            Modifiers = "";

            var moves = _canvas.Moves.Where(_ => _canvas.IsCaptured);
            var drags = Observable.Merge(_canvas.Downs, _canvas.Ups, moves);

            _downs = _canvas.Downs.Where(_ => IsEnabled).Subscribe(p =>
            {
                if (_canvas.IsCaptured)
                {
                    //_xellipse.Point2.X = p.X;
                    //_xellipse.Point2.Y = p.Y;
                    //_nellipse.Point2 = _xellipse.Point2;
#if CONNECTORS
                    ConnectPoint2(p);
#endif
                    _nellipse.Bounds.Hide();
                    _canvas.Render(null);
                    _state = State.None;
                    _canvas.ReleaseCapture();
                }
                else
                {
                    _xellipse = canvasFactory.CreateEllipse();
                    _xellipse.Point1.X = p.X;
                    _xellipse.Point1.Y = p.Y;
                    _xellipse.Point2.X = p.X;
                    _xellipse.Point2.Y = p.Y;
                    _nellipse = nativeConverter.Convert(_xellipse);
                    _canvas.History.Snapshot(_canvas);
#if CONNECTORS
                    ConnectPoint1(p);
#endif
                    _canvas.Add(_nellipse);
                    _nellipse.Bounds = boundsFactory.Create(_canvas, _nellipse);
                    _nellipse.Bounds.Update();
                    _nellipse.Bounds.Show();
                    _canvas.Render(null);
                    _canvas.Capture();
                    _state = State.BottomRight;
                }
            });

            _drags = drags.Where(_ => IsEnabled).Subscribe(p =>
            {
                if (_state == State.BottomRight)
                {
                    _xellipse.Point2.X = p.X;
                    _xellipse.Point2.Y = p.Y;
                    _nellipse.Point2 = _xellipse.Point2;
                    _nellipse.Bounds.Update();
                    _canvas.Render(null);
                }
            });
        }
示例#16
0
 private void Write(IEllipse ellipse)
 {
     Write(NativeType.Ellipse);
     _writer.Write(ellipse.Id);
     Write(ellipse.Point1);
     Write(ellipse.Point2);
     Write(ellipse.Stroke);
     _writer.Write(ellipse.StrokeThickness);
     Write(ellipse.Fill);
 }
示例#17
0
文件: Wpf.cs 项目: 15831944/Sheet
 public bool IsSelected(IEllipse ellipse)
 {
     return((ellipse.Native as Ellipse).Stroke != WpfBlockFactory.SelectedBrush);
 }
示例#18
0
 private void Reset(IEllipse ellipse)
 {
     ellipse.Id = 0;
     Reset(ellipse.Point1);
     Reset(ellipse.Point2);
 }
示例#19
0
 private void Process(IEllipse ellipse)
 {
     ellipse.Id = NextId();
     Process(ellipse.Point1);
     Process(ellipse.Point2);
 }