private void OnDisconnect() { if (this.InvokeRequired) { this.Invoke(new Action(() => { OnDisconnect(); })); return; } ConnectButton.Text = "Connect"; ConnectButton.Enabled = true; IpcDisconnectedPanel.Hide(); DisconnectedPanel.Show(); ConnectedPanel.Hide(); }
private void OnConnect() { if (this.InvokeRequired) { this.Invoke(new Action(() => { OnConnect(); })); return; } IpcDisconnectedPanel.Hide(); ConnectedPanel.Show(); DisconnectedPanel.Hide(); }
private void ClientForm_Load(object sender, EventArgs e) { this.MaximizeBox = false; SetIpcStatusLabelText("Checking if service is\nrunning..."); if (!IsProcessRunning()) { MessageBox.Show("Error: Inputshareservice is not running. exiting"); Exit(); return; } SetIpcStatusLabelText("Connecting to IPC..."); DisconnectedPanel.Hide(); IpcDisconnectedPanel.Show(); IpcDisconnectedPanel.BringToFront(); ConnectedPanel.Visible = false; Task.Run(new Action(() => { IpcConnect(); })); ClientNameTextBox.Text = Environment.MachineName; }
private void IpcConnect() { try { SetIpcStatusLabelText("Connecting to IPC..."); ipcClient = new NamedIpcClient(); ipcClient.ServiceStateReceived += IpcClient_ServiceStateReceived; ipcClient.MessageReceived += IpcClient_MessageReceived; ipcClient.Connected += IpcClient_Connected; ipcClient.Disconnected += IpcClient_Disconnected; ipcClient.Connect(3000); this.Invoke(new Action(() => { IpcDisconnectedPanel.Hide(); })); ipcClient.SendObject(NIpcBasicMessage.GetState); }catch (Exception ex) { SetIpcStatusLabelText("Failed to connect to IPC"); MessageBox.Show("Could not communicate with service: " + ex.Message, "Service error. Make sure that the inputshareservice is running!", MessageBoxButtons.OK); ipcClient.Dispose(); Exit(); return; } }
private void IpcClient_Connected(object s, EventArgs e) { IpcDisconnectedPanel.Hide(); }