Beispiel #1
1
        // find cities with distance of center of map
        private void menuItemSearchWithinDistance_Click(object sender, System.EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                // to compare to SearchWithinScreenRadius, we are calculating
                // the search distance the same way it does
                System.Drawing.Rectangle rect=mapControl1.Bounds;
                System.Drawing.Point pt = new System.Drawing.Point(rect.Left, rect.Top);
                pt.X += rect.Width/2;
                pt.Y += rect.Height/2;

                DPoint dpt1 = new DPoint();
                // convert center point to map coords (could use map.Center)
                _map.DisplayTransform.FromDisplay(pt, out dpt1);

                Distance d = MapInfo.Mapping.SearchInfoFactory.ScreenToMapDistance(_map, rect.Width/6);
                SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWithinDistance(dpt1, _map.GetDisplayCoordSys(), d, ContainsType.Centroid);
                IResultSetFeatureCollection fc = _catalog.Search("uscty_1k", si);

                // show search geometry on screen for visual confirmation
                MapInfo.Geometry.Point p = new MapInfo.Geometry.Point(_map.GetDisplayCoordSys(), dpt1);
                FeatureGeometry buffer = p.Buffer(d.Value, d.Unit, 20, DistanceType.Spherical);
                ShowSearchGeometry(buffer);

                SelectFeatureCollection(fc);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #2
0
 public void FromDisplay(Point pntSrc, out DPoint pntDest)
 {
     double x = pntSrc.X;
     double y = pntSrc.Y;
     double xOut, yOut;
     at.ConvertInverse(x, y, out xOut, out yOut);
     pntDest = new DPoint(xOut, yOut);
 }
Beispiel #3
0
 public TextFeature(DPoint oP, string Text, Style oStyle)
 {
     m_oText = Text;
     //m_oPosition = oP;
     base.m_oStyle = oStyle;
     m_oLineEnd = new Point();
     m_iEndType = 0;
 }
Beispiel #4
0
 public void ToDisplay(DPoint pntSrc, out Point pntDest)
 {
     double x = pntSrc.X;
     double y = pntSrc.Y;
     double xOut, yOut;
     at.Convert(x, y, out xOut, out yOut);
     pntDest = new Point((int)xOut, (int)yOut);
 }
Beispiel #5
0
 /// <summary>
 /// We use the Math.Round method since none of the transforms are exact.
 /// </summary>
 /// <param name="msg"></param>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 private void ComparePoints(string msg, DPoint p1, DPoint p2)
 {
     int prec = 5;
     if (Math.Round(p1.x, prec) == Math.Round(p2.x, prec) &&
         Math.Round(p1.y, prec) == Math.Round(p2.y, prec))
     {
         outputTextBox.AppendText(msg + " points are equal: (" + Math.Round(p1.x, prec) + ", " + Math.Round(p1.y, prec) + ") == (" + Math.Round(p2.x, prec) + ", " + Math.Round(p2.y, prec) + ")\n");
     }
     else
     {
         outputTextBox.AppendText(msg + " points are NOT equal: (" + Math.Round(p1.x, prec) + ", " + Math.Round(p1.y, prec) + ") != (" + Math.Round(p2.x, prec) + ", " + Math.Round(p2.y, prec) + ")\n");
     }
 }
Beispiel #6
0
        public DPoint Divide(params DPoint[] P)
        {
            if (P.Length == 0)
            {
                throw new ArgumentException("there is no data!");
            }
            if (P.Length == 1)
            {
                return(new DPoint(X, Y) / P[0]);
            }
            DPoint NewPoint = new DPoint(X, Y) / P[0];

            for (int i = 1; i < P.Length; i++)
            {
                NewPoint /= P[i];
            }
            return(NewPoint);
        }
Beispiel #7
0
        public DPoint Multiply(params float[] P)
        {
            if (P.Length == 0)
            {
                throw new ArgumentException("there is no data!");
            }
            if (P.Length == 1)
            {
                return(new DPoint(X, Y) * P[0]);
            }
            DPoint NewPoint = new DPoint(X, Y) * P[0];

            for (int i = 1; i < P.Length; i++)
            {
                NewPoint *= P[i];
            }
            return(NewPoint);
        }
Beispiel #8
0
 /// <summary>use Flat or flatten calls.</summary>
 public DPoint ScaleTo(DPoint point)
 {
     if (point.X == X && point.Y == Y)
     {
         throw new InvalidOperationException("you mucker");
     }
     System.Windows.Forms.MessageBox.Show(string.Format("X: {1},Y: {0}", Y / point.Y, X / point.X));
     if (X > point.Y)
     {
                         #if CONSOLE && COR3
         Global.cstat(ConsoleColor.Red, "X is BIGGER");
                         #else
         Debug.Print("X is BIGGER");
                         #endif
     }
                 #if CONSOLE && COR3
     else
     {
         Global.cstat(ConsoleColor.Red, "X is SMALLER");
     }
Beispiel #9
0
 public static DPoint GetScreenMM()
 {
     DPoint sz = new DPoint(0, 0);
     Graphics g = Graphics.FromHwnd((IntPtr)0);
     sz.X = Screen.PrimaryScreen.Bounds.Width / g.DpiX * 25.4;
     sz.Y = Screen.PrimaryScreen.Bounds.Height / g.DpiY * 25.4;
     return sz;
 }
Beispiel #10
0
 internal void CreateIntList(CADDPointCollection DottedSingPts, bool Closed)
 {
     DPoint dPoint1 = new DPoint();
     intPoints.Clear();
     for (int i = 0; i < DottedSingPts.Count; i++)
     {
         DPoint dPoint2 = dPoint1;
         DPoint dPoint3 = DottedSingPts[i];
         intPoints.Add(dPoint3.X);
         intPoints.Add(dPoint3.Y);
     }
     if (Closed)
     {
     }
 }
Beispiel #11
0
 public DPoint GetRation(DPoint dst)
 {
     return(dst / this);
 }
Beispiel #12
0
        // this is similar to searchwithinscreenrect, but the rect constructed is a map rectangle
        // as opposed to a screen rectangle (try both and see the difference)
        private void menuItemSearchWithinRect_Click(object sender, System.EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                System.Drawing.Rectangle rect=mapControl1.Bounds;
                rect.X += rect.Width/3;
                rect.Width = rect.Width/3;
                rect.Y += rect.Height/3;
                rect.Height = rect.Height/3;
                DRect mapRect=new DRect();

                // use csys and transform of feature layer, because that is the
                // layer we are doing the search on
                FeatureLayer layer = _map.Layers["uscty_1k"] as FeatureLayer;
                layer.DisplayTransform.FromDisplay(rect, out mapRect);
                SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWithinRect(mapRect, layer.CoordSys, ContainsType.Centroid);
                IResultSetFeatureCollection fc = _catalog.Search(layer.Table, si);

                // show search geometry on screen for visual confirmation
                DPoint []pts = new DPoint[4];
                mapRect.GetCornersOfRect(pts);
                FeatureGeometry g = new MapInfo.Geometry.MultiPolygon(layer.CoordSys, CurveSegmentType.Linear, pts);
                ShowSearchGeometry(g);

                SelectFeatureCollection(fc);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #13
0
 public VPointD(DPoint _pin, double z) : this(_pin.X, _pin.Y, z)
 {
 }
Beispiel #14
0
 void de_ContextClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     if (clickedFigure != null)
             cmsFigure.Show(wfvcEditor, new Point((int)pt.X, (int)pt.Y));
     else
         cmsCanvas.Show(wfvcEditor, new Point((int)pt.X, (int)pt.Y));
 }
Beispiel #15
0
 void de_FigureClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     if (clickedFigure.UserAttrs.ContainsKey(Links.LinkBody))
         ExecLink(clickedFigure);
 }
Beispiel #16
0
 public bool IsYEq(DPoint P)
 {
     return(Y == P.Y);
 }
Beispiel #17
0
 public bool IsYG(DPoint P)
 {
     return(Y > P.Y);
 }
Beispiel #18
0
 public bool IsYLEq(DPoint P)
 {
     return(IsYG(P) & IsYG(P));
 }
Beispiel #19
0
 public bool IsXEq(DPoint P)
 {
     return(X == P.X);
 }
Beispiel #20
0
 public bool IsXLEq(DPoint P)
 {
     return(IsXG(P) & IsXG(P));
 }
Beispiel #21
0
 public bool IsGEq(DPoint p)
 {
     return((X >= p.X) && (Y >= p.Y));
 }
Beispiel #22
0
 public bool IsLEq(DPoint p)
 {
     return((X <= p.X) && (Y <= p.Y));
 }
Beispiel #23
0
 public static void PreviewFigure(DEngine de, DTkViewer dv, Type figureClass, DAuthorProperties dap, DPoint viewerSize)
 {
     // add figure de so it shows on the viewer
     de.UndoRedo.Start("blah");
     de.ClearPage();
     Figure f = (Figure)Activator.CreateInstance(figureClass);
     dap.ApplyPropertiesToFigure(f);
     if (f is PolylineFigure)
     {
         DPoints pts = new DPoints();
         pts.Add(new DPoint(viewerSize.X / 4.0, viewerSize.Y / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.25 / 4.0, viewerSize.Y * 1.10 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.50 / 4.0, viewerSize.Y * 1.25 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.75 / 4.0, viewerSize.Y * 1.50 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.00 / 4.0, viewerSize.Y * 1.75 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.25 / 4.0, viewerSize.Y * 2.00 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.50 / 4.0, viewerSize.Y * 2.25 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.75 / 4.0, viewerSize.Y * 2.50 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 3 / 4.0, viewerSize.Y * 3 / 4.0));
         ((PolylineFigure)f).Points = pts;
     }
     else if (f is ITextable)
         ((ITextable)f).Text = "Aa";
     f.Left = viewerSize.X / 4.0;
     f.Top = viewerSize.Y / 4.0;
     f.Width = viewerSize.X / 2.0;
     f.Height = viewerSize.Y / 2.0;
     if (f is TextFigure)
     {
         f.Left = viewerSize.X / 8.0;
         f.Width = viewerSize.X * 3 / 4.0;
     }
     de.AddFigure(f);
     de.UndoRedo.Commit();
     dv.Update();
 }
Beispiel #24
0
 public bool IsXG(DPoint P)
 {
     return(X > P.X);
 }
Beispiel #25
0
 public FPoint(DPoint P) : this(P.X, P.Y)
 {
 }
Beispiel #26
0
 // =======================================================
 /// • AutoScale — multiplies agains largest point in “dest / source”
 static public DPoint Fit(DPoint dest, DPoint source)
 {
     return(Fit(dest, source, scaleFlags.autoScale));
 }
Beispiel #27
0
 void de_DragFigureEvt(DEngine de, Figure dragFigure, DPoint pt)
 {
     if (pt.X < 0 || pt.Y < 0 || pt.X > wfvcEditor.Width || pt.Y > wfvcEditor.Height)
     {
         de.CancelFigureDrag();
         dvEditor.Update();
         wfvcEditor.DoDragDrop(de.SelectedFigures, DragDropEffects.Move);
     }
 }
Beispiel #28
0
 public void CopyPoint(DPoint inPoint)
 {
     X = inPoint.X; Y = inPoint.Y;
 }
Beispiel #29
0
 public bool IsYL(DPoint P)
 {
     return(Y < P.Y);
 }
Beispiel #30
0
 /// <summary>
 /// We are going to use the CoordSys transform to transform a point from one coordsys to another then back
 /// again to see if the round trip produces the correct results. Then test the array version of the transform.
 /// </summary>
 private void UseCoordinateTransform()
 {
     // create LongLat projection
     CoordSys csys = Session.Current.CoordSysFactory.CreateFromPrjString("1, 56");
     // Create Robinson projection
     CoordSys csys1 = Session.Current.CoordSysFactory.CreateFromPrjString("12, 62, 7, 0");
     if (csys == csys1)
     {
         outputTextBox.AppendText("Oops, coordsys's are equal, this is bad\n");
     }
     CoordinateTransform coordTransform = Session.Current.CoordSysFactory.CreateCoordinateTransform(csys, csys1);
     DPoint pntSrc = new DPoint(0, 0);
     DPoint pntDest = coordTransform.CoordSys1ToCoordSys2(pntSrc);
     DPoint pntSrc1 = new DPoint(1, 1);
     DPoint pntDest1 = coordTransform.CoordSys1ToCoordSys2(pntSrc1);
     DPoint pntBackToSrc = coordTransform.CoordSys2ToCoordSys1(pntDest1);
     ComparePoints("Round trip", pntSrc1, pntBackToSrc);
     // compare the result with arrays
     DPoint[] pnt = new DPoint[2];
     pnt[0].x = 0;
     pnt[0].y = 0;
     pnt[1].x = 1;
     pnt[1].y = 1;
     coordTransform.CoordSys1ToCoordSys2(pnt, out pnt);
     ComparePoints("Array converted", pntDest, pnt[0]);
     ComparePoints("Array converted", pntDest1, pnt[1]);
 }
Beispiel #31
0
 public FloatPoint(DPoint P)
     : this(P.X,P.Y)
 {
 }
Beispiel #32
0
 public DPoint Translate(DPoint offset, DPoint zoom)
 {
     return((this + offset) * zoom);
 }
Beispiel #33
0
 public override void SetPageSize(DPoint pageSize)
 {
     this.pageSize = pageSize;
     UpdateAutoScroll();
 }
Beispiel #34
0
 /// <summary>same as FlattenPoint overload without boolean</summary>
 static public DPoint FlattenDown(DPoint _pin)
 {
     return(FlattenPoint(_pin));
 }
Beispiel #35
0
 private DPoint GetPoint(DPoint point)
 {
     return new DPoint(point.X - offsetX,pageHeight - point.Y + offsetY,0);
 }
Beispiel #36
0
 static public DPoint FlattenUp(DPoint _pin)
 {
     return(FlattenPoint(_pin, true));
 }
Beispiel #37
0
 public static void SetCairoPDFSurfaceSize(WFCairoGraphics dg, DPoint pgSzMM)
 {
     System.Diagnostics.Debug.Assert(dg.Target is Cairo.PdfSurface);
     //  Convert page size in MM to cairo pdf points (1/72 inch , http://cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-surface-set-size)
     double width = (pgSzMM.X / PageTools.MMPerInch) * 72;
     double height = (pgSzMM.Y / PageTools.MMPerInch) * 72;
     ((Cairo.PdfSurface)dg.Target).SetSize(width, height);
 }
Beispiel #38
0
 /// <summary>Flattens the calling point</summary>
 public void Flatten(bool roundUp)
 {
     DPoint f = Flat(roundUp); this.X = f.X; this.Y = f.Y; f = null;
 }
Beispiel #39
0
 public static DPoint GetScreenRes()
 {
     DPoint sz = new DPoint(0, 0);
     sz.X = Screen.PrimaryScreen.Bounds.Width;
     sz.Y = Screen.PrimaryScreen.Bounds.Height;
     return sz;
 }
Beispiel #40
0
 void de_MouseDown(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     textInsertionPoint = pt;
 }
Beispiel #41
0
        /// <summary>
        /// create features on layer based on gpxFile object
        /// </summary>
        /// <param name="gpxFile"></param>
        /// <param name="oLayerGPXPolylines"></param>
        /// <param name="oLayerGPXSymbols"></param>
        public static void makeMapLayersFromGPX(GPXFile gpxFile, LayerVectors oLayerGPXPolylines, LayerVectors oLayerGPXSymbols)
        {
            oLayerGPXSymbols.FeaturesClear();
            oLayerGPXPolylines.FeaturesClear();

            // fill layers with data
            if (gpxFile != null)
            {
                for (int iTrk = 0; iTrk < gpxFile.trks.Count; iTrk++)
                {
                    GPXTrk trk = gpxFile.trks[iTrk];

                    for (int iSeg = 0; iSeg < trk.trkSeg.Count; iSeg++)
                    {
                        GPXTrkSeg seg = trk.trkSeg[iSeg];
                        List<DPoint> oPoints1 = new List<DPoint>();

                        for (int iWpt = 0; iWpt < seg.wpts.Count; iWpt++)
                        {
                            GpxWpt wpt = seg.wpts[iWpt];

                            DPoint oPoint = new DPoint(wpt.lon, wpt.lat);
                            oPoint.Selected = wpt.selected;

                            oPoints1.Add(oPoint);

                            // add gpx point
                            Feature oSymbol = FeatureFactory.CreateSymbol(wpt.lon, wpt.lat, (uint)0xFF00FF00);
                            oSymbol.Tag = oPoint;
                            oLayerGPXSymbols.FeaturesAdd(oSymbol);

                            // link point to symbol and symbol to point
                            oPoint.Tag = oSymbol;

                            // fill data
                            oSymbol.setField("lat", wpt.lat);
                            oSymbol.setField("lon", wpt.lon);
                            oSymbol.setField("ele", wpt.ele);
                            oSymbol.setField("time", wpt.time);
                        }
                        if (oPoints1.Count > 0)
                        {
                            PolylineFeature oPolyline1 = FeatureFactory.CreatePolyline(oPoints1, new Style(Color.Green));
                            oLayerGPXPolylines.FeaturesAdd(oPolyline1);
                        }
                    }
                }
            }
        }
Beispiel #42
0
 private void SetCurrentDe(DEngine de)
 {
     if (this.de != null)
     {
         this.de.RemoveViewer(dvEditor);
         if (this.de.CurrentFigureClass != null)
             de.HsmSetStateByFigureClass(this.de.CurrentFigureClass);
         else
             de.HsmState = DHsmState.Select;
     }
     de.AddViewer(dvEditor);
     if (dvEditor.Zoom != Zoom.Custom)
         dvEditor.Zoom = dvEditor.Zoom;
     dvEditor.Update();
     this.de = de;
     de_SelectedFiguresChanged();
     UpdateUndoRedoActions();
     // update toolstrips
     tsEngineState.De = de;
     tsPropState.De = de;
     // null textInsertionPoint
     textInsertionPoint = null;
     // personal toolbar
     tsPersonal.De = de;
     // set grid options
     SetGridOptionsForCurrentDe();
 }
Beispiel #43
0
        void mapControl1_MouseMove(object sender, MouseEventArgs e)
        {
            if (false)
            {
                System.Drawing.PointF DisplayPoint = new PointF(e.X, e.Y);
                MapInfo.Geometry.DisplayTransform converter = this.mapControl1.Map.DisplayTransform;
                MapInfo.Geometry.DPoint MapPoint = new MapInfo.Geometry.DPoint();

                converter.FromDisplay(DisplayPoint, out MapPoint);
                double pX = Math.Round(MapPoint.x, 6);
                double pY = Math.Round(MapPoint.y, 6);
                string East = "��";
                string West = "��";
                string Longitude = "����";
                string North = "  ��";
                string South = "  ��";
                string Latitude = "��";

                DPoint p = MapPoint;// selectionFeature[0].Geometry.Centroid;
                //// mapControl1.Map.SetView(new DPoint(p.x, p.y),
                ////Session.Current.CoordSysFactory.CreateLongLat(DatumID.WGS84),
                ////108851.80);

                System.Drawing.Point pntClick = new System.Drawing.Point(e.X, e.Y);
                DPoint pntCenter = new DPoint(0, 0);
                this.mapControl1.Map.DisplayTransform.FromDisplay(pntClick, out pntCenter);
                this.mapControl1.Map.Center = pntCenter;

                if (pX > 0)
                {
                    if (pX <= 180)
                    {
                        toolStripStatusLabel1.Text = string.Format(East + Longitude + ":{0}", pX);
                    }
                    else
                    {
                        toolStripStatusLabel1.Text = string.Format(East + Longitude + ":");
                    }
                }
                else if (pX < 0)
                {
                    if (pX >= -180)
                    {
                        toolStripStatusLabel1.Text = string.Format(West + Longitude + ":{0}", Math.Abs(pX));
                    }
                    else
                    {
                        toolStripStatusLabel1.Text = string.Format(West + Longitude + ":");
                    }
                }
                else
                {
                    toolStripStatusLabel1.Text = string.Format(Longitude + ":{0}", Math.Abs(pX));
                }

                if (pY > 0)
                {
                    if (pY <= 90)
                    {
                        toolStripStatusLabel1.Text += string.Format(North + Latitude + ":{0}", pY);
                    }
                    else
                    {
                        toolStripStatusLabel1.Text += string.Format(North + Latitude + ":");
                    }
                }
                else if (pY < 0)
                {
                    if (pY >= -90)
                    {
                        toolStripStatusLabel1.Text += string.Format(South + Latitude + ":{0}", Math.Abs(pY));
                    }
                    else
                    {
                        toolStripStatusLabel1.Text += string.Format(South + Latitude + ":");
                    }
                }
                else
                {
                    toolStripStatusLabel1.Text += string.Format(Latitude + ":{0}", Math.Abs(pY));
                }
            }
        }
Beispiel #44
0
 ///	static FromControl Methods (relative to the control)
 static public DRect FromClientInfo(DPoint ClientSize, Padding pad)
 {
     return(new DRect(DPoint.GetPaddingTopLeft(pad), ClientSize - DPoint.GetPaddingOffset(pad)));
 }
Beispiel #45
0
 void de_DragFigureEnd(DEngine de, Figure dragFigure, DPoint pt)
 {
 }
Beispiel #46
0
 public DRect(double x, double y, double width, double height)
 {
     Location = new DPoint(x, y); Size = new DPoint(width, height);
 }
Beispiel #47
0
 void de_DragFigureStart(DEngine de, Figure dragFigure, DPoint pt)
 {
 }
Beispiel #48
0
 public DPoint GetScaledRation(DPoint dst)
 {
     return(this * (dst / this));
 }
Beispiel #49
0
 void de_FigureLockClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     undoRedoArea.Start(WbLocale.UnlockFigure);
     clickedFigure.Locked = false;
     undoRedoArea.Commit();
     dvEditor.Update();
 }
