protected override void OnSourceInitialized(EventArgs e)
 {
     base.OnSourceInitialized(e);
     WindowPlacement.SetPlacement(new WindowInteropHelper(this).Handle, Settings.Default.MainWindowPlacement);
 }
 protected override void OnClosing(CancelEventArgs e)
 {
     Settings.Default.MainWindowPlacement = WindowPlacement.GetPlacement(new WindowInteropHelper(this).Handle);
     Settings.Default.Save();
 }