public static void AttachCurrency(DependencyObject dp, DependencyPropertyChangedEventArgs e) { if (!(dp is TextBox)) { return; } var textBox = dp as TextBox; DataObject.AddPastingHandler(textBox, PastingHandler); textBox.PreviewTextInput += TextBox_PreviewTextInput; textBox.TextChanged += TextBox_TextChanged; }
public MainWindow(FileReaderFactory readerFactory) { _readerFactory = readerFactory ?? throw new ArgumentNullException(nameof(readerFactory)); InitializeComponent(); DataContext = _model; DataObject.AddPastingHandler(GridWidth, NumericOnly_OnPaste); DataObject.AddPastingHandler(GridHeight, NumericOnly_OnPaste); DataObject.AddPastingHandler(FluidContact, NumericOnly_OnPaste); }
private static void OnValueChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { if (!(dependencyObject is Control uiElement)) { return; } if (e.NewValue is bool value && value) { uiElement.PreviewTextInput += OnTextInput; uiElement.PreviewKeyDown += OnPreviewKeyDown; DataObject.AddPastingHandler(uiElement, OnPaste); }
//========== CONSTANTS =========== #region Constants #endregion //=========== MEMBERS ============ #region Members #endregion //========= CONSTRUCTORS ========= #region Constructors /**<summary>Constructs the main window.</summary>*/ public MainWindow() { InitializeComponent(); LoadSettings(); // Disable drag/drop text in textboxes so you can scroll their contents easily DataObject.AddCopyingHandler(textBoxExe, OnTextBoxCancelDrag); // Remove quotes from "Copy Path" command on paste DataObject.AddPastingHandler(textBoxExe, OnTextBoxQuotesPaste); }
/// <summary> /// Initializes a new instance of the <see cref="ChannelTextBoxEntryView" /> class. /// </summary> public ChannelTextBoxEntryView() { InitializeComponent(); DataObject.AddPastingHandler(this, OnPaste); Entry.Language = XmlLanguage.GetLanguage(ApplicationSettings.Langauge); OnContextChanged(); DataContextChanged += (s, e) => OnContextChanged(); }
//====================================================================== public SettingsWindow() { InitializeComponent(); DataObject.AddPastingHandler(this.textBox_TreeWidth, this.textBox_Pasting); DataObject.AddPastingHandler(this.textBox_KnobWidth, this.textBox_Pasting); var presenter = new Presenter.SettingsWindow(); this.DataContext = presenter; presenter.RefreshView(); }
public IntegerTextBox() { this.Loaded += (s, e) => { DataObject.RemovePastingHandler(this, this_PastingHandler); DataObject.AddPastingHandler(this, this_PastingHandler); }; this.Unloaded += (s, e) => { DataObject.RemovePastingHandler(this, this_PastingHandler); }; }
protected override void OnAttached() { base.OnAttached(); // 插入要在将 Behavior 附加到对象时运行的代码。 this.AssociatedObject.PreviewTextInput += new TextCompositionEventHandler(OnPreviewTextInput); this.AssociatedObject.TextChanged += new TextChangedEventHandler(OnTextChanged); System.Windows.Input.InputMethod.SetIsInputMethodEnabled(this.AssociatedObject, false); DataObject.AddPastingHandler(this.AssociatedObject, OnClipboardPaste); }
static void IntegerTextBox_Loaded(object sender, RoutedEventArgs e) { var Sender = sender as IntegerTextBox; if (Sender == null) { return; } DataObject.RemovePastingHandler(Sender, IntegerTextBox_PastingHandler); DataObject.AddPastingHandler(Sender, IntegerTextBox_PastingHandler); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); _TextBox = Template.FindName("PART_TextBox", this) as TextBox; _UpButton = Template.FindName("PART_UpButton", this) as RepeatButton; _DownButton = Template.FindName("PART_DownButton", this) as RepeatButton; _UpButton.Click += Increment; _DownButton.Click += Decrement; _TextBox.LostFocus += TextBox_LostFocus; _TextBox.PreviewTextInput += TextBox_PreviewTextInput; _TextBox.PreviewKeyDown += TextBox_PreviewKeyDown; DataObject.AddPastingHandler(_TextBox, new DataObjectPastingEventHandler(TextBox_PreviewPaste)); }
public IPBox() { InitializeComponent(); // 处理粘贴 DataObject.AddPastingHandler(this, new DataObjectPastingEventHandler(IPTextBox_Paste)); // 设置textBox次序 ipTextBox1.setNeighbour(null, ipTextBox2); ipTextBox2.setNeighbour(ipTextBox1, ipTextBox3); ipTextBox3.setNeighbour(ipTextBox2, ipTextBox4); ipTextBox4.setNeighbour(ipTextBox3, null); }
/*****************/ /* RouterTextBox */ /*****************/ public RouterTextBox( int thePriority) : base() { m_TextBoxRouter = new TextBoxRouter(this, thePriority); m_ThreadBridge = new RouterThreadBridge(); this.AcceptsReturn = true; this.IsReadOnly = false; DataObject.AddPastingHandler(this, OnPaste); CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, OnCut, CanCut)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, null, CanPaste)); this.SelectionChanged += new RoutedEventHandler(TextBoxSelectionChanged); this.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(TextBox_PreviewMouseLeftButtonUp); }
private static void OnEnableChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var enable = e.NewValue is bool && (bool)e.NewValue; if (enable) { DataObject.AddPastingHandler(sender, OnPaste); } else { DataObject.RemovePastingHandler(sender, OnPaste); } }
public PendingChangesView(ToolWindowWithEditor <PendingChangesView> toolWindow) { InitializeComponent(); this._toolWindow = toolWindow; this.service = BasicSccProvider.GetServiceEx <SccProviderService>(); SetDiffCodeHightlighter(); VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged; CurrentTracker = RepositoryManager.Instance.ActiveTracker; RepositoryManager.Instance.ActiveTrackerChanged += Instance_ActiveTrackerChanged; //Fix for bug #78 : Commit comment text field shouldn't allow formatting DataObject.AddPastingHandler(textBoxComments, new DataObjectPastingEventHandler(TextBoxPasting)); }
public KeyboardEntryControl() { UseEnterEvents = false; WasCanceled = false; InitializeComponent(); DataObject.AddPastingHandler(textBoxLine, this.OnCancelCommand); DataObject.AddCopyingHandler(textBoxLine, this.OnCancelCommand); DataObject.AddPastingHandler(passwordBoxLine, this.OnCancelCommand); DataObject.AddCopyingHandler(passwordBoxLine, this.OnCancelCommand); this.Loaded += KeyboardEntryControl_Loaded; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); DataObject.AddCopyingHandler(this, PastingEventHandler); DataObject.AddPastingHandler(this, PastingEventHandler); this.CaretIndex = this.Text.Length; this.KeyDown += KeyPressed; this.KeyUp += KeyReleased; this.PreviewMouseDown += MouseClicked; this.PreviewMouseUp += MouseReleased; this.TextChanged += ValueChanged; this.Text = Format(string.Empty); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); InputValidationError += MyDecimalUpDown_InputValidationError; DataObject.AddPastingHandler(this, textbox_PastingHandler); var textBox = this.Template.FindName("PART_TextBox", this) as WatermarkTextBox; if (null != textBox) { InputMethod.SetIsInputMethodSuspended(textBox, true); } }
/// <summary> /// テキストボックスに何か文字が入力されたときに呼ばれるイベントハンドラ /// </summary> /// <param name="sender">テキストボックス</param> /// <param name="e">依存プロパティが変更されたときのイベント</param> private static void IsVelocityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { if (sender is TextBox textBox) { textBox.KeyDown -= OnKeyDown; DataObject.RemovePastingHandler(textBox, TextBoxPastingEventHandler); if ((Boolean)e.NewValue) { textBox.KeyDown += OnKeyDown; DataObject.AddPastingHandler(textBox, TextBoxPastingEventHandler); } } }
public ConnectionHost() { InitializeComponent(); DataObject.AddPastingHandler(tbIp1, OnPaste); DataObject.AddPastingHandler(tbIp2, OnPaste); DataObject.AddPastingHandler(tbIp3, OnPaste); DataObject.AddPastingHandler(tbIp4, OnPaste); tbIp4.Focus(); //tbIp1.Focusable = false; //tbIp2.Focusable = false; //tbIp3.Focusable = false; //tbIp4.Focusable = false; }
public IpTextBox() { InitializeComponent(); DataObject.AddPastingHandler(this, (sender, args) => { IpAddress = args.DataObject.GetData(typeof(string)) as string; }); currentIndex = 0; quartets = new[] { FirstQuartet, SecondQuartet, ThirdQuartet, FourthQuartet }; FirstQuartet.GotFocus += (sender, args) => currentIndex = 0; SecondQuartet.GotFocus += (sender, args) => currentIndex = 1; ThirdQuartet.GotFocus += (sender, args) => currentIndex = 2; FourthQuartet.GotFocus += (sender, args) => currentIndex = 3; }
public MessageBox() { ChannelsViewModel = Mvx.IocConstruct <ChannelsViewModel>(); AvailableColors = new Dictionary <Color, string> { { Colors.Red, "red" }, { Colors.Blue, "blue" }, { Colors.Yellow, "yellow" }, { Colors.Green, "green" }, { Colors.Pink, "pink" }, { Colors.Gray, "gray" }, { Colors.Orange, "orange" }, { Colors.Purple, "purple" }, { Colors.Brown, "brown" }, { Colors.Cyan, "cyan" }, { Colors.Black, "black" }, { Colors.White, "white" }, { Colors.Transparent, "" } }; InitializeComponent(); DataObject.AddPastingHandler(RichTextBox, HandlePaste); RichTextBox.Foreground = new SolidColorBrush(Color.FromArgb(255, 1, 1, 1)); RichTextBox.TextChanged += (sender, args) => OnTextChanged(args); RichTextBox.LostFocus += TextBoxFocusLost; }
public NetMACAddressControl() { InitializeComponent(); DataObject.AddPastingHandler(this, new DataObjectPastingEventHandler(IPTextBox_Paste)); // 设置textBox次序 ipTextBox1.setNeighbour(null, ipTextBox2); ipTextBox2.setNeighbour(ipTextBox1, ipTextBox3); ipTextBox3.setNeighbour(ipTextBox2, ipTextBox4); ipTextBox4.setNeighbour(ipTextBox3, ipTextBox5); ipTextBox5.setNeighbour(ipTextBox4, ipTextBox6); ipTextBox6.setNeighbour(ipTextBox5, null); }
public IntegerBoxOption() : base() { Loaded += (sender, args) => { PreviewTextInput += ContrainPreviewToInt; DataObject.AddPastingHandler(this, ContrainPasteToInt); }; Unloaded += (sender, args) => { PreviewTextInput -= ContrainPreviewToInt; DataObject.RemovePastingHandler(this, ContrainPasteToInt); }; }
/// <summary> /// Called after the behavior is attached into the associated object. /// </summary> protected override void OnAttached() { base.OnAttached(); AssociatedObject.PreviewKeyDown += HandlePreviewKeyDown; AssociatedObject.GotKeyboardFocus += SelectAllText; AssociatedObject.MouseDoubleClick += SelectAllText; AssociatedObject.PreviewMouseLeftButtonDown += SelectivelyIgnoreMouseButton; AssociatedObject.PreviewTextInput += HandlePreviewTextInput; DataObject.AddPastingHandler(AssociatedObject, HandlePaste); AddBindingNotification(); Binding.AddTargetUpdatedHandler(AssociatedObject, HandleTargetUpdated); }
public static void IsAlphaNumericFilterChanged(DependencyObject src, DependencyPropertyChangedEventArgs args) { if ((src != null) && (src is TextBox)) { TextBox textBox = (TextBox)src; InputMethod.SetIsInputMethodEnabled(src, false); if ((bool)args.NewValue) { textBox.KeyDown += AlphaNumericTextBoxKeyDown; DataObject.AddPastingHandler(textBox, AlphaNumericTextBoxPasting); } } }
public UCIPAddressTextBox() { InitializeComponent(); // 处理粘贴 DataObject.AddPastingHandler(this, new DataObjectPastingEventHandler(IPTextBox_Paste)); // 设置textBox次序 IPAddress1.SetNeighbour(null, IPAddress2); IPAddress2.SetNeighbour(IPAddress1, IPAddress3); IPAddress3.SetNeighbour(IPAddress2, IPAddress4); IPAddress4.SetNeighbour(IPAddress3, null); ButtonMoreInformation.Click += ButtonMoreInformation_Click; }
public MainWindow() { InitializeComponent(); numberTextBoxes = new TextBox[] { WinW, WinH, CSX, CSY, CSA, CSB, ObjX1, ObjX2, ObjY1, ObjY2 }; foreach (TextBox tb in numberTextBoxes) { DataObject.AddPastingHandler(tb, TextBox_PasteValidate); tb.PreviewTextInput += TextBox_Validate; tb.TextChanged += TextBox_TextChanged; } CSBind.SelectionChanged += ComboBox_SelectionChanged; }
private void OnLoaded(object sender, RoutedEventArgs e) { this.Loaded -= OnLoaded; InputMethod.SetIsInputMethodEnabled(this, false); InputMethod.SetPreferredImeState(this, InputMethodState.Off); DataObject.AddPastingHandler(this, OnPastingEvent); RoutedEventHandler unloaded = null; unloaded = (obj, args) => { this.Unloaded -= unloaded; DataObject.RemovePastingHandler(this, OnPastingEvent); }; this.Unloaded += unloaded; }
public ImageEditor() { InitializeComponent(); DataObject.AddPastingHandler(tbReply, OnPasting); Paragraph p = new Paragraph(); p.Inlines.Add(new Run("tslff")); BitmapImage image = new BitmapImage(new Uri(@"C:\Users\ycx\Pictures\1.jpg")); p.Inlines.Add(new Image { Source = image, Width = image.PixelWidth }); this.tbReply.Document.Blocks.Clear(); this.tbReply.Document.Blocks.Add(p); }
public Editor() { InitializeComponent(); EditBox.Loaded += EditBoxOnLoaded; EditBox.Options.IndentationSize = 2; EditBox.Options.EnableHyperlinks = false; EditBox.Options.ConvertTabsToSpaces = true; EditBox.Options.AllowScrollBelowDocument = true; EditBox.TextChanged += EditBoxOnTextChanged; EditBox.TextChanged += (s, e) => _executeAutoSaveLater(null); EditBox.PreviewKeyDown += (s, e) => _appsKeyDown = e.Key == Key.Apps && e.IsDown; DataObject.AddPastingHandler(EditBox, OnPaste); CommandBindings.Add(new CommandBinding(EditingCommands.CorrectSpellingError, ExecuteSpellCheckReplace)); CommandBindings.Add(new CommandBinding(EditingCommands.IgnoreSpellingError, ExecuteAddToDictionary)); _executeAutoSaveLater = Utility.Debounce <string>(s => Dispatcher.Invoke(ExecuteAutoSave), 4000); }