Beispiel #50
0
 public bool IsXL(DPoint P)
 {
     return(X < P.X);
 }
Beispiel #51
0
 void linkGlyph_Clicked(IGlyph glyph, Figure figure, DPoint pt)
 {
     ExecLink(figure);
 }
Beispiel #52
0
 static public DPoint FlattenPoint(DPoint _pin)
 {
     return(FlattenPoint(_pin, false));
 }
Beispiel #53
0
 private void SetEnginePageSize(DEngine de, DPoint pageSize)
 {
     de.PageSize = pageSize;
     foreach (Figure fig in de.Figures)
         WorkBookUtils.PutInBounds(de, fig);
 }
Beispiel #54
0
        /// <summary>
        /// Select all objects within the rectangle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            bool modified = false;

            base.MouseUp(sender, e);

            bool keyShift = ((System.Windows.Forms.Control.ModifierKeys & Keys.Shift) == Keys.Shift);
            bool keyControl = ((System.Windows.Forms.Control.ModifierKeys & Keys.Control) == Keys.Control);

            MapControl.Globals.Instance.MapControl.Cursor = Cursors.Arrow;

            if (ActiveRectangle.Width == 0 && ActiveRectangle.Height == 0)
            {
                relocateMode = false;
                rotateMode = false;
                rectSelectionMode = false;
                relocateModeAllowRelocation = false;

                DRect rect = calculateRectangleFromPoint(e.X, e.Y);
                List<DPoint> points = polylineLayer.SearchForPolylinePoints(rect);
                if (points.Count > 0)
                {
                    if (points[0].Selected)
                    {
                        if (!keyControl && !keyShift)
                        {
                            polylineLayer.selectionClear();
                            points[0].Selected = true;
                            MapControl.Globals.Instance.MapControl.InvalidateMap();
                            modified = true;
                        }
                        if (keyControl && !keyShift)
                        {
                            points[0].Selected = false;
                            MapControl.Globals.Instance.MapControl.InvalidateMap();
                            modified = true;
                        }
                    }
                    else
                    {
                        if (keyControl && !keyShift)
                        {
                            points[0].Selected = true;
                            MapControl.Globals.Instance.MapControl.InvalidateMap();
                            modified = true;
                        }
                    }
                    if (modified)
                    {
                        if (ToolUsed != null) ToolUsed(this, new EventArgs());
                    }
                    return;
                }

                // select polyline
                // try to select an object
                List<Feature> features = polylineLayer.SearchForFeaturesColliding(rect);
                if (features.Count > 0)
                {
                    if (features[0].Selected)
                    {
                        if (!keyControl && !keyShift)
                        {
                            polylineLayer.selectionClear();
                            features[0].Selected = true;
                            modified = true;
                            MapControl.Globals.Instance.MapControl.InvalidateMap();
                        }
                        if (keyControl && !keyShift)
                        {
                            features[0].Selected = false;
                            modified = true;
                            MapControl.Globals.Instance.MapControl.InvalidateMap();
                        }
                    }
                    else
                    {
                        if (keyControl && !keyShift)
                        {
                            features[0].Selected = true;
                            modified = true;
                            MapControl.Globals.Instance.MapControl.InvalidateMap();
                        }
                    }
                    if (modified)
                    {
                        if (ToolUsed != null) ToolUsed(this, new EventArgs());
                    }
                    return;
                }

                if (!keyControl && !keyShift)
                {
                    polylineLayer.selectionClear();
                    modified = true;
                }
            }
            else
            {
                // Dragging done
                if (relocateMode && relocateModeAllowRelocation)
                {
                    List<Feature> features = polylineLayer.selectionFeatures();
                    List<DPoint> points = polylineLayer.selectionPoints(true);

                    // calculate delta...
                    // mouse start: m_oMouseStart
                    // mouse end: m_oMouseCurrent

                    int dxi = m_oMouseStart.X - m_oMouseCurrent.X;
                    int dyi = m_oMouseStart.Y - m_oMouseCurrent.Y;
                    int pixelDelta = (int)Math.Sqrt(dxi * dxi + dyi * dyi);

                    DRect r1 = calculateRectangleFromPoint(m_oMouseStart.X, m_oMouseStart.Y);
                    DRect r2 = calculateRectangleFromPoint(m_oMouseCurrent.X, m_oMouseCurrent.Y);

                    double dx = r2.X1 - r1.X1;
                    double dy = r2.Y1 - r1.Y1;

                    // store copy of original point for undo
                    polylineLayer.Manager.startRecordingUndoElement();
                    symbolLayer.Manager.startRecordingUndoElement();

                    // move polylines
                    for (int i = 0; i < points.Count; i++)
                    {
                        DPoint newPoint = new DPoint(points[i].X + dx, points[i].Y + dy);

                        polylineLayer.Manager.recordMovePoint(points[i], newPoint);

                        // find correcponding symbol in symbolLayer
                        SymbolFeature symbol = (SymbolFeature)points[i].Tag;
                        Debug.Assert(symbol != null);

                        SymbolFeature newSymbol = new SymbolFeature(symbol.x + dx, symbol.y + dy);
                        symbolLayer.Manager.recordMoveFeature(symbol, newSymbol);
                        modified = true;
                    }

                    polylineLayer.Manager.stopRecordingUndoElement();
                    symbolLayer.Manager.stopRecordingUndoElement();

                    // refresh view
                    MapControl.Globals.Instance.MapControl.InvalidateMap();
                }
                if (rotateMode)
                {
                    // rotation

                }
                if (rectSelectionMode)
                {
                    if (!keyShift && !keyControl)
                    {
                        polylineLayer.selectionClear();
                        modified = true;

                        /*
                        // emit clear selection for all wpt-s
                        for (int i = 0; i < symbolLayer.FeaturesCount; i++)
                        {
                            SymbolFeature symbol = symbolLayer.FeatureGet(i) as SymbolFeature;
                            if (symbol != null)
                            {
                                //WptSelected(this, (symbol.Tag as GpxWpt), false);
                            }
                        }*/
                    }

                    if (!keyControl)
                    {
                        System.Drawing.Rectangle r = ActiveRectangle;
                        System.Drawing.Point p1 = new System.Drawing.Point(r.X, r.Y);
                        System.Drawing.Point p2 = new System.Drawing.Point(r.X + r.Width, r.Y + r.Height);

                        DPoint pt1, pt2;
                        map.DisplayTransform.FromDisplay(p1, out pt1);
                        map.DisplayTransform.FromDisplay(p2, out pt2);

                        // convert mercator to wgs84
                        CoordConverter occ = new CoordConverter();
                        CoordSys oCSMercator = CoordSysFactory.CreateCoordSys(CoordSysType.Mercator, CoordSysFactory.CreateDatum(DatumID.WGS84), new AffineTransform());
                        CoordSys oCSWGS84 = CoordSysFactory.CreateCoordSys(CoordSysType.LatLong, CoordSysFactory.CreateDatum(DatumID.WGS84), new AffineTransform());
                        occ.Init(oCSMercator, oCSWGS84);
                        occ.Convert(pt1.X, pt1.Y);
                        DPoint dp1 = new DPoint(occ.X, occ.Y);
                        occ.Convert(pt2.X, pt2.Y);
                        DPoint dp2 = new DPoint(occ.X, occ.Y);
                        DRect rect = new DRect(dp1.X, dp2.Y, dp2.X, dp1.Y);

                        List<DPoint> points = polylineLayer.SearchForPolylinePoints(rect);
                        for (int i = 0; i < points.Count; i++)
                        {
                            points[i].Selected = true;
                            modified = true;
                        }

                        List<Feature> features = polylineLayer.SearchForFeaturesContained(rect);
                        for (int i = 0; i < features.Count; i++)
                        {
                            features[i].Selected = true;
                            modified = true;
                        }

                        MapControl.Globals.Instance.MapControl.InvalidateMap();
                    }
                }

                if (timer != null)
                {
                    timer.Stop();
                    timer = null;
                }

                relocateMode = false;
                rotateMode = false;
                rectSelectionMode = false;
                relocateModeAllowRelocation = false;
            }
            if (modified)
            {
                if (ToolUsed != null) ToolUsed(this, new EventArgs());
            }
        }
