public override void OnRenderNormalView(Graphics g, DataModel data, Pen linePen, Brush lineBrush, Brush TextBrush, Brush DataBrush, Font FontText, Font FontData)
 {
     if (!data.IsSpecialAreaDataModel)
     {
         float dd = drawFrame(g, linePen, TextBrush, FontText);
         if (_MyAnimalion != null && !_MyAnimalion.IsPrepareAnimaled)
         {
             string str = (int)(dd * 100) + "%";
             if (int.Parse(TextAndData[1]) >= MaxNum)
             {
                 str = "任务完成!";
             }
             ReportViewUtils.drawString(g, LocationModel.Location_Up_Up, str, FontData, DataBrush, EStartX, EStartY + EViewHeight - 3 * TextSize, EViewWidth, Height - EStartY - EViewHeight);
         }
         //绘制指针//坐标定位
         Point p0;
         Point p1;
         Point p2;
         Point p3;
         LocationPointer(dd, out p0, out p1, out p2, out p3);
         GraphicsPath path = GraphicalDesignUtils.CreatePath(p0, p1, p2, p3);
         g.FillPath(lineBrush, path);
         path.Dispose();
     }
 }
        public override void DrawSelfDefine(System.Drawing.Graphics g, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font FontText, System.Drawing.Font FontData)
        {
            int y = EStartY;

            for (int i = 0; i < RowList.Count; i++)
            {
                int height = RowList[i].RowHeight;
                foreach (Column item in RowList[i].Columns)
                {
                    int x = (int)(EStartX + item.ColStartX);
                    linePen.Color = Color.FromArgb(100, LineColor.R, LineColor.G, LineColor.B);
                    g.DrawLine(linePen, x, y, x, y + height);
                    ReportViewUtils.drawString(g, item.TextLocation, item.Content + "", FontText, TextBrush, x, y, item.ColWidth, height);
                }
                //绘制最后一列
                Column last  = RowList[i].Columns[RowList[i].Columns.Count - 1];
                int    lastX = last.ColStartX + last.ColWidth + EStartX;
                g.DrawLine(linePen, lastX, y, lastX, y + height);
                //绘制一行
                g.DrawLine(linePen, EStartX, y, EStartX + EViewWidth, y);
                //计算下一行的起始位置
                y += RowList[i].RowHeight;
            }
            if (RowList.Count == 0)
            {
                return;
            }
            //绘制最后一行
            g.DrawLine(linePen, EStartX, y, EStartX + RowList[RowList.Count - 1].RowWidth, y);
        }
        public override void childPaint(Graphics g, DataModel data, Pen linePen, Brush lineBrush, Brush TextBrush, Brush DataBrush, Font FontText, Font FontData)
        {
            //图形的绘制
            if (TextAndData != null && data is DetailDataModel)
            {
                OnRenderNormalView(g, data, linePen, lineBrush, TextBrush, DataBrush, FontText, FontData);
            }

            //注解的绘制
            if (isDrawLegendNote && LegendNoteModels != null)
            {
                foreach (LegendNoteModel item in LegendNoteModels)
                {
                    Brush selfBrush      = new SolidBrush(item.Color);
                    Font  LegendNoteFont = new Font("幼圆", LegendNoteFontTextSize);
                    if (item.Area.Height / 4 <= 1)
                    {
                        item.Area.Height = 4;
                    }
                    GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(new Rectangle(item.Area.left, item.Area.top, item.Area.Width, item.Area.Height), item.Area.Height / 4);
                    g.FillPath(selfBrush, path);
                    if (isDrawTextInLegendNote)
                    {
                        ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Center, item.mainText, LegendNoteFont, TextBrush, item.Area.left, item.Area.top, item.Area.Width, item.Area.Height, LegengNoteTextLimiteCount);
                    }
                    else
                    {
                        ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Left_Left, item.mainText, LegendNoteFont, TextBrush, item.Area.right + LegendNoteUpDownPadding, item.Area.top, LegendNoteWidth, LegendNoteHeight, LegengNoteTextLimiteCount);
                    }
                    selfBrush.Dispose();
                    LegendNoteFont.Dispose();
                    path.Dispose();
                }
            }
        }
        public override void OnRenderNormalView(System.Drawing.Graphics g, Model.DataModel data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font TextFont, System.Drawing.Font DataFont)
        {
            //utils.drawReportView(g, RePortViewStyle.Arc_angle_rectangle, StartX, StartY, ViewWidth, ViewHeight, linePen.Color, TextBrush, DataBrush, "录像", 130, 200);

            //圆角的弧度
            int       radius       = EViewHeight / 2;
            float     per          = EViewWidth * 1.0f / MaxNum;
            float     realShowData = per * int.Parse(TextAndData[1]);
            Rectangle rect         = new Rectangle(EStartX, EStartY, EViewWidth, 2 * radius);
            Rectangle rectReal     = new Rectangle(EStartX, EStartY, (int)realShowData, 2 * radius);

            //底色
            Brush        selfBrush = new SolidBrush(Color.FromArgb(200, 88, 94, 92));
            GraphicsPath path      = ReportViewUtils.CreateRoundedRectanglePath(rect, radius);

            //绘制底色
            g.FillPath(selfBrush, path);

            //绘制展示色
            path = ReportViewUtils.CreateRoundedRectanglePath(rectReal, radius);
            g.FillPath(lineBrush, path);

            //绘制字体
            ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Left_Left, TextAndData[0], TextFont, TextBrush, EStartX, EStartY - EViewHeight, EViewWidth / 2, EViewHeight, 8);

            //绘制右侧百分比
            float  perNum = int.Parse(TextAndData[1]) * 1.0f / MaxNum * 100;
            string str    = ((int)perNum).ToString();

            ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Right_Right, str + "%", TextFont, TextBrush, EStartX + EViewWidth / 2, EStartY - EViewHeight, EViewWidth / 2, EViewHeight, 8);


            selfBrush.Dispose();
        }
 public override void DrawSelfDefineView(System.Drawing.Graphics g, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font FontText, System.Drawing.Font FontData)
 {
     System.Drawing.Font textFont = new System.Drawing.Font("幼圆", TextSize, System.Drawing.FontStyle.Bold);
     //ReportViewUtils.drawString(g, Title, textFont, TextBrush, 0, 0, Width, Height);
     ReportViewUtils.drawString(g, locationType, Title, textFont, TextBrush, 0, 0, Width, Height);
     textFont.Dispose();
 }
        public override void AnimalionDraw(System.Drawing.Graphics graphics, DetailDataModel data, System.Drawing.Pen pen, System.Drawing.Brush brush, System.Drawing.Font font, object[] args)
        {
            drawFrame(graphics, pen, brush, font);
            if (TextAndData != null)
            {
                Point  p0;
                Point  p1;
                Point  p2;
                Point  p3;
                string str = Index / MaxIndex * 100 + "%";
                if (Index / MaxIndex >= ((int.Parse(TextAndData[1]) * 1.0f) / MaxNum))
                {
                    //Index = int.Parse(TextAndData[1]);
                    str = (int)((int.Parse(TextAndData[1]) * 1.0f) / MaxNum * 100) + "%";
                    //完成任务
                    if (int.Parse(TextAndData[1]) >= MaxNum)
                    {
                        str = "任务完成!";
                        isAutoUpdateData = false;
                    }
                    LocationPointer((int.Parse(TextAndData[1]) * 1.0f) / MaxNum, out p0, out p1, out p2, out p3);
                }
                else
                {
                    LocationPointer(Index / MaxIndex, out p0, out p1, out p2, out p3);
                }
                ReportViewUtils.drawString(graphics, LocationModel.Location_Up_Up, str, font, brush, EStartX, EStartY + EViewHeight - 2 * TextSize, EViewWidth, EViewHeight / 2);

                GraphicsPath path = GraphicalDesignUtils.CreatePath(p0, p1, p2, p3);
                graphics.FillPath(brush, path);
                path.Dispose();
            }
        }
        /// <summary>
        /// 多组数据的柱形绘制
        /// </summary>
        /// <param name="g"></param>
        /// <param name="data"></param>
        /// <param name="rectange"></param>
        /// <param name="linePen"></param>
        /// <param name="lineBrush"></param>
        /// <param name="TextBrush"></param>
        /// <param name="DataBrush"></param>
        /// <param name="TextFont"></param>
        /// <param name="DataFont"></param>
        private void OnRenderMultiView(System.Drawing.Graphics g, DataModel data, Queue rectange, Queue color, int width, int left)
        {
            Rectangle item = new Rectangle();
            Brush     bs   = new SolidBrush(data.ModelColor);
            Brush     bb   = new SolidBrush(Color.FromArgb(100, 210, 210, 210));

            if (IsRadiusRectAngle)
            {
                GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(item, data.Area.Width / 4);

                if (data.Area.IsMouseIn)
                {
                    while (rectange.Count != 0)
                    {
                        bs   = new SolidBrush((Color)color.Dequeue());
                        item = (Rectangle)rectange.Dequeue();
                        g.FillRectangle(bs, item);
                    }

                    g.FillRectangle(bb, left, CoordinateStartY - CoordinateHeight, width, CoordinateHeight);
                }
                else
                {
                    while (rectange.Count != 0)
                    {
                        bs   = new SolidBrush((Color)color.Dequeue());
                        item = (Rectangle)rectange.Dequeue();
                        g.FillRectangle(bs, item);
                    }
                }

                path.Dispose();
            }
            else
            {
                if (data.Area.IsMouseIn)
                {
                    while (rectange.Count != 0)
                    {
                        bs   = new SolidBrush((Color)color.Dequeue());
                        item = (Rectangle)rectange.Dequeue();
                        g.FillRectangle(bs, item);
                    }
                    g.FillRectangle(bb, left, CoordinateStartY - CoordinateHeight, width, CoordinateHeight);
                }
                else
                {
                    while (rectange.Count != 0)
                    {
                        bs   = new SolidBrush((Color)color.Dequeue());
                        item = (Rectangle)rectange.Dequeue();
                        g.FillRectangle(bs, item);
                    }
                }
            }
            bb.Dispose();
            bs.Dispose();
        }
