gdi+ 折线图

     
panle  为画图的容器,
data 每个项为数据输入格式为 1,2,3,4 
time  格式为 "10:20,10:30,10:40 "
name 格式为 "项目1,项目2";

   
None.gif
None.gif        
static   public   void  StaDrawHdImage(Panel ImagePanle,ArrayList  data, string  time, string  names)
ExpandedBlockStart.gifContractedBlock.gif       
dot.gif
InBlock.gif
InBlock.gif           Imagewidth 
= ImagePanle.Width;
InBlock.gif           ImageHeight 
= ImagePanle.Height;
InBlock.gif            
InBlock.gif           Bitmap bm 
= new Bitmap(ImagePanle.Width,ImagePanle .Height);
InBlock.gif          Graphics  g
=Graphics.FromImage(bm);
InBlock.gif          g.SmoothingMode 
= SmoothingMode.AntiAlias;
InBlock.gif          Rectangle toptile 
= new Rectangle(new Point(00), new Size(Imagewidth, ImageHeight));
InBlock.gif          Brush brtop 
= new SolidBrush(Color.FromArgb(59110165));
InBlock.gif          g.FillRectangle(brtop, toptile);
InBlock.gif          Brush NameBrush
=new SolidBrush (Color .FromArgb (255,255,255));
InBlock.gif         g.DrawString(
"烟尘黑度监视分析系统"new Font("宋体",16), NameBrush, ImagePanle.Width / 2 - 13010);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//*画箭头*/
InBlock.gif         
InBlock.gif         g.DrawLine(
new Pen (NameBrush), new Point(localLeft - 1, LocalTop - 10), new Point(localLeft - 1, ImagePanle.Height - 30));
InBlock.gif         g.DrawLine(
new Pen(NameBrush), new Point(localLeft - 1, ImageHeight - LocalButtom), new Point(Imagewidth - localRight+10, ImageHeight - LocalButtom));
InBlock.gif          g.DrawLine(
new Pen(NameBrush), new Point(localLeft-1, LocalTop-10), new Point(localLeft-1+2, LocalTop-10+2));
InBlock.gif         g.DrawLine(
new Pen(NameBrush), new Point(localLeft-1, LocalTop-10), new Point(localLeft-1-2, LocalTop-10+2));
InBlock.gif         g.DrawLine (
new Pen (NameBrush),new Point(Imagewidth-localRight+10,ImageHeight -LocalButtom),new Point (Imagewidth-localRight+10-2,ImageHeight-LocalButtom-2));
InBlock.gif          g.DrawLine(
new Pen(NameBrush), new Point(Imagewidth - localRight + 10, ImageHeight - LocalButtom), new Point(Imagewidth - localRight + 10 - 2, ImageHeight - LocalButtom + 2));
InBlock.gif          
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//*画垂直刻度*/
InBlock.gif          
for (int i = 0; i <5; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif          
dot.gif{  
InBlock.gif              
int  kd=(ImageHeight-LocalTop-LocalButtom) /5;
InBlock.gif          g.DrawLine(
new Pen(NameBrush), new Point(localLeft-1, LocalTop+kd * i ), new Point(localLeft-4, LocalTop+kd * i ) );
InBlock.gif          g.DrawString (Convert.ToString (
5-i).ToString (),new Font("宋体",9),NameBrush,new Point (localLeft-10, LocalTop+kd * i-4));
InBlock.gif     
ExpandedSubBlockEnd.gif          }

InBlock.gif        
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//*画水平刻度*/
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif          
string[] temptimes = time.Split(new char[] dot.gif',' });
InBlock.gif          
for (int j = 0; j <temptimes.Length; j++)
ExpandedSubBlockStart.gifContractedSubBlock.gif          
dot.gif{
InBlock.gif
InBlock.gif              
float kds = (float)(Imagewidth - localLeft - localRight) / (float)temptimes.Length; ;
InBlock.gif
InBlock.gif              
if (j < temptimes.Length)
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif                  g.DrawLine(
new Pen(NameBrush), new PointF((float)(localLeft - 1 + kds * j), ImageHeight - LocalButtom), new PointF((float)(localLeft - 1 + kds * j), ImageHeight - LocalButtom + 4));
InBlock.gif                  g.DrawString(temptimes[j], 
new Font("宋体"9), NameBrush, new PointF((float)(localLeft - 1 + kds * j - 10), ImageHeight - LocalButtom + 8));
ExpandedSubBlockEnd.gif              }

