当前位置: 首页>>代码示例>>C#>>正文


C# RoutedUICommand.Execute方法代码示例

本文整理汇总了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);
 }
开发者ID:rtnm,项目名称:AvalonEdit,代码行数:6,代码来源:TextEditor.cs

示例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;
         }
     };
 }
开发者ID:goutkannan,项目名称:ironlab,代码行数:45,代码来源:PythonEditingCommandHandler.cs

示例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;
				}
			};
		}
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:17,代码来源:EditingCommandHandler.cs

示例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;
				}
			};
		}
开发者ID:JadeHub,项目名称:Jade,代码行数:35,代码来源:EditingCommandHandler.cs

示例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);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:14,代码来源:UserControl.xaml.cs

示例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);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:14,代码来源:UserControl.xaml.cs

示例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;

        }
开发者ID:alexiej,项目名称:YATE,代码行数:12,代码来源:YATEditor.cmd.cs


注:本文中的System.Windows.Input.RoutedUICommand.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。