private async void ReadOnlyTextBox_ContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; var textbox = (TextBox)sender; if (textbox.SelectionLength > 0) { // Create a menu and add commands specifying an id value for each instead of a delegate. var menu = new PopupMenu(); menu.Commands.Add(new UICommand("Copy", null, 1)); menu.Commands.Add(new UICommandSeparator()); menu.Commands.Add(new UICommand("Highlight", null, 2)); menu.Commands.Add(new UICommand("Look up", null, 3)); // We don't want to obscure content, so pass in a rectangle representing the selection area. // NOTE: this code only handles textboxes with a single line. If a textbox has multiple lines, // then the context menu should be placed at cursor/pointer location by convention. OutputTextBlock.Text = "Context menu shown"; var rect = GetTextboxSelectionRect(textbox); var chosenCommand = await menu.ShowForSelectionAsync(rect); if (chosenCommand != null) { switch ((int)chosenCommand.Id) { case 1: var selectedText = ((TextBox)sender).SelectedText; var dataPackage = new DataPackage(); dataPackage.SetText(selectedText); Clipboard.SetContent(dataPackage); OutputTextBlock.Text = "'" + chosenCommand.Label + "'(" + chosenCommand.Id.ToString() + ") selected; '" + selectedText + "' copied to clipboard"; break; case 2: OutputTextBlock.Text = "'" + chosenCommand.Label + "'(" + chosenCommand.Id.ToString() + ") selected"; break; case 3: OutputTextBlock.Text = "'" + chosenCommand.Label + "'(" + chosenCommand.Id.ToString() + ") selected"; break; } } else { OutputTextBlock.Text = "Context menu dismissed"; } } else { OutputTextBlock.Text = "Context menu not shown because there is no text selected"; } }
async void Lipsum_ContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; TextBox t = (TextBox)sender; PopupMenu p = new PopupMenu(); p.Commands.Add(new UICommand("Cut", null, 0)); p.Commands.Add(new UICommand("Copy", null, 1)); p.Commands.Add(new UICommand("Paste", null, 2)); p.Commands.Add(new UICommand("Select All", null, 3)); p.Commands.Add(new UICommandSeparator()); p.Commands.Add(new UICommand("Delete", null, 4)); var selectedCommand = await p.ShowForSelectionAsync(GetTextBoxRect(t)); if (selectedCommand != null) { String text; DataPackage d; switch ((int)selectedCommand.Id) { case 0: //CUT text = t.SelectedText; t.SelectedText = ""; d = new DataPackage(); d.SetText(text); Clipboard.SetContent(d); break; case 1: //COPY text = t.SelectedText; d = new DataPackage(); d.SetText(text); Clipboard.SetContent(d); break; case 2: //PASTE text = await Clipboard.GetContent().GetTextAsync(); t.SelectedText = text; break; case 3: //SELECT ALL t.SelectAll(); break; case 4: //DELETE t.SelectedText = ""; break; } } }
private async void txtReadOnly_ContextMenuOpening(object sender, ContextMenuEventArgs e) { // True evita que algunos controladores vuelvan a controlar el evento de nuevo e.Handled = true; TextBox textBox = (TextBox)sender; // Nos aseguramos de haber seleccionado texto if (textBox.SelectionLength > 0) { // Se crea el menu y adicionamos los comandos con sus respectivas id var menu = new PopupMenu(); menu.Commands.Add(new UICommand("Copiar", null, 1)); // Se crea un rectangulo para el texto seleccionado Rect rect = GetTextboxSelectionRect(textBox); // Obtenemos de manera asincrona el comando elegido var comandoEscogido = await menu.ShowForSelectionAsync(rect); if (comandoEscogido != null) { // Dependiendo de la cantidad de comandos que tenemos así mismo son los casos switch ((int)comandoEscogido.Id) { case 1: String textoEscogido = txtReadOnly.SelectedText; // Se crea un dataPackege Para poder pasarlo como parametro al ClipBoard var dataPackage = new DataPackage(); // Modificamos el texto del dataPackage dataPackage.SetText(textoEscogido); // agregamos finalmente el texto al ClipBoard Clipboard.SetContent(dataPackage); break; } } } }
private void REB_Value_ContextMenuOpening_1(object sender, ContextMenuEventArgs e) { }
private void TextBox_ContextMenuOpening(object sender, ContextMenuEventArgs e) { iKnow.Text = ""; }
private void testq(object sender, ContextMenuEventArgs e) { }
private void InnerPasswordBoxOnContextMenuOpening(object sender, ContextMenuEventArgs contextMenuEventArgs) { var handler = ContextMenuOpening; if (handler != null) { handler(this, contextMenuEventArgs); } }
private void TextBlock_ContextMenuOpening(object sender, ContextMenuEventArgs e) { }
private void Leveys_ContextMenuOpening(object sender, ContextMenuEventArgs e) { }
private static async void mainBlock_ContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; RichTextBlock textbox = (RichTextBlock)sender; SceneViewModel sceneModel = textbox.DataContext as SceneViewModel; InteractiveScene interactiveScene = sceneModel.CurrentScene as InteractiveScene; if (interactiveScene.Type != SceneType.Interactive || interactiveScene.PossibleScenes.Count == 0) { return; } if (!string.IsNullOrWhiteSpace(textbox.SelectedText) && textbox.SelectedText.Length > 0) { Rect rect = GetTextboxSelectionRect(textbox); Popup popup = new Popup(); popup.VerticalOffset = rect.Y + rect.Height/2; popup.HorizontalOffset = rect.X - 5; popup.IsLightDismissEnabled = true; ScenePickerViewModel scenePickerModel = ScenePickerViewModel.Create(interactiveScene); ScenePickerControl scenePicker = new ScenePickerControl(); scenePicker.PickSceneRequest += (IScene selectedScene) => { string linkId = CreateHyperlink(textbox); scenePickerModel.LinkId = linkId; scenePickerModel.SelectedScene = selectedScene; popup.IsOpen = false; }; scenePicker.DataContext = scenePickerModel; popup.Child = scenePicker; popup.IsOpen = true; } }
private void textBox_ContextMenuOpening(object sender, ContextMenuEventArgs e) { }
private void SearchTextBox_ContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; }