/// <summary> /// Initializes content document and header. /// </summary> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> private void _InitContent(ILicensePageCommands licensePageCommands) { Debug.Assert(licensePageCommands != null); this.ViewHeader = App.Current.FindString(VIEW_HEADER_KEY); var warningString = App.Current.FindString(CONTENT_KEY); var content = (FlowDocument)XamlReaderHelpers.Load(warningString); var command = licensePageCommands.RecoverCredentials; var recoverCredentialsPart = (Section)content.FindName(RECOVER_CREDENTIALS_PART); if (command == null) { recoverCredentialsPart.Blocks.Clear(); } else { var recoverCredentialsLink = (Hyperlink)recoverCredentialsPart.FindName( RECOVER_CREDENTIALS_LINK_NAME); recoverCredentialsLink.Command = command; } this.ContentFirstParagraph = FlowDocumentHelpers.ExtractFirstBlock(content); this.ContentSecondParagraph = content; }
/// <summary> /// Initializes a new instance of the NoSubscriptionStateViewModel class. /// </summary> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> public NoSubscriptionStateViewModel( ILicensePageCommands licensePageCommands) { Debug.Assert(licensePageCommands != null); _InitContent(licensePageCommands); }
/// <summary> /// Initializes a new instance of the ActivatedStateViewModel class. /// </summary> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> public WrongCredentialsStateViewModel( ILicensePageCommands licensePageCommands) { Debug.Assert(licensePageCommands != null); _InitContent(licensePageCommands); }
/// <summary> /// Initializes content document and header. /// </summary> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> private void _InitContent(ILicensePageCommands licensePageCommands) { Debug.Assert(licensePageCommands != null); this.ViewHeader = App.Current.FindString(VIEW_HEADER_KEY); var warningString = App.Current.FindString(CONTENT_KEY); var content = (FlowDocument)XamlReaderHelpers.Load(warningString); var command = licensePageCommands.UpgradeLicense; var purchaseSubscriptionPart = (Section)content.FindName(PURCHASE_PART); if (command == null) { purchaseSubscriptionPart.Blocks.Clear(); } else { var purchaseSubscriptionLink = (Hyperlink)purchaseSubscriptionPart.FindName( PURCHASE_LINK_NAME); purchaseSubscriptionLink.Command = command; } this.ContentFirstParagraph = FlowDocumentHelpers.ExtractFirstBlock(content); this.ContentSecondParagraph = content; }
/// <summary> /// Initializes a new instance of the ConnectedStateViewModel class. /// </summary> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> /// <param name="licenseInfoText">The reference to the flow documents /// collection representing license information text.</param> public ConnectedStateViewModel( ILicensePageCommands licensePageCommands, IEnumerable <FlowDocument> licenseInfoText) { Debug.Assert(licensePageCommands != null); Debug.Assert(licenseInfoText != null); Debug.Assert(licenseInfoText.All(document => document != null)); this.LicenseInfoText = licenseInfoText.ToList(); this.UpdateLicenseCommand = licensePageCommands.UpgradeLicense; }
/// <summary> /// Initializes a new instance of the ConnectedStateViewModel class. /// </summary> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> /// <param name="licenseInfoText">The reference to the flow documents /// collection representing license information text.</param> public ConnectedStateViewModel( ILicensePageCommands licensePageCommands, IEnumerable<FlowDocument> licenseInfoText) { Debug.Assert(licensePageCommands != null); Debug.Assert(licenseInfoText != null); Debug.Assert(licenseInfoText.All(document => document != null)); this.LicenseInfoText = licenseInfoText.ToList(); this.UpdateLicenseCommand = licensePageCommands.UpgradeLicense; }
/// <summary> /// Initializes a new instance of the ActivatedStateViewModel class. /// </summary> /// <param name="licenseManager">The reference to the license manager /// object providing necessary license information.</param> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> /// <param name="showExpirationWarning">A value indicating if the license /// expiration warning should be displayed.</param> public ActivatedStateViewModel( ILicenseManager licenseManager, ILicensePageCommands licensePageCommands, bool showExpirationWarning) { Debug.Assert(licenseManager != null); Debug.Assert(licensePageCommands != null); this.UpgradeLicenseCommand = licensePageCommands.UpgradeLicense; this.ShowExpirationWarning = showExpirationWarning; var license = licenseManager.AppLicense; var currentDate = licenseManager.AppLicenseValidationDate; _InitContent(license, currentDate); }
/// <summary> /// Initializes a new instance of the ExpiredStateViewModel class. /// </summary> /// <param name="licenseManager">The reference to the license manager /// object providing necessary license information.</param> /// <param name="licensePageCommands">The reference to the common license /// page command container object.</param> public ExpiredStateViewModel( ILicenseManager licenseManager, ILicensePageCommands licensePageCommands, Action startSingleVehicleMode) { Debug.Assert(licenseManager != null); Debug.Assert(licensePageCommands != null); Debug.Assert(startSingleVehicleMode != null); this.UpgradeLicenseCommand = licensePageCommands.UpgradeLicense; this.SingleVehicleModeCommand = new DelegateCommand( _ => startSingleVehicleMode()); _InitContent(licenseManager.ExpiredLicense); }
/// <summary> /// Initializes a new instance of the LoginStateViewModel class. /// </summary> /// <param name="licensePageCommands">The reference to the /// license page commands object.</param> /// <param name="executeLogin">The action to be executed when login /// is requested.</param> public LoginStateViewModel( ILicensePageCommands licensePageCommands, LoginActionHandler executeLogin) { Debug.Assert(licensePageCommands != null); Debug.Assert(executeLogin != null); this.RememberCredentialCommand = new DelegateCommand( _ => _ExecuteRememberCredential(), _ => _CanLogin()); this.LoginCommand = new DelegateCommand( _ => executeLogin(this.Username, this.Password, _rememberCredential), _ => _CanLogin()); this.CreateAccountCommand = licensePageCommands.CreateAccount; this.RecoverCredentialsCommand = licensePageCommands.RecoverCredentials; }
/// <summary> /// Initializes a new instance of the LicensingViewModel class. /// </summary> /// <param name="messenger">The messenger object to be used for /// notifications.</param> /// <param name="workingStatusController">The object to be used for /// managing application working status.</param> /// <param name="uriNavigator">The reference to the object to be used /// for navigating to URI's.</param> /// <param name="licenseManager">The reference to the license manager /// object.</param> public LicensingViewModel( IMessenger messenger, IWorkingStatusController workingStatusController, IUriNavigator uriNavigator, ILicenseManager licenseManager) { Debug.Assert(messenger != null); Debug.Assert(workingStatusController != null); Debug.Assert(uriNavigator != null); Debug.Assert(licenseManager != null); _licenseManager = licenseManager; _licenseExpirationChecker = licenseManager.LicenseExpirationChecker; _messenger = messenger; _workingStatusController = workingStatusController; _uriNavigator = uriNavigator; _licensePageCommands = new LicensePageCommands() { CreateAccount = _CreateUrlNavigationCommand( _licenseManager.LicenseComponent.CreateAccountURL, _uriNavigator), RecoverCredentials = _CreateUrlNavigationCommand( _licenseManager.LicenseComponent.RecoverCredentialsURL, _uriNavigator), UpgradeLicense = _CreateUrlNavigationCommand( _licenseManager.LicenseComponent.UpgradeLicenseURL, _uriNavigator), }; this.LicenseActivationStatus = _licenseManager.LicenseActivationStatus; this.LicenseState = this.LicenseActivationStatus == LicenseActivationStatus.Activated ? AgsServerState.Authorized : AgsServerState.Unauthorized; _UpdateExpirationWarningDisplayState(); foreach (var item in EnumHelpers.GetValues<AgsServerState>()) { this.RegisterHeader( item, _licenseManager.LicenseComponent.LoginPrompt); } _CreateLoginState(); _CreateConnectedState(); _CreateNotConnectedState(); this.LicensingNotes = _CreateLicensingNotes( _licenseManager.LicenseComponent.LicensingNotes); this.TroubleshootingNotes = _CreateTroubleshootingNotes( _licenseManager.LicenseComponent.TroubleshootingNotes); _stateFactories = new Dictionary<LicenseActivationStatus, Func<LicenseActivationViewState>>() { { LicenseActivationStatus.None, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = (object)null, } }, { LicenseActivationStatus.Activated, () => new LicenseActivationViewState { LoginViewState = this.ConnectedState, InformationViewState = _CreateActivatedState(), } }, { LicenseActivationStatus.Expired, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = _CreateExpiredState(), } }, { LicenseActivationStatus.WrongCredentials, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = _CreateWrongCredentialsState(), } }, { LicenseActivationStatus.NoSubscription, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = _CreateNoSubscriptionState(), } }, { LicenseActivationStatus.Failed, () => new LicenseActivationViewState { LoginViewState = this.NotConnectedState, InformationViewState = (object)null, } }, }; }