示例#1
0
        public void onMouseUp(object sender, MouseEventArgs e)
        {
            pOld.X = 0;
            pOld.Y = 0;
            pNew.X = 0;
            pNew.Y = 0;

            p2 = new Point(e.X, e.Y);

            if (p1.X == p2.X || p1.Y == p2.Y)
            {
                SharedSettings.flattenSelection();
            }
            else
            {
                if (!ss.getActiveSelection())
                {
                    int tlX = p1.X, tlY = p1.Y;
                    int width  = Math.Abs(p1.X - p2.X);
                    int height = Math.Abs(p1.Y - p2.Y);

                    if (p2.X < p1.X)
                    {
                        tlX = p2.X;
                    }
                    if (p2.Y < p1.Y)
                    {
                        tlY = p2.Y;
                    }

                    tlX    = tlX < 0 ? 0 : tlX;
                    tlY    = tlY < 0 ? 0 : tlY;
                    width  = width + tlX <= SharedSettings.iCanvasWidth ? width : SharedSettings.iCanvasWidth - tlX;
                    height = height + tlY <= SharedSettings.iCanvasHeight ? height : SharedSettings.iCanvasHeight - tlY;

                    Point loc = new Point(tlX, tlY);
                    Size  sze = new Size(width, height);
                    ss.setSelectionPoint(loc);
                    ss.setSelectionSize(sze);

                    updateInterfaceLayer();

                    //Get selected area data
                    bEdit = ss.getBitmapCurrentLayer(true).Clone(new Rectangle(loc, sze), ss.getBitmapCurrentLayer(true).PixelFormat);

                    //clear data below selection
                    ss.getActiveGraphics().CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                    ss.getActiveGraphics().FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(loc, sze));
                    ss.getActiveGraphics().CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;

                    SharedSettings.setSelection(bEdit, loc);
                }
            }
        }
示例#2
0
 public void init(SharedSettings s)
 {
     graphics = s.getActiveGraphics();
     width    = s.getCanvasWidth();
     height   = s.getCanvasHeight();
     settings = s;
     bInit    = true;
 }
示例#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;
            }
        }
示例#4
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;
            }
        }
        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();
        }