Beispiel #55
0
 ///	static FromControl Methods (relative to the control)
 static public DRect FromControl(Control ctl, Padding pad)
 {
     return(new DRect(DPoint.GetPaddingTopLeft(pad), DPoint.GetClientSize(ctl) - DPoint.GetPaddingOffset(pad)));
 }
Beispiel #56
0
        private DRect calculateRectangleFromPoint(int x, int y)
        {
            // try to select a polyline point
            int margin = 3;

            System.Drawing.Point p1 = new System.Drawing.Point(x - margin, y - margin);
            System.Drawing.Point p2 = new System.Drawing.Point(x + margin, y + margin);

            DPoint pt1, pt2;
            map.DisplayTransform.FromDisplay(p1, out pt1);
            map.DisplayTransform.FromDisplay(p2, out pt2);

            // convert mercator to wgs84
            CoordConverter occ = new CoordConverter();
            CoordSys oCSMercator = CoordSysFactory.CreateCoordSys(CoordSysType.Mercator, CoordSysFactory.CreateDatum(DatumID.WGS84), new AffineTransform());
            CoordSys oCSWGS84 = CoordSysFactory.CreateCoordSys(CoordSysType.LatLong, CoordSysFactory.CreateDatum(DatumID.WGS84), new AffineTransform());
            occ.Init(oCSMercator, oCSWGS84);
            occ.Convert(pt1.X, pt1.Y);
            DPoint dp1 = new DPoint(occ.X, occ.Y);
            occ.Convert(pt2.X, pt2.Y);
            DPoint dp2 = new DPoint(occ.X, occ.Y);
            DRect rect = new DRect(dp1.X, dp2.Y, dp2.X, dp1.Y);
            return rect;
        }
Beispiel #57
0
 public DRect(DPoint L, DPoint S) : this(L.X, L.Y, S.X, S.Y)
 {
 }
Beispiel #58
0
 public DPoint Translate(DPoint offset, DPoint zoom)
 {
     return (this+offset)*zoom;
 }