/// <summary> /// Initializes content document and header. /// </summary> /// <param name="license">The reference to the license object.</param> /// <param name="currentDate">The current date/time value.</param> private void _InitContent(License license, DateTime?currentDate) { if (license == null || license.ExpirationDate == null || currentDate == null) { return; } var expirationDate = license.ExpirationDate.Value; var daysLeft = (int)(expirationDate.Date - currentDate.Value.Date).TotalDays; daysLeft = Math.Max(daysLeft, 0); this.ViewHeader = App.Current.GetString(VIEW_HEADER_KEY, daysLeft); var warningString = App.Current.FindString(CONTENT_KEY); var content = (FlowDocument)XamlReaderHelpers.Load(warningString); var daysLeftPart = (Run)content.FindName(DAYS_LEFT_NOTES_PART); daysLeftPart.Text = string.Format( daysLeftPart.Text, daysLeft); var vehicleCountPart = (Run)content.FindName(VEHICLE_COUNT_NOTES_PART); vehicleCountPart.Text = string.Format( vehicleCountPart.Text, license.PermittedRouteNumber); this.ContentFirstParagraph = FlowDocumentHelpers.ExtractFirstBlock(content); this.ContentSecondParagraph = content; }
/// <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 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 content document and header. /// </summary> /// <param name="license">The reference to the license object.</param> private void _InitContent(License license) { this.ViewHeader = App.Current.FindString(VIEW_HEADER_KEY); var warningString = App.Current.FindString(CONTENT_KEY); var content = (FlowDocument)XamlReaderHelpers.Load(warningString); var vehicleCountPart = (Run)content.FindName(VEHICLE_COUNT_NOTES_PART); if (license == null) { vehicleCountPart.Text = string.Empty; } else { vehicleCountPart.Text = string.Format( vehicleCountPart.Text, license.PermittedRouteNumber); } this.Content = content; }