Search code examples
windows-mobilecompact-frameworkc#-2.0opennetcf

Compact-Framework: Play default text alert and vibrate


I'm trying to put a notification into my compact framework 2.0 application that allows me to inform the user when they've received a new job.

I've tried to use the following code with the latest community edition of SDF:

    try
    {
        OpenNETCF.WindowsMobile.Vibrate.Play();
        Thread.Sleep(duration);
        OpenNETCF.WindowsMobile.Vibrate.Stop();
    }
    catch
    {
        // Ignore
    }

No error actually fires, however on the play event, the vibrate doesn't work. Also, I've not worked out a way to play the default message alert - or a sound file. Is any of this possible?


Solution

  • public static void Vibrate(int duration)
    {
    
        try
        {
    
            OpenNETCF.WindowsCE.Notification.Led vib = 
                new OpenNETCF.WindowsCE.Notification.Led();
    
            //---start vibration---
            vib.SetLedStatus(1, Led.LedState.On);
            System.Threading.Thread.Sleep(duration);
    
            //---stop vibration---
            vib.SetLedStatus(1, Led.LedState.Off);
    
        }
        catch
        {
            // Ignore
        }
    
    }
    

    I just found this, works nicely for vibrate, but I still need to know how to play the default message alert.