基本信息
源码名称:C#漂亮的工业软件控件源码(含仪表盘)
源码大小:0.25M
文件格式:.rar
开发语言:C#
更新时间:2018-11-09
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

工业软件控件

工业软件控件

public override bool DrawDivisions( Graphics Gr, RectangleF rc )
		{
			if ( this.AnalogMeter == null )
				return false;
			
			float startAngle = this.AnalogMeter.GetStartAngle();
			float endAngle = this.AnalogMeter.GetEndAngle();
			float scaleDivisions = this.AnalogMeter.ScaleDivisions;
			float scaleSubDivisions = this.AnalogMeter.ScaleSubDivisions;
			double minValue = this.AnalogMeter.MinValue;
			double maxValue = this.AnalogMeter.MaxValue;
			Color scaleColor = this.AnalogMeter.ScaleColor;
			
			float cx = needleCenter.X;
			float cy = needleCenter.Y;
			float w = rc.Width;
			float h = rc.Height;

			float incr = LBMath.GetRadian(( endAngle - startAngle ) / (( scaleDivisions - 1 )* (scaleSubDivisions   1)));
			float currentAngle = LBMath.GetRadian( startAngle );
			float radius = (float)(w / 2 - ( w * 0.08));
			float rulerValue = (float)minValue;

			Pen pen = new Pen ( scaleColor, ( 2 * drawRatio ) );
			SolidBrush br = new SolidBrush ( scaleColor );
			
			PointF ptStart = new PointF(0,0);
			PointF ptEnd = new PointF(0,0);
			PointF ptCenter = new PointF(0,0);
			RectangleF rcTick = new RectangleF(0,0,0,0);
			SizeF sizeMax = new SizeF( 10 * drawRatio, 10 * drawRatio );
			SizeF sizeMin = new SizeF( 4 * drawRatio, 4 * drawRatio );
			
			int n = 0;
			for( ; n < scaleDivisions; n   )
			{
					//Draw Thick Line
				ptCenter.X = (float)(cx   (radius - w/90) * Math.Cos(currentAngle));
				ptCenter.Y = (float)(cy   (radius - w/90) * Math.Sin(currentAngle));
				ptStart.X = ptCenter.X - ( 5 * drawRatio );
				ptStart.Y = ptCenter.Y - ( 5 * drawRatio );
				rcTick.Location = ptStart;
				rcTick.Size = sizeMax;				
				Gr.FillEllipse( br, rcTick );
				
       				//Draw Strings
       			Font font = new Font ( this.AnalogMeter.Font.FontFamily, (float)( 8F * drawRatio ), FontStyle.Italic );
		
				float tx = (float)(cx   (radius - ( 20 * drawRatio )) * Math.Cos(currentAngle));
		        float ty = (float)(cy   (radius - ( 20 * drawRatio )) * Math.Sin(currentAngle));
		        double val = Math.Round ( rulerValue );
		        String str = String.Format( "{0,0:D}", (int)val );
		
				SizeF size = Gr.MeasureString ( str, font );
				Gr.DrawString ( str, 
				                font, 
				                br, 
				                tx - (float)( size.Width * 0.5 ), 
				                ty - (float)( size.Height * 0.5 ) );

				rulerValue  = (float)(( maxValue - minValue) / (scaleDivisions - 1));
		
				if ( n == scaleDivisions -1)
					break;
		
				if ( scaleDivisions <= 0 )
					currentAngle  = incr;
				else
				{
			        for (int j = 0; j <= scaleSubDivisions; j  )
			        {
						currentAngle  = incr;

			        	ptCenter.X = (float)(cx   (radius - w/90) * Math.Cos(currentAngle));
						ptCenter.Y = (float)(cy   (radius - w/90) * Math.Sin(currentAngle));
						ptStart.X = ptCenter.X - ( 2 * drawRatio );
						ptStart.Y = ptCenter.Y - ( 2 * drawRatio );
						rcTick.Location = ptStart;
						rcTick.Size = sizeMin;				
						Gr.FillEllipse( br, rcTick );
					}
				}
			}
			
			return true;
		}
	}