コード例 #1
0
ファイル: ParcourEdit.cs プロジェクト: helios57/anrl
 private void SetHoverPoint(PointTemporaer p, Line l)
 {
     bool change = hoverPoint != p;
     if (change)
     {
         hoverPoint = p;
         PictureBox1.SetHoverLine(l);
         PictureBox1.Invalidate();
     }
 }
コード例 #2
0
ファイル: ParcourEdit.cs プロジェクト: helios57/anrl
        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 (PointTemporaer p in gluePoints)
                    {
                        p.latitude = newLatitude;
                        p.longitude = newLongitude;
                        p.edited = true;
                    }
                    if (checkBoxConnected.Checked)
                    {
                        foreach (PointTemporaer 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 pointSet = 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 PointTemporaer(l.A), l);
                                gluePoints.Clear();
                                gluePoints.AddRange(findGluePoints(activeParcour.Line, new PointTemporaer(l.A)));
                                connectedPoints.Clear();
                                connectedPoints.AddRange(findConnectedPoints(activeParcour.Line, new PointTemporaer(l.A), l));
                                pointSet = true;
                                PictureBox1.Cursor = move;
                                break;
                            }
                            else if (Vector.Abs(mousePos - new Vector(endX, endY, 0)) < 3)
                            {
                                SetHoverPoint(new PointTemporaer(l.B), l);
                                gluePoints.Clear();
                                gluePoints.AddRange(findGluePoints(activeParcour.Line, new PointTemporaer(l.B)));
                                connectedPoints.Clear();
                                connectedPoints.AddRange(findConnectedPoints(activeParcour.Line,new PointTemporaer(l.B), l));
                                pointSet = true;
                                PictureBox1.Cursor = move;
                                break;

                            }
                            else if (Vector.Abs(mousePos - new Vector(orientationX, orientationY, 0)) < 3)
                            {
                                SetHoverPoint(new PointTemporaer(l.O), l);
                                gluePoints.Clear();
                                gluePoints.AddRange(findGluePoints(activeParcour.Line, new PointTemporaer(l.O)));
                                connectedPoints.Clear();
                                connectedPoints.AddRange(findConnectedPoints(activeParcour.Line, new PointTemporaer(l.O), l));
                                pointSet = true;
                                PictureBox1.Cursor = move;
                                break;
                            }
                        }

                    }
                    if (!pointSet)
                    {
                        SetHoverPoint(null, null);
                        PictureBox1.Cursor = select;
                    }
                }
            }
        }
コード例 #3
0
ファイル: ParcourEdit.cs プロジェクト: helios57/anrl
 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;
     }
 }
コード例 #4
0
ファイル: ParcourEdit.cs プロジェクト: helios57/anrl
 private List<PointTemporaer> findGluePoints(ICollection<Line> Line, PointTemporaer original)
 {
     List<PointTemporaer> result = new List<PointTemporaer>();
     foreach (Line l in Line)
     {
         if (samePos(l.A, original) && !(original.Id == l.A.Id))
         {
             result.Add(new PointTemporaer(l.A));
         }
         if (samePos(l.B, original) && !(original.Id == l.B.Id))
         {
             result.Add(new PointTemporaer(l.B));
         }
         if (samePos(l.O, original) && !(original.Id == l.O.Id))
         {
             result.Add(new PointTemporaer(l.O));
         }
     }
     return result;
 }