Наследование: MediaPortal.GUI.Library.GUIWindow
        private void TestAccount(TraktAccount account)
        {
            TraktResponse response = null;

            if (NewAccount)
            {
                if (lblTestConnect != null)
                {
                    GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.CreatingAccount);
                }

                GUIWindowManager.Process();
                response = TraktAPI.TraktAPI.CreateAccount(account);
            }
            else
            {
                if (lblTestConnect != null)
                {
                    GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.SigningIntoAccount);
                }

                GUIWindowManager.Process();
                response = TraktAPI.TraktAPI.TestAccount(account);
            }

            if (response.Status == "failure")
            {
                string errorMessage = string.IsNullOrEmpty(response.Error) ? response.Message : response.Error;
                GUIUtils.ShowNotifyDialog(Translation.Error, errorMessage);
                if (lblTestConnect != null)
                {
                    GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, string.Empty);
                }
            }
            else
            {
                // Save New Account Settings
                TraktSettings.Username = account.Username;
                TraktSettings.Password = account.Password;
                if (!TraktSettings.UserLogins.Exists(u => u.Username == TraktSettings.Username))
                {
                    TraktSettings.UserLogins.Add(new TraktAuthentication {
                        Username = TraktSettings.Username, Password = TraktSettings.Password
                    });
                }
                TraktSettings.AccountStatus = ConnectionState.Connected;
                HideAccountControls();
                InitProperties();

                // clear caches
                // watch lists are stored by user so dont need clearing.
                GUITraktFriends.ClearCache();
                GUICalendar.ClearCache();
                GUIRecommendationsMovies.ClearCache();
                GUIRecommendationsShows.ClearCache();
            }
        }
        private void DisconnectAccount()
        {
            TraktLogger.Info("Disconnecting Account: {0}", TraktSettings.Username);

            // clear account settings
            TraktSettings.Username      = string.Empty;
            TraktSettings.Password      = string.Empty;
            TraktSettings.AccountStatus = ConnectionState.Disconnected;

            InitProperties();

            // clear caches
            // watchlists are stored by user so dont need clearing.
            GUINetwork.ClearCache();
            GUICalendar.ClearCache();
            GUIRecommendationsMovies.ClearCache();
            GUIRecommendationsShows.ClearCache();

            // clear any stored user data
            TraktCache.ClearSyncCache();
        }
        private void TestAccount(TraktAuthentication account)
        {
            TraktUserToken response = null;

            if (NewAccount)
            {
                // No longer supported with v2 API.
                //if (lblTestConnect != null)
                //    GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.CreatingAccount);

                //GUIWindowManager.Process();
                //response = TraktAPI.v1.TraktAPI.CreateAccount(account);
            }
            else
            {
                if (lblTestConnect != null)
                {
                    GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.SigningIntoAccount);
                }

                GUIWindowManager.Process();
                response = TraktAPI.TraktAPI.Login(account.ToJSON());
            }

            if (response == null || string.IsNullOrEmpty(response.Token))
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.FailedLogin);
                if (lblTestConnect != null)
                {
                    GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, string.Empty);
                }
            }
            else
            {
                // Save User Token
                TraktAPI.TraktAPI.UserToken = response.Token;

                // Save New Account Settings
                TraktSettings.Username = account.Username;
                TraktSettings.Password = account.Password;
                if (!TraktSettings.UserLogins.Exists(u => u.Username == TraktSettings.Username))
                {
                    TraktSettings.UserLogins.Add(new TraktAuthentication {
                        Username = TraktSettings.Username, Password = TraktSettings.Password
                    });
                }
                TraktSettings.AccountStatus = ConnectionState.Connected;
                HideAccountControls();
                InitProperties();

                // clear caches
                // watchlists are stored by user so dont need clearing.
                GUINetwork.ClearCache();
                GUICalendar.ClearCache();
                GUIRecommendationsMovies.ClearCache();
                GUIRecommendationsShows.ClearCache();

                // clear any stored user data
                TraktCache.ClearSyncCache();
            }
        }