Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 31st, 2012  |  syntax: C#  |  size: 0.76 KB  |  hits: 50  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         Compass _compass;        
  2.         public BlankPage()
  3.         {
  4.             this.InitializeComponent();
  5.             _compass = Compass.GetDefault();
  6.            if (_compass != null)
  7.            {
  8.                 DispatcherTimer timer = new DispatcherTimer();
  9.                 timer.Interval = TimeSpan.FromMinutes(10);
  10.                 timer.Tick += timer_Tick;
  11.                 timer.Start();
  12.            }
  13.         }
  14.  
  15.         void timer_Tick(object sender, object e)
  16.         {
  17.            double last_reading = 0;
  18.             CompassReading reading = _compass.GetCurrentReading();
  19.             if (reading.HeadingMagneticNorth != last_reading)
  20.            {
  21.                 //różne, rób coś tam
  22.            }
  23.            else
  24.            {
  25.                 //to samo, rób coś tam
  26.            }
  27.             last_reading = reading.HeadingMagneticNorth;
  28.         }