Esempio n. 1
0
        /// <summary>
        ///     ''' 画双线
        ///     ''' </summary>
        ///     ''' <param name="g">Graphics对象</param>
        ///     ''' <remarks></remarks>
        public override void Draw(System.Drawing.Graphics g)
        {
            Point  eb, ee;     // 设备坐标下的线段起点,终点
            PointF ebF, eeF;   // 实际坐标下的线段起点,终点
            PointF ebF2, eeF2; // 实际坐标下的线段起点,终点(双线)


            ebF = new PointF(mStartPt.X, mStartPt.Y);
            eeF = new PointF(mEndPt.X, mEndPt.Y);
            double angleA = GetAngle(ebF, eeF);     // 求直线倾角(0-2Pi)
            double d      = BaseFunction.DPToRP(4); // 直线偏移距离(4个像素)

            ebF2 = new PointF((float)(ebF.X + d * Math.Sin(angleA)), (float)(ebF.Y + d * Math.Cos(angleA)));
            eeF2 = new PointF((float)(eeF.X + d * Math.Sin(angleA)), (float)(eeF.Y + d * Math.Cos(angleA)));

            eb = BaseFunction.RPToDP(ebF);
            ee = BaseFunction.RPToDP(eeF);
            Pen pen = new Pen(Color, 1.0f);

            g.DrawLine(pen, eb, ee);  // 画第1条线

            eb = BaseFunction.RPToDP(ebF2);
            ee = BaseFunction.RPToDP(eeF2);
            g.DrawLine(pen, eb, ee); // 画第2条线
        }
Esempio n. 2
0
        // 初始化
        private void Initl()
        {
            int    parts    = 5;                                  // 坐标分段数(坐标范围小的轴)
            PointF startPtF = new PointF(mPointSW.X, mPointSW.Y); // 坐标原点(实际坐标)
            Point  startPt  = BaseFunction.RPToDP(startPtF);      // 中心点(设备坐标)
            PointF endPtF   = new PointF(mPointNE.X, mPointNE.Y); // 坐标轴最大点(实际坐标)
            Point  endPt    = BaseFunction.RPToDP(endPtF);        // 坐标轴最大点(设备坐标)

            // 坐标轴范围内缩30个像素
            int offsetVal = 30;

            startPt.X += offsetVal;
            startPt.Y -= offsetVal;
            endPt.X   -= offsetVal;
            endPt.Y   += offsetVal;
            // 再转回实际坐标
            startPtF = BaseFunction.DPToRP(startPt);
            endPtF   = BaseFunction.DPToRP(endPt);

            mOPoint.X = (float)(Math.Ceiling(startPtF.X / (double)10) * 10);
            mOPoint.Y = (float)(Math.Ceiling(startPtF.Y / (double)10) * 10);
            mMaxX     = (float)(Math.Ceiling(endPtF.X / (double)10) * 10);
            mMaxY     = (float)(Math.Ceiling(endPtF.Y / (double)10) * 10);

            double lenX = endPtF.X - mOPoint.X;
            double lenY = endPtF.Y - mOPoint.Y;

            if (lenX < lenY)
            {
                mXParts = parts;
                mLen    = Math.Floor(lenX / (double)(parts * 10)) * 10; // 刻度间隔长度,取整10
                mYParts = (int)Math.Ceiling(lenY / (double)mLen);
            }
            else
            {
                mYParts = parts;
                mLen    = Math.Floor(lenY / (double)(parts * 10)) * 10; // 刻度间隔长度,取整10
                mXParts = (int)Math.Ceiling(lenX / (double)mLen);
            }
        }