示例#1
0
        private void ToolModeZoom(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (zoom == 1)
                {
                    if (!setZoomRect)
                    {
                        setZoomRect = true;
                        zoomRectx   = e.X;
                        zoomRecty   = e.Y;
                        zoomRecth   = zoomRectw = 0;
                    }
                    else
                    {
                        Graphics g = Graphics.FromImage(pictureBox.Image);
                        if (zoomRecth != 0 || zoomRectw != 0)
                        {
                            XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, zoomRectx, zoomRecty, zoomRectx + zoomRectw, zoomRecty + zoomRecth);
                        }
                        zoomRectw = e.X - zoomRectx;
                        zoomRecth = e.Y - zoomRecty;
                        XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, zoomRectx, zoomRecty, zoomRectx + zoomRectw, zoomRecty + zoomRecth);
                        pictureBox.Refresh();
                    }
                }
            }
            else
            if (e.Button == MouseButtons.Right)
            {
                if (!unZoom)
                {
                    unZoom = true;
                    if (zoom >= 2)
                    {
                        zoom >>= 1;
                    }

                    DoZoom();
                }
            }
            else
            {
                unZoom = false;
                if (setZoomRect)
                {
                    setZoomRect = false;
                    if (zoomRectw != 0 && zoomRecth != 0)
                    {
                        Graphics g = Graphics.FromImage(pictureBox.Image);
                        XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, zoomRectx, zoomRecty, zoomRectx + zoomRectw, zoomRecty + zoomRecth);
                        zoom = Math.Max(1, Math.Min(Math.Abs(768 / zoomRectw), Math.Abs(544 / zoomRecth)) & 0x7E);
                        DoZoom();
                    }
                }
            }
        }
示例#2
0
        private void pictureBox_MouseLeave(object sender, EventArgs e)
        {
            if (fenetreCapture != null)
            {
                int      sprSize = fenetreCapture.CaptSize << 5;
                Graphics g       = Graphics.FromImage(pictureBox.Image);
                if (captx > -1 && capty > -1)
                {
                    XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, captx, capty, captx + sprSize, capty + sprSize);
                }

                pictureBox.Refresh();
                captx = -1;
                capty = -1;
            }
        }
示例#3
0
        private void CaptureSprites(MouseEventArgs e)
        {
            int      sprSize = fenetreCapture.CaptSize << 5;
            Graphics g       = Graphics.FromImage(pictureBox.Image);

            if (captx > -1 && capty > -1)
            {
                XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, captx, capty, captx + sprSize, capty + sprSize);
                if (e.Button == MouseButtons.Left)
                {
                    fenetreCapture.SetCapture(BmpLock, captx, capty);
                }
            }
            captx = e.X & 0xFFE;
            capty = e.Y & 0xFFE;
            XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, captx, capty, captx + sprSize, capty + sprSize);
            pictureBox.Refresh();
        }
示例#4
0
        private void ToolModeCopy(MouseEventArgs e)
        {
            int yReel = ((e.Y / zoom) & 0xFFE) * zoom;
            int tx    = BitmapCpc.CalcTx(yReel);
            int xReel = ((e.X / zoom) & -tx) * zoom;

            if (e.Button == MouseButtons.Left && xReel >= 0 && yReel >= 0)
            {
                if (imgMotif != null)
                {
                    for (int y = 0; y < imgMotif.Height; y += 2)
                    {
                        tx = BitmapCpc.CalcTx(y + yReel);
                        for (int x = 0; x < imgMotif.Width; x += tx)
                        {
                            if (x + xReel < BitmapCpc.NbCol << 3 && y + yReel < BitmapCpc.NbLig << 1)
                            {
                                int c = imgMotif.GetPixel(x, y);
                                undo.MemoUndoRedo(x + xReel, y + yReel, BmpLock.GetPixel(x + xReel, y + yReel), c, doDraw);
                                BmpLock.SetHorLineDouble(x + xReel, y + yReel, tx, c);
                                doDraw = true;
                            }
                        }
                    }
                    imgCopy.CopyBits(BmpLock);
                    Render();
                }
                else
                {
                    if (!setCopyRect)
                    {
                        setCopyRect = true;
                        copyRectx   = xReel;
                        copyRecty   = yReel;
                        copyRecth   = copyRectw = 0;
                    }
                    else
                    {
                        Graphics g = Graphics.FromImage(pictureBox.Image);
                        if (copyRecth != 0 || copyRectw != 0)
                        {
                            XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, copyRectx, copyRecty, copyRectx + copyRectw, copyRecty + copyRecth);
                        }
                        copyRectw = xReel - copyRectx;
                        copyRecth = yReel - copyRecty;
                        XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, copyRectx, copyRecty, copyRectx + copyRectw, copyRecty + copyRecth);
                        pictureBox.Refresh();
                    }
                }
            }
            else
            {
                if (setCopyRect)
                {
                    setCopyRect = false;
                    if (copyRectw != 0 && copyRecth != 0)
                    {
                        Graphics g = Graphics.FromImage(pictureBox.Image);
                        XorDrawing.DrawXorRectangle(g, (Bitmap)pictureBox.Image, copyRectx, copyRecty, copyRectx + copyRectw, copyRecty + copyRecth);
                        imgMotif = new DirectBitmap(Math.Abs(copyRectw / zoom), Math.Abs(copyRecth / zoom));
                        for (int x = 0; x < imgMotif.Width; x++)
                        {
                            for (int y = 0; y < imgMotif.Height; y++)
                            {
                                imgMotif.SetPixel(x, y, BmpLock.GetPixel(offsetX + x + copyRectx / zoom, offsetY + y + copyRecty / zoom));
                            }
                        }

                        if (zoom != 1)
                        {
                            zoom = 1;
                            DoZoom();
                        }
                        imgCopy          = new DirectBitmap(BmpLock.Width, BmpLock.Height);
                        pictureBox.Image = imgCopy.Bitmap;
                    }
                }
                if (doDraw)
                {
                    doDraw = false;
                    undo.EndUndoRedo();
                }
                DrawCopy(e);
                pictureBox.Refresh();
            }
        }