//private static ListResults CreateDataOLE() //{ // string dir = Directory.GetCurrentDirectory(); //} private static ListResults CreateData() { //Create COM Objects. Create a COM object for everything that is referenced string dir = Directory.GetCurrentDirectory(); Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(Path.GetFullPath(Path.Combine(dir, @"..\..\Excel\EuroMillions.xlsx"))); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Excel.Range xlRange = xlWorksheet.UsedRange; int rowCount = xlRange.Rows.Count; int colCount = xlRange.Columns.Count; ListResults results = new ListResults(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 2; i <= rowCount; i++) { List <int> numbers = new List <int>(); for (int j = 2; j <= colCount - 2; j++) { var cell = xlRange.Cells[i, j]; var number = Convert.ToInt32(cell.Value2); if (number >= 1) { numbers.Add(number); } } if (numbers.Count == 5) { results.Add(new Results ( numbers[0], numbers[1], numbers[2], numbers[3], numbers[4] )); } else { Console.Write("Something didnt get counted"); } } stopwatch.Stop(); return(results); }
private void UpdateSearchResults(IList <SearchCriteria> searches) { if (searches == null || searches.Count == 0) { ListResults.Clear(); } else { // Find dinos that match the given searches var found = new List <Dino>(); var sourceDinos = ShowTames ? arkReader.TamedDinos : arkReader.WildDinos; var total = 0; foreach (var search in searches) { if (String.IsNullOrWhiteSpace(search.Species)) { foreach (var speciesDinos in sourceDinos.Values) { found.AddRange(speciesDinos); total += speciesDinos.Count; } } else { if (sourceDinos.ContainsKey(search.Species)) { var dinoList = sourceDinos[search.Species]; found.AddRange(dinoList.Where(d => search.Matches(d))); total += dinoList.Count; } } } ListResults.Clear(); foreach (var result in found) { ListResults.Add(result); } ShowCounts = true; ResultTotalCount = ShowTames ? sourceDinos.Sum(species => species.Value.Count()) : total; ResultMatchingCount = ListResults.Count; } ((CollectionViewSource)Resources["OrderedResults"]).View.Refresh(); TriggerNameSearch(true); }
private void Dev_DummyData_Click(object sender, MouseButtonEventArgs e) { ListResults.Clear(); var dummyData = new Dino[] { new Dino { Location = new Position { Lat = 10, Lon = 10 }, Type = "Testificate", Name = "10,10" }, new Dino { Location = new Position { Lat = 90, Lon = 10 }, Type = "Testificate", Name = "90,10" }, new Dino { Location = new Position { Lat = 10, Lon = 90 }, Type = "Testificate", Name = "10,90" }, new Dino { Location = new Position { Lat = 90, Lon = 90 }, Type = "Testificate", Name = "90,90" }, new Dino { Location = new Position { Lat = 50, Lon = 50 }, Type = "Testificate", Name = "50,50" }, }; var rnd = new Random(); foreach (var result in dummyData) { result.Id = (ulong)rnd.Next(); DinoViewModel vm = new DinoViewModel(result) { Color = Colors.Green }; ListResults.Add(vm); } var cv = (CollectionView)CollectionViewSource.GetDefaultView(ListResults); cv.Refresh(); }
private void UpdateSearchResults(IList <SearchCriteria> searches) { if (searches == null || searches.Count == 0) { ListResults.Clear(); } else { // Find dinos that match the given searches var found = new List <Dino>(); var reader = ShowTames ? arkReaderTamed : arkReaderWild; foreach (var search in searches) { if (String.IsNullOrWhiteSpace(search.Species)) { foreach (var speciesDinos in reader.FoundDinos.Values) { found.AddRange(speciesDinos); } } else { if (reader.FoundDinos.ContainsKey(search.Species)) { var dinoList = reader.FoundDinos[search.Species]; found.AddRange(dinoList.Where(d => search.Matches(d))); } } } ListResults.Clear(); foreach (var result in found) { ListResults.Add(result); } } ((CollectionViewSource)Resources["OrderedResults"]).View.Refresh(); TriggerNameSearch(true); }
/* * make async */ private void CallToApi(string query) { try { string response = APICaller.Call("https://api.themoviedb.org/3/search/movie?api_key=1a9755b22a226ad22bb40fc91e9ed04a", "&query=" + query); _resultsModel = JsonConvert.DeserializeObject <ResultsModel>(response); Console.WriteLine("response here: " + response); Console.WriteLine("results model: " + _resultsModel.results.Count); ImageBackground = new BitmapImage(new Uri("https://image.tmdb.org/t/p/original/" + _resultsModel.results[0].backdrop_path)); _resultsModel.results.ForEach(delegate(Result s) { ListResults.Add(s); }); RaisePropertyChanged("ListResults"); } catch (JsonReaderException e) { Console.WriteLine(e.StackTrace); } }
private async Task GenerateCalibrationPoints() { IsLoading = true; try { StatusDetailText = "...converting"; StatusText = "Processing saved ARK (for calibration)"; var boxes = await arkReader.PerformCalibrationRead(Properties.Settings.Default.SaveFile); if (boxes.Count == 0) { MessageBox.Show(@"Map calibration requires storage boxes named 'Calibration: XX.X, YY.Y', " + "where XX.X and YY.Y are read from the GPS when standing on top of the box. " + "At least 4 are required for a calculation but 16+ are recommended!", "Calibration Boxes", MessageBoxButton.OK, MessageBoxImage.Information); return; } var rnd = new Random(); foreach (var(pos, name) in boxes) { var dino = new Dino { Location = pos, Type = "Calibration", Name = name, Id = (ulong)rnd.Next() }; var vm = new DinoViewModel(dino) { Color = Colors.Blue }; ListResults.Add(vm); } ((CollectionViewSource)Resources["OrderedResults"]).View.Refresh(); StatusText = "ARK processing completed"; StatusDetailText = $"{boxes.Count} valid calibration boxes located"; if (boxes.Count >= 4) { var((xO, xD, xC), (yO, yD, yC)) = CalculateCalibration(boxes.Select(p => p.pos).ToArray()); var warning = (xC < 0.99 || yC < 0.99) ? "\nWARNING: Correlation is poor - add more boxes!\n" : ""; var result = MessageBox.Show("UE->LatLon conversion...\n" + "\n" + $"X: {xO:F2} + x / {xD:F3} (correlation {xC:F5})\n" + $"Y: {yO:F2} + y / {yD:F3} (correlation {yC:F5})\n" + warning + "\nOpen Calibration window with these presets?", "Calibration Box Results", MessageBoxButton.YesNo); if (MessageBoxResult.Yes == result) { var win = new CalibrationWindow(new Calibration { Bounds = new Bounds(), Filename = MapCalibration.Filename, LonOffset = xO, LonDivisor = xD, LatOffset = yO, LatDivisor = yD, }); Dispatcher.Invoke(() => win.ShowDialog()); } } } catch (Exception ex) { StatusText = "ARK processing failed"; StatusDetailText = ""; MessageBox.Show(ex.Message, "Savegame Read Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } finally { IsLoading = false; } }