Ejemplo n.º 1
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + Messages.WindowsConnectionTitle;

            m_connectionActive = Connection.BuildConnectionActive(true);

            TxtOvpnGenerated.Value = Core.Platform.Instance.NormalizeString(m_connectionActive.OpenVpnProfileStartup.Get());
            if (Connection.Path != "")
            {
                if (Core.Platform.Instance.FileExists(Connection.Path))
                {
                    string original = Core.Platform.Instance.FileContentsReadText(Connection.Path);
                    TxtOvpnOriginal.Value = original;
                }
            }
            else
            {
                TabMain.Remove(TabMain.Items[1]);
            }

            CmdOk.Activated += (object sender, EventArgs e) =>
            {
                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };
        }
Ejemplo n.º 2
0
        public void EnabledUI()
        {
            ConnectionInfo selectedConnection = null;

            if (TableServers.SelectedRowCount == 1)
            {
                selectedConnection = TableServersController.GetRelatedItem((int)TableServers.SelectedRow);
            }

            bool connected = Engine.IsConnected();
            bool waiting   = Engine.IsWaiting();

            if (Engine.Instance.AirVPN != null)
            {
                LblLoginIcon.Hidden = false;
                LblLogin.Hidden     = false;
                TxtLogin.Hidden     = false;
                LblPassword.Hidden  = false;
                TxtPassword.Hidden  = false;
                CmdLogin.Hidden     = false;
                ChkRemember.Hidden  = false;

                bool airvpnLogged = Engine.IsLogged();

                if (airvpnLogged == false)
                {
                    CmdLogin.Title = LanguageManager.GetText("CommandLoginButton");
                }
                else
                {
                    CmdLogin.Title = LanguageManager.GetText("CommandLogout");
                }

                CmdLogin.Enabled = ((waiting == false) && (connected == false) && (TxtLogin.StringValue.Trim() != "") && (TxtPassword.StringValue.Trim() != ""));

                TxtLogin.Enabled    = (airvpnLogged == false);
                TxtPassword.Enabled = (airvpnLogged == false);
                LblKey.Hidden       = ((airvpnLogged == false) || (CboKey.ItemCount < 2));
                CboKey.Hidden       = LblKey.Hidden;
            }
            else
            {
                LblLoginIcon.Hidden = true;
                LblLogin.Hidden     = true;
                TxtLogin.Hidden     = true;
                LblPassword.Hidden  = true;
                TxtPassword.Hidden  = true;
                CmdLogin.Hidden     = true;
                LblKey.Hidden       = true;
                CboKey.Hidden       = true;
                ChkRemember.Hidden  = true;
            }

            ChangeVisibility(this.Window.IsVisible);

            CmdConnect.Enabled = Engine.Instance.CanConnect();

            CmdProviderAdd.Enabled    = true;
            CmdProviderRemove.Enabled = (TableProviders.SelectedRowCount > 0);
            CmdProviderEdit.Enabled   = (TableProviders.SelectedRowCount > 0);

            CmdServersConnect.Enabled   = ((selectedConnection != null) && (selectedConnection.CanConnect()));
            CmdServersWhiteList.Enabled = (TableServers.SelectedRowCount > 0);
            CmdServersBlackList.Enabled = CmdServersWhiteList.Enabled;
            CmdServersUndefined.Enabled = CmdServersWhiteList.Enabled;
            MnuServersConnect.Enabled   = CmdServersConnect.Enabled;
            MnuServersWhitelist.Enabled = CmdServersWhiteList.Enabled;
            MnuServersBlacklist.Enabled = CmdServersBlackList.Enabled;
            MnuServersUndefined.Enabled = CmdServersUndefined.Enabled;

            CmdServersMore.Enabled = (TableServers.SelectedRowCount == 1);
            MnuServersMore.Enabled = CmdServersMore.Enabled;

            CmdServersRename.Enabled = ((selectedConnection != null) && (selectedConnection.Provider is Core.Providers.OpenVPN));
            MnuServersRename.Enabled = CmdServersRename.Enabled;

            CmdAreasWhiteList.Enabled = (TableAreas.SelectedRowCount > 0);
            CmdAreasBlackList.Enabled = CmdAreasWhiteList.Enabled;
            CmdAreasUndefined.Enabled = CmdAreasWhiteList.Enabled;
            MnuAreasWhitelist.Enabled = CmdAreasWhiteList.Enabled;
            MnuAreasBlacklist.Enabled = CmdAreasBlackList.Enabled;
            MnuAreasUndefined.Enabled = CmdAreasUndefined.Enabled;

            CmdLogsCommand.Hidden = (Engine.Storage.GetBool("advanced.expert") == false);

            if (Engine.Instance.NetworkLockManager != null)
            {
                CmdNetworkLock.Hidden = (Engine.Instance.NetworkLockManager.CanEnabled() == false);
                ImgNetworkLock.Hidden = CmdNetworkLock.Hidden;
                if (Engine.Instance.NetworkLockManager.IsActive())
                {
                    CmdNetworkLock.Title = LanguageManager.GetText("NetworkLockButtonActive");
                    ImgNetworkLock.Image = NSImage.ImageNamed("netlock_on.png");

                    LblNetLockStatus.Image   = NSImage.ImageNamed("netlock_status_on.png");
                    LblNetLockStatus.ToolTip = LanguageManager.GetText("NetworkLockStatusActive");
                }
                else
                {
                    CmdNetworkLock.Title = LanguageManager.GetText("NetworkLockButtonDeactive");
                    ImgNetworkLock.Image = NSImage.ImageNamed("netlock_off.png");

                    LblNetLockStatus.Image   = NSImage.ImageNamed("netlock_status_off.png");
                    LblNetLockStatus.ToolTip = LanguageManager.GetText("NetworkLockStatusDeactive");
                }
            }

            if (Engine.Instance.Storage.GetBool("advanced.providers"))
            {
                if (TabMain.Items[1] != TabProviders)
                {
                    TabMain.Insert(TabProviders, 1);
                }
            }
            else
            {
                if (TabMain.Items[1] == TabProviders)
                {
                    TabMain.Remove(TabProviders);
                }
            }
        }