Exemple #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (cds != null)
            {
                cds.repaint();
            }
            if (cdlg != null)
            {
                cdlg.update();
            }
            if (redraw_image)
            {
                pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmpDisplay);
                Render.renderColorPicker(img, _bhue);
                img.Dispose();
                redraw_image = false;
            }

            e.Graphics.DrawImage(bmpDisplay, 0, 0, Width, Height);
            e.Graphics.DrawEllipse(Pens.Black, mx - 5, my - 5, 10, 10);
            e.Graphics.DrawEllipse(Pens.White, mx - 4, my - 4, 8, 8);
            e.Graphics.DrawEllipse(Pens.Black, mx - 3, my - 3, 6, 6);

            PaintFunctions.PaintFrame(e.Graphics, 0, 0, Width, Height);
        }
Exemple #2
0
        public void paste()
        {
            if (!WindowsClipboard.IsImage)
            {
                return;
            }

            if (!bSelection)
            {
                return;
            }

            pr2.IRenderImage img = WindowsClipboard.getImage();

            int tx = img.Width / 16;
            int ty = img.Height / 16;

            Selection s = originalSelection;

            this.selection = originalSelection.copy();

            if (tx != s.width)
            {
                return;
            }
            if (ty != s.height)
            {
                return;
            }

            Operations.OperationManager om = Global.opManager;
            om.beginGroup("VSP Manager: Paste Tiledata");

            Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp);

            int y0 = s.y;
            int x0 = s.x;

            int[] arrImg = img.GetArray();
            for (int y = 0; y < s.height; y++)
            {
                for (int x = 0; x < s.width; x++)
                {
                    int t = (s.y + y) * TilesWide + s.x + x;
                    stdg.addRecord(t, Global.Misc.sliceIntArrayImage(arrImg, img.Width, x * 16, y * 16, 16, 16));
                }
            }

            om.add(stdg);
            om.endGroupExec();


            img.Dispose();
            Invalidate();
        }
Exemple #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (parent == null)
            {
                e.Graphics.FillRectangle(System.Drawing.Brushes.Black, e.ClipRectangle.Left, e.ClipRectangle.Right, e.ClipRectangle.Width, e.ClipRectangle.Height);
                return;
            }

            e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            Bitmap bmp = new Bitmap(TilesWide * 16, (TilesHigh + 1) * 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            pr2.IRenderImage qimg = pr2.RenderImage.LockBitmap(bmp);

            int row = 0, col = 0;

            for (int i = scrollOffset; i < parent.vsp.Tiles.Count; i++)
            {
                Render.render(qimg, col * 16, row * 16, parent.vsp.GetTile(i).Image, true);

                if (bSelection)
                {
                    int xx = col;
                    int yy = row + logicalRow;
                    if (selection.getPoint(xx, yy))
                    {
                        int tile = originalSelection.getPointIntegerValue(xx - selection.x + originalSelection.x, yy - selection.y + originalSelection.y, this);
                        if (tile != -1)
                        {
                            Render.render(qimg, col * 16, row * 16, parent.vsp.GetTile(tile).Image, true);
                        }
                    }
                }

                col++;
                if (col == TilesWide)
                {
                    col = 0;
                    row++;
                    if (row == TilesHigh)
                    {
                        break;
                    }
                }
            }

            //render the empty area
            while (row != TilesHigh + 1)
            {
                while (col != TilesWide)
                {
                    Render.renderColoredStippleTile(qimg, col * 16, row * 16, Render.makeColor(0, 0, 0), Render.makeColor(192, 192, 192));
                    col++;
                }
                col = 0;
                row++;
            }

            qimg.Dispose();
            e.Graphics.DrawImage(bmp, 0, 0, TilesWide * 16, (TilesHigh + 1) * 16);
            bmp.Dispose();


            e.Graphics.PixelOffsetMode = PixelOffsetMode.Default;

            if (bSelectingRect)
            {
                Point p0  = (new Point(Math.Min(mtx, mtx1), Math.Min(mty, mty1)));
                Point p1  = (new Point(Math.Max(mtx, mtx1), Math.Max(mty, mty1)));
                Pen   pen = new Pen(Color.White);
                pen.DashStyle = DashStyle.Dash;
                pen.Width     = 1;
                e.Graphics.DrawRectangle(pen, p0.X * 16, (p0.Y - logicalRow) * 16, (p1.X - p0.X) * 16, (p1.Y - p0.Y) * 16);
                pen.Dispose();
            }
            if (bSelection)
            {
                GraphicsPath gp = new GraphicsPath();

                selection.updateGraphicsPath(gp, 16, 0, -logicalRow * 16);
                Pen pen = new Pen(Color.FromArgb(128, 0, 0, 0));
                pen.Width     = 5;
                pen.DashStyle = DashStyle.Solid;
                e.Graphics.TranslateTransform(1.0f, 1.0f);
                e.Graphics.DrawPath(pen, gp);
                e.Graphics.TranslateTransform(-1.0f, -1.0f);

                pen.Color     = Color.White;
                pen.Width     = 1;
                pen.DashStyle = DashStyle.Dash;
                e.Graphics.DrawPath(pen, gp);
                pen.Dispose();
                gp.Dispose();
            }
        }