ExpandedSubBlockEnd.gif          }

InBlock.gif          Rectangle ra
=new Rectangle (new Point (localLeft,LocalTop),new Size(Imagewidth-localLeft-localRight,ImageHeight-LocalButtom -LocalTop));
InBlock.gif           Brush br 
= new LinearGradientBrush(ra,Color .FromArgb (0,0,0),Color.FromArgb(255,255,255), LinearGradientMode.Vertical);
InBlock.gif          
InBlock.gif          g.FillRectangle(br, ra);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//*画线*/ 
InBlock.gif              
int  kdy=(ImageHeight-LocalTop-LocalButtom) /5;
InBlock.gif              
float kdx = (float)(Imagewidth - localLeft - localRight) / (float)temptimes.Length;
InBlock.gif              
InBlock.gif            
// PointF[] poins=new PointF[data.Length];
InBlock.gif
             for (int i = 0; i < data.Count; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif             
dot.gif{
InBlock.gif                 Brush databrush 
= new SolidBrush(colordata [i]);
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
string[] temp =data[i].ToString ().Split(new char[] dot.gif',' });
InBlock.gif                 PointF[] poins 
= new PointF[temp.Length];
InBlock.gif                  
for (int j=0;j<temp.Length ;j++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
dot.gif
InBlock.gif                     
InBlock.gif                  poins[ j] 
= new PointF((float)(localLeft + kdx * j), LocalTop + kdy * (5 -int.Parse (temp[j])));
ExpandedSubBlockEnd.gif                 }

InBlock.gif                 g.DrawLines(
new Pen(databrush), poins);
InBlock.gif                 
InBlock.gif                 
ExpandedSubBlockEnd.gif             }

ExpandedSubBlockStart.gifContractedSubBlock.gif                
/**//* poins[0] = new PointF((float)(localLeft + kdx * 0), LocalTop + kdy * (5 - 2));
InBlock.gif              poins[1] = new PointF((float)(localLeft + kdx * 1), LocalTop + kdy * (5 - 1));
InBlock.gif              poins[2] = new PointF((float)(localLeft + kdx * 2), LocalTop+ kdy * (5 - 3));
ExpandedSubBlockEnd.gif                 
*/

InBlock.gif             
InBlock.gif                        
InBlock.gif             Brush b
=new SolidBrush(Color.Black );
InBlock.gif             
InBlock.gif           g.FillRectangle(NameBrush,
new Rectangle (new Point(Imagewidth-200,ImageHeight-200),new Size (170,170)));
InBlock.gif           
if (names != null)
ExpandedSubBlockStart.gifContractedSubBlock.gif           
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif               
string[] tempName = names.Split(new char[] dot.gif',' });
InBlock.gif               
for (int l = 0; l < tempName.Length; l++)
ExpandedSubBlockStart.gifContractedSubBlock.gif               
dot.gif{
InBlock.gif                   g.FillRectangle(
new SolidBrush(colordata[l]), new Rectangle(new Point(Imagewidth - 200 + 20, ImageHeight - 200 + 20 * l + 10 * (l + 1)), new Size(2020)));
InBlock.gif                   g.DrawString(tempName[l].ToString(), 
new Font("宋体"9), b, new PointF(Imagewidth - 200 + 60, ImageHeight - 200 + 20 * l + 10 * (l + 1)));
InBlock.gif
ExpandedSubBlockEnd.gif               }

ExpandedSubBlockEnd.gif           }

InBlock.gif         
InBlock.gif            ImagePanle.BackgroundImage 
= bm;
InBlock.gif           
InBlock.gif
ExpandedBlockEnd.gif       }



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值