public static Decimal GetTwitterAccountID(TextBoxBase textBoxBase)
 {
     if (textBoxBase == null)
     throw new ArgumentNullException("textBoxBase");
       else
     return (Decimal) textBoxBase.GetValue(URLShortening.TwitterAccountIDProperty);
 }
 public static bool GetIsEnabled(TextBoxBase textBoxBase)
 {
     if (textBoxBase == null)
     throw new ArgumentNullException("textBoxBase");
       else
     return (bool) textBoxBase.GetValue(URLShortening.IsEnabledProperty);
 }
 public static void SetIsEnabled(TextBoxBase textBoxBase, bool value)
 {
     if (textBoxBase == null)
     {
     throw new ArgumentNullException("textBoxBase");
     }
     textBoxBase.SetValue(IsEnabledProperty, value);
 }
Beispiel #4
0
 private static void AttachEventHandlers(TextBoxBase textBox, UndoManager manager)
 {
     if (textBox != null && manager != null)
     {
         textBox.AddHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(manager.ExecutedHandler), true); // we need to see all events to subvert the built-in undo/redo tracking in the text boxes
         textBox.TextChanged += new TextChangedEventHandler(manager.TextChangedHandler);
     }
 }
 /// <summary>
 /// Detaches the TextBox selection behavior.
 /// </summary>
 public static void Detach(TextBoxBase textBox)
 {
     if (textBox != null)
     {
         textBox.PreviewMouseDown -= TextBoxPreviewMouseDown;
         textBox.LostMouseCapture -= TextBoxLostMouseCapture;
         textBox.GotKeyboardFocus -= TextBoxGotKeyboardFocus;
     }
 }
Beispiel #6
0
        /// <summary>
        /// Gets if spell checking is enabled within a TextBoxBase.
        /// </summary>
        public static bool GetIsEnabled(TextBoxBase textBoxBase)
        {
            if (textBoxBase == null)
            {
                throw new ArgumentNullException("textBoxBase");
            }

            return (bool)textBoxBase.GetValue(IsEnabledProperty);
        }
 private MenuItem GetMenu(string header, ICommand command, TextBoxBase target, bool Bold = false)
 {
     MenuItem item = new MenuItem();
     item.Header = header;
     item.FontWeight = Bold ? FontWeights.Bold : FontWeights.Normal;
     item.Command = command;
     item.CommandParameter = header;
     item.CommandTarget = target;
     return item;
 }
 private void Window_PreviewKeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         IInputElement inputElement = Keyboard.FocusedElement;
         if (inputElement != null)
         {
             System.Windows.Controls.Primitives.TextBoxBase textBoxBase = inputElement as System.Windows.Controls.Primitives.TextBoxBase;
             if (textBoxBase != null)
             {
                 if (!textBoxBase.AcceptsReturn)
                 {
                     MoveFocus_Next(textBoxBase);
                 }
                 return;
             }
             if (
                 MoveFocus_Next(inputElement as ComboBox)
                 ||
                 MoveFocus_Next(inputElement as Button)
                 ||
                 MoveFocus_Next(inputElement as DatePicker)
                 ||
                 MoveFocus_Next(inputElement as CheckBox)
                 ||
                 MoveFocus_Next(inputElement as DataGrid)
                 ||
                 MoveFocus_Next(inputElement as TabItem)
                 ||
                 MoveFocus_Next(inputElement as RadioButton)
                 ||
                 MoveFocus_Next(inputElement as ListBox)
                 ||
                 MoveFocus_Next(inputElement as ListView)
                 ||
                 MoveFocus_Next(inputElement as PasswordBox)
                 ||
                 MoveFocus_Next(inputElement as Window)
                 ||
                 MoveFocus_Next(inputElement as Page)
                 ||
                 MoveFocus_Next(inputElement as Frame)
                 )
             {
                 return;
             }
         }
     }
 }
Beispiel #9
0
        public static VerticalAlignment GetScrollVerticalAlignment(System.Windows.Controls.Primitives.TextBoxBase control)
        {
            // Vertical scroll position.
            var offset = control.VerticalOffset;
            // Vertical size of the scrollable content area.
            var height = control.ViewportHeight;
            // Vertical size of the visible content area.
            var visibleView = control.ExtentHeight;
            // Allow flexibility of 2 pixels.
            var flex = 2;

            if (offset + height - visibleView < flex)
            {
                return(VerticalAlignment.Bottom);
            }
            if (offset < flex)
            {
                return(VerticalAlignment.Top);
            }
            return(VerticalAlignment.Center);
        }
 public static void SetScrollToBottomOnTextChanged(TextBoxBase target, object value)
 {
     target.SetValue(ScrollToBottomOnTextChangedProperty, value);
 }
 public static object GetScrollToBottomOnTextChanged(TextBoxBase target)
 {
     return target.GetValue(ScrollToBottomOnTextChangedProperty);
 }
 public static void SetTwitterAccountID(TextBoxBase textBoxBase, Decimal value)
 {
     if (textBoxBase == null)
     throw new ArgumentNullException("textBoxBase");
       textBoxBase.SetValue(IntellisenseExtension.TwitterAccountIDProperty, (object) value);
 }
