Exemple #1
0
        void OnMapControlViewportChanged(object sender, PrjRectangleF oldviewport, PrjRectangleF newviewport)
        {
            if (_viewport.Width < double.Epsilon || _viewport.Height < double.Epsilon)
            {
                return;
            }
            _resolutionX = _viewport.Width / mapImage.ActualWidth;
            _resolutionY = _viewport.Height / mapImage.ActualHeight;
            double res = _resolutionY;
            double x   = (newviewport.MinX - _viewport.MinX) / res;
            double y   = (_viewport.MaxY - newviewport.MaxY) / res;
            double w   = newviewport.Width / res;
            double h   = newviewport.Height / res;

            Canvas.SetLeft(foucusBox, x + cstLeftBanks / 2);
            Canvas.SetTop(foucusBox, y + cstTopBanks / 2 + 4);
            foucusBox.Width = w;
            if (h > 8)
            {
                foucusBox.Height = h - 8;
            }
            else
            {
                foucusBox.Height = h;
            }
        }
        void OnMapControlViewportChanged(object sender, PrjRectangleF oldviewport, PrjRectangleF newviewport)
        {
            IMapControl mapcontrol = sender as IMapControl;

            txtDistance.Text   = (ActualWidth * mapcontrol.Resolution / 1000).ToString("0.###") + "公里";
            txtScale.Text      = "1:" + mapcontrol.Scale.ToString();
            txtResolution.Text = mapcontrol.Resolution.ToString("0.00") + "米";
        }
Exemple #3
0
        protected override void HandleRectBox(Point prjLeftUp, Point prjRightBottom)
        {
            PrjRectangleF viewport = new PrjRectangleF();

            viewport.MinX = prjLeftUp.X;
            viewport.MaxX = prjRightBottom.X;
            viewport.MinY = prjRightBottom.Y;
            viewport.MaxY = prjLeftUp.Y;
            _mapcontrol.SetViewportByPrj(viewport);
        }
Exemple #4
0
        public static PrjRectangleF FromLTRB(double left, double top, double right, double bottom)
        {
            PrjRectangleF rect = new PrjRectangleF();

            rect.MinX = left;
            rect.MaxX = right;
            rect.MinY = bottom;
            rect.MaxY = top;
            return(rect);
        }
Exemple #5
0
        public void ZoomOut()
        {
            PrjRectangleF _viewport        = _mapcontrol.Viewport;
            double        zoomWidthAmount  = _viewport.Width * panzoomFactor;
            double        zoomHeightAmount = _viewport.Height * panzoomFactor;
            PrjRectangleF newViewport      = _viewport;

            newViewport.Inflate(zoomWidthAmount, zoomHeightAmount);
            //
            _mapcontrol.SetViewportByPrj(newViewport);
        }
Exemple #6
0
 private void foucusBox_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (_dragingBox)
     {
         //
         PrjRectangleF viewport = new PrjRectangleF();
         double        x        = Canvas.GetLeft(foucusBox);
         double        y        = Canvas.GetTop(foucusBox);
         viewport.MinX = x * _resolutionX + _viewport.MinX;
         viewport.MaxY = _viewport.MaxY - y * _resolutionY;
         viewport.MaxX = viewport.MinX + foucusBox.Width * _resolutionX;
         viewport.MinY = viewport.MaxY - foucusBox.Height * _resolutionY;
         //
         _mapcontrol.SetViewportByPrj(viewport);
     }
     _dragingBox = false;
 }
Exemple #7
0
        private void ComputePrjTransfrom()
        {
            PrjRectangleF newViewport = _viewport;

            //如果_offsetX与_offsetY不为0,则表示地图正在漫游
            newViewport.Offset(-_offsetX, _offsetY);
            if (_onMapControlViewportChanged != null)
            {
                _onMapControlViewportChanged(this, _viewport, newViewport);
            }
            TranslateTransform translateMatrix = null;
            ScaleTransform     scaleMatrix     = null;

            if (_prj2PixelTransform == null)
            {
                TransformGroup tran = new TransformGroup();
                translateMatrix = new TranslateTransform();
                scaleMatrix     = new ScaleTransform();
                ScaleTransform negMatrix = new ScaleTransform();
                negMatrix.ScaleX = 1;
                negMatrix.ScaleY = -1;

                tran.Children.Add(negMatrix);
                tran.Children.Add(translateMatrix);
                tran.Children.Add(scaleMatrix);
                //
                translateMatrix.X  = -newViewport.MinX; //left
                translateMatrix.Y  = newViewport.MaxY;  //top
                scaleMatrix.ScaleX = 1d / _resolutionX;
                scaleMatrix.ScaleY = 1d / _resolutionY;
                //
                _prj2PixelTransform = tran;
            }
            else
            {
                translateMatrix = (_prj2PixelTransform as TransformGroup).Children[1] as TranslateTransform;
                scaleMatrix     = (_prj2PixelTransform as TransformGroup).Children[2] as ScaleTransform;
                //
                translateMatrix.X  = -newViewport.MinX;
                translateMatrix.Y  = newViewport.MaxY;
                scaleMatrix.ScaleX = 1d / _resolutionX;
                scaleMatrix.ScaleY = 1d / _resolutionY;
            }
            _pixel2PrjTransform = _prj2PixelTransform.Inverse as Transform;
        }
Exemple #8
0
        protected override void HandleRectBox(Point prjLeftUp, Point prjRightBottom)
        {
            PrjRectangleF rect = new PrjRectangleF();

            rect.MinX = prjLeftUp.X;
            rect.MaxX = prjRightBottom.X;
            rect.MinY = prjRightBottom.Y;
            rect.MaxY = prjLeftUp.Y;
            //
            PrjRectangleF oldrect          = _mapcontrol.Viewport;
            double        panzoomFactor    = Math.Min(oldrect.Width / rect.Width, oldrect.Height / rect.Height);
            double        zoomWidthAmount  = oldrect.Width * panzoomFactor;
            double        zoomHeightAmount = oldrect.Height * panzoomFactor;

            //
            rect.Inflate(zoomWidthAmount, zoomHeightAmount);
            //
            _mapcontrol.SetViewportByPrj(rect);
        }
Exemple #9
0
        void MapServiceClient_GeoEnvelope2PrjEnvelopeCompleted(object sender, AgileMapServiceProxy.GeoEnvelope2PrjEnvelopeCompletedEventArgs e)
        {
            if (!IsResponseFromInsideRequested(e.UserState))
            {
                return;
            }
            string rect = e.Result;

            if (string.IsNullOrEmpty(rect))
            {
                return;
            }
            string[]      ds           = rect.Split(',');
            PrjRectangleF fullViewport = new PrjRectangleF();

            fullViewport.MinX = double.Parse(ds[0]);
            fullViewport.MaxX = fullViewport.MinX + double.Parse(ds[2]);
            fullViewport.MinY = double.Parse(ds[1]);
            fullViewport.MaxY = fullViewport.MinY + double.Parse(ds[3]);
            RequestMap(fullViewport);
        }
Exemple #10
0
 private void RequestMap(PrjRectangleF fullViewport)
 {
     _mapcontrol.MapServerAgent.MapServiceClient.GetMapImageAsync(fullViewport.MinX,
                                                                  fullViewport.MinY, fullViewport.Width, fullViewport.Height, (int)ActualWidth, (int)ActualHeight, null, cstInsideRequestIdentify);
 }
Exemple #11
0
 public void SetViewportByPrj(PrjRectangleF viewport)
 {
     _viewport = viewport;
     RefreshMap();
 }