private void StopMirroring() { Thread.CurrentThread.Priority = ThreadPriority.Normal; btnStop.Enabled = false; mnuNfyStopMirroring.Enabled = false; if (_mirror != null) { _mirror.StopMirroring(); try { _mirror.Dispose(); _mirror = null; } catch { } } gbNetworkingOptions.Enabled = true; gbGeneralOptions.Enabled = true; gbPerformanceOptions.Enabled = true; btnStart.Enabled = true; mnuNfyStartMirroring.Enabled = true; }
private void StartMirroring() { Thread.CurrentThread.Priority = Settings.Default.Priority; IPAddress address = null; if (rdoClientMode.Checked) { var validIpAddress = false; validIpAddress = IPAddress.TryParse(txtServerIPAddress.Text, out address); if (String.IsNullOrEmpty(txtServerIPAddress.Text.Trim()) || !validIpAddress) { MessageBox.Show("Please enter a valid IP address for the " + Application.ProductName + " server.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); RestoreFromSystemTray(); txtServerIPAddress.Focus(); return; } if (String.IsNullOrEmpty(txtServerPortNum.Text.Trim())) { MessageBox.Show("Please enter the port number of the " + Application.ProductName + " server.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); RestoreFromSystemTray(); txtServerPortNum.Focus(); return; } } if (rdoServerMode.Checked) { if (String.IsNullOrEmpty(txtServerPortNum.Text.Trim())) { MessageBox.Show( "Please enter the port number to publish the " + Application.ProductName + " service on.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); RestoreFromSystemTray(); txtServerPortNum.Focus(); return; } } var portNum = 21142; Int32.TryParse(Settings.Default.ServerPortNum, out portNum); btnStart.Enabled = false; mnuNfyStartMirroring.Enabled = false; if (_mirror != null) { _mirror.StopMirroring(); } btnStart.Enabled = false; mnuNfyStartMirroring.Enabled = false; _mirror = new Mirror(); if (rdoClientMode.Checked) { _mirror.NetworkingMode = NetworkingMode.Client; _mirror.ClientIPAddress = address; } else if (rdoServerMode.Checked) { _mirror.NetworkingMode = NetworkingMode.Server; } _mirror.PortNumber = (ushort)portNum; gbPerformanceOptions.Enabled = false; gbNetworkingOptions.Enabled = false; gbGeneralOptions.Enabled = false; if (chkRunMinimized.Checked) { if (chkMinimizeToSystemTray.Checked) { MinimizeToSystemTray(); } else { WindowState = FormWindowState.Minimized; } } btnStop.Enabled = true; mnuNfyStopMirroring.Enabled = true; _mirror.StartMirroring(); }