Ejemplo n.º 1
0
        /// <summary>
        /// Called when the XAML text property is changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnXamlTextPropertyChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            RichTextBoxExtended textBox = (RichTextBoxExtended)dependencyObject;
            string value = (string)e.NewValue;

            if (string.IsNullOrWhiteSpace(value))
            {
                textBox.isXamlTextChanging = true;
                textBox.SetText(string.Empty);
                textBox.isXamlTextChanging = false;

                textBox.ClearUndo();
            }
            else
            {
                if (textBox.isXamlTextChanging)
                {
                    return;
                }

                textBox.isXamlTextChanging = true;
                textBox.SetXaml(value);
                textBox.isXamlTextChanging = false;

                textBox.ClearUndo();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Event handler for ApplicationCommands.Copy command.
        /// <remarks>
        /// We want to enforce that data can be set on the clipboard
        /// only in plain text format from this RichTextBox.
        /// </remarks>
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnCopy(object sender, ExecutedRoutedEventArgs e)
        {
            RichTextBoxExtended myRichTextBox = (RichTextBoxExtended)sender;
            string selectionText = myRichTextBox.Selection.Text;

            Clipboard.SetText(selectionText);
            e.Handled = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when the foreground of the current selection is changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        private static void OnSelectionForegroundChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            RichTextBoxExtended richTextBoxExtended = (RichTextBoxExtended)dependencyObject;

            if (!richTextBoxExtended.suppressSetSelectionProperties)
            {
                richTextBoxExtended.Focus();
                richTextBoxExtended.Selection.ApplyPropertyValue(RichTextBox.ForegroundProperty, richTextBoxExtended.SelectionForeground);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Event handler for ApplicationCommands.Paste command.
        /// <remarks>
        /// We want to allow paste only in plain text format.
        /// </remarks>
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnPaste(object sender, ExecutedRoutedEventArgs e)
        {
            RichTextBoxExtended myRichTextBox = (RichTextBoxExtended)sender;

            // Handle paste only if clipboard supports text format.
            if (Clipboard.ContainsText())
            {
                myRichTextBox.Selection.Text = Clipboard.GetText();
            }

            e.Handled = true;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called when the text property is changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnTextPropertyChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            RichTextBoxExtended textBox = (RichTextBoxExtended)dependencyObject;
            string value = (string)e.NewValue;

            if (textBox.isTextChanging)
            {
                return;
            }

            textBox.isTextChanging = true;
            textBox.SetText(value);
            textBox.isTextChanging = false;

            textBox.ClearUndo();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called when plain text paste enabled is changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnIsPlainTextPasteEnabledChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            RichTextBoxExtended richTextBox = (RichTextBoxExtended)dependencyObject;

            if (richTextBox.IsPlainTextPasteEnabled)
            {
                richTextBox.CommandBindings.Add(new CommandBinding(
                                                    ApplicationCommands.Paste,
                                                    new ExecutedRoutedEventHandler(OnPaste),
                                                    new CanExecuteRoutedEventHandler(OnCanExecutePaste)));
            }
            else
            {
                CommandBinding commandBinding = richTextBox.CommandBindings
                                                .OfType <CommandBinding>()
                                                .FirstOrDefault(x => x.Command == ApplicationCommands.Paste);
                if (commandBinding != null)
                {
                    richTextBox.CommandBindings.Remove(commandBinding);
                }
            }
        }
Ejemplo n.º 7
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.TextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 2:
     this.TransparentTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 3:
     this.MultiLineTextBoxStyle = ((System.Windows.Controls.TextBox)(target));
     return;
     case 4:
     this.TextBoxExtended = ((Framework.UI.Controls.TextBoxExtended)(target));
     return;
     case 5:
     this.TransparentTextBoxExtended = ((Framework.UI.Controls.TextBoxExtended)(target));
     return;
     case 6:
     this.MultiLineTextBoxExtendedStyle = ((Framework.UI.Controls.TextBoxExtended)(target));
     return;
     case 7:
     this.FilterTextBoxExtended = ((Framework.UI.Controls.TextBoxExtended)(target));
     return;
     case 8:
     this.RichTextBox = ((Framework.UI.Controls.RichTextBoxExtended)(target));
     return;
     case 9:
     this.PlainTextCutCheckBox = ((System.Windows.Controls.CheckBox)(target));
     return;
     case 10:
     this.PlainTextCopyCheckBox = ((System.Windows.Controls.CheckBox)(target));
     return;
     case 11:
     this.PlainTextPasteCheckBox = ((System.Windows.Controls.CheckBox)(target));
     return;
     case 12:
     this.PlainTextTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 13:
     this.RtfTextTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 14:
     this.XamlTextTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 15:
     this.ButtonTextBox = ((Framework.UI.Controls.ButtonTextBox)(target));
     return;
     case 16:
     this.SearchButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
     return;
     case 17:
     this.FolderButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
     return;
     case 18:
     this.RefreshButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
     return;
     case 19:
     this.LargeSearchButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
     return;
     case 20:
     this.DatePicker = ((System.Windows.Controls.DatePicker)(target));
     return;
     case 21:
     this.TransparentDatePicker = ((System.Windows.Controls.DatePicker)(target));
     return;
     case 22:
     this.Calendar = ((System.Windows.Controls.Calendar)(target));
     return;
     case 23:
     this.CheckBox = ((System.Windows.Controls.CheckBox)(target));
     return;
     case 24:
     this.ToggleSwitch = ((Elysium.Controls.ToggleSwitch)(target));
     return;
     case 25:
     this.RadioButton = ((System.Windows.Controls.RadioButton)(target));
     return;
     case 26:
     this.ComboBox = ((System.Windows.Controls.ComboBox)(target));
     return;
     case 27:
     this.IsEditableToggleSwitch = ((Elysium.Controls.ToggleSwitch)(target));
     return;
     case 28:
     this.MaxLengthDecimalUpDown = ((Framework.UI.Controls.DecimalUpDown)(target));
     return;
     case 29:
     this.TransparentComboBox = ((System.Windows.Controls.ComboBox)(target));
     return;
     case 30:
     this.ComboDataGrid = ((Framework.UI.Controls.ComboDataGrid)(target));
     return;
     case 31:
     this.DecimalUpDown = ((Framework.UI.Controls.DecimalUpDown)(target));
     return;
     case 32:
     this.TransparentDecimalUpDown = ((Framework.UI.Controls.DecimalUpDown)(target));
     return;
     case 33:
     this.ShowButtonSpinnerCheckBox = ((System.Windows.Controls.CheckBox)(target));
     return;
     case 34:
     this.AllowSpinCheckBox = ((System.Windows.Controls.CheckBox)(target));
     return;
     case 35:
     this.FormatStringTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 36:
     this.IncrementTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 37:
     this.MinimumTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 38:
     this.MaximumTextBox = ((System.Windows.Controls.TextBox)(target));
     return;
     case 39:
     this.IsRedOnNegativeCheckBox = ((System.Windows.Controls.CheckBox)(target));
     return;
     }
     this._contentLoaded = true;
 }
Ejemplo n.º 8
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.TextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 2:
                this.TransparentTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 3:
                this.MultiLineTextBoxStyle = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.TextBoxExtended = ((Framework.UI.Controls.TextBoxExtended)(target));
                return;

            case 5:
                this.TransparentTextBoxExtended = ((Framework.UI.Controls.TextBoxExtended)(target));
                return;

            case 6:
                this.MultiLineTextBoxExtendedStyle = ((Framework.UI.Controls.TextBoxExtended)(target));
                return;

            case 7:
                this.FilterTextBoxExtended = ((Framework.UI.Controls.TextBoxExtended)(target));
                return;

            case 8:
                this.RichTextBox = ((Framework.UI.Controls.RichTextBoxExtended)(target));
                return;

            case 9:
                this.PlainTextCutCheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 10:
                this.PlainTextCopyCheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 11:
                this.PlainTextPasteCheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 12:
                this.PlainTextTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 13:
                this.RtfTextTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 14:
                this.XamlTextTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 15:
                this.ButtonTextBox = ((Framework.UI.Controls.ButtonTextBox)(target));
                return;

            case 16:
                this.SearchButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
                return;

            case 17:
                this.FolderButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
                return;

            case 18:
                this.RefreshButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
                return;

            case 19:
                this.LargeSearchButtonTextBoxStyle = ((Framework.UI.Controls.ButtonTextBox)(target));
                return;

            case 20:
                this.DatePicker = ((System.Windows.Controls.DatePicker)(target));
                return;

            case 21:
                this.TransparentDatePicker = ((System.Windows.Controls.DatePicker)(target));
                return;

            case 22:
                this.Calendar = ((System.Windows.Controls.Calendar)(target));
                return;

            case 23:
                this.CheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 24:
                this.ToggleSwitch = ((Elysium.Controls.ToggleSwitch)(target));
                return;

            case 25:
                this.RadioButton = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 26:
                this.ComboBox = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 27:
                this.IsEditableToggleSwitch = ((Elysium.Controls.ToggleSwitch)(target));
                return;

            case 28:
                this.MaxLengthDecimalUpDown = ((Framework.UI.Controls.DecimalUpDown)(target));
                return;

            case 29:
                this.TransparentComboBox = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 30:
                this.ComboDataGrid = ((Framework.UI.Controls.ComboDataGrid)(target));
                return;

            case 31:
                this.DecimalUpDown = ((Framework.UI.Controls.DecimalUpDown)(target));
                return;

            case 32:
                this.TransparentDecimalUpDown = ((Framework.UI.Controls.DecimalUpDown)(target));
                return;

            case 33:
                this.ShowButtonSpinnerCheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 34:
                this.AllowSpinCheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 35:
                this.FormatStringTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 36:
                this.IncrementTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 37:
                this.MinimumTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 38:
                this.MaximumTextBox = ((System.Windows.Controls.TextBox)(target));
                return;

            case 39:
                this.IsRedOnNegativeCheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// CanExecute event handler for ApplicationCommand.Paste.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="args">The <see cref="CanExecuteRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnCanExecutePaste(object target, CanExecuteRoutedEventArgs args)
        {
            RichTextBoxExtended myRichTextBox = (RichTextBoxExtended)target;

            args.CanExecute = myRichTextBox.IsEnabled && !myRichTextBox.IsReadOnly && Clipboard.ContainsText();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// CanExecute event handler for ApplicationCommands.Cut.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="args">The <see cref="CanExecuteRoutedEventArgs"/> instance containing the event data.</param>
        private static void OnCanExecuteCut(object target, CanExecuteRoutedEventArgs args)
        {
            RichTextBoxExtended myRichTextBox = (RichTextBoxExtended)target;

            args.CanExecute = myRichTextBox.IsEnabled && !myRichTextBox.IsReadOnly && !myRichTextBox.Selection.IsEmpty;
        }