Пример #1
0
        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();
        }
Пример #2
0
        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;
            }
        }