一.扩展说明
好久没有写Blog了,索性将以前做的柱状图做了下立体效果的扩展,贴出来做为自己懒惰的一种提示。
二.设计时效果
三.运行时效果
四.部分源代码
 private void DrawSolidHistogram(Graphics g)
        {
            Rectangle rect = this.GetClientRect();
            //绘制主标题
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            using (Font f = new Font("宋体", 12, FontStyle.Bold))
            {
                using (SolidBrush b = new SolidBrush(Color.Black))
                {
                    using (StringFormat sf1 = new StringFormat())
                    {
                        sf1.Alignment = StringAlignment.Center;
                        g.DrawString(_caption, f, b, new Rectangle(rect.Left, rect.Top + 5, rect.Width, _captionHeight), sf1);
                    }
                }
            }
            ////绘制网格点
            //if (_isShowGridPoint)
            //{
            //    Rectangle rectgrid = rect;
            //    rectgrid.Inflate(0, -_captionHeight);
            //    ControlPaint.DrawGrid(g, rectgrid, new Size(20, 20), Color.Gray);
            //}
            //绘制X轴,Y轴
            using (Pen p = new Pen(Color.Black),p1 = new Pen(Color.LightGray ))
            {
                //x轴
                g.DrawLine(p, _xAxisLeft, rect.Bottom, _xAxisLeft + rect.Width, rect.Bottom);
                //x轴扭曲
                g.DrawLine(p1, _xAxisLeft, rect.Bottom, _xAxisLeft + _xContort, rect.Bottom - _yContort);
                g.DrawLine(p1, _xAxisLeft + rect.Width, rect.Bottom, _xAxisLeft + rect.Width + _xContort, rect.Bottom - _yContort);
                g.DrawLine(p1, _xAxisLeft + _xContort, rect.Bottom - _yContort, _xAxisLeft + rect.Width + _xContort, rect.Bottom - _yContort);
                
                //y轴
                g.DrawLine(p, _xA
                
                  
                  
                  
                  
本文介绍了如何扩展WinForm的柱状图控件,添加立体效果。作者分享了设计时和运行时的效果,并提供了部分源代码。
          
最低0.47元/天 解锁文章
                          
                      
      
          
                
                
                
                
              
                
                
                
                
                
              
                
                
              
            
                  
					2189
					
被折叠的  条评论
		 为什么被折叠?
		 
		 
		
    
  
    
  
            


            