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;
}