解决方案 »
- .net问题,请教各位高手。 谢谢
- 有没有人使用过lemur的c#接口?急!!!
- 水晶报表布署问题
- 日期格式问题
- datagridview 中怎么让文本右对齐.
- 98系统下安装Framework为什么要升级IE呢?有没有什么办法解决这个问题?
- datagrid中,序列问题!!
- 求助~~大神们看下哪里的问题。。搞了N久没弄好。我是小白
- 有在深圳想卖书的吗?我想买一本二手的C#高级编程,书旧一点无所谓要便宜一些。别外想卖一本,ASP。NET应用开发指南!up者有分
- 急急!数据库问题!!
- windows service OnStart时 打开一个外部exe 不显示exe窗体。。求解
- WPF 怎么通过 button的Click事件传递参数到后台处理
Graphics g = this.pictureBox_CurveDivide.CreateGraphics();
Pen mypen = new Pen(System.Drawing.Color.Black, 2);
public void DrawArc(Arc arc,Graphics g,Pen mypen)
{
XYZ startpoint = FindStartpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));//圆弧的起点也是第一条直线的终点
XYZ endpoint = FindEndpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));//圆弧的终点也是第二条直线的起点
XYZ center = arc.Center;//圆弧的圆心坐标
double r = arc.Radius;//圆弧的半径
double k = Math.Sqrt((endpoint.X - startpoint.X) * (endpoint.X - startpoint.X) + (endpoint.Y - startpoint.Y) * (endpoint.Y - startpoint.Y));//圆弧起始/终止点之间的直线距离
double x = center.X - r;
double y = center.Y - r;
double width = 2 * r;
double height = 2 * r;
RectangleF myrectangle = new RectangleF((float)x, (float)y, (float)width, (float)height);
double startangle = Math.Atan(startpoint.Y / startpoint.X);
double sweepangle = 2 * Math.Asin((k / 2) / r);
g.DrawArc(mypen, myrectangle, (float)startangle, (float)sweepangle);
}
大神,求指教~~picturebox上完全看不到弧线。
然后还是依照我贴的那个代码继续运行吗??只是修改下圆心??
public void DrawArc(Arc arc,Graphics g,Pen mypen,float offsety)
{
XYZ startpoint = FindStartpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));
XYZ endpoint = FindEndpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));
//XYZ center = arc.Center;
XYZ center = new XYZ((startpoint.X+endpoint.X)/2,(startpoint.Y+endpoint.Y)/2,0);
double r = arc.Radius;
//TaskDialog.Show("startpoint", startpoint.ToString());
//TaskDialog.Show("endpoint", endpoint.ToString());
//TaskDialog.Show("center", center.ToString());
//TaskDialog.Show("r", r.ToString());
double k = Math.Sqrt((endpoint.X - startpoint.X) * (endpoint.X - startpoint.X) + (endpoint.Y - startpoint.Y) * (endpoint.Y - startpoint.Y));
double x = (center.X - r)*8+0;
double y = offsety-(center.Y - r)*8;
double width = 2 * r;
double height = 2 * r;
RectangleF myrectangle = new RectangleF((float)x, (float)y, (float)width, (float)height);
double startangle = Math.Atan(startpoint.Y / startpoint.X);
double sweepangle = 2 * Math.Asin((k / 2) / r);
g.DrawArc(mypen, myrectangle, (float)startangle, (float)sweepangle);
}
还是不行哎。求指教啊~~
DrawArc(Pen, Rectangle, Single, Single),需要两个角度,圆心用来怎么用,固定Rectangle的位置么??大侠,该怎么固定啊??不太明白,求指教啊~~新人勿怪~~~
gp.AddLine();
gp.AddArc();
gp.CloseCurver();Graphics.DrawPath(Pens.Red,gp);
运行结果图如下:
问题已解决,现在发现编程遇到的很多问题还是得靠自己的领悟,依然是用的drawArc方法,只是这次自己的rectangle设置对了,感谢楼上的各位抽出时间回答问题,但是我还是想说作为新手真的有很多不懂得即使自己百度查资料依然还是有不懂得地方,有时候高手的一句话就能点拨我们,希望高手们在回答的时候不要太高冷,万分感谢。