Exemple #8
0
        public override void childPaint(System.Drawing.Graphics g, Model.DataModel Data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font font_Text, System.Drawing.Font font_Data)
        {
            if (isFirst)
            {
                oldColor = linePen.Color;
                isFirst  = false;
            }
            if (Data != null)
            {
                ///建议把绘制的直接写在这里
                if (Data.Area.IsMouseIn)
                {
                    linePen.Color = ReportViewUtils.perferRed;
                }
                else
                {
                    linePen.Color = oldColor;
                }
                ChildDataModel data = Data as ChildDataModel;
                //圆点的大小
                int        startX      = data.Area.left;
                int        startY      = data.Area.top;
                int        width       = data.Area.right - startX;
                int        height      = data.Area.bottom - startY;
                int        CircleRaius = 10;
                SolidBrush sbrush1     = new SolidBrush(Color.FromArgb(150, 1, 77, 103));
                SolidBrush sf          = new SolidBrush(linePen.Color);
                Rectangle  rect        = new Rectangle(startX, startY, width, height);
                float      realAngle   = 360 * data.mainData * 1.0f / MaxNum;
                //顺时针绘制
                float startAngle = 360 - realAngle;
                g.DrawArc(linePen, rect, startAngle, realAngle);
                //绘制圆弧内的字体
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Down, data.mainText, font_Text, TextBrush, startX, startY, width, height / 2, 5);
                //绘制圆弧内的数据
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Up, data.mainData + "", font_Data, DataBrush, startX, startY + height / 2, width, height / 2, 5);

                //绘制圆弧外的字体
                Rectangle    Arc_Out = new Rectangle(startX, startY + height + height / 2, width, 30);
                GraphicsPath path    = ReportViewUtils.CreateRoundedRectanglePath(Arc_Out, 15);
                g.FillPath(sbrush1, path);
                path.Dispose();
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Center, data.childText + "" + data.childData, font_Data, DataBrush, startX, startY + height + height / 2, width, 30, 8);


                //定位圆点
                int       y           = (int)(Math.Sin(startAngle / 180 * Math.PI) * width / 2);
                int       x           = (int)(Math.Cos(startAngle / 180 * Math.PI) * height / 2);
                Rectangle rect_Circle = new Rectangle(startX + width / 2 - CircleRaius / 2 + x, startY + height / 2 - CircleRaius / 2 + y, CircleRaius, CircleRaius);
                //绘制圆点
                g.FillEllipse(sf, rect_Circle);

                sf.Dispose();
                sbrush1.Dispose();
            }
        }
Exemple #9
0
        public override void childPaint(System.Drawing.Graphics g, Model.DataModel Data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font FontText, System.Drawing.Font FontData)
        {
            //绘制Pie自定义标题
            if (IsDrawPieTiTle)
            {
                Brush pieTitleBrush = new SolidBrush(pieTitleColor);
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, pieTitle, pieTitleFont, pieTitleBrush, 0, 3, this.Width, padding);

                pieTitleBrush.Dispose();
            }

            int length = this.Height > this.Width ? (this.Width / 2) : (this.Height / 2);
            int startX = (this.Width - length) / 2;
            int startY = (this.Height - length) / 2;

            if (Data is DetailDataModel)
            {
                DetailDataModel data  = (DetailDataModel)Data;
                string[]        datas = data.TextAndData;
                linePen = new Pen(Color.FromArgb(180, 71, 85, 182), 60);
                //7/12的效果最好看
                piePenWidth = 7 * length / 12;
                Rectangle rectangle = new Rectangle(startX, startY, length, length);

                IsFirst    = true;
                sweepAngle = 0;
                float startAngle = 360;
                for (int i = 0; i < datas.Length / 2; i++)
                {
                    string str       = datas[2 * i + 1];
                    float  realAngle = 360 * int.Parse(str) * 1.0f / allNum;

                    linePen.Width = piePenWidth * int.Parse(str) / maxNum;
                    int realX      = startX + (int)(piePenWidth - linePen.Width + 0.5f) / 2;
                    int realY      = startY + (int)(piePenWidth - linePen.Width + 0.5f) / 2;
                    int realLength = length - (int)(piePenWidth - linePen.Width);

                    rectangle     = new Rectangle(realX, realY, realLength, realLength);
                    linePen.Color = ReportViewUtils.PerferColors[i % ReportViewUtils.PerferColors.Length];
                    startAngle   -= (realAngle - 0.5f);
                    g.DrawArc(linePen, rectangle, startAngle, realAngle + 0.7f);

                    if (IsDrawLineNote)
                    {
                        DrawLineNote(g, linePen.Color, data, 2 * i + 1, startAngle, realAngle, realLength / 2);
                    }
                }
            }

            linePen.Dispose();
            lineBrush.Dispose();
            TextBrush.Dispose();
            DataBrush.Dispose();
            FontText.Dispose();
            FontData.Dispose();
        }
Exemple #10
0
        private void DrawLineNote(Graphics g, Color dataColor, DetailDataModel data, int index, float startAngle, float realAngle, int radius)
        {
            Pen   bl           = new Pen(dataColor);
            Brush brush        = new SolidBrush(NoteColor);
            Font  LineNoteFont = new Font("微软雅黑", 9);

            string[] str = data.TextAndData;

            ///绘制线
            float midAngle;

            if (IsFirst)
            {
                midAngle   = realAngle / 2;
                sweepAngle = realAngle;
                IsFirst    = false;
            }
            else
            {
                midAngle    = sweepAngle + realAngle / 2;
                sweepAngle += realAngle;
            }
            float rmidAngle = (float)(2 * Math.PI / (360 / (midAngle)));

            float startx = radius * (float)Math.Cos(rmidAngle) + this.Width / 2;
            float starty = this.Height / 2 - radius * (float)Math.Sin(rmidAngle);
            float endx   = (radius + 3 * piePenWidth / 4) * (float)Math.Cos(rmidAngle) + this.Width / 2;
            float endy   = this.Height / 2 - (radius + 3 * piePenWidth / 4) * (float)Math.Sin(rmidAngle);

            g.DrawLine(bl, startx, starty, endx, endy);

            float end   = endx;
            float fonty = endy - padding / 2;
            float fontx;

            if (end >= this.Width / 2)
            {
                end  += (piePenWidth / 3);
                fontx = end;
                ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, str[index - 1], LineNoteFont, brush, fontx, fonty, padding, padding);
            }
            else
            {
                end  -= (piePenWidth / 3);
                fontx = end - padding;
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, str[index - 1], LineNoteFont, brush, fontx, fonty, padding, padding);
            }
            g.DrawLine(bl, endx, endy, end, endy);
            ///绘制标签
            //ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, str[index - 1], LineNoteFont, brush, fontx, fonty, padding, padding);

            bl.Dispose();
            brush.Dispose();
            LineNoteFont.Dispose();
        }
