コード例 #1
0
        public void DrawHoverSample(Map map, DrawingGroup drawingArea, double zoom, Point pixelPosition)
        {
            bool isIntersecting = ImageUtils.Intersects(map.CurrentLayer.Value.Group, pixelPosition);

            if (!isIntersecting && !this.isDrawing)
            {
                return;
            }
            Point topLeft     = GeometryUtils.TopLeftPoint(this.pressPoint, pixelPosition);
            Point bottomRight = GeometryUtils.BottomRightPoint(this.pressPoint, pixelPosition);

            topLeft     = ImageUtils.BindPoint(map.CurrentLayer.Value.Group, topLeft);
            bottomRight = ImageUtils.BindPoint(map.CurrentLayer.Value.Group, bottomRight);

            Stack <Tile> tiles;

            if (!this.isDrawing)
            {
                tiles = DrawBrushModel(pixelPosition);
            }
            else
            {
                tiles = DrawTiles(topLeft, bottomRight);
            }

            if (this.IsErasing)
            {
                DrawAction action = new DrawAction(this.ToolName, tiles);
                tiles = map.DrawSample(action).Tiles;
            }

            using (DrawingContext context = drawingArea.Open())
            {
                if (this.isDrawing)
                {
                    if (isIntersecting)
                    {
                        bottomRight += new Vector(this.Brush.TileWidth.Value, this.Brush.TileHeight.Value);
                    }

                    double thickness = 4 / zoom;
                    this.AreaPen.Thickness = thickness > this.maxGridThickness ? thickness : this.maxGridThickness;
                    Rect rect = new Rect(topLeft, bottomRight);
                    context.DrawRectangle(this.AreaBrush, this.AreaPen, rect);
                }
                if (typeof(Layer).IsAssignableFrom(map.CurrentLayer.GetType()))
                {
                    Layer currentLayer = map.CurrentLayer.Value as Layer;
                    foreach (Tile tile in tiles)
                    {
                        if (tile.Bounds.IntersectsWith(currentLayer.GetBoundsExclusive()))
                        {
                            context.DrawDrawing(tile.Image.Value);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void DrawReleased(Map map, Point pixelPosition)
        {
            if (!ImageUtils.Intersects(map.CurrentLayer.Value.Group, pixelPosition))
            {
                pixelPosition = ImageUtils.BindPoint(map.CurrentLayer.Value.Group, pixelPosition);
            }
            Point        topLeft     = GeometryUtils.TopLeftPoint(this.pressPoint, pixelPosition);
            Point        bottomRight = GeometryUtils.BottomRightPoint(this.pressPoint, pixelPosition);
            Stack <Tile> tiles       = DrawTiles(topLeft, bottomRight);
            DrawAction   action      = new DrawAction(this.ToolName, tiles);

            map.Draw(action);
            this.isDrawing = false;
        }