?
Solved

Vibrate in Windows Mobile.

Posted on 2008-11-11
4
Medium Priority
?
1,626 Views
Last Modified: 2013-12-27
Hi

How do i send a Vibrate command to my PDA within my C# .NET application ?
0
Comment
Question by:mSchmidt
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
tomasgruener earned 2000 total points
ID: 22932689
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
 

Author Comment

by:mSchmidt
ID: 22932934
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
 
LVL 2

Expert Comment

by:tomasgruener
ID: 22933042
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
 

Author Comment

by:mSchmidt
ID: 22933091
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question