Пример #1
0
        public ImageCache(Viewport viewport, ShapeDrawer shapeDrawer, Filler filler, Page page, int width, int height)
        {
            _viewport = viewport;
            _shapeDrawer = shapeDrawer;
            _filler = filler;
            _page = page;

            _page.ImageBuffer = new Bitmap(width, height);
            using (var graph = Graphics.FromImage(_page.ImageBuffer))
            {
                graph.Clear(Color.White);
            }

            _page.AddedShape += Page_AddedShape;
        }
Пример #2
0
        public void LoadShape(ShapeBase shape, Viewport viewport)
        {
            _shape = shape;
            _viewport = viewport;

            foreach (var ctrl in _controlPoints)
            {
                ctrl.LocationChanged -= Control_LocationChanged;
            }
            _controlPoints.Clear();

            foreach (var v in _shape.Vertices)
            {
                var control = new ControlPoint((int)Math.Round(v.X), (int)Math.Round(v.Y), null);
                control.LocationChanged += Control_LocationChanged;
                control.Tag = v;
                control.Cursor = Cursors.SizeAll;
                _controlPoints.Add(control);
            }

            if (_shape.GetShapeType() == ShapeType.Ellipse)
            {
                _controlPoints.Add(new ControlPoint((int) Math.Round(_shape.Location.X + _shape.Size.Width/2),
                    (int) Math.Round(_shape.Location.Y), null));

                _controlPoints.Add(new ControlPoint((int)Math.Round(_shape.Location.X + _shape.Size.Width),
                    (int)Math.Round(_shape.Location.Y + _shape.Size.Height/2), null));

                _controlPoints.Add(new ControlPoint((int)Math.Round(_shape.Location.X + _shape.Size.Width/2),
                    (int)Math.Round(_shape.Location.Y + _shape.Size.Height), null));

                _controlPoints.Add(new ControlPoint((int)Math.Round(_shape.Location.X),
                    (int)Math.Round(_shape.Location.Y + _shape.Size.Height/2), null));

            }
        }