private void geoImage_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            var mousePosition = e.GetPosition(geoImage);

            if (((WriteableBitmap)geoImage.Source).GetPixel((int)mousePosition.X, (int)mousePosition.Y) == editColor)
            {
                // Edit mode and user rightclicked an edit point
                LatLongRegion      foundRegion = null;
                LatLongDegreePoint hitPoint    = FindHitPoint(mousePosition, out foundRegion);
                if (hitPoint != null)
                {
                    var msg = LatLongUtil.GetLatLongStringFromPoint(new Point(hitPoint.X, hitPoint.Y));
                    if (foundRegion != null)
                    {
                        msg += "\nRegion: " + foundRegion.Name
                               + "\nColor code: " + foundRegion.ColorName;
                    }
                    MessageBox.Show(msg);
                }
            }
            else
            {
                // Enter pan mode
                origin      = e.GetPosition(this);
                this.Cursor = Cursors.Hand;
                geoImage.CaptureMouse();
            }
        }
        private void geoImage_MouseMove(object sender, MouseEventArgs e)
        {
            var mousePosition = e.GetPosition(geoImage);

            textBlockLatLong.Text = LatLongUtil.GetLatLongStringFromPoint(mousePosition);

            if (geoImage.IsMouseCaptured)
            {
                // Panning mode
                Vector v   = e.GetPosition(this) - origin;
                var    pos = e.GetPosition(this);

                var dragVector = new Point(v.X / LatLongUtil.ScaleTransform.ScaleX, v.Y / LatLongUtil.ScaleTransform.ScaleY);
                LatLongUtil.TranslateTransform.X += dragVector.X;
                LatLongUtil.TranslateTransform.Y += dragVector.Y;
                origin = e.GetPosition(this);
                toolWindow.UpdateLabels();
            }


            else if (draggingEditPoint)
            {
                // Move point
                Debug.WriteLine("Moving in edit mode");

                var bitmap = (WriteableBitmap)geoImage.Source;

                // Restore previous area
                if (previousEditPointRect.HasValue)
                {
                    bitmap.Blit(previousEditPointRect.Value, savedBackground, savedBackgroundRect);
                }

                // Save area before drawing

                previousEditPointRect = new Rect(mousePosition.X - editPointDelta, mousePosition.Y - editPointDelta, 2 * editPointDelta, 2 * editPointDelta);
                savedBackground.Blit(savedBackgroundRect, bitmap, previousEditPointRect.Value);
                // Draw moved edit point
                bitmap.FillRectangle((int)mousePosition.X - editPointDelta, (int)mousePosition.Y - editPointDelta, (int)mousePosition.X + editPointDelta, (int)mousePosition.Y + editPointDelta, editColor);


                // Draw lines from each neighbor to point being edited
            }
        }
示例#3
0
        public void TestGetPointFromLatLongString()
        {
            LatLongUtil.ScaleTransform.ScaleX = 100000;
            LatLongUtil.ScaleTransform.ScaleY = 100000;


            LatLongUtil.TranslateTransform.X = -12.65;
            LatLongUtil.TranslateTransform.Y = -67.239;

            // LatLongUtil.ScaleTransform.CenterX = 1.00; ; //  LatLongUtil.TranslateTransform.X;
            // LatLongUtil.ScaleTransform.CenterY = 80.239; //LatLongUtil.TranslateTransform.Y;

            var point = LatLongUtil.GetPointFromLatLongString("N055.37.40.078 E012.39.12.954");
            var str   = LatLongUtil.GetLatLongStringFromPoint(point);

            Assert.AreEqual("N055.37.40.078 E012.39.12.953", str);  // 1 msec off, probably due to rounding errors

            var point2 = LatLongUtil.GetPointFromLatLongString("N55.37.40.078 E12.39.12.954");

            Assert.AreEqual(point.X, point2.X);
            Assert.AreEqual(point.Y, point2.Y);
        }
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     ApplicationSettings.Instance.Center     = LatLongUtil.GetLatLongStringFromPoint(new Point(geoImage.ActualWidth / 2, geoImage.ActualHeight / 2));
     ApplicationSettings.Instance.ZoomFactor = LatLongUtil.ScaleTransform.ScaleX;
 }