473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need help C# TO VB conversion

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);
}
}
Nov 20 '05 #1
3 1170
to be short, all I need to convert is

idleHandler = new EventHandler(ApplicationIdle);
Application.Idle += idleHandler;
Application.Idle -= idleHandler;
--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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);
}
}

Nov 20 '05 #2
I figured out, finaly :)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
to be short, all I need to convert is

idleHandler = new EventHandler(ApplicationIdle);
Application.Idle += idleHandler;
Application.Idle -= idleHandler;
--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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);
}
}


Nov 20 '05 #3
* "Crirus" <Cr****@datagroup.ro> scripsit:
to be short, all I need to convert is

idleHandler = new EventHandler(ApplicationIdle);
Application.Idle += idleHandler;
Application.Idle -= idleHandler;


Have a look at 'AddHandler' and 'RemoveHandler'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nikhil Patel | last post by:
Hi all, I am a VB6 programmer and learning C#. I am currently reading a chapter on types. I have question regarding enums. Why do we need to convert enum members to the value that they represent?...
3
by: Francesc | last post by:
Hi, I'm new at this newsgroup and I want do ask some questions and opinions about this subject. I'm developing an application focused in a very specific task: clean and labelling text documents...
4
by: Gregory Edigaroff | last post by:
Hello, Everybody! Ok, I urgently need the solution for a following task in C++. This is the task from programmers contest, so I believe somebody have a solution for it. I need either a full...
1
by: Dancefire | last post by:
Hi, everyone, I'm trying to use std::codecvt<to do the encoding conversion. I am using following code for encoding conversion between wchar_t string and char string(MBCS). I am not sure am I...
15
by: Jess | last post by:
Hello, Sometimes declarations are all what we need when we define/declare classes (or functions?), but sometimes we need definitions. I learned that if we define a class (B) that has an object...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.