Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        public double CalcScale(AxMapObjects2.AxMap map)
        {
            System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd((System.IntPtr)map.hWnd);
            MPoint[] pts = new MPoint[2];
            pts[0]   = new MPoint();
            pts[0].x = map.Extent.Left;
            pts[0].y = map.Extent.Bottom;
            pts[1]   = new MPoint();
            pts[1].x = map.Extent.Right;
            pts[1].y = map.Extent.Top;
            double Len1 = pts[1].x - pts[0].x;
            double Len2 = pts[1].y - pts[0].y;

            return(Len1 * Len2);

            #region ...
//			System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd((System.IntPtr)map.hWnd);
//
//			MPoint[] pts = new MPoint[2];
//			pts[0] = new MPoint();
//			pts[0].x = map.Extent.Left;
//			pts[0].y = map.Extent.Top;
//			pts[1] = new MPoint();
//			pts[1].x = map.Extent.Right;
//			pts[1].y = map.Extent.Top;
//
//			double dLen1 = this.CalcLenght(pts,2);
//
//			double dLen2 = map.Width / g.DpiX * 2.54 /100;
//
//			return dLen1 / dLen2;
            #endregion //...
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        public double CalcScale(AxMapObjects2.AxMap map)
        {
            System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd((System.IntPtr)map.hWnd);
            MPoint[] pts = new MPoint[2];
            pts[0] = new MPoint();
            pts[0].x = map.Extent.Left;
            pts[0].y = map.Extent.Bottom;
            pts[1] = new MPoint();
            pts[1].x = map.Extent.Right;
            pts[1].y = map.Extent.Top;
            double Len1=pts[1].x-pts[0].x;
            double Len2=pts[1].y-pts[0].y;
            return Len1*Len2;

            #region ...
            //			System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd((System.IntPtr)map.hWnd);
            //
            //			MPoint[] pts = new MPoint[2];
            //			pts[0] = new MPoint();
            //			pts[0].x = map.Extent.Left;
            //			pts[0].y = map.Extent.Top;
            //			pts[1] = new MPoint();
            //			pts[1].x = map.Extent.Right;
            //			pts[1].y = map.Extent.Top;
            //
            //			double dLen1 = this.CalcLenght(pts,2);
            //
            //			double dLen2 = map.Width / g.DpiX * 2.54 /100;
            //
            //			return dLen1 / dLen2;
            #endregion //...
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="nSize"></param>
        /// <returns></returns>
        private double CalcLenght(MPoint[] pt,int nSize)
        {
            double dLength = 0;
            double x1=0,x2=0,y1=0,y2=0;
            int nCenterL = ((int)(pt[0].x)/6+1)*6-3;

            for(int i=0;i<nSize-1;i++)
            {
                CalGuassFromLB(pt[i].x, pt[i].y, ref x1, ref y1, nCenterL);
                CalGuassFromLB(pt[i+1].x, pt[i+1].y, ref x2, ref y2, nCenterL);
                dLength += Math.Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
            }

            return dLength;
        }