private void TransferFile(object parameter) { Task.Run(() => { this.IsBusy = true; try { var fileName = this.GetFileName(); this.SaveDataToCsv(fileName); var files = new List <string>(); files.Add(fileName); if (!String.IsNullOrEmpty(this.LastImageFileName)) { files.Add(this.LastImageFileName); } SendFileByEmailMessage.Send(files.ToArray()); this.State = StartPageStates.Rescan; } catch (Exception exception) { ShowToastMessage.Send(exception.Message); } finally { this.IsBusy = false; } }); }
public CurrentPage() : base() { NavigationPage.SetHasNavigationBar(this, false); this.SizeChanged += (sender, args) => { if (this.Content == null) { bool added = false; int count = 0; while ((!added) && (count < 3)) { try { var content = this.BuildPageContent(); if (content != null) { this.Content = content; } added = true; } catch (Exception exception) { Console.WriteLine("BuildPageContent exception: {0}", exception.Message); count++; if (count == 3) { ShowToastMessage.Send("Error create view. " + exception.Message); } } } } }; }
private void Scan(object parameter) { Task.Run(() => { this.IsBusy = true; try { this.SetProgress(0); this.SetProgressVisible(true); var result = _scannerService.Scan(); //Task.Delay(3000).Wait(); //var result = new ScannerData[] { // new ScannerData { X = 1, Y = 1, N = 1 }, // new ScannerData { X = 2, Y = 2, N = 2 }, // new ScannerData { X = 3, Y = 3, N = 3 }, // new ScannerData { X = 4, Y = 4, N = 4 }, // new ScannerData { X = 5, Y = 5, N = 5 }, // new ScannerData { X = 6, Y = 6, N = 6 }, // new ScannerData { X = 7, Y = 7, N = 7 }, // new ScannerData { X = 8, Y = 8, N = 8 }, // new ScannerData { X = 9, Y = 9, N = 9 } //}; _currentData = result; this.State = StartPageStates.Store; } catch (Exception exception) { ShowToastMessage.Send(exception.Message); } finally { this.SetProgressVisible(false); this.IsBusy = false; } }); }
private void BuildContent() { Task.Run(() => { try { _content = this.CreateContent(); } catch (Exception exception) { Console.WriteLine("Create panel content: " + exception.Message); ShowToastMessage.Send(exception.Message); } }).LogExceptions("Panel BuildContent"); }
public StartViewModel() : base() { _scannerService = DependencyService.Get <IScannerService>(); _scannerService.Listener = this; _fileService = DependencyService.Get <IFileService>(); _oakCrossCorr = DependencyService.Get <IOakCrossCorr>(); try { _scannerService.FindDevice(); } catch (Exception exception) { ShowToastMessage.Send(exception.Message); } this.StartConnectionCommand = new VisualCommand(this.StartConnection); this.AlcoholCommand = new VisualCommand(this.Alcohol); this.OilCommand = new VisualCommand(this.Oil); this.MilkCommand = new VisualCommand(this.Milk); this.WaterCommand = new VisualCommand(this.Water); this.TakePhotoCommand = new VisualCommand(this.TakePhoto); this.ScanCommand = new VisualCommand(this.Scan); this.StoreCommand = new VisualCommand(this.Store); this.TestCommand = new VisualCommand(this.Test); this.KeepInPhoneCommand = new VisualCommand(this.KeepInPhone); this.TransferFileCommand = new VisualCommand(this.TransferFile); this.Program1Command = new VisualCommand(this.Program1); this.Program2Command = new VisualCommand(this.Program2); this.Program3Command = new VisualCommand(this.Program3); this.Program4Command = new VisualCommand(this.Program4); this.Program5Command = new VisualCommand(this.Program5); this.Program6Command = new VisualCommand(this.Program6); this.Program7Command = new VisualCommand(this.Program7); this.Program8Command = new VisualCommand(this.Program8); this.RescanCommand = new VisualCommand(this.Rescan); this.RetestCommand = new VisualCommand(this.Retest); this.CloseCommand = new VisualCommand(this.Close); this.CompareCommand = new VisualCommand(this.Compare); this.CheckCommand = new VisualCommand(this.Check); this.NextCommand = new VisualCommand(this.Next); this.TestResultContinueCommand = new VisualCommand(this.TestResultContinue); }
private void StartConnection(object parameter) { Task.Run(() => { try { this.State = StartPageStates.Connecting; var result = _scannerService.Connect(); //Task.Delay(2000).Wait(); this.State = StartPageStates.Connected; } catch (Exception exception) { Console.WriteLine(exception.Message); ShowToastMessage.Send(exception.Message); this.State = StartPageStates.WaitConnection; } finally { } }); }
public Panel() : base() { this.ID = Guid.NewGuid(); this.HorizontalOptions = LayoutOptions.Fill; this.VerticalOptions = LayoutOptions.Fill; var grid = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, RowSpacing = 0, ColumnSpacing = 0 }; this.SizeChanged += (sender, args) => { if (_content == null) { try { _content = this.CreateContent(); if (_content != null) { grid.Children.Add(_content); } } catch (Exception exception) { Console.WriteLine("Create panel content: " + exception.Message); ShowToastMessage.Send(exception.Message); } } }; this.Content = grid; //this.BuildContent(); }
private void SaveDataToCsv(int index) { Task.Run(() => { this.IsBusy = true; try { var fileName = this.GetFileName(index); this.SaveDataToCsv(fileName); this.State = StartPageStates.Rescan; } catch (Exception exception) { ShowToastMessage.Send(exception.Message); } finally { this.IsBusy = false; } }); }
private void CheckData(int index) { Task.Run(() => { this.IsBusy = true; try { var storeData = this.ReadDataFromCsv(index); //var currentSample = _currentData.Select(sd => (double)sd.Y).ToArray(); //var storeSample = storeData.Select(sd => (double)sd.Y).ToArray(); var current = new List <Double>(); var store = new List <Double>(); foreach (var currentItem in _currentData) { var storeItem = storeData.FirstOrDefault(sd => sd.X == currentItem.X); if (storeItem != null) { current.Add(currentItem.Y); store.Add(storeItem.Y); } } //var adv = _oakCrossCorr.ADV(current.ToArray(), store.ToArray()); //var fdav = _oakCrossCorr.FDAV(current.ToArray(), store.ToArray()); //var fdls = _oakCrossCorr.FDLS(current.ToArray(), store.ToArray()); //var idiff = _oakCrossCorr.IDIFF(current.ToArray(), store.ToArray()); //var iis = _oakCrossCorr.IS(current.ToArray(), store.ToArray()); //var ls = _oakCrossCorr.LS(current.ToArray(), store.ToArray()); //var savg = _oakCrossCorr.SAVG(current.ToArray(), store.ToArray()); var coeff = _oakCrossCorr.GetCoeff(current.ToArray(), store.ToArray()); var text = ""; var result = TestResults.OK; if (coeff > 0.9) { result = TestResults.OK; text = "SAFE ({0})"; } else if ((coeff > 0.7) && (coeff <= 0.9)) { result = TestResults.Warning; text = "WARNING ({0})"; } else { result = TestResults.Danger; text = "DANGER ({0})"; } Device.BeginInvokeOnMainThread(() => { this.TestResultText = String.Format(text, coeff.ToString("0.0000")); this.TestResult = result; this.IsTestResultVisible = true; }); } catch (Exception exception) { ShowToastMessage.Send(exception.Message); } finally { this.IsBusy = false; } }); }