本文整理匯總了C#中System.Drawing.SizeF.GetLength方法的典型用法代碼示例。如果您正苦於以下問題:C# SizeF.GetLength方法的具體用法?C# SizeF.GetLength怎麽用?C# SizeF.GetLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.SizeF
的用法示例。
在下文中一共展示了SizeF.GetLength方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Render
/// <summary>
/// Renders the key in the specified surface.
/// </summary>
/// <param name="g">The GDI+ surface to render on.</param>
/// <param name="speed">The speed of the mouse.</param>
public void Render(Graphics g, SizeF speed)
{
var subStyle = GlobalSettings.CurrentStyle.TryGetElementStyle<MouseSpeedIndicatorStyle>(this.Id)
?? GlobalSettings.CurrentStyle.DefaultMouseSpeedIndicatorStyle;
// Small circles have a fifth of the radius of the full control.
var smallRadius = (float)this.Radius / 5;
// The sensitivity is a factor over the mouse speed.
var sensitivity = GlobalSettings.Settings.MouseSensitivity / (float)100;
// The total length is determined by the sensitivity, speed and radius. But never more than the radius.
var pointerLength = (int)Math.Min(this.Radius, sensitivity * speed.GetLength() * this.Radius);
var colorMultiplier = Math.Max(0, Math.Min(1, (float)pointerLength / this.Radius));
Color color1 = subStyle.InnerColor;
Color outerColor = subStyle.OuterColor;
// The second color should be averaged over the two specified colours, based upon how far out the thingymabob is.
var color2 = Color.FromArgb(
(int)(color1.R * (1 - colorMultiplier) + outerColor.R * colorMultiplier),
(int)(color1.G * (1 - colorMultiplier) + outerColor.G * colorMultiplier),
(int)(color1.B * (1 - colorMultiplier) + outerColor.B * colorMultiplier));
// Draw the edge.
g.DrawEllipse(
new Pen(color1, subStyle.OutlineWidth),
Geom.CircleToRectangle(this.Location, this.Radius));
// Only calculate the pointer data if it has some length.
if (pointerLength > 0)
{
// Determine the angle of the pointer.
var angle = speed.GetAngle();
// Determine the location of the pointer end.
var pointerEnd = this.Location.CircularTranslate(pointerLength, angle);
// If the pointer doesn't end where it starts, draw it.
if (pointerEnd.X != this.Location.X || pointerEnd.Y != this.Location.Y)
{
// Draw the pointer, as a pie.
g.FillPie(
new LinearGradientBrush(this.Location, pointerEnd, color1, color2),
Geom.CircleToRectangle(this.Location, pointerLength),
Geom.RadToDeg(angle) - 10,
20);
// Draw a circle on the outter edge in the direction of the pointer.
var pointerEdge = this.Location.CircularTranslate(this.Radius, angle);
g.FillEllipse(new SolidBrush(color2), Geom.CircleToRectangle(pointerEdge, (int)smallRadius));
}
}
// Draw the circle in the center.
g.FillEllipse(new SolidBrush(color1), Geom.CircleToRectangle(this.Location, (int)smallRadius));
}