Ejemplo n.º 1
0
        public ZoomControl(SharedSettings ss)
        {
            dZoomFactor = 100;
            settings    = ss;
            int temp = ss.getCanvasWidth();

            temp = temp < ss.getCanvasHeight() ? temp : ss.getCanvasHeight();


            if (temp > 100)
            {
                ZOOM_MIN = 1; //Prevent sub-pixel scaling
            }
            else if (temp > 10 && temp <= 100)
            {
                ZOOM_MIN = 10; //Prevent sub-pixel scaling
            }
            else
            {
                ZOOM_MIN = 100; //Prevent sub-pixel scaling
            }


            InitializeComponent();
            tbZoom.Text = "100";
        }
Ejemplo n.º 2
0
 public void init(SharedSettings s)
 {
     graphics = s.getActiveGraphics();
     width    = s.getCanvasWidth();
     height   = s.getCanvasHeight();
     settings = s;
     bInit    = true;
 }
Ejemplo n.º 3
0
        public void init(SharedSettings s)
        {
            graphics   = s.getActiveGraphics();
            width      = s.getCanvasWidth();
            height     = s.getCanvasHeight();
            settings   = s;
            bInit      = true;
            bMouseDown = false;
            updateColors();

            if (graphics != null)
            {
                graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
            }
        }
Ejemplo n.º 4
0
        public void updateInterfaceLayer()
        {
            Bitmap temp = new Bitmap(ss.getCanvasWidth(), ss.getCanvasHeight());

            ss.setSelectionPoint(new Point(ss.getSelectionPoint().X, ss.getSelectionPoint().Y));

            Pen p = new Pen(Color.Black);

            p.DashPattern = new float[] { 3.0F, 3.0F };
            p.DashCap     = System.Drawing.Drawing2D.DashCap.Flat;

            Graphics tmpGr = Graphics.FromImage(temp);

            tmpGr.DrawRectangle(p, new Rectangle(SharedSettings.pSelectionPoint, SharedSettings.sSelectionSize));
            ss.setInterfaceBitmap(temp);
        }
Ejemplo n.º 5
0
        public void init(SharedSettings s)
        {
            graphics   = s.getActiveGraphics();
            width      = s.getCanvasWidth();
            height     = s.getCanvasHeight();
            settings   = s;
            bInit      = true;
            bMouseDown = false;


            eraser       = new Pen(Color.Transparent);
            eraser.Width = settings.getBrushSize() / 2;
            eraser.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);

            if (graphics != null)
            {
                graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
            }
        }
Ejemplo n.º 6
0
        public void GridDraw(Graphics g)
        {
            Pen   p      = new Pen(Color.Black);
            int   yMod   = ss.getCanvasHeight();
            int   xMod   = ss.getCanvasWidth();
            int   width  = ss.getGridWitdh();
            int   zoom   = (int)ss.getDrawScale();
            float factor = (ss.getDrawScale());


            if (width > 0)
            {
                for (int y = 0; y < (int)(yMod * factor); y += (int)(width * factor))
                {
                    g.DrawLine(p, 0, y, (int)(yMod * factor), y);
                }
                for (int x = 0; x < (int)(xMod * factor); x += (int)(width * factor))
                {
                    g.DrawLine(p, x, 0, x, (int)(xMod * factor));
                }
            }
            else if (width == -1)
            {
                if (zoom >= 15)
                {
                    for (int y = 0; y < yMod; y += zoom)
                    {
                        g.DrawLine(p, 0, y, yMod, y);
                    }
                    for (int x = 0; x < xMod; x += zoom)
                    {
                        g.DrawLine(p, x, 0, x, xMod);
                    }
                }
                else if (zoom < 15 && zoom > 10)
                {
                    //TODO
                }
            }
        }
Ejemplo n.º 7
0
        public void init(SharedSettings s)
        {
            graphics   = s.getActiveGraphics();
            width      = s.getCanvasWidth();
            height     = s.getCanvasHeight();
            settings   = s;
            bInit      = true;
            bMouseDown = false;

            pOld = pNew = new Point(-1, -1);

            updateBrush();
            pen = new Pen(primaryColor, settings.getBrushSize() / 2);

            pen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);

            if (graphics != null)
            {
                graphics.SmoothingMode   = SmoothingMode.AntiAlias;
                graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
            }

            updateBrush();
        }
Ejemplo n.º 8
0
        public void updateCanvas(Graphics k)
        {
            if (ss.getBitmapLayerUpdate() != null)
            {
                lv.updateActiveLayer();
            }

            SharedSettings.bitmapCanvas = lv.getRender();
            Bitmap bit2 = (Bitmap)bg.Clone();

            Graphics temp = Graphics.FromImage(bit2);

            temp.DrawImage(SharedSettings.bitmapCanvas, 0, 0);

            Bitmap iitmp = ss.getImportImage();

            if (iitmp != null)
            {
                lv.addImportImage(iitmp);
            }

            p.Invalidate();

            //if (GCCurrentFrame == GCperFrames)
            //{
            //    System.GC.Collect(); //Prevent OutOfMemory Execptions
            //}
            //GCCurrentFrame += 1;
            //GCCurrentFrame %= 100;

            System.GC.Collect();

            p.Width  = (int)(ss.getDrawScale() * ss.getCanvasWidth());
            p.Height = (int)(ss.getDrawScale() * ss.getCanvasHeight());
            Rectangle source = new Rectangle(0, 0, bit2.Width, bit2.Height);
            Rectangle dest   = new Rectangle(0, 0, p.Width, p.Height);

            k.InterpolationMode = InterpolationMode.NearestNeighbor;
            k.PixelOffsetMode   = PixelOffsetMode.Half;

            if (ss.getRenderBitmapInterface() && ss.getInterfaceBitmap() != null)
            {
                Tools[6].updateInterfaceLayer();
                temp.DrawImage(ss.getInterfaceBitmap(), 0, 0);
            }

            if (ss.getActiveSelection() && ss.getBitmapSelectionArea() != null)
            {
                temp.DrawImage(ss.getBitmapSelectionArea(), ss.getSelectionPoint().X, ss.getSelectionPoint().Y);
            }

            if (ss.getFlattenSelection())
            {
                ss.setFlattenSelection(false);
                lv.updateActiveLayerSettings();
                foreach (ITool t in Tools)
                {
                    if (t is SelectionTool)
                    {
                        ((SelectionTool)t).Clean();
                    }
                }
            }

            handleWatermark(temp);

            k.DrawImage(bit2, dest, source, GraphicsUnit.Pixel);
            if (ss.getGridToggle())
            {
                lv.GridDraw(k);
            }

            bit2.Dispose();
            if (iitmp != null)
            {
                iitmp.Dispose();
            }
        }