// /////////////////////////////////////////////////////////////////////////////////////////// public PageRun(IRunMode runMode, IDeviceGps gps, IDeviceAcceleromter accelerometer, PageMain parentPage, bool demoMode) { InitializeComponent(); Debug.LogToFileMethod(); NavigationPage.SetHasBackButton(this, false); NavigationPage.SetHasNavigationBar(this, false); gpsProvider = gps; accelerometerProvider = accelerometer; runModeProvider = runMode; pageNavigation = parentPage; isDemoMode = demoMode; var speedoFilter = Settings.GetValueOrDefault(Settings.SpeedoFilter, 1); var filterSize = speedoFilter * 10; Debug.LogToFile("filter mode: " + Tools.ToFilterMode(speedoFilter)); // default = 1*10 = 10 samples = medium // 0 = off // strong = 2*10 = 20 samples movingAverageForDisplay = new MovingAverage(filterSize); isAccelerationMode = runModeProvider.Mode.Equals(RunModeAcceleration.Mode); InitLayout(); }
/// <inheritdoc /> public int Load() { // Load and run environment var loadResult = LoadEnvironment(out var env); if (loadResult == EnvironmentLoadResult.Success) { _env = env; } return((int)loadResult); }
/// <summary> /// Method to wrap all execution exceptions /// </summary> /// <param name="environment">Environment to execute</param> private static RuntimeErrorCode RunEnvironment(IRunMode environment) { try { return(environment.Run()); } catch (Exception ex) { CrashHandler.HandleCrash(null, new UnhandledExceptionEventArgs(ex, true)); return(RuntimeErrorCode.Error); } }
void OnButtonTabAcceleration(object sender, EventArgs args) { if (btnTabAcceleration.Image.File.Contains("_active") == false) { btnTabAcceleration.Image = Localization.tab_acceleration_active; btnTabBrake.Image = Localization.tab_brake; btnTabZeroToZero.Image = Localization.tab_zero; runModeProvider = new RunModeAcceleration(accelerometerProvider, soundProvider); SetModeGraphics(); } }
public PageMain() { InitializeComponent(); Debug.LogToFileMethod(); NavigationPage.SetHasBackButton(this, false); NavigationPage.SetHasNavigationBar(this, false); // DependencyService decides if to use iOS or Android gpsProvider = DependencyService.Get <IDeviceGps>(); accelerometerProvider = DependencyService.Get <IDeviceAcceleromter>(); soundProvider = DependencyService.Get <IDeviceSound>(); runModeProvider = new RunModeAcceleration(accelerometerProvider, soundProvider); accelerometerRecorder = new AccelerometerRecorder(true); // true: use queue mode to limit recording size // on first start -> use device language -> update our settings // on next starts -> use our updated settings LocaleId deviceLanguage = DependencyService.Get <IDeviceLocale>().GetLocale(); // set language, use system language as default Localization.isEnglish = Settings.GetValueOrDefault(Settings.Language, deviceLanguage == LocaleId.English); Settings.AddOrUpdateValue(Settings.Language, Localization.isEnglish); InitLayout(); InitLocalisation(); InitHelp(); bool showDisclaimer = Settings.GetValueOrDefault(Settings.Disclaimer, true); bool showTipOfDay = Settings.GetValueOrDefault(Settings.TipOfDay, true); if (showDisclaimer || showTipOfDay) { Device.StartTimer(TimeSpan.FromMilliseconds(50), () => { if (isStartUpNoteShown == false) // only show once { isStartUpNoteShown = true; if (showDisclaimer) { Navigation.PushAsync(new PageText(PageText.ContentType.Disclaimer)); } else { Navigation.PushAsync(new PageText(PageText.ContentType.TipOfDay)); } } return(false); // stop timer }); } }
/// <summary> /// Selects and loads the environment by arguments of the heart of gold /// </summary> private EnvironmentLoadResult LoadEnvironment(out IRunMode runMode) { var runModes = _container.ResolveAll <IRunMode>(); var runModeMap = (from existing in runModes let runModeAttr = existing.GetType().GetCustomAttribute <RunModeAttribute>() where runModeAttr != null select new EnvironmentInfo { RunMode = existing, OptionType = runModeAttr.OptionType }).ToArray(); var optionTypes = runModeMap.Select(r => r.OptionType).ToArray(); EnvironmentInfo env = null; var loadResult = EnvironmentLoadResult.Error; try { Parser.Default.ParseArguments(_args, optionTypes) .WithParsed(delegate(object parsed) { // Select run mode env = runModeMap.First(m => m.OptionType == parsed.GetType()); env.Options = (RuntimeOptions)parsed; loadResult = EnvironmentLoadResult.Success; }) .WithNotParsed(errors => loadResult = EvaluateParserErrors(errors)); if (loadResult == EnvironmentLoadResult.Success) { SetupEnvironment(env); } } catch (Exception ex) { loadResult = EnvironmentLoadResult.Error; CrashHandler.HandleCrash(null, new UnhandledExceptionEventArgs(ex, true)); } finally { runMode = env?.RunMode; } return(loadResult); }
void OnButtonTabZeroToZero(object sender, EventArgs args) { // check if feature is purchased, show app-store if not purchased if (AppStore.Instance.IsAppStoreShown(layout)) { return; } if (btnTabZeroToZero.Image.File.Contains("_active") == false) { btnTabAcceleration.Image = Localization.tab_acceleration; btnTabBrake.Image = Localization.tab_brake; btnTabZeroToZero.Image = Localization.tab_zero_active; runModeProvider = new RunModeZeroToZero(accelerometerProvider, soundProvider); SetModeGraphics(); } }
private void RunmodeCb_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedValue = RunmodeCb.SelectedValue; if (selectedValue == null) { return; } var selectedValueString = selectedValue.ToString(); if (selectedValueString == "Building") { _runMode = new ValidateBuilding(); } else if (selectedValueString == "StreetSeg") { _runMode = new ValidateStreetSeg(false); } else if (selectedValueString == "StreetSegBuilding") { _runMode = new ValidateStreetSeg(true); } }
public void Dispose() // IDisposable { imgBackground.Source = null; imgBackground = null; imgGpsStateOk.Source = null; imgGpsStateOk = null; imgGpsStateNotOk.Source = null; imgGpsStateNotOk = null; imgMountStateOk.Source = null; imgMountStateOk = null; imgMountStateNotOk.Source = null; imgMountStateNotOk = null; imgVelocityStateOk.Source = null; imgVelocityStateOk = null; imgVelocityStateNotOk.Source = null; imgVelocityStateNotOk = null; if (Config.Debug.PageRunAdjustEnabled) { imgDebugRunAdjust.Source = null; imgDebugRunAdjust = null; tgrDebugRunAdjust.Tapped -= OnImageDebugRunAdjust; tgrDebugRunAdjust = null; } lblGpsState.SizeChanged -= OnLayoutSizeChanged; lblMountState.SizeChanged -= OnLayoutSizeChanged; lblVelocityState.SizeChanged -= OnLayoutSizeChanged; lblGpsState = null; lblMountState = null; lblVelocityState = null; lytHorizontalTab = null; btnTabAcceleration.Image = null; btnTabAcceleration.Clicked -= OnButtonTabAcceleration; btnTabAcceleration = null; btnTabBrake.Image = null; btnTabBrake.Clicked -= OnButtonTabBrake; btnTabBrake = null; btnTabZeroToZero.Image = null; btnTabZeroToZero.Clicked -= OnButtonTabZeroToZero; btnTabZeroToZero = null; btnTabResults.Image = null; btnTabResults.Clicked -= OnButtonTabResults; btnTabResults = null; btnHelp.Image = null; btnHelp.Clicked -= OnButtonHelp; btnHelp = null; if (Config.Debug.PagePurchaseEnabled) { btnDebugPurchase.Image = null; btnDebugPurchase.Clicked -= OnButtonDebugPurchase; btnDebugPurchase = null; } btnConfig = null; btnConfig.Image = null; btnConfig.Clicked -= OnButtonConfig; btnSetup.Image = null; btnSetup.Clicked -= OnButtonSetup; btnSetup = null; btnRun.Image = null; btnRun.Clicked -= OnButtonRun; btnRun = null; btnProfile.Image = null; btnProfile.Clicked -= OnButtonProfile; btnProfile = null; gpsProvider = null; accelerometerProvider = null; runModeProvider = null; soundProvider = null; accelerometerRecorder = null; pageRun = null; pageConfig = null; pageProfile = null; pageResults = null; pageHelp = null; pageDebugRunAdjust = null; pageDebugPurchase = null; pageSetup = null; }