示例#1
0
 private void showOneFX(PropertyGridEx pg, CFXProj fx, int fxID)
 {
     pg.SelectedObject = fx;
     chart1.Series[fxID].Points.Clear();
     for (int j = 0; j < fx.strDate.Count; j++)
     {
         chart1.Series[fxID].Points.AddXY(DateTime.ParseExact(fx.strDate[j], "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture),
                                          Math.Round(fx.doneAmount[j] / fx.TotalAmount * 100, 1));
     }
 }
示例#2
0
        /// <summary>
        /// 绘制分项工程进度
        /// </summary>
        /// <param name="myGraphics"></param>
        /// <param name="tunnel"></param>
        /// <param name="winHeight"> 隧道绘制宽度(像素),一般60</param>
        /// <param name="winWidth">窗口panel的宽度(像素),包围盒,用于判断是否该图形越界</param>
        /// <param name="pm">变换矩阵</param>
        /// <param name="scaleX">x方向上 里程长度 * scaleX = 像素长度</param>
        /// <param name="unitM">单位里程(米)</param>

        private bool draw_PrjFX(Graphics myGraphics, CRailwayProject prj, string prjType, float winHeight, float winWidth, Matrix pm, float scaleX, bool fxOnly = true, float unitM = 8)
        {
            bool  needDrawDetails = false;
            float prjLength       = (float)prj.Length;
            float prjPixelLength  = prjLength * scaleX;
            float done;

            bool  isReverse = prj.mMileage_End < prj.mMileage_Start;
            float sx, ex;

            if (isReverse)
            {
                sx = (float)prj.mMainMileageE;
                ex = (float)prj.mMainMileageS;
            }
            else
            {
                sx = (float)prj.mMainMileageS;
                ex = (float)prj.mMainMileageE;
            }


            PointF[] sd = { new PointF(0, 100), new PointF(0, 100) }; // 窗口
            sd[0].X = (float)sx;
            sd[1].X = (float)ex;
            pm.TransformPoints(sd);
            if (sd[1].X <0 || sd[0].X> winWidth)   // 如果桥梁不在绘制区域,返回false,也不需要绘制细节
            {
                return(needDrawDetails);
            }

            float unitPixelLength = unitM * scaleX;
            float startPixelX     = sd[0].X;
            float endPixelX       = sd[1].X;
            float actualPixelS    = Math.Max(startPixelX, 0);
            float actualPixelE    = Math.Min(endPixelX, winWidth); // 屏幕内的起始终止位置
            float unitHeight      = (winHeight / 3);

            Pen p = defaultPen;

            RectangleF areaf;
            float      sy = prjStartY + 25;

            // 1、绘制左右边界,上方线,以及工程名
            areaf = new RectangleF(actualPixelS, prjStartY, actualPixelE - actualPixelS, 20);
            if (prj.mAvgProgress > 0)
            {
                myGraphics.DrawLine(p, endPixelX, prjStartY, endPixelX, prjEndY);
                myGraphics.DrawLine(p, startPixelX, 47, endPixelX, 47);
                myGraphics.DrawLine(p, startPixelX, prjStartY, startPixelX, prjEndY);
                if (areaf.Width > 200)
                {
                    if (isReverse)
                    {
                        myGraphics.DrawString("<<< " + prj.ProjectName, defaultFont, Brushes.Black, areaf, centerFormat);
                    }
                    else
                    {
                        myGraphics.DrawString(prj.ProjectName + ">>>", defaultFont, Brushes.Black, areaf, centerFormat);
                    }
                }
                else if (areaf.Width > 20)
                {
                    myGraphics.DrawString(prjType, defaultFont, Brushes.Black, areaf, centerFormat);
                }
            }

            // 如果8米对应3个像素以内,逐条绘制分项工程
            if (fxOnly || unitPixelLength < 4)
            {
                if (!(prj.FXProgress == null || prj.FXProgress.Count == 0))
                {
                    for (int i = 0; i < 3; i++) //road.FXProgress.Count, FIXME 选3项绘制
                    {
                        int sIndex = prj.selectedFXid[i];
                        if (sIndex < 0)
                        {
                            continue;
                        }
                        CFXProj proj      = prj.FXProgress[sIndex];
                        int     lastIndex = proj.doneAmount.Count - 1;
                        done = (float)(proj.doneAmount[lastIndex] / proj.TotalAmount);
                        //areaf = new RectangleF(sx, sy, tunnelLength, unitHeight);
                        myGraphics.DrawRectangle(Pens.Black, startPixelX, sy, prjPixelLength, unitHeight);


                        if (isReverse)
                        {
                            myGraphics.FillRectangle(notDoneB, startPixelX, sy + 1, prjPixelLength * (1 - done), unitHeight - 2);
                            myGraphics.FillRectangle(backBrush[i], startPixelX + prjPixelLength * (1 - done) + 1, sy + 1, prjPixelLength * done, unitHeight - 2);
                        }
                        else
                        {
                            myGraphics.FillRectangle(backBrush[i], startPixelX, sy + 1, prjPixelLength * done, unitHeight - 2);
                            myGraphics.FillRectangle(notDoneB, startPixelX + prjPixelLength * done + 1, sy + 1, prjPixelLength * (1 - done), unitHeight - 2);
                        }


                        areaf = new RectangleF(actualPixelS, sy, actualPixelE - actualPixelS, unitHeight);
                        if (areaf.Width > 100)
                        {
                            myGraphics.DrawString(Math.Round(done, 3) * 100 + "%", defaultFont, Brushes.Black, areaf, centerFormat);
                        }
                        sy += unitHeight;
                    }
                }
                return(false);
            }

            needDrawDetails = true;
            return(needDrawDetails);
        }