Exemple #11
0
        public void initData(List <DataModel> list)
        {
            if (list == null)
            {
                Random rm = ReportViewUtils.CreateRandom();
                list = new List <DataModel>();
                for (int i = 200; i > 0; i--)
                {
                    list.Add(new AutoSortDataModel("ffas花开的军国的地方计算机对方啊fsdfd空打飞000" + i, (int)(rm.NextDouble() * 100), 100, ReportViewUtils.PerferColors[i % 5]));
                }
            }

            //radius_Rectangle_ReportView1.Height = 2000;
            ReportViewAdapter adapter = new SimpleListViewAdapter();

            //设置数据源
            adapter.setData(list);
            //用于设置起始位置
            adapter.setBasePostitionRect(new AreaPositionRect(0, 2 * padding, this.Width, rowHeight + 30));
            setAdapter(adapter);//设置panel的高度


            if (PropertyName == null)
            {
                PropertyName.Add("Member");
                PropertyName.Add("Member of Value");
            }

            //初始化分栏的宽度
            memberWidth = (Width - RightPadding - LeftPadding) / 4;

            //ShowScrollerBar();
            if (IsEnableScrollerBar)
            {
                if (this.Parent is Panel)
                {
                    Panel panel = this.Parent as Panel;
                    if (this.Created && this.IsHandleCreated && !this.IsDisposed)
                    {
                        try
                        {
                            this.Invoke((EventHandler) delegate
                            {
                                panel.AutoScroll = true;
                                panel.Controls.Add(label);
                                label.Location = new Point(0, list.Count * rowHeight);
                            });
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
Exemple #12
0
        private void DrawString(Graphics g, Brush TextBrush, System.Drawing.Font font_Text, DataModel data, string text, string moreText)
        {
            int x      = data.Area.left + padding;
            int y      = data.Area.top;
            int width  = data.Area.right - data.Area.left;
            int height = data.Area.bottom - data.Area.top;

            switch (HisTextLocation)
            {
            case HisTextLocations.left:
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, text, font_Text, TextBrush, x, y, LeftPadding, height);
                break;

            case HisTextLocations.left_up_down:
                ReportViewUtils.drawString(g, LocationModel.Location_Up_Right_Right, moreText, font_Text, TextBrush, x, y - TextAndTextPadding, LeftPadding, height);
                ReportViewUtils.drawString(g, LocationModel.Location_Down_Right_Right, text, font_Text, TextBrush, x, y + TextAndTextPadding, LeftPadding, height);
                break;

            case HisTextLocations.up:
                ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, text, font_Text, TextBrush, x + LeftPadding, y - height, width, height);
                break;

            case HisTextLocations.right:
                ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, text, font_Text, TextBrush, EStartX + EViewWidth, y, width, height);
                break;

            case HisTextLocations.bottom:
                ReportViewUtils.drawString(g, LocationModel.Location_Down_Down, text, font_Text, TextBrush, x + LeftPadding, y + height, width, height);
                break;

            case HisTextLocations.center:
                if (moreText.Trim().Equals(""))
                {
                    ReportViewUtils.drawString(g, LocationModel.Location_Center, text, font_Text, TextBrush, x, y, width, height);
                }
                else
                {
                    if (IsTwoLineShow)
                    {
                        ReportViewUtils.drawString(g, LocationModel.Location_Center, text, font_Text, TextBrush, x, y - TextAndTextPadding, width, height);
                        ReportViewUtils.drawString(g, LocationModel.Location_Center, moreText, font_Text, TextBrush, x, y + TextAndTextPadding, width, height);
                    }
                    else
                    {
                        ReportViewUtils.drawString(g, LocationModel.Location_Center, text, font_Text, TextBrush, x, y, width, height);
                    }
                }

                break;

            default:
                break;
            }
        }
        public override void childPaint(Graphics g, DataModel data, Pen linePen, Brush lineBrush, Brush TextBrush, Brush DataBrush, Font FontText, Font FontData)
        {
            if (data is DetailDataModel)
            {
                DetailDataModel model = (DetailDataModel)data;
                string[]        datas = model.TextAndData;

                imgLabelWidth = _rentalImg1.Width;
                int       startX = LeftPadding + imgLabelWidth + 3;
                int       startY = TopPadding + DataTitleHeight + 8;
                int       width  = (this.Width - 2 * LeftPadding) / 2 - startX;
                int       height = (imgLabelHeight - 8) / 2;
                Brush     brush  = new SolidBrush(Color.White);
                Rectangle rectangle;
                float     realWidth;

                for (int i = 0; i < 4; i = i + 3)
                {
                    DrawmainText(g, datas[i], FontText, startX - imgLabelWidth);
                    if (i == 0)
                    {
                        g.DrawImage(_rentalImg1, new Rectangle(startX - imgLabelWidth - 3, startY, _rentalImg1.Width, _rentalImg1.Height), 0, 0, _rentalImg1.Width, _rentalImg1.Height, GraphicsUnit.Pixel, _attr);
                    }
                    else
                    {
                        g.DrawImage(_rentalImg2, new Rectangle(startX - imgLabelWidth - 3, startY, _rentalImg2.Width, _rentalImg2.Height), 0, 0, _rentalImg2.Width, _rentalImg2.Height, GraphicsUnit.Pixel, _attr);
                    }

                    realWidth = width * (int.Parse(datas[i + 1]) * 1.0f / (int.Parse(datas[i + 1]) + int.Parse(datas[i + 2])));
                    brush     = new SolidBrush(LegendnoteColor1);
                    rectangle = new Rectangle(startX, startY, (int)realWidth, height);
                    g.FillRectangle(brush, rectangle);
                    SizeF size = g.MeasureString(datas[i + 1], FontData);
                    ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, datas[i + 1], FontData, DataBrush, startX + realWidth, startY, size.Width, height);

                    realWidth = width * (int.Parse(datas[i + 2]) * 1.0f / (int.Parse(datas[i + 1]) + int.Parse(datas[i + 2])));
                    brush     = new SolidBrush(LegendnoteColor2);
                    rectangle = new Rectangle(startX, startY + height + 4, (int)realWidth, height);
                    g.FillRectangle(brush, rectangle);
                    size = g.MeasureString(datas[i + 2], FontData);
                    ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, datas[i + 2], FontData, DataBrush, startX + realWidth, startY + height + 4, size.Width, height);

                    startX += (width + imgLabelWidth + 3);
                }

                brush.Dispose();
            }

            if (interfaceLegendnote != null)
            {
                interfaceLegendnote.drawLegendnote(g, linePen, lineBrush, TextBrush, DataBrush, FontText, FontData);
            }
        }
        public override void childPaint(Graphics g, DataModel Data, Pen linePen, Brush lineBrush, Brush TextBrush, Brush DataBrush, System.Drawing.Font font_Text, System.Drawing.Font font_Data)
        {
            ///建议把绘制的直接写在这里
            int newStart_X = Data.Area.left + 5 * padding;
            //圆角的弧度
            int height = Data.Area.bottom - Data.Area.top;

            int width = this.Width - newStart_X - 2 * padding - height;
            //int width = this.Width - newStart_X - 2 * padding;
            int   radius       = height / 2;
            float per          = width * 1.0f / maxNum;
            float realShowData = per * Data.mainData;

            Rectangle rect     = new Rectangle(newStart_X, Data.Area.top, width + height, height);
            Rectangle rectReal = new Rectangle(newStart_X, Data.Area.top, (int)realShowData + height, height);

            //Rectangle rect = new Rectangle(newStart_X, Data.Area.top, width, height);
            //Rectangle rectReal = new Rectangle(newStart_X, Data.Area.top, (int)realShowData, height);
            //底色
            Brush        selfBrush = new SolidBrush(Color.FromArgb(200, 88, 94, 92));
            GraphicsPath path      = ReportViewUtils.CreateRoundedRectanglePath(rect, radius);

            //绘制底色
            g.FillPath(selfBrush, path);

            //绘制展示色
            path = ReportViewUtils.CreateRoundedRectanglePath(rectReal, radius);
            g.FillPath(lineBrush, path);

            //绘制字体
            g.DrawString(Data.mainText, font_Text, TextBrush, Data.Area.left + (newStart_X - Data.Area.left - Data.mainText.Length * TextSize) / 2, Data.Area.top);

            //绘制右侧百分比
            //float perNum = Data.mainData * 1.0f / maxNum * 100;
            //string str = ((int)perNum).ToString();
            //g.DrawString(str + "%", font_Data, DataBrush, width - (str.Length + 1) * TextSize + startX, startY);

            path.Dispose();
            selfBrush.Dispose();

            //utils.drawReportView(g, RePortViewStyle.Arc_Angle_rectangle_EventHandle, Data.Area.left, Data.Area.top, Data.Area.right, Data.Area.bottom - Data.Area.top, linePen.Color, Data.mainText, Data.mainData, 400, TextSize, DataSize);

            ///建议把绘制的直接写在这里
            if (Data.Area.IsMouseIn)
            {
                Color color   = linePen.Color;
                Brush myBrush = new SolidBrush(Color.FromArgb(50, color.R, color.G, color.B));
                g.FillRectangle(myBrush, new Rectangle(Data.Area.left, Data.Area.top - padding / 2,
                                                       this.Width, Data.Area.bottom - Data.Area.top + padding));
                myBrush.Dispose();
            }
        }
        /// 初始化数据
        public void initData()
        {
            List <DataModel> list = new List <DataModel>();

            if (Title == null)
            {
                Title = "报表";
            }
            if (TextAndData == null)
            {
                TextAndData = new string[] { "数据一", "20", "数据二", "30", "数据三", "40" };
            }
            //计算数据之和以及设定最大数据
            allNum = 0;
            CalculateAllNum();
            //CalculateAllNum();
            if (IsDescendingOrder)
            {
                TextAndData = ReportViewUtils.SortTextAndData(TextAndData);
            }
            DataModel model = new DetailDataModel(Title, 0, TextAndData);

            if (IsHorizontally)
            {
                EStartX = this.Width / 2 - EViewWidth / 2;
                EStartY = this.Height / 2 - EViewHeight / 2;
            }
            model.Area = new AreaPositionRect(EStartX, EStartY, EViewWidth + EStartX, EViewHeight + EStartY);
            list.Add(model);

            //添加图形注解,用于解释该图形代表什么
            LegendNoteModels = GetLegendNotes();
            //添加特殊的鼠标响应区域, 注意数据模型必须是坐标已赋值的
            DataModel[] datamodels = LegendNoteModels;
            if (datamodels != null)
            {
                foreach (DataModel item in datamodels)
                {
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            ReportViewAdapter adapter = new SingleReportViewAdapter();

            //设置数据源
            adapter.setData(list);
            adapter.IsVerticalShowData = false;
            setAdapter(adapter);
            AutoResizeWithHeightAndPos();
        }
        public override void OnRenderNormalView(System.Drawing.Graphics g, Model.DataModel Data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font TextFont, System.Drawing.Font DataFont)
        {
            if (isFirst)
            {
                oldColor = linePen.Color;
                isFirst  = false;
            }
            if (Data != null)
            {
                ///建议把绘制的直接写在这里
                if (Data.Area.IsMouseIn)
                {
                    linePen.Color = MouseMoveInColor;
                }
                else
                {
                    linePen.Color = oldColor;
                }
                DetailDataModel data = Data as DetailDataModel;

                System.Drawing.SolidBrush sbrush1 = new System.Drawing.SolidBrush(Color.FromArgb(150, 1, 77, 103));
                System.Drawing.SolidBrush sf      = new System.Drawing.SolidBrush(linePen.Color);
                System.Drawing.Rectangle  rect    = new System.Drawing.Rectangle(EStartX, EStartY, EViewWidth, EViewHeight);
                float realAngle = 360 * int.Parse(data.TextAndData[1]) * 1.0f / MaxNum;
                //顺时针绘制
                float startAngle = 360 - realAngle;
                g.DrawArc(linePen, rect, startAngle, realAngle);
                //绘制圆弧内的字体
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Down, data.TextAndData[0], TextFont, TextBrush, EStartX, EStartY, EViewWidth, EViewHeight / 2, 5);
                //绘制圆弧内的数据
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Up, data.TextAndData[1] + "", DataFont, DataBrush, EStartX, EStartY + EViewHeight / 2, EViewWidth, EViewHeight / 2, 5);

                //绘制圆弧外的字体
                //Rectangle Arc_Out = new Rectangle(StartX, StartY + ViewHeight + bottomLegendHeight, ViewWidth, bottomLegendHeight);
                //GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(Arc_Out, bottomLegendHeight / 2);
                // g.FillPath(sbrush1, path);
                //path.Dispose();
                //ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Center, data.TextAndData[2] + "" + data.TextAndData[3], DataFont, DataBrush, StartX, StartY + ViewHeight + bottomLegendHeight, ViewWidth, bottomLegendHeight, 8);


                //定位圆点
                float      y           = (float)(Math.Sin(startAngle / 180 * Math.PI) * EViewWidth / 2);
                float      x           = (float)(Math.Cos(startAngle / 180 * Math.PI) * EViewHeight / 2);
                RectangleF rect_Circle = new RectangleF((EStartX + EViewWidth / 2 - CircleRaius / 2 + x), (EStartY + EViewHeight / 2 - CircleRaius / 2) + y, CircleRaius, CircleRaius);
                //绘制圆点
                g.FillEllipse(sf, rect_Circle);

                sf.Dispose();
                sbrush1.Dispose();
            }
        }
        private void drawAllsumText(Graphics g, System.Drawing.Font LableFont, Brush TextBrush, int CoordinateStartX, int CoordinateStartY, int CoordinateWidth, int CoordinateHeight)
        {
            string str = allNum + LableAllNum;

            switch (DrawAllSumLocation)
            {
            case AllSumLocation.none:
                break;

            case AllSumLocation.left_up:
                ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY - CoordinateHeight, CoordinateWidth, padding);
                break;

            case AllSumLocation.left_down:
                ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY, CoordinateWidth, padding);
                break;

            case AllSumLocation.left_center:
                ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY - CoordinateHeight / 2, CoordinateWidth, padding);
                break;

            case AllSumLocation.center_up:
                ReportViewUtils.drawString(g, LocationModel.Location_Center, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY - CoordinateHeight, CoordinateWidth, padding);
                break;

            case AllSumLocation.center_down:
                ReportViewUtils.drawString(g, LocationModel.Location_Center, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY, CoordinateWidth, padding);
                break;

            case AllSumLocation.center_center:
                ReportViewUtils.drawString(g, LocationModel.Location_Center, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY - CoordinateHeight / 2, CoordinateWidth, padding);
                break;

            case AllSumLocation.right_up:
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY - CoordinateHeight, CoordinateWidth, padding);
                break;

            case AllSumLocation.right_down:
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY, CoordinateWidth, padding);
                break;

            case AllSumLocation.right_center:
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, str, LableFont, TextBrush, CoordinateStartX, CoordinateStartY - CoordinateHeight / 2, CoordinateWidth, padding);
                break;

            default:
                break;
            }
        }
