private void RestoreSettings() { object value = this.settings["WindowBounds"]; if (value is Rect r && !r.IsEmpty) { // make sure it is visible on the user's current screen configuration. var bounds = new Rect( XamlExtensions.ConvertFromDeviceIndependentPixels(r.X), XamlExtensions.ConvertFromDeviceIndependentPixels(r.Y), XamlExtensions.ConvertFromDeviceIndependentPixels(r.Width), XamlExtensions.ConvertFromDeviceIndependentPixels(r.Height)); var virtualScreen = new Rect(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop, SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight); if (virtualScreen.Contains(bounds)) { this.Left = XamlExtensions.ConvertToDeviceIndependentPixels((int)bounds.X); this.Top = XamlExtensions.ConvertToDeviceIndependentPixels((int)bounds.Y); this.Width = XamlExtensions.ConvertToDeviceIndependentPixels((int)bounds.Width); this.Height = XamlExtensions.ConvertToDeviceIndependentPixels((int)bounds.Height); } } UpdateTheme(); this.recentFiles.SetFiles(this.settings["RecentFiles"] as Uri[]); this.Visibility = Visibility.Visible; }
private void RestorePosition() { this.SizeChanged -= OnWindowSizeChanged; this.LocationChanged -= OnWindowLocationChanged; this.settings = App.Instance.LoadSettings(); if (settings.WindowLocation.X != 0 && settings.WindowSize.Width != 0 && settings.WindowSize.Height != 0) { // make sure it is visible on the user's current screen configuration. var bounds = new System.Drawing.Rectangle( XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowLocation.X), XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowLocation.Y), XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowSize.Width), XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowSize.Height)); var screen = System.Windows.Forms.Screen.FromRectangle(bounds); bounds.Intersect(screen.WorkingArea); this.Left = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.X); this.Top = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.Y); this.Width = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.Width); this.Height = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.Height); } this.Visibility = Visibility.Visible; this.SizeChanged += OnWindowSizeChanged; this.LocationChanged += OnWindowLocationChanged; }
private async void RestoreSettings() { Settings settings = await((App)App.Current).LoadSettings(); if (settings.WindowLocation.X != 0 && settings.WindowSize.Width != 0 && settings.WindowSize.Height != 0) { // make sure it is visible on the user's current screen configuration. var bounds = new System.Drawing.Rectangle( XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowLocation.X), XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowLocation.Y), XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowSize.Width), XamlExtensions.ConvertFromDeviceIndependentPixels(settings.WindowSize.Height)); var screen = System.Windows.Forms.Screen.FromRectangle(bounds); bounds.Intersect(screen.WorkingArea); this.Left = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.X); this.Top = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.Y); this.Width = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.Width); this.Height = XamlExtensions.ConvertToDeviceIndependentPixels(bounds.Height); } ConnectionPanel.DefaultUdpPort = settings.Port; this.Visibility = Visibility.Visible; }
void ShowMap() { myMap.Children.Clear(); List <Flight> selected = GetSelectedFlights(); if (selected.Count == 0) { // show everything. selected.Add(new Flight() { StartTime = DateTime.MinValue, Duration = TimeSpan.MaxValue }); } var glitchIcon = XamlExtensions.LoadImageResource("Assets.GpsGlitchIcon.png"); var imageLayer = new MapLayer(); myMap.Children.Add(imageLayer); MapPolyline last = currentFlight; foreach (IDataLog log in this.logs) { if (log != null) { bool gpsIsBad = false; foreach (var flight in selected) { if (flight.Log == null || flight.Log == log) { MapPolyline line = new MapPolyline(); line.StrokeThickness = 4; line.Stroke = new SolidColorBrush(GetRandomColor()); LocationCollection points = new LocationCollection(); Debug.WriteLine("time,\t\tlat,\t\tlong,\t\t\tnsat,\talt,\thdop,\tfix"); foreach (var row in log.GetRows("GPS", flight.StartTime, flight.Duration)) { LogEntryGPS gps = new LogEntryGPS(row); Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.GPSTime, gps.Lat, gps.Lon, gps.nSat, gps.Alt, gps.EPH, gps.Fix); if (!(Math.Floor(gps.Lat) == 0 && Math.Floor(gps.Lon) == 0)) { var pos = new Location() { Altitude = gps.Alt, Latitude = gps.Lat, Longitude = gps.Lon }; points.Add(pos); ulong time = (ulong)gps.GPSTime; if (time != 0) { if ((gps.nSat < 5 || gps.EPH > 20)) { if (!gpsIsBad) { gpsIsBad = true; Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.GPSTime, gps.Lat, gps.Lon, gps.nSat, gps.Alt, gps.EPH, gps.Fix); Image img = new Image(); img.Width = 30; img.Height = 30; img.Source = glitchIcon; img.Stretch = Stretch.None; img.ToolTip = "GPS Glitch!"; imageLayer.AddChild(img, pos, PositionOrigin.Center); } } else { gpsIsBad = false; } } } } if (points.Count > 0) { line.Locations = points; myMap.Children.Add(line); last = line; } } } } } // hide the stuff on top... QuadButton.IsChecked = false; ConsoleButton.IsChecked = false; SystemConsole.Hide(); ChartStack.Visibility = Visibility.Collapsed; myMap.Visibility = Visibility.Visible; myMap.UpdateLayout(); if (last != null) { try { myMap.SetView(last.Locations, new Thickness(20.0), 0); } catch (Exception ex) { ShowStatus(ex.Message); } } }
private void OnSettings(object sender, RoutedEventArgs e) { XamlExtensions.Flyout(AppSettingsPanel); }