/// <summary> /// main window initialization /// </summary> public MainWindow() { InitializeComponent(); // default is walking walking_speed.IsChecked = true; running_speed.IsChecked = false; driving_speed.IsChecked = false; // default is reverse walking stop_at_end.IsChecked = false; loop_to_start.IsChecked = false; loop_reverse.IsChecked = true; gpx_save_button.IsEnabled = false; stop_spoofing_button.IsEnabled = false; // load native libraries for iDevice NativeLibraries.Load(); // init walking timer. walking_timer = new DispatcherTimer(); walking_timer.Interval = TimeSpan.FromMilliseconds(500); // 0.5 sec timer_callback = new walking_timer_callback(g_polyline, myMap, this); timer_callback.walking_speed = c_fast_walking_speed; walking_timer.Tick += timer_callback.one_step; walking_timer.IsEnabled = true; walking_timer.Stop(); loc_service = location_service.GetInstance(this); loc_service.ListeningDevice(); if (loc_service.Devices.Count < 1) { device_prov.IsEnabled = false; } string ddi_path = AppDomain.CurrentDomain.BaseDirectory + "DDILocalRepo\\"; if (!System.IO.Directory.Exists(ddi_path)) { System.IO.Directory.CreateDirectory(ddi_path); } // set map center. Location map_center = new Location(); map_center.Latitude = Properties.Settings.Default.home_lat; map_center.Longitude = Properties.Settings.Default.home_lon; myMap.Center = map_center; }
/// <summary> /// start to walk and auto repeat. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void walk_Button_Click(object sender, RoutedEventArgs e) { if (g_gpx_file_name == null) { System.Windows.Forms.MessageBox.Show("Please load a GPX file and then walk."); return; } // initialize the timer call back if (timer_callback == null) { timer_callback = new walking_timer_callback(g_polyline, myMap, this); } if (timer_callback.m_polyline == null) { timer_callback.set_route(g_polyline); } switch (cur_walking_state) { case e_walking_state.walking_stopped: // stopped -- > active walking.Content = "Pause"; // indicate use can pause in active. walking_timer.Start(); option.IsEnabled = false; cur_walking_state = e_walking_state.walking_active; break; case e_walking_state.walking_paused: // paused -- > active walking.Content = "Pause"; // indicate use can pause in active. walking_timer.Start(); option.IsEnabled = false; cur_walking_state = e_walking_state.walking_active; break; case e_walking_state.walking_active: // active --> paused walking.Content = "Resume"; // indicate use can resume in paused. walking_timer.Stop(); option.IsEnabled = true; cur_walking_state = e_walking_state.walking_paused; break; default: break; } }