Exemple #18
0
        private void DrawMultiRanking(Graphics g, DataModel Data, Pen linePen, Brush lineBrush, Brush TextBrush, Brush DataBrush, System.Drawing.Font font_Text, System.Drawing.Font font_Data)
        {
            if (Data is RankModel)
            {
                RankModel rankmodel = Data as RankModel;
                EStartX = rankmodel.Area.left + 10;
                EStartY = rankmodel.Area.top;
                //宽高
                EViewWidth  = (this.Width - 20);
                EViewHeight = rankmodel.Area.bottom - rankmodel.Area.top;
                int rankWidth = EViewWidth / 8;
                //绘制其它色的个数
                if (IsDrawColorfulRectAngle)
                {
                    lineBrush.Dispose();
                    lineBrush = new SolidBrush(rankmodel.ModelColor);
                }
                //绘制排名
                Rectangle    rect = new Rectangle(EStartX, EStartY, rankWidth, EViewHeight);
                GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(rect, EViewHeight / 4);
                g.FillPath(lineBrush, path);
                ReportViewUtils.drawString(g, rankmodel.Index + "", font_Text, TextBrush, EStartX, EStartY, rankWidth, EViewHeight);
                path.Dispose();

                //绘制名称
                int    startText     = EStartX + rankWidth + 20;
                int    rankTextWidth = EViewWidth / 3;
                string text          = rankmodel.mainText;
                text = ReportViewUtils.LimiteText(g, font_Text, text, rankTextWidth);
                ReportViewUtils.drawString(g, text, font_Text, TextBrush, startText, EStartY, rankTextWidth, EViewHeight);

                //绘制数据
                startText += rankTextWidth;
                text       = rankmodel.mainData + "";
                text       = ReportViewUtils.LimiteText(g, font_Text, text, rankTextWidth);
                ReportViewUtils.drawString(g, text, font_Text, TextBrush, startText, EStartY, rankTextWidth, EViewHeight);

                ///建议把绘制的直接写在这里
                if (rankmodel.Area.IsMouseIn)
                {
                    Color color   = rankmodel.ModelColor;
                    Brush myBrush = new SolidBrush(Color.FromArgb(BackGroundAlpha, color.R, color.G, color.B));
                    g.FillRectangle(myBrush, new Rectangle(rankmodel.Area.left, rankmodel.Area.top - padding / 2,
                                                           this.Width, rankmodel.Area.bottom - rankmodel.Area.top + padding));
                    myBrush.Dispose();
                }
            }
        }
        private void DrawmainText(Graphics g, string p, System.Drawing.Font FontText, int startX)
        {
            if (p == null)
            {
                return;
            }

            Brush brush = new SolidBrush(DataTitleColor);

            FontText = new Font("微软雅黑", DataTitleSize);
            SizeF size = g.MeasureString(p, FontText);

            ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, p, FontText, brush, startX, TopPadding, size.Width, DataTitleHeight);

            brush.Dispose();
        }
