//Button void ConnectCIPC(object sender, RoutedEventArgs e) { //Connect if (this.cipcMain == null) { CIPCClientWindow.CIPCSettingWindow settingWindow = new CIPCClientWindow.CIPCSettingWindow(this.preIP, this.preServerPort, this.preCLientPort); if (settingWindow.ShowDialog() == true) { this.cipcMain = new CIPCClientWindow.MainWindow("CIPC", settingWindow); this.cipcMain.Show(); this.CIPCButton.Content = "Close"; this.cipcMain.DataReceived += this.DataReceived; Console.WriteLine("eventhander"); } } //Close else { try { this.preIP = this.cipcMain.TextBlock_ServerIPAdress.Text; this.preCLientPort = int.Parse(this.cipcMain.TextBlock_ClientPort.Text); this.preServerPort = int.Parse(this.cipcMain.TextBlock_ServerPort.Text); this.cipcMain.Close(); this.cipcMain = null; this.CIPCButton.Content = "Connect"; } catch (Exception ex) { Console.Write(ex.Message); } } }