public override async Task InitializeAsync(object navigationData) { MessagingCenter.Subscribe <CircuitDetailsPage, string>(this, MessengerCenterMessages.ChangeTitleOnCircuitTab, (circuit, s) => { Title = s; }); MessagingCenter.Subscribe <CircuitTestDetailsPage, string>(this, MessengerCenterMessages.ChangeTitleOnCircuitTab, (circuit, s) => { Title = s; }); var circuitId = navigationData as string; if (circuitId != null) { _circuitId = circuitId; } try { using (var dlg = this.Dialogs.Loading("Progress (No Cancel)")) { var circuitResult = await _boardsService.GetTestedCircuit(_circuitId); if (!circuitResult.Success) { Dialogs.Toast(circuitResult.Message); return; } var circuit = circuitResult.ResultObject as CircuitTest; if (circuit != null) { CircuitViewModel.Circuit = circuit; CircuitTestViewModel.Circuit = circuit; await CircuitTestViewModel.InitializeAsync(null); await CircuitViewModel.InitializeAsync(null); } } } catch (ServiceAuthenticationException e) { var result = await TryToLogin(); if (!result) { await NavigationService.NavigateToAsync <LoginViewModel>(); } else { await InitializeAsync(_circuitId); } } catch (Exception e) { await ShowErrorAlert(e?.Message); } }
internal static CircuitViewModel GetCircuitFromHierarchy(SetupFileInfo setupFileInfo, ICollection <VehicleViewModel> hierarchy) { var vehicle = hierarchy.FirstOrDefault(v => v.Identifier == setupFileInfo.VehicleIdentifier); if (vehicle == null) { vehicle = new VehicleViewModel { Identifier = setupFileInfo.VehicleIdentifier, Name = FolderNameMapper.GetFriendlyVehicleName(setupFileInfo.VehicleIdentifier) }; dispatcher.InvokeAsync(() => hierarchy.Add(vehicle)); } var circuit = vehicle.Circuits.FirstOrDefault(c => c.Identifier == setupFileInfo.CircuitIdentifier); if (circuit == null) { circuit = new CircuitViewModel { Identifier = setupFileInfo.CircuitIdentifier, Name = FolderNameMapper.GetFriendlyCircuitName(setupFileInfo.CircuitIdentifier) }; dispatcher.InvokeAsync(() => vehicle.Circuits.Insert(0, circuit)); } return(circuit); }
public void LoadCellValues(CircuitViewModel circuit) { ExceptionUtility.Try(() => { this._circuit = circuit; if (circuit.Running) { this.SetLine1Font(BoldCellTextFont); this._checkbox.Hidden = true; } else { this.SetLine1Font(NormalCellTextFont); this._checkbox.Hidden = false; } if (circuit.HasFault) { this.SetLine2TextColor(Colors.ErrorTextColor); } else { this.SetLine2TextColor(Colors.StandardTextColor); } if (circuit.HighlightGreen) { this.SetTextColor(Colors.AquamonixGreen); } else { this.SetTextColor(Colors.AquamonixBrown); } this.LoadCellValues(this._circuit.Id, this._circuit.Name, this._circuit.Description); _checkbox.SetChecked(circuit.Selected); if (circuit.Running) { this.SetStatus(StringLiterals.Running.ToUpper()); //"RUNNING"); } else if (circuit.Starting) { this.SetStatus(StringLiterals.Starting.ToUpper()); //"STARTING"); } else { this.SetStatus(null); } _powerIconImageView.Hidden = (!circuit.DisplayPowerIcon); }); }
private static IEnumerable <VehicleViewModel> BuildHierarchy(string rootFolder, bool isVersion) { var result = new List <VehicleViewModel>(); var vehicleFolderPaths = Directory.GetDirectories(rootFolder); foreach (var vehicleFolderPath in vehicleFolderPaths) { var vehicleIdentifier = PathProvider.GetLastFolderName(vehicleFolderPath); var vehicle = new VehicleViewModel { Identifier = vehicleIdentifier, Name = FolderNameMapper.GetFriendlyVehicleName(vehicleIdentifier) }; var circuitFolderPaths = Directory.GetDirectories(vehicleFolderPath); foreach (var circuitFolderPath in circuitFolderPaths) { var circuitIdentifier = PathProvider.GetLastFolderName(circuitFolderPath); var circuit = new CircuitViewModel { Identifier = circuitIdentifier, Name = FolderNameMapper.GetFriendlyCircuitName(circuitIdentifier) }; var setupFilePaths = Directory.GetFiles(circuitFolderPath); foreach (var setupFilePath in setupFilePaths) { var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(setupFilePath); var setup = new SetupViewModel { Name = fileNameWithoutExtension, FilePath = setupFilePath, VehicleIdentifier = vehicleIdentifier, CircuitIdentifier = circuitIdentifier, IsVersion = isVersion }; circuit.Setups.Add(setup); } vehicle.Circuits.Add(circuit); } result.Add(vehicle); } return(result); }
public override async Task OnAppearing() { await CircuitTestViewModel.OnAppearing(); await CircuitViewModel.OnAppearing(); }
public CircuitsPage(CircuitViewModel viewModel) { InitializeComponent(); BindingContext = this.viewModel = viewModel; }