代码的合并

flora198423 2009-01-15 10:13:34
我现在要将一段独立的画圆的代码合并到程序里,但是在合并过程中许多关键字出错
在合并的时候应该注意些什么问题啊?才接触C#不久,所以很多地方知道。麻烦大虾门指教。下面就是独立的画圆的代码
public Rectangle GetEllopse(Point p_CenterPoint, int p_Radius)
{
int _X = p_CenterPoint.X - p_Radius;
int _Y = p_CenterPoint.Y - p_Radius;
return new Rectangle(_X, _Y, p_Radius * 2, p_Radius * 2);
}

public void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{

if (m_Panit)
{
Graphics _Graphics = pictureBox1.CreateGraphics();
_Graphics.Clear(pictureBox1.BackColor);
int _RadiusW = m_Point.X - e.X;
int _RadiusH = m_Point.Y - e.Y;

_RadiusH = Math.Abs(_RadiusH);
_RadiusW = Math.Abs(_RadiusW);
if (_RadiusW > _RadiusH) _RadiusH = _RadiusW;
Rectangle _EllopseRectangle = GetEllopse(m_Point, _RadiusH);

_Graphics.DrawEllipse(new Pen(Brushes.Red, 2), _EllopseRectangle);

_Graphics.Dispose();
}
}
/// <summary>
/// 绘制标示
/// </summary>
public bool m_Panit = false;
/// <summary>
/// 开始坐标
/// </summary>
public Point m_Point = new Point(0, 0);

public void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
m_Panit = true;
m_Point.X = e.X;
m_Point.Y = e.Y;
}
public void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
m_Panit = false;

}
...全文
122 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
flora198423 2009-01-15
  • 打赏
  • 举报
回复
谢谢指点~~我先试试~~
jacklee_008 2009-01-15
  • 打赏
  • 举报
回复
public bool m_Panit = false;
public Point m_Point = new Point(0, 0);
要声明在使用之前
jacklee_008 2009-01-15
  • 打赏
  • 举报
回复
(1)↓直接用;
public Rectangle GetEllopse(Point p_CenterPoint, int p_Radius)
{
int _X = p_CenterPoint.X - p_Radius;
int _Y = p_CenterPoint.Y - p_Radius;
return new Rectangle(_X, _Y, p_Radius * 2, p_Radius * 2);
}


(2)pictureBox1_MouseMove,pictureBox1_MouseDown,pictureBox1_MouseUp,是事件,就是pictureBox1中的属性面板中的像雷电符号中的内中,找到后双击进入,复制对应代码即可。
sunrobust 2009-01-15
  • 打赏
  • 举报
回复
合并的最好方法不是 ctrl v ctrl p, 是理解了逻辑以后, 自己在程序中有选择的实现.

111,130

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