Exemple #20
0
        public override void OnRenderNormalView(System.Drawing.Graphics g, Model.DataModel data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font TextFont, System.Drawing.Font DataFont)
        {
            //绘制点
            Rectangle item = new Rectangle(data.Area.left, data.Area.top, data.Area.Width, data.Area.Height);

            if (IsDrawDetailData)
            {
                //ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, CoordinateDataModelBean.Y_Data[i] + "", FontData, DataBrush, StartX, StartY, LeftPadding, padding);
                g.DrawString(data.mainData + "", DataFont, DataBrush, (item.X), item.Y - 2 * DataSize);
            }
            Brush bs = new SolidBrush(data.ModelColor);
            Brush bb = new SolidBrush(Color.FromArgb(100, data.ModelColor.R, data.ModelColor.G, data.ModelColor.B));

            if (IsRadiusRectAngle)
            {
                GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(item, data.Area.Width / 4);

                if (data.Area.IsMouseIn)
                {
                    g.FillPath(bs, path);
                    g.FillRectangle(bb, data.Area.left, CoordinateStartY - CoordinateHeight, data.Area.Width, CoordinateHeight);
                }
                else
                {
                    g.FillPath(bs, path);
                }

                path.Dispose();
            }
            else
            {
                if (data.Area.IsMouseIn)
                {
                    g.FillRectangle(bs, item);
                    g.FillRectangle(bb, data.Area.left, CoordinateStartY - CoordinateHeight, data.Area.Width, CoordinateHeight);
                }
                else
                {
                    g.FillRectangle(bs, item);
                }
            }

            bb.Dispose();
            bs.Dispose();
        }
        public void drawLegendnote(Graphics g, Pen linePen, Brush lineBrush, Brush TextBrush, Brush DataBrush, Font FontText, Font FontData)
        {
            if (CoordinateModels == null)
            {
                return;
            }
            //设定默认的初始颜色
            if (CoordinateModels != null && CoordinateModels.Count > 0)
            {
                ModelColor = CoordinateModels[0].ModelColor;
            }
            foreach (DataModel item in CoordinateModels)
            {
                if (IsGroup(item))
                {
                    GroupData = new List <DataModel>();
                    GroupData.Add(item);
                }
            }
            List <Rectangle> position = GetAllRectangle();

            //圆角矩形标签绘制
            for (int i = 0; i < position.Count; i++)
            {
                ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, TitlesName[i], FontData, TextBrush, position[i].X + LegendNoteWidth, position[i].Y - LegendNoteHeight, (Width - EViewWidth) / 2, LegendNoteHeight + padding);
                GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(position[i], LegendNoteHeight / 2);
                Brush        bbsh = new SolidBrush(ALLGroup[0][i].ModelColor);
                g.FillPath(bbsh, path);
                bbsh.Dispose();
                path.Dispose();
            }

            // 绘制围绕点旋转的文本
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            for (int i = 0; i < ALLGroup.Count; i++)
            {
                DrawRoateText.DrawString(g, ALLGroup[i][0].mainText, LableFont, TextBrush, new PointF(ALLGroup[i][0].Area.left + MultiPadding / 2, CoordinateStartY + padding), format, TextRotate);
            }

            ALLGroup  = new List <List <DataModel> >();
            GroupData = new List <DataModel>();
        }
Exemple #22
0
 public override void detailDraw(Graphics g, DataModel model, Brush TextBrush, Brush DataBrush, Brush BackGroundBrush, Font TextFont, Font DataFont)
 {
     if (model != null)
     {
         Rectangle    rect = new Rectangle(LocalPosition.X + Padding, LocalPosition.Y, Width, Height);
         GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(rect, Height / 3);
         //绘制底色
         g.FillPath(BackGroundBrush, path);
         int centerTextX = (this.Width - model.mainText.Length * TextSize) / 2;
         int centerTextY = (this.Height / 2 - TextSize) / 2;
         int centerDataX = (this.Width - model.mainData.ToString().Length *TextSize) / 2;
         int centerDataY = (this.Height / 2 - DataSize) / 2 + this.Height / 2;
         //绘制字体
         g.DrawString(model.mainText, TextFont, TextBrush, LocalPosition.X + Padding + centerTextX, LocalPosition.Y + centerTextY);
         g.DrawString(model.mainData + "", DataFont, DataBrush, LocalPosition.X + Padding + centerDataX, LocalPosition.Y + centerDataY);
         path.Dispose();
     }
 }
        private float drawFrame(Graphics g, Pen linePen, Brush TextBrush, Font FontText)
        {
            Rectangle rect = new Rectangle(EStartX, EStartY, EViewWidth, EViewHeight);

            linePen.Width = linepenWidth;
            //顺时针绘制, 绘制弧形
            linePen.Color = Color.FromArgb(255, 197, 129, 123);
            g.DrawArc(linePen, rect, 140, 40 + 1);
            linePen.Color = ReportViewUtils.perferBlue;
            g.DrawArc(linePen, rect, 180, 180);
            linePen.Color = Color.FromArgb(255, 66, 190, 189);
            g.DrawArc(linePen, rect, 0 - 1, 41);
            //绘制刻度(定制绘制)
            linePen.Width = 0.1f;
            for (int i = 0; i < 14; i++)
            {
                switch (i)
                {
                case 0:
                    linePen.Color = Color.FromArgb(255, 197, 129, 123);
                    break;

                case 3:
                    linePen.Color = ReportViewUtils.perferBlue;
                    break;

                case 8:
                    linePen.Color = Color.FromArgb(255, 66, 190, 189);
                    break;

                default:
                    break;
                }
                Point point1 = LocationPointFromAngle(140 + 20 * i, EViewWidth / 2, EViewWidth, EStartX, EStartY);
                Point point2 = LocationPointFromAngle(140 + 20 * i, (EViewWidth - ScaleLength) / 2, EViewWidth, EStartX, EStartY);
                g.DrawLine(linePen, point1, point2);
            }
            //绘制名称
            float dd = int.Parse(TextAndData[1]) * 1.0f / MaxNum;

            //ReportViewUtils.drawString(g, data.mainText, font_Text, TextBrush, StartX, StartY + ViewHeight, ViewWidth, ViewHeight / 2);
            ReportViewUtils.drawString(g, TextAndData[0], FontText, TextBrush, EStartX, EStartY + EViewHeight, EViewWidth, Height - EStartY - EViewHeight);
            return(dd);
        }
        public void drawLegendnote(Graphics g, Pen linePen, Brush lineBrush, Brush TextBrush, Brush DataBrush, Font FontText, Font FontData)
        {
            if (Legendnote1 == null)
            {
                return;
            }
            TextBrush = new SolidBrush(ReportViewUtils.perferOrange);
            int   width = (this.Width - LeftPadding - RightPadding) / 2;
            Brush brush = new SolidBrush(LegendnoteColor1);

            FontText = new Font("微软雅黑", 9);
            SizeF size = g.MeasureString(Legendnote1, FontText);

            g.FillRectangle(brush, this.Width - 2 * size.Width - RightPadding, TopPadding + 3, size.Width, 2 * size.Height / 3);
            ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, Legendnote1, FontText, TextBrush, this.Width - size.Width - RightPadding, TopPadding, size.Width, size.Height);
            brush = new SolidBrush(LegendnoteColor2);
            g.FillRectangle(brush, this.Width - 2 * size.Width - RightPadding, TopPadding + size.Height + 3, size.Width, 2 * size.Height / 3);
            ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, Legendnote2, FontText, TextBrush, this.Width - size.Width - RightPadding, TopPadding + size.Height, size.Width, size.Height);

            brush.Dispose();
        }
