Ejemplo n.º 1
0
        /// <summary>
        /// Occurs when content changes in the email address textbox.
        /// </summary>
        /// <param name="sender">The object that raised the event (TextBox).</param>
        /// <param name="e">The event data (RoutedEventArgs).</param>
        private void WatermarkTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            // Get the email address textbox
            _textBox = (WatermarkTextBox)sender;

            // If text has been entered
            if (!string.IsNullOrWhiteSpace(_textBox.Text))
            {
                // Get matching email addresses
                IEnumerable <EmailAddress> foundEmailAddresses = ComposeMailPage.Current.StoredEmailAddresses.Where(o => ((!string.IsNullOrEmpty(o.DisplayName) &&
                                                                                                                           o.DisplayName.ToLower().Contains(_textBox.Text.ToLower()))) ||
                                                                                                                    o.Address.ToLower().Contains(_textBox.Text.ToLower()));

                // If any matches are found
                if (foundEmailAddresses.Count() > 0)
                {
                    // Position the popup and display it
                    pSuggestions.VerticalOffset = icEmailAddress.ActualHeight + 1;
                    pSuggestions.IsOpen         = true;
                    lvEmailAddress.ItemsSource  = foundEmailAddresses;
                    lvEmailAddress.Visibility   = Visibility.Visible;
                    _textBox.Focus(FocusState.Programmatic);
                }
                // Else if there are not matches
                else
                {
                    // Close the popup
                    CloseSuggestions();
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Occurs when this control gets focus.
 /// </summary>
 /// <param name="sender">The object that raised the event (TextBox).</param>
 /// <param name="e">The event data (RoutedEventArgs).</param>
 private void UserControl_GotFocus(object sender, RoutedEventArgs e)
 {
     if (this.FocusState == FocusState.Programmatic)
     {
         if (_textBox != null)
         {
             _textBox.Focus(FocusState.Programmatic);
         }
     }
 }
        /// <summary>
        /// If valid, add the user-provided Watermark and logo image details to local
        /// storage to be read by the background task
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">Event arguments</param>
        private async void SetWatermarkButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValidWatermark(Watermark))
            {
                // Save required values to local storage
                localStorage.SaveWatermarkTextToLocalStorage(Watermark);

                // If the check box for a logo image has been selected then add that too
                await AddLogoImageIfRequiredAsync();

                // Let the OnXpsDataAvailable finish by signalling that all the required parameters are now available
                SignalThatAllRequiredInformationIsAvailable();
            }
            else
            {
                // If bad number switch focus to the text box
                WatermarkTextBox.Focus(FocusState.Programmatic);
                // Highlight the text
                WatermarkTextBox.SelectAll();
            }
        }