コード例 #1
0
        private void UpdateConnectionStatus(bool ready, VPN.Status status, string error)
        {
            if (ready)
            {
                txtConnectionStatus.Text = Resources.GetString(VPN.DescriptionResource(status));
            }
            else
            {
                txtConnectionStatus.Text = Resources.GetString(Resource.String.conn_status_initialize);
            }

            btnConnectProfile.Enabled = ready && (status == VPN.Status.NotConnected);

            btnDisconnectProfile.Enabled = (status == VPN.Status.Connecting) || (status == VPN.Status.Connected);

            if (currentConnectionStatus != status)
            {
                currentConnectionStatus = status;

                switch (status)
                {
                case VPN.Status.Connected:
                {
                    supportTools.InfoDialog(string.Format(Resources.GetString(Resource.String.connection_success), profileInfo["server"]));

                    settingsManager.SystemLastProfileIsConnected = true;
                }
                break;

                case VPN.Status.NotConnected:
                {
                    supportTools.InfoDialog(string.Format(Resources.GetString(Resource.String.connection_disconnected), profileInfo["server"]));

                    settingsManager.SystemLastProfileIsConnected = false;
                }
                break;

                default:
                {
                    settingsManager.SystemLastProfileIsConnected = false;
                }
                break;
                }
            }

            ShowErrorMessage(error);
        }
コード例 #2
0
        private void UpdateConnectionStatus(bool ready, VPN.Status status, string error)
        {
            if (ready)
            {
                txtVpnStatus.Text = Resources.GetString(VPN.DescriptionResource(status));
            }
            else
            {
                txtVpnStatus.Text = Resources.GetString(Resource.String.conn_status_initialize);
            }

            btnConnectProfile.Enabled = ready && (status == VPN.Status.NOT_CONNECTED) && NetworkStatusReceiver.IsNetworkConnected();

            btnDisconnectProfile.Enabled = (status == VPN.Status.CONNECTING) || (status == VPN.Status.CONNECTED) || (status == VPN.Status.PAUSED) || (status == VPN.Status.LOCKED);

            if (currentConnectionStatus != status)
            {
                currentConnectionStatus = status;

                switch (status)
                {
                case VPN.Status.CONNECTED:
                {
                    if (profileInfo.ContainsKey("server") == true)
                    {
                        supportTools.InfoDialog(string.Format(Resources.GetString(Resource.String.connection_success), profileInfo["server"], NetworkStatusReceiver.GetNetworkDescription()));
                    }

                    settingsManager.SystemLastProfileIsConnected = true;
                }
                break;

                case VPN.Status.NOT_CONNECTED:
                {
                    if (profileInfo.ContainsKey("server") == true)
                    {
                        supportTools.InfoDialog(string.Format(Resources.GetString(Resource.String.connection_disconnected), profileInfo["server"]));
                    }

                    settingsManager.SystemLastProfileIsConnected = false;
                }
                break;

                case VPN.Status.PAUSED:
                {
                    supportTools.InfoDialog(Resources.GetString(Resource.String.connection_paused));

                    settingsManager.SystemLastProfileIsConnected = true;
                }
                break;

                default:
                {
                    settingsManager.SystemLastProfileIsConnected = false;
                }
                break;
                }
            }

            ShowErrorMessage(error);
        }