public TextList() { ItemsSeparator = ", "; DataObject.AddCopyingHandler(this, OnCopy); DataObject.AddPastingHandler(this, OnPaste); IsUndoEnabled = false; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); // Bind Text to Number with the specified StringFormat var textBinding = new Binding(); textBinding.Path = new PropertyPath("Value"); textBinding.RelativeSource = new RelativeSource(RelativeSourceMode.Self); textBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBinding.StringFormat = "C"; textBinding.ConverterCulture = CultureInfo.CurrentCulture; BindingOperations.SetBinding(this, TextBox.TextProperty, textBinding); // Disable copy/paste DataObject.AddCopyingHandler(this, PastingEventHandler); DataObject.AddPastingHandler(this, PastingEventHandler); this.CaretIndex = this.Text.Length; this.PreviewKeyDown += TextBox_PreviewKeyDown; this.PreviewMouseDown += TextBox_PreviewMouseDown; this.PreviewMouseUp += TextBox_PreviewMouseUp; this.TextChanged += TextBox_TextChanged; this.ContextMenu = null; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); // Bind Text to Number with the specified StringFormat var textBinding = new Binding { Path = new PropertyPath("Number"), RelativeSource = new RelativeSource(RelativeSourceMode.Self), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, StringFormat = StringFormat, ConverterCulture = Culture }; BindingOperations.SetBinding(this, TextProperty, textBinding); // Disable copy/paste DataObject.AddCopyingHandler(this, CopyPasteEventHandler); DataObject.AddPastingHandler(this, CopyPasteEventHandler); //Events SetCaretPositionFromInputMode(this); //Disable contextmenu ContextMenu = null; }
private static void OnModeEnabledChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var textBox = (TextBox)dependencyObject; var isEnabled = (bool)e.NewValue; if (isEnabled) { textBox.PreviewTextInput += textBox_PreviewTextInput; textBox.PreviewKeyDown += textBox_PreviewKeyDown; DataObject.AddPastingHandler(textBox, Pasting); DataObject.AddCopyingHandler(textBox, NoDragCopy); CommandManager.AddPreviewExecutedHandler(textBox, NoCutting); // Default context menu has cut & paste, we want only copy. textBox.ContextMenu = _contextMenuWithCopyOnly; // Remove if you want to set the style of readonly textboxes via styles textBox.Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); } else { textBox.PreviewTextInput -= textBox_PreviewTextInput; textBox.PreviewKeyDown -= textBox_PreviewKeyDown; DataObject.RemovePastingHandler(textBox, Pasting); DataObject.RemoveCopyingHandler(textBox, NoDragCopy); CommandManager.RemovePreviewExecutedHandler(textBox, NoCutting); textBox.ClearValue(TextBox.ContextMenuProperty); textBox.ClearValue(TextBox.BackgroundProperty); } }
private void EmojiRichTextBox_Loaded(object sender, RoutedEventArgs e) { _msg = (DataContext as MessageModel).Message; // Sets width of control. This is an approximation FormattedText txt = new FormattedText(_msg, CultureInfo.CurrentCulture, Document.FlowDirection, new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), FontSize + 1.6, Foreground); txt.MaxTextWidth = MaxWidth - 5; ParseText(_msg); Width = txt.Width; if (Width < MinWidth) { Width = MinWidth + 2; } if (Width + 2 > MaxWidth) { Width = MaxWidth - 2; } Document.PageWidth = Width; DataObject.AddCopyingHandler(this, OnCopy); }
private static void OnMaskChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var textBox = dependencyObject as TextBox; var mask = e.NewValue as string; textBox.PreviewTextInput -= textBox_PreviewTextInput; textBox.PreviewKeyDown -= textBox_PreviewKeyDown; DataObject.RemovePastingHandler(textBox, Pasting); DataObject.RemoveCopyingHandler(textBox, NoDragCopy); CommandManager.RemovePreviewExecutedHandler(textBox, NoCutting); if (mask == null) { textBox.ClearValue(MaskProperty); textBox.ClearValue(MaskExpressionProperty); } else { textBox.SetValue(MaskProperty, mask); SetMaskExpression(textBox, new Regex(mask, RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace)); textBox.PreviewTextInput += textBox_PreviewTextInput; textBox.PreviewKeyDown += textBox_PreviewKeyDown; DataObject.AddPastingHandler(textBox, Pasting); DataObject.AddCopyingHandler(textBox, NoDragCopy); CommandManager.AddPreviewExecutedHandler(textBox, NoCutting); } }
public JoinNetworkView() { InitializeComponent(); DataObject.AddPastingHandler(joinNetworkBox, onPaste); DataObject.AddCopyingHandler(joinNetworkBox, onCopyCut); }
//========= CONSTRUCTORS ========= #region Constructors /**<summary>Constructs the main window.</summary>*/ public MainWindow() { loaded = false; InitializeComponent(); lastFolderPath = ""; lastFilePath = ""; // Disable drag/drop text in textboxes so you can scroll their contents easily DataObject.AddCopyingHandler(textBoxTerrariaContent, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxExtractInput, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxExtractOutput, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxConvertInput, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxConvertOutput, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxContent, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxBackup, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxScript, OnTextBoxCancelDrag); // Remove quotes from "Copy Path" command on paste DataObject.AddPastingHandler(textBoxTerrariaContent, OnTextBoxQuotesPaste); DataObject.AddPastingHandler(textBoxExtractInput, OnTextBoxQuotesPaste); DataObject.AddPastingHandler(textBoxExtractOutput, OnTextBoxQuotesPaste); DataObject.AddPastingHandler(textBoxConvertInput, OnTextBoxQuotesPaste); DataObject.AddPastingHandler(textBoxConvertOutput, OnTextBoxQuotesPaste); DataObject.AddPastingHandler(textBoxContent, OnTextBoxQuotesPaste); DataObject.AddPastingHandler(textBoxBackup, OnTextBoxQuotesPaste); DataObject.AddPastingHandler(textBoxScript, OnTextBoxQuotesPaste); labelDrop.Visibility = Visibility.Hidden; LoadConfig(); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); // Bind Text to Number with the specified StringFormat var textBinding = new Binding(); textBinding.Path = new PropertyPath("Number"); textBinding.RelativeSource = new RelativeSource(RelativeSourceMode.Self); textBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; textBinding.StringFormat = StringFormat; BindingOperations.SetBinding(this, TextBox.TextProperty, textBinding); // Disable copy/paste DataObject.AddCopyingHandler(this, CopyPasteEventHandler); DataObject.AddPastingHandler(this, CopyPasteEventHandler); //Events CaretIndex = Text.Length; PreviewKeyDown += TextBox_PreviewKeyDown; PreviewMouseDown += TextBox_PreviewMouseDown; PreviewMouseUp += TextBox_PreviewMouseUp; TextChanged += TextBox_TextChanged; //Disable contextmenu ContextMenu = null; }
/// <summary> /// Default constructor. /// </summary> public Terminal() { _buffer = new List <string>(); _paragraph = new Paragraph { Margin = ItemsMargin, LineHeight = ItemHeight }; IsUndoEnabled = false; _promptInline = new Run(Prompt); Document = new FlowDocument(_paragraph); AddPrompt(); TextChanged += (s, e) => { Line = AggregateAfterPrompt(); ScrollToEnd(); }; DataObject.AddPastingHandler(this, PasteCommand); DataObject.AddCopyingHandler(this, CopyCommand); SetResourceReference(StyleProperty, "TerminalStyle"); }
public zMaskedTextBox() : base() { //disable copy and paste DataObject.AddPastingHandler(this, this.OnCancelCommand); DataObject.AddCopyingHandler(this, this.OnCancelCommand); this.ContextMenu = null; AddHandler(PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(SelectivelyIgnoreMouseButton), true); }
public FloatInputWPF() { InitializeComponent(); DataObject.AddCopyingHandler(_numberControl, (s, e) => { if (e.IsDragDrop) { e.CancelCommand(); } }); }
//-------------------------------------------------------------------------------------------------- public ValueEditBox() { DataObject.AddPastingHandler(this, PastingHandler); DataObject.AddCopyingHandler(this, (sender, e) => { if (e.IsDragDrop) { e.CancelCommand(); } }); Text = "0"; }
public NoteView() { InitializeComponent(); PropertyChanged += NoteViewPropertyChanged; DataContextChanged += NoteViewDataContextChanged; DataObject.AddCopyingHandler(FlowDocumentPageViewer, OnTextCopy); }
/// <summary> /// Initializes a new instance of the <see cref="BbCodeBlock"/> class. /// </summary> public SelectableBbCodeBlock() { // ensures the implicit BbCodeBlock style is used DefaultStyleKey = typeof(SelectableBbCodeBlock); IsDocumentEnabled = true; AddHandler(FrameworkContentElement.LoadedEvent, new RoutedEventHandler(OnLoaded)); AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(OnRequestNavigate)); DataObject.AddCopyingHandler(this, OnCopy); }
public EditFolderWindow(SetupFolder folder) { InitializeComponent(); // Init icon combo box int index = 0; int folderIndex = -1; foreach (var pair in Setup.SetupIcons) { comboBoxIcon.Items.Add(pair.Key); if (folder.Icon == pair.Key) { comboBoxIcon.SelectedIndex = index; } if (pair.Key == "Folder") { folderIndex = index; } index++; } if (comboBoxIcon.SelectedIndex == -1 && folderIndex != -1) { comboBoxIcon.SelectedIndex = folderIndex; } textBoxName.Text = folder.Name; if (Setup.SetupIcons.ContainsKey(folder.Icon)) { comboBoxIcon.Visibility = Visibility.Visible; textBoxCustomIcon.Visibility = Visibility.Hidden; buttonBrowseCustomIcon.Visibility = Visibility.Hidden; checkBoxCustomIcon.IsChecked = false; } else { textBoxCustomIcon.Text = folder.Icon; comboBoxIcon.Visibility = Visibility.Hidden; textBoxCustomIcon.Visibility = Visibility.Visible; buttonBrowseCustomIcon.Visibility = Visibility.Visible; checkBoxCustomIcon.IsChecked = true; } UpdateIcon(folder.Icon); // Remove quotes from "Copy Path" command on paste DataObject.AddPastingHandler(textBoxCustomIcon, OnTextBoxQuotesPaste); // Disable drag/drop text in textboxes so you can scroll their contents easily DataObject.AddCopyingHandler(textBoxName, OnTextBoxCancelDrag); DataObject.AddCopyingHandler(textBoxCustomIcon, OnTextBoxCancelDrag); }
//create instance using TextBox control as base public CurrencyTextBox() : base() { //disable copy and paste DataObject.AddPastingHandler(this, this.OnCancelCommand); DataObject.AddCopyingHandler(this, this.OnCancelCommand); this.ContextMenu = null; AddHandler(PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(SelectivelyIgnoreMouseButton), true); AddHandler(GotKeyboardFocusEvent, new RoutedEventHandler(SelectAllText), true); AddHandler(MouseDoubleClickEvent, new RoutedEventHandler(SelectAllText), true); }
public MainWindow() { InitializeComponent(); InitializeMesh(); geometryMenuItem.IsChecked = true; kTextBox.Text = mesh.K.ToString(); DataObject.AddPastingHandler(kTextBox, OnCancelCommand); DataObject.AddCopyingHandler(kTextBox, OnCancelCommand); UpdateInfoLabel(); }
public NoteView() { InitializeComponent(); PropertyChanged += NoteViewPropertyChanged; DataContextChanged += NoteViewDataContextChanged; DataObject.AddCopyingHandler(FlowDocumentPageViewer, OnTextCopy); Messenger.Default.Register <ChangeViewMode>(this, SelectViewMode); Messenger.Default.Register <SelectedNoteChanged>(this, OnSelectedNoteChanged); }
//========== 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); }
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 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 uiCrearMaestroAvanzado(MainWindow pMW) { InitializeComponent(); txtbNombreTabla.Focus(); lista = new List <data>(); pw = pMW; txtbNombreTabla.Focus(); DataObject.AddCopyingHandler(txtbNombreTabla, NoDragCopy); DataObject.AddCopyingHandler(txtCNombre, NoDragCopy); DataObject.AddCopyingHandler(txtTamanioR1, NoDragCopy); }
public uiModMAvanzado(string pNTabla, MainWindow pMW) { InitializeComponent(); nombreTabla = pNTabla; txtbMaestro.Text += nombreTabla; cargarDatosMaestroA(); txtCNombre.Focus(); pw = pMW; DataObject.AddCopyingHandler(txtbNombreTabla, NoDragCopy); DataObject.AddCopyingHandler(txtCNombre, NoDragCopy); DataObject.AddCopyingHandler(txtTamanioR1, NoDragCopy); }
//load the textbox and disable drag'n'drop for selected text private void LoadTextBox() { DataObject.AddCopyingHandler(TextBoxCode, (s, e) => { if (e.IsDragDrop) { e.CancelCommand(); } }); TextBoxCode.PreviewMouseLeftButtonDown += (s, e) => { if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift)) { TextBoxCode.Select(0, 0); } }; }
public ChatHistoryView(IMModels.ChatModel chat) { InitializeComponent(); this.DataContext = _hisVM = new ChatHistoryViewModel(chat); this.rictBox.SizeChanged += RictBox_SizeChanged; this.sv.PreviewMouseWheel += Sv_PreviewMouseWheel; DataObject.AddCopyingHandler(this.rictBox, (s, e) => { e.CancelCommand(); e.Handled = true; DoCopy(); }); this.Loaded += ChatHistoryView_Loaded; this.flowDoc.MouseUp += FlowDoc_PreviewMouseUp; this.Unloaded += ChatHistoryView_Unloaded; }
public PathTrimmingTextBlock() { DefaultStyleKey = typeof(PathTrimmingTextBlock); Loaded += OnLoaded; SizeChanged += OnSizeChanged; Background = new SolidColorBrush(Colors.Transparent); // TextTrimming = TextTrimming.CharacterEllipsis; DataObject.AddCopyingHandler(this, CopyCommand); MouseDown += OnMouseDown; HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; Document.PageWidth = 2000; }
private void InitialSetup() { txtb_wordCount.Text = Refs.dataBank.GetSetting("defWordCount"); txtb_charCount.Text = Refs.dataBank.GetSetting("defCharCount"); if (Refs.dataBank.GetSetting("rememberLastWordList") == "True") { Refs.passGen.PrepareWordList(Refs.dataBank.GetSetting("lastWordList")); } else { Refs.passGen.PrepareWordList(string.Empty); } DataObject.AddCopyingHandler(txtb_passTarget, ClipboardProtection); }
public winMain(winSplash splash = null) { InitializeComponent(); DataContext = this; if (splash != null) { splash.InvokeUpdate("Loading application settings ..."); } _FormulaZoom = Settings.Default.FormulaScale; ClipBgColor.SelectedColor = Settings.Default.BgColorToClip; JpgBgColor.SelectedColor = Settings.Default.BgColorToJpg; if (splash != null) { splash.InvokeUpdate("Loading V8 javascipt engine ..."); } _ = MathjaxParser.GetInstance(); if (splash != null) { splash.InvokeUpdate("Loading application resouces ..."); } //InitializeFontSelector(); //formulaFontName = ((FontFamily)eFontFamily.GetFirstCheckedItem().Tag).ToString(); //formulaFontSize = (double)eFontSize.EditValue; DataObject.AddCopyingHandler(txtInputFomula, OnInputFomulaCopying); if (Clipboard.ContainsText()) { myClipboard.Add(Clipboard.GetText()); } if (splash != null) { splash.InvokeUpdate("Loading latex resources ..."); } LoadSymbols(); if (splash != null) { splash.InvokeUpdate("Show window ..."); } AddNotifiactions(); Application.Current.Exit += OnApplicationExit; }
public TimespanTextbox(TextBox textBox) { _textBox = textBox; _formatString = DefaultMask; textBox.PreviewTextInput += OnTextInput; textBox.PreviewKeyDown += OnPreviewKeyDown; textBox.SelectionChanged += OnSelectionChanged; DataObject.AddPastingHandler(textBox, OnPaste); _timerFormat = GetTimeFormat(textBox); //Get default //Disable the possibility to drag text inside the textBox, because bad things were happening.... DataObject.AddCopyingHandler(_textBox, (sender, e) => { if (e.IsDragDrop) { e.CancelCommand(); } }); }