public void Scan() { _watcher.Created += async(sender, e) => { var data = await ReadFile(e.Name !); var picture = new Picture() { Data = data }; NewScanEvent?.Invoke(this, new NewScanEventArgs() { FileName = Path.GetFileName(e.Name), Picture = picture }); }; _watcher.EnableRaisingEvents = true; }
private void Scan() { _scanAngle = (_scanAngle + _ship.ScannerDegreePerScan < 360) ? _scanAngle + _ship.ScannerDegreePerScan - 2 : _scanAngle + _ship.ScannerDegreePerScan - 362; try { List <Unit> scannedUnits = _ship.Scan(_scanAngle, _ship.ScannerArea.Limit); _map.Insert(scannedUnits); NewScanEvent?.Invoke(); } catch (GameException e) { if (e.ErrorNumber == 84) { Continue(); } else { Console.WriteLine(e.Message); } } }