C
Crirus
Can someone help me convert C# to VB the code following my signature?
The main problem I face it is event handlers mapping to delegates
Thanks
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
namespace BetterMouseCS
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class BetterMouser : UserControl
{
private bool idleSet; // we are catching the Application.Idle event
private MouseEventArgs savedMouseMove; // last mouse move
private EventHandler idleHandler; // to avoid creating over and over
public event MouseEventHandler IdleMouseMove; // called when idle, to
avoid redundant events
Public BetterMouser()
{
idleHandler = new EventHandler(ApplicationIdle);
}
protected override void OnMouseDown(MouseEventArgs e)
{
savedMouseMove = null;
base.OnMouseDown(e);
}
protected override void OnMouseMove(MouseEventArgs e)
{
savedMouseMove = e;
// allow client to only process the mouse events when idle -- otherwise,
// we process a lot of mouse events that are unnecessary
if (!idleSet)
{
idleSet = true;
Application.Idle += idleHandler;
} base.OnMouseMove(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
savedMouseMove = null;
base.OnMouseUp(e);
}
private void ApplicationIdle(object sender, EventArgs e)
{
idleSet = false;
Application.Idle -= idleHandler;
if (savedMouseMove != null)
{
OnIdleMouseMove(savedMouseMove);
savedMouseMove = null;
}
}
protected virtual void OnIdleMouseMove(MouseEventArgs e)
{
if (IdleMouseMove != null) IdleMouseMove(this, e);
}
}
The main problem I face it is event handlers mapping to delegates
Thanks
--
Ceers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
namespace BetterMouseCS
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class BetterMouser : UserControl
{
private bool idleSet; // we are catching the Application.Idle event
private MouseEventArgs savedMouseMove; // last mouse move
private EventHandler idleHandler; // to avoid creating over and over
public event MouseEventHandler IdleMouseMove; // called when idle, to
avoid redundant events
Public BetterMouser()
{
idleHandler = new EventHandler(ApplicationIdle);
}
protected override void OnMouseDown(MouseEventArgs e)
{
savedMouseMove = null;
base.OnMouseDown(e);
}
protected override void OnMouseMove(MouseEventArgs e)
{
savedMouseMove = e;
// allow client to only process the mouse events when idle -- otherwise,
// we process a lot of mouse events that are unnecessary
if (!idleSet)
{
idleSet = true;
Application.Idle += idleHandler;
} base.OnMouseMove(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
savedMouseMove = null;
base.OnMouseUp(e);
}
private void ApplicationIdle(object sender, EventArgs e)
{
idleSet = false;
Application.Idle -= idleHandler;
if (savedMouseMove != null)
{
OnIdleMouseMove(savedMouseMove);
savedMouseMove = null;
}
}
protected virtual void OnIdleMouseMove(MouseEventArgs e)
{
if (IdleMouseMove != null) IdleMouseMove(this, e);
}
}