When switching the vibration on the parameter sets the duration for which it should be on. The duration is between 0 and 5 seconds. With the function TimeSpan.FromMilliseconds(duration), where duration is a number, the parameter can be set easily.
There is more information on the vibration controller on the Microsoft site.
See below the c# example for controling the vibration a windows phone 7.
You can also download the vibration project directory in a single ZIP-file.
using System;
using System.Windows;
using Microsoft.Phone.Controls;
// example of how switch on the vibration motor for a given time
// another call to switch it off
// Albrecht Schmidt, University of Stuttgart
// see:
// http://msdn.microsoft.com/en-us/library/microsoft.devices.vibratecontroller.default(v=VS.92).aspx
namespace Vibration
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
double duration;
duration = Convert.ToDouble(textBox1.Text);
if (duration > 5000)
{
duration = 5000;
}
// starts the vibrations (valid duration are between 0 and 5 seconds)
Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(duration));
}
private void button2_Click(object sender, RoutedEventArgs e)
{
Microsoft.Devices.VibrateController.Default.Stop();
}
}
}
1 comment:
kanchipuram sarees
kanchipuram silk sarees
kanchipuram silk sarees wholesalers
kanchipuram sarees
kanchipuram silk sarees
kanchipuram silk sarees wholesalers
Herbal Powder
golu dolls
Post a Comment