本文整理汇总了C#中System.Windows.Input.RoutedUICommand.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# RoutedUICommand.Execute方法的具体用法?C# RoutedUICommand.Execute怎么用?C# RoutedUICommand.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Input.RoutedUICommand
的用法示例。
在下文中一共展示了RoutedUICommand.Execute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
void Execute(RoutedUICommand command)
{
TextArea textArea = this.TextArea;
if (textArea != null)
command.Execute(null, textArea);
}
示例2: OnDelete
internal static ExecutedRoutedEventHandler OnDelete(RoutedUICommand selectingCommand)
{
return (target, args) =>
{
TextArea textArea = GetTextArea(target);
if (textArea != null && textArea.Document != null)
{
// call BeginUpdate before running the 'selectingCommand'
// so that undoing the delete does not select the deleted character
using (textArea.Document.RunUpdate())
{
Type textAreaType = textArea.GetType();
MethodInfo method;
if (textArea.Selection.IsEmpty)
{
TextViewPosition oldCaretPosition = textArea.Caret.Position;
selectingCommand.Execute(args.Parameter, textArea);
bool hasSomethingDeletable = false;
foreach (ISegment s in textArea.Selection.Segments)
{
method = textAreaType.GetMethod("GetDeletableSegments", BindingFlags.Instance | BindingFlags.NonPublic);
//textArea.GetDeletableSegments(s).Length > 0)
if ((int)method.Invoke(textArea, new Object[]{s}) > 0)
{
hasSomethingDeletable = true;
break;
}
}
if (!hasSomethingDeletable)
{
// If nothing in the selection is deletable; then reset caret+selection
// to the previous value. This prevents the caret from moving through read-only sections.
textArea.Caret.Position = oldCaretPosition;
textArea.Selection = Selection.Empty;
}
}
method = textAreaType.GetMethod("RemoveSelectedText", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(textArea, new Object[]{});
//textArea.RemoveSelectedText();
}
textArea.Caret.BringCaretToView();
args.Handled = true;
}
};
}
示例3: OnDelete
static ExecutedRoutedEventHandler OnDelete(RoutedUICommand selectingCommand)
{
return (target, args) => {
TextArea textArea = GetTextArea(target);
if (textArea != null && textArea.Document != null) {
// call BeginUpdate before running the 'selectingCommand'
// so that undoing the delete does not select the deleted character
using (textArea.Document.RunUpdate()) {
if (textArea.Selection.IsEmpty)
selectingCommand.Execute(args.Parameter, textArea);
textArea.RemoveSelectedText();
}
textArea.Caret.BringCaretToView();
args.Handled = true;
}
};
}
示例4: OnDelete
static ExecutedRoutedEventHandler OnDelete(RoutedUICommand selectingCommand)
{
return (target, args) => {
TextArea textArea = GetTextArea(target);
if (textArea != null && textArea.Document != null) {
// call BeginUpdate before running the 'selectingCommand'
// so that undoing the delete does not select the deleted character
using (textArea.Document.RunUpdate()) {
if (textArea.Selection.IsEmpty) {
TextViewPosition oldCaretPosition = textArea.Caret.Position;
if (textArea.Caret.IsInVirtualSpace && selectingCommand == EditingCommands.SelectRightByCharacter)
EditingCommands.SelectRightByWord.Execute(args.Parameter, textArea);
else
selectingCommand.Execute(args.Parameter, textArea);
bool hasSomethingDeletable = false;
foreach (ISegment s in textArea.Selection.Segments) {
if (textArea.GetDeletableSegments(s).Length > 0) {
hasSomethingDeletable = true;
break;
}
}
if (!hasSomethingDeletable) {
// If nothing in the selection is deletable; then reset caret+selection
// to the previous value. This prevents the caret from moving through read-only sections.
textArea.Caret.Position = oldCaretPosition;
textArea.ClearSelection();
}
}
textArea.RemoveSelectedText();
}
textArea.Caret.BringCaretToView();
args.Handled = true;
}
};
}
示例5: EraseText
IEnumerable<DispatcherPriority> EraseText(RoutedUICommand deleteCommand)
{
IViewContent vc = FileService.NewFile("stresstest.cs", "");
ITextEditor editor = ((ITextEditorProvider)vc).TextEditor;
TextArea textArea = (TextArea)editor.GetService(typeof(TextArea));
editor.Document.Text = File.ReadAllText(bigFile);
editor.Caret.Offset = editor.Document.TextLength / 2;
yield return DispatcherPriority.SystemIdle;
for (int i = 0; i < Repetitions; i++) {
deleteCommand.Execute(null, textArea);
yield return DispatcherPriority.SystemIdle;
}
vc.WorkbenchWindow.CloseWindow(true);
}
示例6: EraseText
async Task EraseText(RoutedUICommand deleteCommand)
{
IViewContent vc = FileService.NewFile("stresstest.cs", "");
ITextEditor editor = vc.GetRequiredService<ITextEditor>();
TextArea textArea = editor.GetRequiredService<TextArea>();
editor.Document.Text = File.ReadAllText(bigFile);
editor.Caret.Offset = editor.Document.TextLength / 2;
await Dispatcher.Yield(Idle);
for (int i = 0; i < Repetitions; i++) {
deleteCommand.Execute(null, textArea);
await Dispatcher.Yield(Idle);
}
vc.WorkbenchWindow.CloseWindow(true);
}
示例7: cmdExecute
/// <summary>
/// Commands the execute.
/// </summary>
/// <param name="command">The command.</param>
/// <param name="par">The par.</param>
public void cmdExecute(RoutedUICommand command, object par = null)
{
_cmdIsRun = true;
command.Execute(par, rtb_Main);
_cmdIsRun = false;
}