Exemple #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!live)
            {
                return;
            }

            int xScroll = hscrollbar.Value;
            int yScroll = vscrollbar.Value;

            Map currMap = ParentMap;

            pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp);
            img.Clear(unchecked ((int)0xFF000000));

            Map      mOld  = null;
            MapLayer mlOld = null;

            if (currMapTool is Plugins.IMapTweaker)
            {
                mOld  = currMapEventInfo.editedMap;
                mlOld = currMapEventInfo.editedLayer;
                currMapEventInfo.editedMap   = mOld.tileCopy();
                currMapEventInfo.editedLayer = currMapEventInfo.editedMap.findLayer(mlOld.name);
                currMap = currMapEventInfo.editedMap;
                currMapEventInfo.bTweak = true;
                ((Plugins.IMapTweaker)currMapTool).tweakMap(currMapEventInfo);
                currMapEventInfo.bTweak = false;
            }

            bool bottomlayer = false;
            bool blayerfound = false;

            for (int c = 0; c < ParentMap.RenderManager.Layers.Count; c++)
            {
                MapLayer mlCurr = (MapLayer)ParentMap.RenderManager.Layers[c];

                if (!blayerfound && mlCurr.type == LayerType.Tile)
                {
                    bottomlayer = true;
                    blayerfound = true;
                }

                if (!ParentMap.IsBrush)
                {
                    if (!ParentMap.UIState[c].bRender)
                    {
                        continue;
                    }
                }

                if (mlCurr.type == LayerType.Entity)
                {
                    renderEntities(img, mlCurr, xScroll, yScroll);
                }

                if (mlCurr.type == LayerType.Tile || mlCurr.type == LayerType.Obs || mlCurr.type == LayerType.Zone)
                {
                    if (bDragging && currMapEventInfo.editedLayerIndex == c && currMapTool is Plugins.IMapPainter)
                    {
                        //if(Global.editedLayer == mlCurr && currMapTool is Plugins.IMapPainter) {
                        MapLayer mlOld2 = currMapEventInfo.editedLayer;
                        MapLayer mlTemp = mlOld2.copy();
                        currMapEventInfo.editedLayer = mlTemp;
                        currMapEventInfo.bTweak      = true;
                        ((Plugins.IMapPainter)currMapTool).tweakLayer(currMapEventInfo);
                        currMapEventInfo.editedLayer = mlOld2;
                        currMapEventInfo.bTweak      = false;
                        renderLayer(img, mlTemp, xScroll, yScroll, bottomlayer);

                        ((Plugins.IMapPainter)currMapTool).paintMap(currMapEventInfo, img);
                    }
                    else
                    {
                        renderLayer(img, mlCurr, xScroll, yScroll, bottomlayer);
                    }
                    if (bottomlayer)
                    {
                        bottomlayer = false;
                    }
                }
            }

            if (currMapTool is Plugins.IMapTweaker)
            {
                currMapEventInfo.editedMap   = mOld;
                currMapEventInfo.editedLayer = mlOld;
            }

            img.Dispose();
            e.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
            e.Graphics.InterpolationMode  = InterpolationMode.NearestNeighbor;
            e.Graphics.CompositingMode    = CompositingMode.SourceCopy;
            e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;


            e.Graphics.DrawImage(bmp, 0, 0, bmp.Width * ZoomLevel, bmp.Height * ZoomLevel);



            if (!bDragging && bMouseContained)
            {
                Pen p = new Pen(Color.White, 2.0f);

                Plugins.MapCursorLocation mcl = new winmaped2.Plugins.MapCursorLocation();
                setupMapCursorLocation(ref mcl, cursorX, cursorY);

                int dx = (mcl.tx * 16 - xScroll);
                int dy = (mcl.ty * 16 - yScroll);

                //				if(dx != last_cursorX || dy != last_cursorY)
                //if (cursorX > 0 && cursorX < Size.Width && cursorY>0 && cursorY<Size.Height)
                e.Graphics.DrawRectangle(p, dx * ZoomLevel, dy * ZoomLevel, 16 * ZoomLevel, 16 * ZoomLevel);

                //				last_cursorX = dx;
                //				last_cursorY = dy;
            }

            if (currMapTool is Plugins.IMapPainter)
            {
                ((Plugins.IMapPainter)currMapTool).paintWindow(currMapEventInfo, e.Graphics);
            }
        }