问题描述
我一直在兜圈子,试图弄清楚如何将拨号控件合并到Windows窗体中(而不必购买第三方解决方案)。从我完成的研究看来,我需要microsoft.toolkit.uwp.ui.controls。我试图安装6.1.1版(从.nupkg),但收到以下安装错误:“无法安装软件包'Microsoft.Toolkit.Uwp.UI.Controls 6.1.1'。您正在尝试将此软件包安装到项目中面向“ .NETFramework,Version = v4.7.2”,但该软件包不包含任何与该框架兼容的程序集引用或内容文件。”任何指导/帮助将不胜感激。
解决方法
谢谢吉米。链接(Arc图形质量)的工作原理很吸引人。我需要做一些调整才能使其与VB一起使用,但它可以工作。我已经附上了VB代码。
导入System.Drawing.Drawing2D
公共类表格1
Dim GaugeValue As Single = 75 'move the needle with this value (0 - 100 percent)
Dim GaugeSweepAngle As Single = 270
Dim GaugeStartAngle As Single = 135
Private Sub Canvas_Paint(sender As Object,e As PaintEventArgs) Handles Canvas.Paint
Dim canvas As New Control
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Dim outerRectangle = New Rectangle(10,10,180,180)
Dim innerRectangle = New Rectangle(30,30,140,140)
Dim blendRectangle = New Rectangle(10,160)
Dim innerCenter = New PointF(outerRectangle.Left + (outerRectangle.Width / 2),outerRectangle.Top + (outerRectangle.Height / 2))
Dim gaugeLength = (outerRectangle.Width / 2) - 2
Using Path = New GraphicsPath
Path.AddPie(outerRectangle,GaugeStartAngle,GaugeSweepAngle)
Path.AddPie(innerRectangle,GaugeSweepAngle)
innerRectangle.Inflate(-1,-1)
Using pen = New Pen(Color.Black,3.0F)
Using backgroundbrush = New SolidBrush(canvas.BackColor)
Using gradientBrush = New LinearGradientBrush(blendRectangle,Color.Green,Color.Red,LinearGradientMode.ForwardDiagonal)
Dim blend = New Blend
Dim factors(0.0,0.0,0.1,0.3,0.7,1.0)
Dim positions(0.0,0.2,0.4,0.6,0.8,1.0)
gradientBrush.Blend = blend
e.Graphics.FillPath(gradientBrush,Path)
e.Graphics.DrawPath(pen,Path)
e.Graphics.FillEllipse(backgroundbrush,innerRectangle)
Using format = New StringFormat
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center
innerRectangle.Location = New Point(innerRectangle.X,innerRectangle.Y + canvas.Font.Height)
e.Graphics.DrawString(GaugeValue.ToString() + "%",canvas.Font,Brushes.Black,innerRectangle,format)
Using mx = New Matrix
mx.RotateAt(GaugeStartAngle + 90 + (GaugeValue * (GaugeSweepAngle / 100)),innerCenter)
e.Graphics.Transform = mx
e.Graphics.DrawLine(pen,innerCenter,New PointF(innerCenter.X,innerCenter.Y - gaugeLength))
e.Graphics.ResetTransform()
End Using
End Using
End Using
End Using
End Using
End Using
End Sub
结束类。