async public void ShowPageRun() { ApplyCalibration(true); if (isDemoMode) { DemoAcceleromter demoAcceleromter = new DemoAcceleromter(runModeProvider.Mode, accelerometerProvider); DemoGps demoGps = new DemoGps(demoAcceleromter); pageRun = new PageRun(runModeProvider, demoGps, demoAcceleromter, this, true); } else { pageRun = new PageRun(runModeProvider, gpsProvider, accelerometerProvider, this, false); } await Navigation.PushAsync(pageRun); }
public DemoGps(DemoAcceleromter demoAcceleromter) { Debug.LogToFileMethod(); Debug.LogToFile("gps sensor init (demo mode)"); this.demoAcceleromter = demoAcceleromter; }
void InitLayout() { // gps icon imgGps = new Image(); if (isDemoMode) { imgGps.Source = "@drawable/icn_gps_no.png"; // if demo mode -> gps is always off } else { imgGps.Source = "@drawable/icn_gps_yes.png"; } layout.Children.Add ( imgGps, Constraint.RelativeToParent((parent) => parent.Width - imgGps.Width * 1.1), Constraint.RelativeToParent((parent) => parent.Y) ); imgGps.SizeChanged += ((obj, sender) => layout.ForceLayout()); // test mode labelMode = new CustomLabel(); labelMode.Size = CustomLabel.SIZE_CAPTION; labelMode.TextColor = Color.FromUint(runModeProvider.Color); labelMode.Text = runModeProvider.ModeText; //labelMode.SizeChanged += ((obj, sender) => layout.ForceLayout()); layout.Children.Add ( labelMode, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - labelMode.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height * 0.06) ); // /////////////////////////////////////////////////////////////////////////////////////////// // debug and test if (Config.Run.DebugStartEnabled) { Button btnDebugStart = new Button(); btnDebugStart.Text = "DebugStart"; btnDebugStart.Clicked += (sender, e) => { DemoAcceleromter demoAccelerometerProvider = accelerometerProvider as DemoAcceleromter; if (demoAccelerometerProvider != null) { demoAccelerometerProvider.OnAcceleromterLaunchDetected(); } else { OnAcceleromterLaunchDetected(); // cast was not successful -> we have a real sensor } }; layout.Children.Add ( btnDebugStart, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - btnDebugStart.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height * 0.1) ); } // /////////////////////////////////////////////////////////////////////////////////////////// // speedo imgSpeedo = new Image(); imgSpeedo.Source = runModeProvider.Speedo; imgSpeedo.Scale = 0.85; imgSpeedo.SizeChanged += OnSpeedoBackgroundResize; layout.Children.Add ( imgSpeedo, Constraint.RelativeToParent((parent) => parent.X), Constraint.RelativeToParent((parent) => parent.Y), Constraint.RelativeToParent((parent) => parent.Width), Constraint.RelativeToParent((parent) => parent.Height) ); // distance indicator if (isDemoMode) { // replace distance indicator in demo mode labelDemoMode = new CustomLabel(); labelDemoMode.Size = CustomLabel.SIZE_CAPTION_DE; labelDemoMode.Text = "Demo Mode"; labelDemoMode.TextColor = Color.FromUint(runModeProvider.Color); layout.Children.Add ( labelDemoMode, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - labelDemoMode.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height * 0.4) ); } else { if (isAccelerationMode) { imgDistanceOff = new Image(); imgDistanceOff.Source = "@drawable/display_distance1.png"; layout.Children.Add ( imgDistanceOff, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - imgDistanceOff.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height * 0.36) ); imgDistanceOff.IsVisible = true; imgDistanceQuarter = new Image(); imgDistanceQuarter.Source = "@drawable/display_distance2.png"; layout.Children.Add ( imgDistanceQuarter, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - imgDistanceQuarter.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height * 0.36) ); imgDistanceQuarter.IsVisible = false; imgDistanceHalf = new Image(); imgDistanceHalf.Source = "@drawable/display_distance3.png"; layout.Children.Add ( imgDistanceHalf, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - imgDistanceHalf.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height * 0.36) ); imgDistanceHalf.IsVisible = false; } } // label speed labelSpeed = new CustomLabel(); labelSpeed.Text = "000"; labelSpeed.Size = CustomLabel.SIZE_SPEEDO; labelSpeed.TextColor = Color.White; layout.Children.Add ( labelSpeed, Constraint.RelativeToParent((parent) => parent.Width * 0.55), Constraint.RelativeToParent((parent) => parent.Height * 0.56) ); // label unit labelUnit = new CustomLabel(); labelUnit.Text = Settings.GetSpeedUnit(); labelUnit.Size = CustomLabel.SIZE_SPEEDO_UNIT; labelSpeed.TextColor = Color.White; layout.Children.Add ( labelUnit, Constraint.RelativeToParent((parent) => parent.Width * 0.57 + labelSpeed.Width * 0.54), Constraint.RelativeToParent((parent) => parent.Height * 0.57 + labelSpeed.Height * 0.8) ); // needle imgNeedle = new Image(); imgNeedle.Source = runModeProvider.Needle; //imgNeedle.AnchorY = 1.0 / 378.0 * 340; // 1 / imgHeight * centerOfNeedlePivot imgNeedle.AnchorY = 1.0 / 365.0 * 337; // 1 / imgHeight * centerOfNeedlePivot //imgNeedle.AnchorY = 1.0 / 487.0 * 450; // 1 / imgHeight * centerOfNeedlePivot imgNeedle.Rotation = ROTATION_TARGET_MAX; layout.Children.Add ( imgNeedle, Constraint.RelativeToView(imgSpeedo, (parent, view) => (view.Width * 0.5) - (35.0 * 0.5)), Constraint.RelativeToView(imgSpeedo, (parent, view) => (view.Height * 0.5) - (165.5)), Constraint.Constant(35.0), Constraint.Constant(184.0) ); // split time if (isAccelerationMode) { labelSplitTime = new CustomLabel(); labelSplitTime.Size = CustomLabel.SIZE_LARGE; SetSplitTimeText(); layout.Children.Add ( labelSplitTime, Constraint.RelativeToParent((parent) => parent.Width * 0.07), Constraint.RelativeToParent((parent) => parent.Height * 0.8) ); } // mode status labelStatus = new CustomLabel(); labelStatus.Size = CustomLabel.SIZE_LARGE; SetStatusText(runModeProvider.Status); layout.Children.Add ( labelStatus, Constraint.RelativeToParent(delegate(RelativeLayout parent) { if (isAccelerationMode) { return(parent.Width * 0.55); } else { return(parent.Width * 0.55 - labelStatus.Width * 0.5); } }), Constraint.RelativeToParent((parent) => parent.Height * 0.8) ); // abort button btnAbort = new Button(); btnAbort.Image = Localization.btn_abort; btnAbort.BackgroundColor = Color.Transparent; btnAbort.Clicked += OnButtonAbort; layout.Children.Add ( btnAbort, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - btnAbort.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height - btnAbort.Height) ); // overlay stop vehicle btnStopVehicle = new Button(); btnStopVehicle.Image = Localization.stop_vehicle; btnStopVehicle.BackgroundColor = Color.Transparent; btnStopVehicle.IsEnabled = false; btnStopVehicle.IsVisible = false; layout.Children.Add ( btnStopVehicle, Constraint.RelativeToParent((parent) => parent.Width * 0.5 - btnStopVehicle.Width * 0.5), Constraint.RelativeToParent((parent) => parent.Height - btnStopVehicle.Height) ); }