Exemple #25
0
        /// <summary>
        /// 绘制属性栏
        /// </summary>
        /// <param name="g"></param>
        /// <param name="contentFont"></param>
        private void DrawSelfDefine(Graphics g, Font contentFont, int width)
        {
            Brush barBrush     = new SolidBrush(Color.Blue);
            Brush contentBrush = new SolidBrush(Color.White);

            //Rectangle rectangle = new Rectangle(0, 0, Width, padding);
            //Brush brush = new SolidBrush(BackColor);
            //g.FillRectangle(brush, rectangle);

            Rectangle memrectangle = new Rectangle(0 + LeftPadding / 2, 0 + padding / 2, memberWidth + LeftPadding / 2, padding);

            g.FillRectangle(barBrush, memrectangle);
            ReportViewUtils.drawString(g, LocationModel.Location_Left, PropertyName[0], contentFont, contentBrush, 0 + LeftPadding / 2, 0 + padding / 2, memberWidth, padding);

            Rectangle numrectangle = new Rectangle(LeftPadding + memberWidth + (padding / 4), 0 + padding / 2, width, padding);

            g.FillRectangle(barBrush, numrectangle);
            ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, PropertyName[1], contentFont, contentBrush, LeftPadding + memberWidth + (padding / 4), 0 + padding / 2, width, padding);

            barBrush.Dispose();
            contentBrush.Dispose();
            //brush.Dispose();
        }
