//Constructor, wordt aangeroepen bij start van de Training. public Training() { //Track lijst aanmaken en de eerste Track toevoegen. Tracks = new List <Track>(); Tracks.Add(new Track()); trackCount = 0; //Timer instellen en starten timer = new MyTimer(); stopWatch = new Stopwatch(); stopWatch.Start(); timer.Start(); }
// Methode om alle variabelen toe te wijzen en de UI op te zetten private void SetUpVariables() { // bool variabelen inTraining = false; firstStart = true; // UI variabelen metrics = Resources.DisplayMetrics; contentLayout = Activity.FindViewById <LinearLayout>(Resource.Id.content_layout); mapsLayout = Activity.FindViewById <RelativeLayout>(Resource.Id.maps_layout); recenter = Activity.FindViewById <Button>(Resource.Id.zoomToLoc); startButton = Activity.FindViewById <ImageButton>(Resource.Id.startTraining); contentLayout.LayoutParameters.Height = ViewGroup.LayoutParams.WrapContent; mapsLayout.LayoutParameters.Height = (int)(metrics.HeightPixels - contentLayout.LayoutParameters.Height); leftLayout = Activity.FindViewById <LinearLayout>(Resource.Id.layout_left); rightLayout = Activity.FindViewById <LinearLayout>(Resource.Id.layout_left); stopButton = Activity.FindViewById <ImageButton>(Resource.Id.stopTraining); distanceText = Activity.FindViewById <TextView>(Resource.Id.distanceText); stopWatchText = Activity.FindViewById <TextView>(Resource.Id.stopWatchView); bottomLayout = Activity.FindViewById <LinearLayout>(Resource.Id.stats_layout); masterLayout = Activity.FindViewById <RelativeLayout>(Resource.Id.master_layout); masterLayout.RemoveView(bottomLayout); // Roep method aan om de layout te organiseren om een run te kunnen starten LayoutToStart(); // Timer opzetten timer = new MyTimer(); timer.Interval = 1000; timer.Elapsed += Timer_Elapsed; ResetTimer(); // Handler voor recenter recenter.Click += delegate { mListener.OnRecenterClick(); }; // Handler voor start startButton.Click += delegate { //Als de training bezig is, pauzeer de training if (inTraining) { this.PauseTraining(); } //Als de training niet bezig is, hervat of start deze else { if (firstStart) { if (mListener.LocationIsOn()) { this.StartTraining(); } } else { if (mListener.LocationIsOn()) { this.ResumeTraining(); } } } }; // Handler voor stop stopButton.Click += delegate { //Alert Android.Support.V7.App.AlertDialog.Builder dialog = new Android.Support.V7.App.AlertDialog.Builder(Activity); dialog.SetMessage("Stop Training?"); dialog.SetPositiveButton("Stop", delegate { StopTraining(); }); dialog.SetNegativeButton("Cancel", delegate { }); dialog.Show(); }; }