BioSlayer Posted May 30, 2006 Share Posted May 30, 2006 I was getting annoyed when I was dealing with small lines, that it would select the wrong nub. So I changed the OnStylusDown method in the LineTool. Now it works perfectly. Because instead of stopping at the first nub that passes the IsPointTouching method, it also checks all the nubs and picks the one closer to the mouse. Here is the changed method: protected override void OnStylusDown(StylusEventArgs e) { bool callBase = false; if (!this.inCurveMode) { callBase = true; } else { PointF mousePt = new PointF(e.Fx, e.Fy); //start of change Single mindistance = Single.MaxValue; for (int i = 0; i < this.moveNubs.Length; ++i) { if (this.moveNubs[i].IsPointTouching(Point.Truncate(mousePt), true)) { PointF[] points = new PointF[]{this.moveNubs[i].Location}; this.moveNubs[i].Transform.TransformPoints(points); Single distX = points[0].X - mousePt.X; Single distY = points[0].Y - mousePt.Y; Single distance = (Single)Math.Sqrt(distX * distX + distY * distY); if (distance < mindistance) { mindistance = distance; this.draggingNubIndex = i; this.Cursor = this.handCursorMouseDown; if (this.curveType == CurveType.NotDecided) { if (e.Button == MouseButtons.Right) { this.curveType = CurveType.Bezier; } else { this.curveType = CurveType.Spline; } } } } } //end of change if (this.draggingNubIndex == -1) { callBase = true; } else { for (int i = 0; i < this.moveNubs.Length; ++i) { this.moveNubs[i].Visible = false; } string helpText2 = PdnResources.GetString("LineTool.CurvingHelpText"); SetStatus(null, helpText2); OnStylusMove(e); } } if (callBase) { base.OnStylusDown(e); } } the original method is from 2.61 Quote Link to comment Share on other sites More sharing options...
Born2killx Posted May 31, 2006 Share Posted May 31, 2006 I'm a programmer wannabe, but I don't understand a single word you're saying T_T. Quote I built my first computer at age 11! Link to comment Share on other sites More sharing options...
BioSlayer Posted May 31, 2006 Author Share Posted May 31, 2006 Basically I fixed the line tool so that when you pick one of the 4 points on the line it will choose the one closest to the mouse. It currently does not do this for very small lines. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted June 1, 2006 Share Posted June 1, 2006 I'm planning on making some changes to the way Tools handle this type of stuff anyway, I'll make sure this type of proximity association is implemented in 3.0. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.