private void miNewConnection_Click(object sender, RoutedEventArgs e) { // open new connection from NewConnection nc = new NewConnection(); nc.ShowDialog(); }
protected override void OnStartup(StartupEventArgs e) { InDesignMode = false; Current = (App)Application.Current; Res = new AppResources(); EnsureUserFolders(); Task.Run(() => Firewall.Instance.GrantAuthorizationToSelf()); var firstArg = e.Args.FirstOrDefault(); if (firstArg?.Equals("-nonew", StringComparison.OrdinalIgnoreCase) == true) { new MainWindow().Show(); } else if (firstArg?.Equals("-settings", StringComparison.OrdinalIgnoreCase) == true && e.Args.Length == 2) { var cs = ConnectionSettings.Deserialize(File.ReadAllBytes(e.Args[1])); var session = cs.CreateSession(); if (session != null) { var mainWindow = new MainWindow(); mainWindow.Show(); mainWindow.AddSessionAndStart(session); } } else { Rect rect = Rect.Empty; var session = SessionFromArgs(e.Args); if (session == null) { ShutdownMode = ShutdownMode.OnExplicitShutdown; var dlg = new NewConnection() { ShowInTaskbar = true, Title = "Swiddler", WindowStartupLocation = WindowStartupLocation.CenterScreen }; dlg.ShowDialog(); session = dlg.Result; rect = new Rect(dlg.Left, dlg.Top, dlg.Width, dlg.Height); } if (session != null) { ShutdownMode = ShutdownMode.OnLastWindowClose; var mainWindow = new MainWindow(); if (!rect.IsEmpty) { mainWindow.Left = (rect.Width - mainWindow.Width) / 2.0 + rect.Left; // center of closed NewConnection dialog mainWindow.Top = (rect.Height - mainWindow.Height) / 2.0 + rect.Top; } mainWindow.Show(); mainWindow.AddSessionAndStart(session); } } }
private void ShowNewConnectionWindow(NewConnection newConnection) { newConnection.Closing += newConnection_Closing; newConnection.ShowDialog(); }