Jump to content

BioSlayer

Newbies
  • Posts

    2
  • Joined

  • Last visited

Posts posted by BioSlayer

  1. 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

×
×
  • Create New...