public MainWindow(ref OpenSshController controller, ref FolderManager FolderManager) { this.controller = controller; this.FolderManager = FolderManager; DataBinding = new MainWindowDataBinding(); registerWithAwsThread = new Thread(RegisterWithAws); InitializeComponent(); FindOrInstallOpenSshLocation(); // This can be read in from the settings file. // TODO: create persistent settings file. this.FolderManager.DirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); DataBinding.LanIp = controller.GetLocalIp(); DataBinding.LanPort = controller.GetLocalPort().ToString(); DataBinding.WanIp = controller.GetRemoteIp(); DataBinding.WanPort = controller.GetRemotePort().ToString(); WanIpTextBox.IsReadOnly = true; WanPortTextBox.IsReadOnly = true; LanIpTextBox.IsReadOnly = true; LanPortTextBox.IsReadOnly = true; }
/* * This ONLY goes inside of a thread. */ private void RegisterWithAws() { while (true) { string keyword = AwsRequest.RegisterWithAws( controller.GetRemoteIp(), controller.GetRemotePort().ToString(), controller.GetLocalIp(), controller.GetLocalPort().ToString()); if (!string.IsNullOrEmpty(keyword)) { // Present the ID to the user in the GUI Dispatcher.Invoke(new Action(() => { currentId = keyword; ConnectionStatusLabel.Content = keyword; })); } Thread.Sleep(180100); } }