Example #1
0
        private void SetHoverPoint(PointTempExtension p, Line l)
        {
            bool change = hoverPoint != p;

            if (change)
            {
                hoverPoint = p;
                PictureBox1.SetHoverLine(l);
                PictureBox1.Invalidate();
            }
        }
Example #2
0
 private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     drag = false;
     if (chkAutocalc.Checked)
     {
         btnRecalc_Click(null, null);
     }
     PictureBox1_MouseMove(PictureBox1, e);
     if (hoverPoint != null)
     {
         selectedPoint  = hoverPoint;
         numLatA.Value  = (decimal)selectedPoint.latitude;
         numLongA.Value = (decimal)selectedPoint.longitude;
     }
 }
Example #3
0
        private List <PointTempExtension> findGluePoints(ICollection <Line> Line, PointTempExtension original)
        {
            List <PointTempExtension> result = new List <PointTempExtension>();

            foreach (Line l in Line)
            {
                if (samePos(l.A, original) && !(original.Id == l.A.Id))
                {
                    result.Add(new PointTempExtension(l.A));
                }
                if (samePos(l.B, original) && !(original.Id == l.B.Id))
                {
                    result.Add(new PointTempExtension(l.B));
                }
                if (samePos(l.O, original) && !(original.Id == l.O.Id))
                {
                    result.Add(new PointTempExtension(l.O));
                }
            }
            return(result);
        }
Example #4
0
 private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
 {
     fldCursorX.Text = e.X.ToString();
     fldCursorY.Text = e.Y.ToString();
     if (c != null)
     {
         double latitude  = c.YtoLatitude(e.Y);
         double longitude = c.XtoLongitude(e.X);
         fldLatitude.Text  = latitude.ToString();
         fldLongitude.Text = longitude.ToString();
         if (drag && (hoverPoint != null || dragPoint != null))
         {
             if (dragPoint == null)
             {
                 dragPoint = hoverPoint;
             }
             double newLatitude  = c.YtoLatitude(e.Y);
             double newLongitude = c.XtoLongitude(e.X);
             double oldLat       = dragPoint.latitude;
             double oldLong      = dragPoint.longitude;
             dragPoint.latitude  = newLatitude;
             dragPoint.longitude = newLongitude;
             dragPoint.edited    = true;
             foreach (PointTempExtension p in gluePoints)
             {
                 p.latitude  = newLatitude;
                 p.longitude = newLongitude;
                 p.edited    = true;
             }
             if (checkBoxConnected.Checked)
             {
                 foreach (PointTempExtension p in connectedPoints)
                 {
                     if (p != dragPoint)
                     {
                         p.latitude  = dragPoint.latitude + (p.latitude - oldLat);
                         p.longitude = dragPoint.longitude + (p.longitude - oldLong);
                         p.edited    = true;
                     }
                 }
             }
             PictureBox1.Invalidate();
         }
         else
         {
             dragPoint = null;
             bool Point = false;
             lock (activeParcour)
             {
                 foreach (Line l in activeParcour.Line)
                 {
                     int    startX       = c.getStartX(l);
                     int    startY       = c.getStartY(l);
                     int    endX         = c.getEndX(l);
                     int    endY         = c.getEndY(l);
                     int    midX         = startX + (endX - startX) / 2;
                     int    midY         = startY + (endY - startY) / 2;
                     int    orientationX = c.getOrientationX(l);
                     int    orientationY = c.getOrientationY(l);
                     Vector mousePos     = new Vector(e.X, e.Y, 0);
                     if (Vector.Abs(mousePos - new Vector(startX, startY, 0)) < 3)
                     {
                         SetHoverPoint(new PointTempExtension(l.A), l);
                         gluePoints.Clear();
                         gluePoints.AddRange(findGluePoints(activeParcour.Line, new PointTempExtension(l.A)));
                         connectedPoints.Clear();
                         connectedPoints.AddRange(findConnectedPoints(activeParcour.Line, new PointTempExtension(l.A), l));
                         Point = true;
                         PictureBox1.Cursor = move;
                         break;
                     }
                     else if (Vector.Abs(mousePos - new Vector(endX, endY, 0)) < 3)
                     {
                         SetHoverPoint(new PointTempExtension(l.B), l);
                         gluePoints.Clear();
                         gluePoints.AddRange(findGluePoints(activeParcour.Line, new PointTempExtension(l.B)));
                         connectedPoints.Clear();
                         connectedPoints.AddRange(findConnectedPoints(activeParcour.Line, new PointTempExtension(l.B), l));
                         Point = true;
                         PictureBox1.Cursor = move;
                         break;
                     }
                     else if (Vector.Abs(mousePos - new Vector(orientationX, orientationY, 0)) < 3)
                     {
                         SetHoverPoint(new PointTempExtension(l.O), l);
                         gluePoints.Clear();
                         gluePoints.AddRange(findGluePoints(activeParcour.Line, new PointTempExtension(l.O)));
                         connectedPoints.Clear();
                         connectedPoints.AddRange(findConnectedPoints(activeParcour.Line, new PointTempExtension(l.O), l));
                         Point = true;
                         PictureBox1.Cursor = move;
                         break;
                     }
                 }
             }
             if (!Point)
             {
                 SetHoverPoint(null, null);
                 PictureBox1.Cursor = select;
             }
         }
     }
 }