コード例 #1
0
        private void ToRasterPointF(ref PointF pt, ICanvas canvas)
        {
            ICoordinateTransform coordTran = canvas.CoordTransform;

            if (canvas.PrimaryDrawObject != null)//有活动影像是返回栅格坐标
            {
                float row = 0, col = 0;
                coordTran.Screen2Raster(pt.X, pt.Y, out row, out col);
                pt.X = col;
                pt.Y = row;
            }
            else//无活动影像时返回投影坐标
            {
                double prjX = 0, prjY = 0;
                canvas.CoordTransform.Screen2Prj(pt.X, pt.Y, out prjX, out prjY);
                pt.X = (float)prjX;
                pt.Y = (float)prjY;
            }
        }
コード例 #2
0
        private void EventPoint(object sender, enumCanvasEventType eventType, DrawingMouseEventArgs e)
        {
            if (eventType != enumCanvasEventType.MouseDown)
            {
                return;
            }
            GeometryOfDrawed geometry = new GeometryOfDrawed();

            geometry.ShapeType = _pencilType.ToString();
            ICoordinateTransform tran = (sender as ICanvas).CoordTransform;
            float row = 0, col = 0;

            tran.Screen2Raster(e.ScreenX, e.ScreenY, out row, out col);
            geometry.RasterPoints = new PointF[] { new PointF(row, col) };
            if (this._pencilDrawedResultFinished != null)
            {
                this._pencilDrawedResultFinished(geometry);
            }
        }
コード例 #3
0
ファイル: ProfileLayer.cs プロジェクト: windygu/hispeed
        private PixelInfo GetPixelInfo(ICanvas canvas, int screenX, int screenY)
        {
            ICoordinateTransform coordTran = canvas.CoordTransform;
            PixelInfo            pInfo     = new PixelInfo();

            pInfo.ScreenX = screenX;
            pInfo.ScreenY = screenY;
            if (canvas.IsReverseDirection)
            {
                IReversedCoordinateTransform tran = canvas as IReversedCoordinateTransform;
                tran.Screen2Prj(screenX, screenY, out pInfo.PrjX, out pInfo.PrjY);
                tran.Screen2Raster((float)screenX, (float)screenY, out pInfo.RasterY, out pInfo.RasterX);
            }
            else
            {
                coordTran.Screen2Prj(screenX, screenY, out pInfo.PrjX, out pInfo.PrjY);
                coordTran.Screen2Raster((float)screenX, (float)screenY, out pInfo.RasterY, out pInfo.RasterX);
            }
            //coordTran.Prj2Geo(pInfo.PrjX, pInfo.PrjY, out pInfo.GeoX, out pInfo.GeoY);
            return(pInfo);
        }
コード例 #4
0
 private void NotifyResult(ICoordinateTransform coordTran, ICanvas canvas)
 {
     if (_pencilDrawedResultFinished == null)
     {
         return;
     }
     using (GraphicsPath path = GetGraphicsPath())
     {
         if (path == null)
         {
             return;
         }
         GeometryOfDrawed geometry = new GeometryOfDrawed();
         geometry.ShapeType    = _pencilType.ToString();
         geometry.RasterPoints = path.PathData.Points;
         //using (StreamWriter sw = new StreamWriter("F:\\1.txt", false, Encoding.Default))
         //{
         //    for (int i = 0; i < geometry.RasterPoints.Length; i++)
         //    {
         //        sw.WriteLine(geometry.RasterPoints[i].ToString());
         //    }
         //}
         float  row, col;
         double prjY, prjX;
         for (int i = 0; i < geometry.RasterPoints.Length; i++)
         {
             if (canvas.PrimaryDrawObject != null)//有活动影像是返回栅格坐标
             {
                 coordTran.Screen2Raster(geometry.RasterPoints[i].X, geometry.RasterPoints[i].Y, out row, out col);
                 geometry.RasterPoints[i].X = col;
                 geometry.RasterPoints[i].Y = row;
             }
             else//无活动影像时返回投影坐标
             {
                 canvas.CoordTransform.Screen2Prj(geometry.RasterPoints[i].X, geometry.RasterPoints[i].Y, out prjX, out prjY);
                 geometry.RasterPoints[i].X = (float)prjX;
                 geometry.RasterPoints[i].Y = (float)prjY;
                 geometry.IsPrjCoord        = true;
             }
         }
         //记录拐点(例如:海冰冰缘线绘制时使用)
         if (_pencilType == enumPencilType.ControlFreeCurve && _controls.Count > 0)
         {
             geometry.ControlRasterPoints = new PointF[_controls.Count];
             for (int i = 0; i < _controls.Count; i++)
             {
                 if (canvas.PrimaryDrawObject != null)//有活动影像是返回栅格坐标
                 {
                     coordTran.Screen2Raster(_controls[i].X, _controls[i].Y, out row, out col);
                     geometry.ControlRasterPoints[i].X = col;
                     geometry.ControlRasterPoints[i].Y = row;
                 }
                 else//无活动影像时返回投影坐标
                 {
                     canvas.CoordTransform.Screen2Prj(_controls[i].X, _controls[i].Y, out prjX, out prjY);
                     geometry.ControlRasterPoints[i].X = (float)prjX;
                     geometry.ControlRasterPoints[i].Y = (float)prjY;
                     geometry.IsPrjCoord = true;
                 }
             }
         }
         //
         geometry.Types = path.PathData.Types;
         _pencilDrawedResultFinished(geometry);
     }
 }