Vibrate in Windows Mobile.

Hi

How do i send a Vibrate command to my PDA within my C# .NET application ?
mSchmidtAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tomasgruenerCommented:
Try following
OpenNETCF.WindowsCE.Notification.Led vib = new OpenNETCF.WindowsCE.Notification.Led();
 
//---start vibration--- 
 
vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.On);
 
System.Threading.Thread.Sleep(2000);
 
//---stop vibration--- 
 
vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.Off); 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mSchmidtAuthor Commented:
That works great !

Do you have any idea how i can override the click event of all my buttons click event which are using System.Windows.Forms.Button, i want to override the click event and add a Vibrate on all button clicks.

I implemented your vibration example like this :


    public class Vibration
    {
        static System.Threading.Timer mTimer;
        public static void Vibrate()
        {
            //---start vibration--- 
            OpenNETCF.WindowsCE.Notification.Led vib = new OpenNETCF.WindowsCE.Notification.Led();
            vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.On);
            mTimer = new System.Threading.Timer(stopVibrate, null, 50, 1000);
        }
        public static void stopVibrate(object e) {
            //---stop vibration--- 
            mTimer.Dispose();
            OpenNETCF.WindowsCE.Notification.Led vib = new OpenNETCF.WindowsCE.Notification.Led();
            vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.Off); 
        }
    }

Open in new window

0
tomasgruenerCommented:
Sorry, I have no Idea... or maybe, but I think it would be better, if you apply it by hand...
but, you should have a main control collection...
go through this collection. on every button, apply the event. on every element, that has itselfs child controls, go into the childcontrols and go on.

implement it with a recursive function. something like this (but watch it, Î'm not sure, if it works on mobile application and how it will affect the performance):
private void BindClickEvent( Control root, EventHandler eventToAttach)
{
    if (root == null)
        return;
    Button b = root as Button;
    if (b != null)
        b.Click += eventToAttach;
    if (root.Controls == null)
        return;
    foreach (Control sub in root.Controls)
    {
        BindClickEvent(sub, eventToAttach);
    }
}

Open in new window

0
mSchmidtAuthor Commented:
hmm okay, i thought that it might have been possible to extend the System.Windows.Forms.Button using the partial syntax.

However i think the best idea would be to extend the Button into my own Button control and then replace that in my entire application.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphone Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.