110,534
社区成员
发帖
与我相关
我的任务
分享
private void button_Shoot_Click(object sender, EventArgs e)
{
#region 定义自定义线帽
float arrowWidth = 3;
float arrowHeight = 3;
bool arrowFill = true;
AdjustableArrowCap myArrow = new AdjustableArrowCap(arrowWidth,
arrowHeight,
arrowFill);
CustomLineCap customArrow = myArrow;
Pen p = new Pen(Color.Red, 1);
p.EndCap = LineCap.Custom;
p.CustomEndCap = customArrow;
#endregion
Graphics g = Graphics.FromHwnd(this.Handle);//获得窗口句柄,通过Hwnd获得Graphics对象
List<Point> myPts = new List<Point>();
if (numericUpDown_Force.Value == 2 && numericUpDown_Force.Value == 2)
{
myPts.Add(new Point(136, 165));
myPts.Add(new Point(250, 119));
myPts.Add(new Point(347, 140));
myPts.Add(new Point(412, 160));
}
else if (numericUpDown_Force.Value == 1 && numericUpDown_Angle.Value == 2)
{
myPts.Add(new Point(136, 165));
myPts.Add(new Point(180, 119));
myPts.Add(new Point(297, 140));
myPts.Add(new Point(412, 160));
}
g.DrawBezier(p, myPts[0], myPts[1], myPts[2], myPts[3]);
}
[DllImport("user32.dll",CharSet = CharSet.Auto)]
public static extern bool InvalidateRect(IntPtr hWnd,IntPtr lpRect,bool bErase);