Beispiel #13
0
        /// <summary>
        /// Applies the text box view margin.
        /// </summary>
        /// <param name="textBox">The text box.</param>
        /// <param name="margin">The margin.</param>
        private static void ApplyTextBoxViewMargin(TextBoxBase textBox, Thickness margin)
        {
            if (margin.Equals(new Thickness(double.NegativeInfinity)))
            {
                return;
            }

            var scrollViewer = textBox.Template.FindName("PART_ContentHost", textBox) as ScrollViewer;
            if (scrollViewer == null)
            {
                return;
            }

            var frameworkElement = scrollViewer.Content as FrameworkElement;

            // remove nice new sytax until i get appveyor working	
            // var frameworkElement = (textBox.Template.FindName("PART_ContentHost", textBox) as ScrollViewer)?.Content as FrameworkElement;
            if (frameworkElement != null)
            {
                frameworkElement.Margin = margin;
            }
        }
 public static void SetSelectAllOnKeyboardFocus(TextBoxBase element, bool Value)
 {
     element.SetValue(SelectAllOnKeyboardFocusProperty, Value);
 }
 public static bool GetSelectAllOnKeyboardFocus(TextBoxBase element)
 {
     return (bool)element.GetValue(SelectAllOnKeyboardFocusProperty);
 }
Beispiel #16
0
 /// <summary>
 /// Gets the collection of custom dictionaries used for spell checking of custom words.
 /// </summary>
 /// <param name="textBoxBase"></param>
 /// <returns></returns>
 public static IList GetCustomDictionaries(TextBoxBase textBoxBase)
 {
     if (textBoxBase == null)
     {
         throw new ArgumentNullException("textBoxBase");
     }
     return (IList)textBoxBase.GetValue(CustomDictionariesProperty);
 }
 static bool GetIsVisible(TextBoxBase element)
 {
     return (bool)element.GetValue(IsVisibleProperty);
 }
Beispiel #18
0
 public UndoOperation(TextBoxBase sender, UndoAction action)
 {
     this.Sender = sender;
     this.Action = action;
 }
Beispiel #19
0
 private void PushUndoOperation(TextBoxBase sender, UndoAction action)
 {
     undoStack.Push(new UndoOperation(sender, action));
     System.Diagnostics.Debug.WriteLine("PUSHED");
 }
Beispiel #20
0
 private void AddUndoableAction(TextBoxBase sender, UndoAction action)
 {
     if (action == UndoAction.Undo)
     {
         redoStack.Push(new UndoOperation(sender, action));
     }
     else
     {
         if (undoStack.Count > 0)
         {
             UndoOperation op = undoStack.Peek();
             if ((op.Sender == sender) && (action == UndoAction.Merge))
             {
                 // no-op
             }
             else
             {
                 PushUndoOperation(sender, action);
             }
         }
         else
         {
             PushUndoOperation(sender, action);
         }
     }
 }
Beispiel #21
0
 private static void RemoveEventHandlers(TextBoxBase textBox, UndoManager manager)
 {
     if (textBox != null && manager != null)
     {
         textBox.RemoveHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(manager.ExecutedHandler));
         textBox.TextChanged -= new TextChangedEventHandler(manager.TextChangedHandler);
     }
 }
 public TextBoxHistoryPoint(TextBoxBase textbox, object value, DependencyProperty property, UpdateReason updateReason)
     : base(textbox, value, property, updateReason)
 {
 }
Beispiel #23
0
        /// <summary>
        /// Sets the spelling reform mode for a TextBoxBase.
        /// </summary>
        public static void SetSpellingReform(TextBoxBase textBoxBase, SpellingReform value)
        {
            if (textBoxBase == null)
            {
                throw new ArgumentNullException("textBoxBase");
            }

            textBoxBase.SetValue(SpellingReformProperty, value);
        }
 public static string GetText(TextBoxBase element)
 {
     return (string)element.GetValue(TextProperty);
 }
Beispiel #25
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        // Ctor.
        internal SpellCheck(TextBoxBase owner)
        {
            _owner = owner;
        }
Beispiel #26
0
 public static void SetAutoSelectAll(TextBoxBase tb, bool value)
 {
     tb.SetValue(AutoSelectAllProperty, value);
 }
 static void SetIsVisible(TextBoxBase element, bool value)
 {
     element.SetValue(IsVisibleProperty, value);
 }
		public static void SetCueBanner( TextBoxBase control, Object value )
		{
			control.SetValue( CueBannerProperty, value );
		}
 public static void SetText(TextBoxBase element, string value)
 {
     element.SetValue(TextProperty, value);
 }
		static Boolean ShouldShowCueBanner( TextBoxBase c )
		{
			var value = c.GetValue( TextBox.TextProperty ) as String;
			var isVisible = Convert.ToBoolean( c.GetValue( TextBox.IsVisibleProperty ) );

			return isVisible && String.IsNullOrEmpty( value );
		}
        static void UpdateWatermarkVisibility(TextBoxBase tb)
        {
            // Never show when focused
            if (tb.IsFocused || tb.IsKeyboardFocusWithin)
            {
                SetIsVisible(tb, false);
                return;
            }

            var textBox = tb as TextBox;
            if (textBox != null)
            {
                // Only show when text is empty
                SetIsVisible(tb, textBox.Text.IsNullOrEmpty());
                return;
            }
        }
		public static Object GetCueBanner( TextBoxBase control )
		{
			return control.GetValue( CueBannerProperty );
		}