Пример #1
0
        public void OnPaintInView(Graphics viewGraphics, CanvasViewport viewViewport, IConvertWorldView convertWorldView)
        {
            int selectedTileIndex = @interface.SelectedTileIndex;

            if (@interface.SelectedTileIndex == -1)
            {
                return;
            }
            int   nRows           = @interface.TilesModel.TileRows;
            int   nColumns        = @interface.TilesModel.TileColumns;
            int   tileWidth       = @interface.TilesModel.TileWidth;
            int   tileHeight      = @interface.TilesModel.TileHeight;
            var   worldMatrix     = @interface.TilesModel.Matrix;
            Point prepareLocation = @interface.TilePrepareAddLocation;

            for (int rIndex = 0; rIndex < nRows; rIndex++)
            {
                for (int cIndex = 0; cIndex < nColumns; cIndex++)
                {
                    if (worldMatrix[rIndex, cIndex] == @interface.SelectedTileIndex)
                    {
                        Rectangle locationRect = new Rectangle(cIndex * tileWidth, rIndex * tileHeight, tileWidth, tileHeight);
                        locationRect = convertWorldView.GetViewRect(locationRect);
                        viewGraphics.DrawRectangle(new Pen(@interface.SelectedTileInWorldColor, 2),
                                                   locationRect);
                        viewGraphics.FillRectangle(new SolidBrush(Color.FromArgb(50, @interface.SelectedTileInWorldColor.R, @interface.SelectedTileInWorldColor.G, @interface.SelectedTileInWorldColor.B)), locationRect);
                    }
                }
            }

            if (@interface.CanAddTile)
            {
                int rIndex = prepareLocation.Y / tileHeight;
                int cIndex = prepareLocation.X / tileWidth;

                Rectangle locationRect = new Rectangle(cIndex * tileWidth, rIndex * tileHeight, tileWidth, tileHeight);
                locationRect = convertWorldView.GetViewRect(locationRect);
                viewGraphics.DrawRectangle(new Pen(@interface.SelectedTileInWorldColor, 2),
                                           locationRect);

                var cropRect = new Rectangle(tileWidth * (selectedTileIndex % @interface.TilesModel.TilesheetColumns),
                                             tileHeight * (selectedTileIndex / @interface.TilesModel.TilesheetColumns), tileWidth, tileHeight
                                             );

                viewGraphics.DrawImageFromOtherImage(@interface.TilesModel.Tilesheet, cropRect, locationRect);
            }
        }
        public void OnPaintInView(Graphics viewGraphics, CanvasViewport viewViewport, IConvertWorldView convertWorldView)
        {
            if ([email protected])
            {
                return;
            }
            Rectangle locationRect = convertWorldView.GetViewRect(@interface.SelectingRect);

            viewGraphics.DrawRectangle(new Pen(@interface.SelectingColorBorder, 1), locationRect);
            viewGraphics.FillRectangle(new SolidBrush(@interface.SelectingBackColor), locationRect);
        }
Пример #3
0
        private void DrawQuadnode(QuadNode node, Graphics viewGraphics, IConvertWorldView convertWorldView)
        {
            Rectangle locationRect = new Rectangle(node.X, node.Y, node.Width, node.Height);

            locationRect = convertWorldView.GetViewRect(locationRect);
            viewGraphics.DrawRectangle(new Pen(@interface.QuadtreeBorderColor, 2), locationRect);
            if (node.TL != null)
            {
                DrawQuadnode(node.TL, viewGraphics, convertWorldView);
                DrawQuadnode(node.TR, viewGraphics, convertWorldView);
                DrawQuadnode(node.BL, viewGraphics, convertWorldView);
                DrawQuadnode(node.BR, viewGraphics, convertWorldView);
            }
        }
 public void OnPaintInView(Graphics viewGraphics, CanvasViewport viewViewport, IConvertWorldView convertWorldView)
 {
     if (@interface.FocusedObjectCategory != null)
     {
         if (@interface.FocusedObjectCategory.TreeViewObject.TreeViewObjectType == Controls.TreeViewControl.TreeViewObjectType.CategoryRectangle)
         {
             return;
         }
         RectangleF locationRect = new RectangleF(@interface.FocusedObjectCategoryLocation,
                                                  @interface.FocusedObjectCategory.ObjectCategoryImage.Size
                                                  );
         locationRect = convertWorldView.GetViewRect(locationRect);
         viewGraphics.DrawImageFromOtherImage(@interface.FocusedObjectCategory.ObjectCategoryImage,
                                              new RectangleF(Point.Empty, @interface.FocusedObjectCategory.ObjectCategoryImage.Size),
                                              locationRect);
     }
 }
Пример #5
0
        public void OnPaintInView(Graphics viewGraphics, CanvasViewport viewViewport, IConvertWorldView convertWorldView)
        {
            if ([email protected])
            {
                return;
            }
            var tileRenderParent = @interface.TilesModel;
            int tileWidth        = tileRenderParent.TileWidth;
            int tileHeight       = tileRenderParent.TileHeight;
            int tileRows         = tileRenderParent.TileRows;
            int tileColumns      = tileRenderParent.TileColumns;
            int tileSheetColumns = tileRenderParent.TilesheetColumns;

            viewGraphics.FillRectangle(new SolidBrush(Color.FromArgb(50, 30, 30, 30)),
                                       viewGraphics.ClipBounds);

            int rowIndex = @interface.SelectTileFromWorldLocation.Y / @interface.TileHeight;
            int colIndex = @interface.SelectTileFromWorldLocation.X / @interface.TileWidth;

            if (rowIndex < 0 || rowIndex >= tileRenderParent.TileRows ||
                colIndex < 0 || colIndex >= tileRenderParent.TileColumns
                )
            {
                return;
            }

            int        tileIndex  = @interface.TilesModel.Matrix[rowIndex, colIndex];
            RectangleF cropedRect = new RectangleF((tileIndex % tileSheetColumns) * tileWidth,
                                                   (tileIndex / tileSheetColumns) * tileHeight, tileWidth, tileHeight
                                                   );

            var viewRect = new Rectangle(@interface.TileWidth * (@interface.SelectTileFromWorldLocation.X / @interface.TileWidth),
                                         @interface.TileHeight * (@interface.SelectTileFromWorldLocation.Y / @interface.TileHeight),
                                         @interface.TileWidth,
                                         @interface.TileHeight);

            viewRect = convertWorldView.GetViewRect(viewRect);

            viewGraphics.DrawImageFromOtherImage(tileRenderParent.Tilesheet
                                                 , cropedRect, viewRect);
        }