namespace Yw.WinFrmUI.Hydro
|
{
|
public partial class OrthoRotate2d : UserControl
|
{
|
public OrthoRotate2d()
|
{
|
InitializeComponent();
|
InitializeGLEvents();
|
}
|
|
private OrthoRotate2dHelper _helper = null;
|
|
/// <summary>
|
/// 是否初始化
|
/// </summary>
|
public bool Initialized
|
{
|
get
|
{
|
if (_helper == null)
|
{
|
return false;
|
}
|
return true;
|
}
|
}
|
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
public void Initial()
|
{
|
_helper = new OrthoRotate2dHelper();
|
_helper.Initial(this.glControl1);
|
}
|
|
|
#region 私有方法
|
|
//初始化GL事件
|
private void InitializeGLEvents()
|
{
|
this.glControl1.Load += GlControl1_Load;
|
this.glControl1.MouseDown += GlControl1_MouseDown;
|
this.glControl1.MouseUp += GlControl1_MouseUp;
|
this.glControl1.MouseMove += GlControl1_MouseMove;
|
this.glControl1.MouseWheel += GlControl1_MouseWheel;
|
this.glControl1.MouseClick += GlControl1_MouseClick;
|
this.glControl1.MouseDoubleClick += GlControl1_MouseDoubleClick;
|
this.glControl1.Resize += GlControl1_Resize;
|
this.glControl1.Paint += GlControl1_Paint;
|
}
|
|
#endregion
|
|
#region 交互处理
|
|
//加载处理
|
private void GlControl1_Load(object sender, EventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.Load();
|
}
|
|
//鼠标按下
|
private void GlControl1_MouseDown(object sender, MouseEventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.MouseDown(e);
|
}
|
|
//鼠标弹起
|
private void GlControl1_MouseUp(object sender, MouseEventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.MouseUp(e);
|
}
|
|
//鼠标移动
|
private void GlControl1_MouseMove(object sender, MouseEventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.MouseMove(e);
|
}
|
|
//鼠标滚轮
|
private void GlControl1_MouseWheel(object sender, MouseEventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.MouseWheel(e);
|
}
|
|
//鼠标点击
|
private void GlControl1_MouseClick(object sender, MouseEventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.MouseClick(e);
|
}
|
|
//鼠标双击
|
private void GlControl1_MouseDoubleClick(object sender, MouseEventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.MouseDoubleClick(e);
|
}
|
|
//绘制
|
private void GlControl1_Paint(object sender, PaintEventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.Render();
|
}
|
|
//尺寸改变
|
private void GlControl1_Resize(object sender, EventArgs e)
|
{
|
if (!Initialized)
|
{
|
return;
|
}
|
_helper.Resize();
|
}
|
|
|
#endregion
|
|
|
}
|
}
|