Exemple #26
0
        public void initData(List <DataModel> list)
        {
            if (list == null)
            {
                Random rm = ReportViewUtils.CreateRandom();
                list = new List <DataModel>();
                for (int i = 200; i > 0; i--)
                {
                    list.Add(new AutoSortDataModel("ffas花开的军国的地方计算机对方啊fsdfd空打飞000" + i, (int)(rm.NextDouble() * 100), 100, ReportViewUtils.PerferColors[i % 5]));
                }
            }
            ///以后的自动刷新怎么办?????
            if (RePortViewStyle == RePortViewStyles.Ranking)
            {
                int      count       = list.Count;
                string[] textAndData = new string[count * 2];
                int      k           = 0;
                foreach (var item in list)
                {
                    textAndData[2 * k]     = item.mainText;
                    textAndData[2 * k + 1] = item.mainData + "";
                    k++;
                }
                textAndData = ReportViewUtils.SortTextAndData(textAndData);
                list.Clear();
                RankModel model = null;
                for (int i = 0; i < count; i++)
                {
                    model            = new RankModel(textAndData[2 * i], int.Parse(textAndData[2 * i + 1]), i + 1);
                    model.ModelColor = ReportViewUtils.PerferColors[i % 5];
                    list.Add(model);
                }
            }

            //radius_Rectangle_ReportView1.Height = 2000;
            ReportViewAdapter adapter = new SimpleListViewAdapter();

            //设置数据源
            adapter.setData(list);
            //用于设置起始位置
            adapter.setBasePostitionRect(new AreaPositionRect(0, 20, this.Width, rowHeight + 20));
            setAdapter(adapter);//设置panel的高度
            //ShowScrollerBar();
            if (IsEnableScrollerBar)
            {
                if (this.Parent is Panel)
                {
                    Panel panel = this.Parent as Panel;
                    if (this.Created && this.IsHandleCreated && !this.IsDisposed)
                    {
                        try
                        {
                            this.Invoke((EventHandler) delegate
                            {
                                panel.AutoScroll = true;
                                panel.Controls.Add(label);
                                label.Location = new Point(0, list.Count * rowHeight);
                            });
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
Exemple #27
0
        public override void DrawSelfDefine(System.Drawing.Graphics g, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font FontText, System.Drawing.Font FontData)
        {
            linePen.Width = 1.0f;
            Font LableFont  = new Font("Arial", LableSize);
            Font AllSumFont = new Font("Arial", AllSumSize);


            //绘制横坐标和标题
            ReportViewUtils.drawString(g, Title, FontText, TextBrush, EStartX, EStartY, EViewWidth, TopPadding);
            g.DrawLine(linePen, CoordinateStartX, CoordinateStartY, CoordinateStartX + CoordinateWidth, CoordinateStartY);
            if (!IsEnableGridLine)
            {
                g.DrawLine(linePen, CoordinateStartX + CoordinateWidth, CoordinateStartY, CoordinateStartX + CoordinateWidth - 6, CoordinateStartY + 3);
                g.DrawLine(linePen, CoordinateStartX + CoordinateWidth, CoordinateStartY, CoordinateStartX + CoordinateWidth - 6, CoordinateStartY - 3);
            }

            // 绘制围绕点旋转的文本
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            //绘制标签
            DrawRoateText.DrawString(g, LableX, LableFont, TextBrush, new PointF(CoordinateStartX + CoordinateWidth + padding, CoordinateStartY + padding), format, TextRotate);


            //数据源长度
            int dataLength = 0;

            if (CoordinateModels != null)
            {
                dataLength = CoordinateModels.Count / (ModelCount);
            }

            Point[] listPoint = new Point[dataLength];
            //绘制刻度
            float per_X = 0;

            if (IsEnableGridLine)
            {
                per_X = (CoordinateWidth * 1.0f) / Count_X;
            }
            else
            {
                per_X = (CoordinateWidth - padding) * 1.0f / Count_X;
            }
            for (int i = 0; i < Count_X + 1; i++)
            {
                //绘制刻度
                int x = (int)(CoordinateStartX + i * per_X);
                if (IsEnableGridLine)
                {
                    linePen.Color = Color.FromArgb(30, LineColor.R, LineColor.G, LineColor.B);
                    g.DrawLine(linePen, x, CoordinateStartY, x, CoordinateStartY - CoordinateHeight);
                }
                else
                {
                    g.DrawLine(linePen, x, CoordinateStartY, x, CoordinateStartY - padding / 10);
                }

                if (dataLength > i)
                {
                    listPoint[i] = new Point(x, 0);
                }


                //绘制刻度值
                if (IsShowX_Scale)
                {
                    if (dataLength > i)
                    {
                        if (CoordinateDataModelBean != null)
                        {
                            DrawRoateText.DrawString(g, CoordinateDataModelBean.X_Data[i], LableFont, TextBrush, new PointF(CoordinateStartX + i * per_X, CoordinateStartY + padding), format, TextRotate);
                        }
                    }
                }
            }
            linePen.Color = LineColor;


            //如果自动刷新时间, 则会刷新最大值, 从而刷新Y轴
            if (isAutoUpdateData)
            {
                if (CoordinateDataModelBean != null)
                {
                    if (CoordinateDataModelBean.Y_Data != null)
                    {
                        MaxNum = ReportViewUtils.getMaxNumFromData(CoordinateDataModelBean.Y_Data);
                    }
                }
            }

            //绘制Y轴
            g.DrawLine(linePen, CoordinateStartX, CoordinateStartY, CoordinateStartX, CoordinateStartY - CoordinateHeight);
            if (!IsEnableGridLine)
            {
                g.DrawLine(linePen, CoordinateStartX + 3, CoordinateStartY - CoordinateHeight + 6, CoordinateStartX, CoordinateStartY - CoordinateHeight);
                g.DrawLine(linePen, CoordinateStartX - 3, CoordinateStartY - CoordinateHeight + 6, CoordinateStartX, CoordinateStartY - CoordinateHeight);
            }
            //绘制标签
            int lableLength = CoordinateDataModelBean.Lable_Y.Length;

            ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, LableY, LableFont, TextBrush, EStartX, CoordinateStartY - CoordinateHeight - padding, LeftPadding - 10, padding);
            //g.DrawString(LableY, LableFont, TextBrush, (padding - lableLength * lableSize) / 2 + startX, startY + topPadding);
            //对应到坐标上
            //规定Y轴刻度值
            float perNum = MaxNum / Count_Y;
            //规定Y轴刻度
            float per_Y = 0;

            if (IsEnableGridLine)
            {
                per_Y = (CoordinateHeight) * 1.0f / Count_Y;
            }
            else
            {
                per_Y = (CoordinateHeight - padding) * 1.0f / Count_Y;
            }
            //绘制刻度值和刻度
            linePen.Color = Color.FromArgb(30, LineColor.R, LineColor.G, LineColor.B);
            for (int i = 0; i < Count_Y + 1; i++)
            {
                if (IsShowY_Scale)
                {
                    ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, perNum * i + "", LableFont, TextBrush, EStartX, CoordinateStartY - i * per_Y - padding / 2, LeftPadding - 10, padding);
                    //g.DrawString(perNum * i + "", LableFont, TextBrush, (padding - lableSize * 3) / 2 + startX, height - padding - i * per_Y - lableSize - bottomPadding);
                }
                int y = (int)(CoordinateStartY - i * per_Y);
                g.DrawLine(linePen, CoordinateStartX, y, CoordinateStartX + CoordinateWidth, y);
            }
            linePen.Color = LineColor;



            for (int j = 0; j < ModelCount; j++)
            {
                linePen.Color = CoordinateDataModelBean.CoordinateModelList[dataLength * j].ModelColor;
                //计算数据中的点对应到坐标的点
                bool isMouseIn = false;
                for (int i = 0; i < dataLength; i++)
                {
                    float dataY = CoordinateDataModelBean.Y_Data[i + dataLength * j];
                    //把数据对应到实际的坐标
                    int posY = (int)(CoordinateStartY - dataY * per_Y / perNum);
                    listPoint[i].Y = posY;
                    //重新定位数据模型的坐标
                    isMouseIn = adapter.DataList[i + dataLength * j].Area.IsMouseIn;
                    adapter.DataList[i + dataLength * j].Area = ReLoadAreaPosition(listPoint[i].X, listPoint[i].Y, (int)per_X, (int)per_Y);
                    //adapter.DataList[i].Area = new AreaPositionRect(listPoint[i].X, listPoint[i].Y, listPoint[i].X, listPoint[i].Y);
                    adapter.DataList[i + dataLength * j].Area.IsMouseIn = isMouseIn;
                }


                //绘制曲线
                if (IsDrawCurve)
                {
                    if (listPoint.Length > 0)
                    {
                        g.DrawCurve(linePen, listPoint, Tension);
                    }
                }

                if (IsFillPathCurve)
                {
                    Point[] point2 = new Point[4];

                    if (listPoint.Length > 0)
                    {
                        GraphicsPath path = null;
                        point2[0].X = listPoint[dataLength - 1].X;
                        point2[0].Y = listPoint[dataLength - 1].Y;
                        point2[1].X = listPoint[dataLength - 1].X;
                        point2[1].Y = CoordinateStartY;
                        point2[2].X = CoordinateStartX;
                        point2[2].Y = CoordinateStartY;

                        point2[3].X = CoordinateStartX;
                        point2[3].Y = listPoint[0].Y;
                        path        = CreatePath(listPoint, point2);
                        Brush fillBrush = new SolidBrush(Color.FromArgb(FillBrushAlpha, linePen.Color.R, linePen.Color.G, linePen.Color.B));
                        g.FillPath(fillBrush, path);
                        fillBrush.Dispose();
                        path.Dispose();
                    }
                }
                if (IsShowLegendnote)
                {
                    CalculateAllNum(dataLength, j);
                    ReportViewUtils.drawString(g, LocationModel.Location_Left_Left, Titles[j] + allNum + LableAllNum, LableFont, TextBrush, CoordinateStartX + CoordinateWidth + ((Width - EViewWidth) / 4 + LegendNoteWidth + 10), CoordinateStartY - CoordinateHeight + (LegendNoteHeight + padding) * j, (Width - EViewWidth) / 2, LegendNoteHeight + padding);
                    Rectangle    rect = new Rectangle(CoordinateStartX + CoordinateWidth + ((Width - EViewWidth) / 2 - LegendNoteWidth) / 2, CoordinateStartY - CoordinateHeight + (LegendNoteHeight + padding) * (j) + padding / 2, LegendNoteWidth, LegendNoteHeight);
                    GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(rect, LegendNoteHeight / 2);
                    Brush        bbsh = new SolidBrush(linePen.Color);
                    g.FillPath(bbsh, path);
                    bbsh.Dispose();
                    path.Dispose();
                }
                //drawAllsumText(g, AllSumFont, TextBrush, CoordinateStartX, CoordinateStartY, CoordinateWidth, CoordinateHeight);
            }
            AllSumFont.Dispose();
            LableFont.Dispose();
        }
Exemple #28
0
        public void initData()
        {
            //List<DataModel> list = new List<DataModel>();
            //DataModel model = new DataModel();
            if (Title != null)
            {
                CoordinateDataModelBean.Title = Title;
            }
            else
            {
                Title = CoordinateDataModelBean.Title;
            }
            if (LableX != null)
            {
                CoordinateDataModelBean.Lable_X = LableX;
            }
            else
            {
                LableX = CoordinateDataModelBean.Lable_X;
            }
            if (LableY != null)
            {
                CoordinateDataModelBean.Lable_Y = LableY;
            }
            else
            {
                LableY = CoordinateDataModelBean.Lable_Y;
            }
            if (CoordinateModels != null)
            {
                CoordinateDataModelBean.CoordinateModelList = CoordinateModels;
            }
            else
            {
                List <DataModel> Models = new List <DataModel>();
                Models.Add(new DataModel("时间01", 50));
                Models.Add(new DataModel("时间02", 100));
                Models.Add(new DataModel("时间03", 150));
                Models.Add(new DataModel("时间04", 200));
                Models.Add(new DataModel("时间05", 200));
                Models.Add(new DataModel("时间06", 200));
                Models.Add(new DataModel("时间07", 200));
                addDifferentModels(Models);
                Models = new List <DataModel>();
                Models.Add(new DataModel("时间01", 80));
                Models.Add(new DataModel("时间02", 10));
                Models.Add(new DataModel("时间03", 50));
                Models.Add(new DataModel("时间04", 20));
                Models.Add(new DataModel("时间05", 220));
                Models.Add(new DataModel("时间06", 10));
                Models.Add(new DataModel("时间07", 230));
                addDifferentModels(Models);
                Models = new List <DataModel>();
                Models.Add(new DataModel("时间01", 180));
                Models.Add(new DataModel("时间02", 110));
                Models.Add(new DataModel("时间03", 150));
                Models.Add(new DataModel("时间04", 120));
                Models.Add(new DataModel("时间05", 80));
                Models.Add(new DataModel("时间06", 50));
                Models.Add(new DataModel("时间07", 30));
                addDifferentModels(Models);
                CoordinateDataModelBean.CoordinateModelList = CoordinateModels;
            }

            CoordinateDataModelBean.initXYData();
            //计算数据之和以及设定最大数据
            //AllNum = 0;
            MaxNum = ReportViewUtils.getMaxNumFromData(CoordinateDataModelBean.Y_Data);
            //CalculateAllNum();
            if (IsNeedDataPartitioning)
            {
                //整理数据
            }
            //自动缩放
            if (IsAutoReSizeView)
            {
                ResizeReportViewChange();
            }
            else
            {
                if (EViewWidth == 0)
                {
                    throw new ArgumentException("请设定绘制图像的宽高, 或者设置IaAutoReSize = true");
                }
            }

            if (IsHorizontally)
            {
                if (EViewWidth != 0)
                {
                    EStartX = this.Width / 2 - EViewWidth / 2;
                    EStartY = this.Height / 2 - EViewHeight / 2;
                }
            }
            //自动调整位置
            if (IsHorizontally)
            {
                ReLocationModelPos();
            }
            //model.Area = new AreaPositionRect(StartX, StartY, ViewWidth + StartX, ViewHeight + StartY);
            //list.Add(model);
            ReportViewAdapter adapter = new SingleReportViewAdapter();

            //设置数据源
            adapter.setData(CoordinateModels);
            adapter.IsVerticalShowData = false;
            setAdapter(adapter);
        }
Exemple #29
0
        private void DrawArcRectAngle(Graphics g, DataModel Data, Pen linePen, Brush lineBrush, Brush TextBrush, System.Drawing.Font font_Text)
        {
            if (Data.Area.top < 2 * padding)
            {
                return;
            }

            if (Data is AutoSortDataModel)
            {
                AutoSortDataModel model = Data as AutoSortDataModel;
                //建议把绘制的直接写在这里
                int PaddingStart_X = Data.Area.left + LeftPadding + memberWidth + padding / 2;
                //宽高
                int height = Data.Area.bottom - Data.Area.top;

                int   width        = this.Width - PaddingStart_X - RightPadding;
                float per          = width * 1.0f / model.MaxData;
                float realShowData = per * Data.mainData;
                //Rectangle rect = new Rectangle(PaddingStart_X, Data.Area.top, width, height);
                Rectangle rectReal = new Rectangle(PaddingStart_X, Data.Area.top, (int)realShowData, height);

                if (IsDrawColorfulRectAngle)
                {
                    lineBrush.Dispose();
                    lineBrush = new SolidBrush(Data.ModelColor);
                }
                g.FillRectangle(lineBrush, rectReal);

                //绘制字体
                string text      = Data.mainText;
                string firstText = "";
                if (isOvertTextShowCount(g, text, font_Text))
                {
                    if (TextShowCount < text.Length)
                    {
                        firstText = LimiteText(g, font_Text, text);
                    }
                    else
                    {
                        firstText = text;
                    }

                    if (!IsTwoLineShow)
                    {
                        if (TextLeaveOutIsEnd)
                        {
                            text = firstText;
                        }
                        if (HisTextLocation == HisTextLocations.none)
                        {
                            HisTextLocation = HisTextLocations.left;
                        }
                        //ReportViewUtils.drawString(g, LocationModel.Location_Up_Right_Right, text, font_Text, TextBrush, Data.Area.left, Data.Area.top - TextAndTextPadding, LeftPadding, height);
                    }
                    else
                    {
                        string endText = text.Substring(TextShowCount);
                        if (isOvertTextShowCount(g, endText, font_Text))
                        {
                            if (TextLeaveOutIsEnd)
                            {
                                text = endText.Substring(0, TextShowCount - 3) + "...";
                            }
                            else
                            {
                                text = "..." + endText.Substring(TextShowCount);
                            }
                        }
                        if (HisTextLocation == HisTextLocations.none)
                        {
                            HisTextLocation = HisTextLocations.left_up_down;
                        }
                    }
                }
                else
                {
                    if (HisTextLocation == HisTextLocations.none)
                    {
                        HisTextLocation = HisTextLocations.left;
                    }
                }
                //g.DrawString(text, font_Text, TextBrush, Data.Area.left + (newStart_X - Data.Area.left - text.Length * TextSize) / 2, Data.Area.top);
                DrawString(g, TextBrush, font_Text, Data, text, firstText);

                if (IsDrawValue)
                {
                    ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, Data.mainData + "", font_Text, TextBrush, PaddingStart_X + realShowData, Data.Area.top, padding, height);
                }

                ///建议把绘制的直接写在这里
                if (Data.Area.IsMouseIn)
                {
                    Color color   = Data.ModelColor;
                    Brush myBrush = new SolidBrush(Color.FromArgb(100, 210, 210, 210));
                    g.FillRectangle(myBrush, new Rectangle(Data.Area.left, Data.Area.top - padding / 4,
                                                           this.Width, Data.Area.bottom - Data.Area.top + padding / 2));
                    myBrush.Dispose();
                }

                if (IsShowPropertyBer)
                {
                    DrawSelfDefine(g, PropertycontentFont, width + RightPadding);
                }
            }
        }
        private void drawLine(Graphics graphics, Pen pen, Brush brush, Font font, Object[] args, DetailDataModel data)
        {
            if (data != null)
            {
                string[] strs = data.TextAndData;
                if (args != null)
                {
                    //绘制的中心点
                    int centerX = EStartX + EViewWidth / 2;
                    int centerY = EStartY + EViewHeight / 2;
                    for (int i = 0; i < args.Length / 2; i++)
                    {
                        if (strs[2 * i + 1].Equals("0"))
                        {
                            continue;
                        }
                        pen.Color = ReportViewUtils.PerferColors[i % ReportViewUtils.PerferColors.Length];
                        //Console.WriteLine("object = {0}", (double)item);
                        float x  = (float)args[2 * i];
                        float y  = (float)args[2 * i + 1];
                        float sx = x;
                        float sy = y;
                        graphics.FillEllipse(brush, new RectangleF(x - 2f, y - 2f, 2f, 2f));
                        if (x < centerX)
                        {
                            sx = x - Index;
                            if (y < centerY)
                            {
                                sy = y - Index;
                                if (Index >= MaxIndex)
                                {
                                    graphics.DrawLine(pen, sx, sy, sx - LineWidth, sy);
                                    if (LineWidth >= MaxLineWidth)
                                    {
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i + 1], font, brush, (sx - LineWidth), sy, LineWidth, LineHeight, TextLimiteCount);
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i], font, brush, (sx - LineWidth), sy - LineHeight, LineWidth, LineHeight, TextLimiteCount);
                                    }
                                }
                                graphics.DrawLine(pen, x, y, sx, sy);
                            }
                            else
                            {
                                sy = y + Index;
                                if (Index >= MaxIndex)
                                {
                                    graphics.DrawLine(pen, sx, sy, sx - LineWidth, sy);
                                    if (LineWidth >= MaxLineWidth)
                                    {
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i + 1], font, brush, (sx - LineWidth), sy, LineWidth, LineHeight, TextLimiteCount);
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i], font, brush, (sx - LineWidth), sy - LineHeight, LineWidth, LineHeight, TextLimiteCount);
                                    }
                                }
                                graphics.DrawLine(pen, x, y, sx, sy);
                            }
                        }
                        else
                        {
                            sx = x + Index;
                            if (y < centerY)
                            {
                                sy = y - Index;
                                if (Index >= MaxIndex)
                                {
                                    graphics.DrawLine(pen, sx, sy, sx + LineWidth, sy);
                                    if (LineWidth >= MaxLineWidth)
                                    {
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i + 1], font, brush, (sx), sy, LineWidth, LineHeight, TextLimiteCount);
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i], font, brush, (sx), sy - LineHeight, LineWidth, LineHeight, TextLimiteCount);
                                    }
                                }
                                graphics.DrawLine(pen, x, y, sx, sy);
                            }
                            else
                            {
                                sy = y + Index;
                                if (Index >= MaxIndex)
                                {
                                    graphics.DrawLine(pen, sx, sy, sx + LineWidth, sy);
                                    if (LineWidth >= MaxLineWidth)
                                    {
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i + 1], font, brush, (sx), sy, LineWidth, LineHeight, TextLimiteCount);
                                        ReportViewUtils.drawStringWithLimiteText(graphics, LocationModel.Location_Center, strs[2 * i], font, brush, (sx), sy - LineHeight, LineWidth, LineHeight, TextLimiteCount);
                                    }
                                }
                                graphics.DrawLine(pen, x, y, sx, sy);
                            }
                        }
                    }
                }

                if (Index >= MaxIndex)
                {
                    if (LineWidth <= MaxLineWidth)
                    {
                        LineWidth += 4;
                    }
                }
                //Console.WriteLine("AnimalionDraw");
                //graphics.DrawLine(pen, 0, 0, index, index);
            }
        }