Exemplo n.º 1
0
        private void Dev_Calibration_Click(object sender, MouseButtonEventArgs e)
        {
            var win = new CalibrationWindow(new Calibration {
                Bounds = new Bounds(), Filename = MapCalibration.Filename
            });

            win.ShowDialog();
        }
Exemplo n.º 2
0
        private void Calibration_Click(object sender, MouseButtonEventArgs e)
        {
            var win = new CalibrationWindow(new Calibration {
                Bounds = new Bounds()
            });

            win.ShowDialog();
        }
Exemplo n.º 3
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;
            }
        }