private void Form1_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = new Rectangle(90, 40, 200, 100);
Rectangle rect1 = new Rectangle(rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 3, 3);
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), rect);
e.Graphics.DrawRectangle(new Pen(Color.Blue, 1), rect);
e.Graphics.FillEllipse(Brushes.Blue, rect1);
e.Graphics.RotateTransform(30.0F);
e.Graphics.DrawEllipse(new Pen(Color.Red, 3), rect);
e.Graphics.DrawRectangle(new Pen(Color.Red, 1), rect);
e.Graphics.FillEllipse(Brushes.Red, rect1);
}
得到的效果图,怎样将中心点对其
{
Rectangle rect = new Rectangle(90, 40, 200, 100);
Rectangle rect1 = new Rectangle(rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 3, 3);
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), rect);
e.Graphics.DrawRectangle(new Pen(Color.Blue, 1), rect);
e.Graphics.FillEllipse(Brushes.Blue, rect1);
e.Graphics.RotateTransform(30.0F);
e.Graphics.DrawEllipse(new Pen(Color.Red, 3), rect);
e.Graphics.DrawRectangle(new Pen(Color.Red, 1), rect);
e.Graphics.FillEllipse(Brushes.Red, rect1);
}
得到的效果图,怎样将中心点对其
解决方案 »
- C# DataGridView怎样交换两列,有一个"左移"按钮是将第一列往左移一列,让第二列成为第一列?
- viewstate的问题
- 关于catch中再throw的问题
- 关于类的问题
- Repter控件问题:Repter控件绑定的CheckBox控件,如何在用户点其中的一个Checkbox时就提交到服务器端进行判断?
- 一个自动备份系统的问题。
- 这段代码什么意思﹖看不懂
- .NET中有没类似JUNIT或者DUNIT的测试框架?
- 怎么修改XML格式的字符串中的某一项内容?
- 如何捕捉在DataGrid中添加行中,数据不合法,运行时弹出的System.data.NoNullAllowedException,我要自定义它。(在线)
- 分页代码问题
- SqlCommandBuilder
private void Form1_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = new Rectangle(90, 40, 200, 100);
Rectangle rect1 = new Rectangle(rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 3, 3);
float offsetX = (float)Math.Cos(45) * (rect.X + rect.Width / 2);
float offsetY = -(float)Math.Sin(45) * (rect.Y + rect.Height / 2);
float r = (float)Math.Sqrt(rect.X * rect.X + rect.Y * rect.Y);
//e.Graphics.DrawEllipse(new Pen(Color.Black, 1), -r, -r, r * 2, r * 2);
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), rect);
e.Graphics.DrawRectangle(new Pen(Color.Blue, 1), rect);
e.Graphics.FillEllipse(Brushes.Blue, rect1); //Matrix myMatrix = new Matrix();
//myMatrix.Rotate(30);
//myMatrix.Scale(1, 2, MatrixOrder.Append);
//myMatrix.Translate(offsetX, offsetY, MatrixOrder.Append);
//e.Graphics.Transform = myMatrix;
e.Graphics.RotateTransform(30.0F);
e.Graphics.TranslateTransform(offsetX, offsetY,System.Drawing.Drawing2D.MatrixOrder.Append);
e.Graphics.DrawEllipse(new Pen(Color.Red, 3), rect);
e.Graphics.DrawRectangle(new Pen(Color.Red, 1), rect);
e.Graphics.FillEllipse(Brushes.Red, rect1);
}