/// <summary> /// display buttons and text as needed /// </summary> /// <param name="ss">new State</param> private void setState(StateSnapshot ss) { bool showConnect = true;// If false then show Disconnect bool showConnectEnable = true; String ip = null; switch (ss.ConnectionState) { case VPNConnectionState.Initializing: pbStatus.Image = Properties.Resources.STATE_Initializing; showConnect = false; break; case VPNConnectionState.Running: pbStatus.Image = Properties.Resources.STATE_Running; showConnect = false; ip = m_config.VPNConnection.IP; break; case VPNConnectionState.Stopped: pbStatus.Image = Properties.Resources.STATE_Stopped; break; case VPNConnectionState.Stopping: showConnectEnable = false; pbStatus.Image = Properties.Resources.STATE_Stopping; break; case VPNConnectionState.Error: default: pbStatus.Image = Properties.Resources.STATE_Error; break; } if (showConnect) { btnConnect.Image = Properties.Resources.BUTTON_Connect; toolTip.SetToolTip(btnConnect, Program.res.GetString("QUICKINFO_Connect")); } else { toolTip.SetToolTip(btnConnect, Program.res.GetString("QUICKINFO_Disconnect")); btnConnect.Image = Properties.Resources.BUTTON_Disconnect; } btnConnect.Enabled = showConnectEnable; llIP.SetIP(ip); }
private void raiseEvents(StateSnapshot ea) { if (StateChanged != null && !m_connection.NoEvents) StateChanged(this, new StateChangedEventArgs(ea)); }
/// <summary> /// Generates the new object. /// </summary> /// <param name="newState">The snapshot to return</param> internal StateChangedEventArgs(StateSnapshot newState) { m_state = newState; }
private void setState(StateSnapshot ss) { string text = ss.VPNState[1]; text = Program.res.GetString("VPNSTATE_" + text); if (text != null) { if (text.StartsWith("VPNSTATE_", StringComparison.OrdinalIgnoreCase)) { text = ss.VPNState[1]; } lblVPNState.Text = text; } else { lblVPNState.Text = ""; } llIP.SetIP(m_config.VPNConnection.IP); lblVPNState.Left = llIP.Left - lblVPNState.Width - 16; llIP.SetIP(m_config.VPNConnection.IP); if(ss.ConnectionState != lastConnectionState) { lastConnectionState = ss.ConnectionState; switch (ss.ConnectionState) { case VPNConnectionState.Initializing: lstLog.Items.Clear(); lblState.Text = Program.res.GetString("STATE_Initializing"); pbStatus.Image = Properties.Resources.STATE_Initializing; toolTip.SetToolTip(btnConnect, Program.res.GetString("QUICKINFO_Disconnect")); btnConnect.Image = Properties.Resources.BUTTON_Disconnect; btnConnect.Enabled = true; break; case VPNConnectionState.Running: lblState.Text = Program.res.GetString("STATE_Connected"); pbStatus.Image = Properties.Resources.STATE_Running; toolTip.SetToolTip(btnConnect, Program.res.GetString("QUICKINFO_Disconnect")); btnConnect.Image = Properties.Resources.BUTTON_Disconnect; btnConnect.Enabled = true; break; case VPNConnectionState.Stopped: lblState.Text = Program.res.GetString("STATE_Stopped"); pbStatus.Image = Properties.Resources.STATE_Stopped; toolTip.SetToolTip(btnConnect, Program.res.GetString("QUICKINFO_Connect")); btnConnect.Image = Properties.Resources.BUTTON_Connect; btnConnect.Enabled = true; lblVPNState.Text = ""; break; case VPNConnectionState.Stopping: lblState.Text = Program.res.GetString("STATE_Stopping"); pbStatus.Image = Properties.Resources.STATE_Stopping; toolTip.SetToolTip(btnConnect, Program.res.GetString("QUICKINFO_Connect")); btnConnect.Image = Properties.Resources.BUTTON_Connect; btnConnect.Enabled = false; break; case VPNConnectionState.Error: default: lblState.Text = Program.res.GetString("STATE_Error"); pbStatus.Image = Properties.Resources.STATE_Error; toolTip.SetToolTip(btnConnect, Program.res.GetString("QUICKINFO_Connect")); btnConnect.Image = Properties.Resources.BUTTON_Connect; btnConnect.Enabled = true; lblVPNState.Text = ""; break; } } }