当前位置: 首页>>代码示例>>C#>>正文


C# SizeF.GetLength方法代码示例

本文整理汇总了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));
        }
开发者ID:ThoNohT,项目名称:NohBoard,代码行数:62,代码来源:MouseSpeedIndicatorDefinition.cs


注:本文中的System.Drawing.SizeF.GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。