private MouseEventArgs scaleMouseEvent(MouseEventArgs e) { int offset = 0;// (int)(SharedSettings.fScale); if (!ss.getActiveSelection()) { if (lv.getActiveLayer().isLayerVisible()) { return(new MouseEventArgs(e.Button, e.Clicks, (int)((e.X - offset) / ss.getDrawScale()), (int)((e.Y - offset) / ss.getDrawScale()), e.Delta)); } else { return(null); } } else if (Tools[iActiveTool] is MoveTool) { return(new MouseEventArgs(e.Button, e.Clicks, (int)(((e.X - ss.getSelectionPoint().X) - offset) / ss.getDrawScale()), (int)(((e.Y - ss.getSelectionPoint().Y) - offset) / ss.getDrawScale()), e.Delta)); } else { Rectangle rect = new Rectangle(ss.getSelectionPoint(), ss.getSelectionSize()); if ((ss.getActiveSelection() && rect.Contains(e.X, e.Y)) || Tools[iActiveTool] is SelectionTool) { return(new MouseEventArgs(e.Button, e.Clicks, (int)(((e.X - ss.getSelectionPoint().X) - offset) / ss.getDrawScale()), (int)(((e.Y - ss.getSelectionPoint().Y) - offset) / ss.getDrawScale()), e.Delta)); } else { return(null); } } return(null); }
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); } } }