public MainWindow(string title, CIPCClientWindow.CIPCSettingWindow settingwindow) { try { InitializeComponent(); this.TextBlock_TitleName.Text = title; this.TextBlock_ClientName.Text = settingwindow.ClientName; this.TextBlock_ClientPort.Text = settingwindow.ClientPort.ToString(); this.TextBlock_ServerIPAdress.Text = settingwindow.ServerIPAdress; this.TextBlock_ServerPort.Text = settingwindow.ServerPort.ToString(); this.TextBlock_Mode.Text = settingwindow.Mode.ToString(); this.TextBlock_FPS.Text = settingwindow.FPS.ToString(); this.MouseLeftButtonDown += (s, e) => this.DragMove(); this.TitleName = "CIPCClient"; this.client = new CIPC_CS.CLIENT.CLIENT(settingwindow.ClientPort, settingwindow.ServerIPAdress, settingwindow.ServerPort, settingwindow.ClientName, settingwindow.FPS); this.client.Setup(settingwindow.Mode); this.client.DataReceived += client_DataReceived; this.Closing += MainWindow_Closing; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
//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); } } }