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


C# TextArea.OnTextCopied方法代码示例

本文整理汇总了C#中ICSharpCode.AvalonEdit.Editing.TextArea.OnTextCopied方法的典型用法代码示例。如果您正苦于以下问题:C# TextArea.OnTextCopied方法的具体用法?C# TextArea.OnTextCopied怎么用?C# TextArea.OnTextCopied使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.AvalonEdit.Editing.TextArea的用法示例。


在下文中一共展示了TextArea.OnTextCopied方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyWholeLine

		const string LineSelectedType = "MSDEVLineSelect";  // This is the type VS 2003 and 2005 use for flagging a whole line copy
		
		static void CopyWholeLine(TextArea textArea, DocumentLine line)
		{
			ISegment wholeLine = new SimpleSegment(line.Offset, line.TotalLength);
			string text = textArea.Document.GetText(wholeLine);
			// Ensure we use the appropriate newline sequence for the OS
			text = NewLineFinder.NormalizeNewLines(text, Environment.NewLine);
			DataObject data = new DataObject(text);
			
			// Also copy text in HTML format to clipboard - good for pasting text into Word
			// or to the SharpDevelop forums.
			IHighlighter highlighter = textArea.GetService(typeof(IHighlighter)) as IHighlighter;
			HtmlClipboard.SetHtml(data, HtmlClipboard.CreateHtmlFragment(textArea.Document, highlighter, wholeLine, new HtmlOptions(textArea.Options)));
			
			MemoryStream lineSelected = new MemoryStream(1);
			lineSelected.WriteByte(1);
			data.SetData(LineSelectedType, lineSelected, false);
			
			try {
				Clipboard.SetDataObject(data, true);
			} catch (ExternalException) {
				// Apparently this exception sometimes happens randomly.
				// The MS controls just ignore it, so we'll do the same.
				return;
			}
			textArea.OnTextCopied(new TextEventArgs(text));
		}
开发者ID:pusp,项目名称:o2platform,代码行数:28,代码来源:EditingCommandHandler.cs

示例2: CopySelectedText

		static void CopySelectedText(TextArea textArea)
		{
			var data = textArea.Selection.CreateDataObject(textArea);
			
			try {
				Clipboard.SetDataObject(data, true);
			} catch (ExternalException) {
				// Apparently this exception sometimes happens randomly.
				// The MS controls just ignore it, so we'll do the same.
				return;
			}
			
			string text = textArea.Selection.GetText(textArea.Document);
			text = NewLineFinder.NormalizeNewLines(text, Environment.NewLine);
			textArea.OnTextCopied(new TextEventArgs(text));
		}
开发者ID:pusp,项目名称:o2platform,代码行数:16,代码来源:EditingCommandHandler.cs

示例3: CopyWholeLine

        static void CopyWholeLine(TextArea textArea, DocumentLine line)
        {
            ISegment wholeLine = new SimpleSegment(line.Offset, line.TotalLength);
            string text = textArea.Document.GetText(wholeLine);
            // Ensure we use the appropriate newline sequence for the OS
            text = NewLineFinder.NormalizeNewLines(text, Environment.NewLine);
            DataObject data = new DataObject(text);

            // Also copy text in HTML format to clipboard - good for pasting text into Word
            // or to the SharpDevelop forums.
            DocumentHighlighter highlighter = textArea.GetService(typeof(DocumentHighlighter)) as DocumentHighlighter;
            HtmlClipboard.SetHtml(data, HtmlClipboard.CreateHtmlFragment(textArea.Document, highlighter, wholeLine, new HtmlOptions(textArea.Options)));

            MemoryStream lineSelected = new MemoryStream(1);
            lineSelected.WriteByte(1);
            data.SetData(LineSelectedType, lineSelected, false);

            Clipboard.SetDataObject(data, true);

            textArea.OnTextCopied(new TextEventArgs(text));
        }
开发者ID:kjk,项目名称:kjkpub,代码行数:21,代码来源:EditingCommandHandler.cs

示例4: CopySelectedText

		static bool CopySelectedText(TextArea textArea)
		{
			var data = textArea.Selection.CreateDataObject(textArea);
			var copyingEventArgs = new DataObjectCopyingEventArgs(data, false);
			textArea.RaiseEvent(copyingEventArgs);
			if (copyingEventArgs.CommandCancelled)
				return false;
			
			try {
				Clipboard.SetDataObject(data, true);
			} catch (ExternalException) {
				// Apparently this exception sometimes happens randomly.
				// The MS controls just ignore it, so we'll do the same.
			}
			
			string text = textArea.Selection.GetText();
			text = TextUtilities.NormalizeNewLines(text, Environment.NewLine);
			textArea.OnTextCopied(new TextEventArgs(text));
			return true;
		}
开发者ID:krolli,项目名称:ILSpy,代码行数:20,代码来源:EditingCommandHandler.cs

示例5: CopySelectedText

        static void CopySelectedText(TextArea textArea)
        {
            Clipboard.SetDataObject(textArea.Selection.CreateDataObject(textArea), true);

            string text = textArea.Selection.GetText(textArea.Document);
            text = NewLineFinder.NormalizeNewLines(text, Environment.NewLine);
            textArea.OnTextCopied(new TextEventArgs(text));
        }
开发者ID:kjk,项目名称:kjkpub,代码行数:8,代码来源:EditingCommandHandler.cs


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