public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl) { this.motherTextAreaControl = motherTextAreaControl; this.motherTextEditorControl = motherTextEditorControl; this.caret = new ICSharpCode.TextEditor.Caret(this); this.selectionManager = new ICSharpCode.TextEditor.Document.SelectionManager(this.Document, this); this.textAreaClipboardHandler = new TextAreaClipboardHandler(this); base.ResizeRedraw = true; base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); base.SetStyle(ControlStyles.Opaque, false); base.SetStyle(ControlStyles.ResizeRedraw, true); base.SetStyle(ControlStyles.Selectable, true); this.textView = new ICSharpCode.TextEditor.TextView(this); this.gutterMargin = new ICSharpCode.TextEditor.GutterMargin(this); this.foldMargin = new ICSharpCode.TextEditor.FoldMargin(this); this.iconBarMargin = new ICSharpCode.TextEditor.IconBarMargin(this); List <AbstractMargin> abstractMargins = this.leftMargins; AbstractMargin[] abstractMarginArray = new AbstractMargin[] { this.iconBarMargin, this.gutterMargin, this.foldMargin }; abstractMargins.AddRange(abstractMarginArray); this.OptionsChanged(); (new TextAreaMouseHandler(this)).Attach(); (new TextAreaDragDropHandler()).Attach(this); this.bracketshemes.Add(new BracketHighlightingSheme('{', '}')); this.bracketshemes.Add(new BracketHighlightingSheme('(', ')')); this.bracketshemes.Add(new BracketHighlightingSheme('[', ']')); this.caret.PositionChanged += new EventHandler(this.SearchMatchingBracket); this.Document.TextContentChanged += new EventHandler(this.TextContentChanged); this.Document.FoldingManager.FoldingsChanged += new EventHandler(this.DocumentFoldingsChanged); }
public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl) { this.motherTextAreaControl = motherTextAreaControl; this.motherTextEditorControl = motherTextEditorControl; caret = new Caret(this); selectionManager = new SelectionManager(Document, this); this.textAreaClipboardHandler = new TextAreaClipboardHandler(this); ResizeRedraw = true; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // SetStyle(ControlStyles.AllPaintingInWmPaint, true); // SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.Opaque, false); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.Selectable, true); textView = new TextView(this); gutterMargin = new GutterMargin(this); foldMargin = new FoldMargin(this); iconBarMargin = new IconBarMargin(this); leftMargins.AddRange(new AbstractMargin[] { iconBarMargin, gutterMargin, foldMargin }); OptionsChanged(); new TextAreaMouseHandler(this).Attach(); // 下列语句需要在STAThread 下才能运行 //new TextAreaDragDropHandler().Attach(this); bracketshemes.Add(new BracketHighlightingSheme('{', '}')); bracketshemes.Add(new BracketHighlightingSheme('(', ')')); bracketshemes.Add(new BracketHighlightingSheme('[', ']')); caret.PositionChanged += new EventHandler(SearchMatchingBracket); Document.TextContentChanged += new EventHandler(TextContentChanged); Document.FoldingManager.FoldingsChanged += new EventHandler(DocumentFoldingsChanged); }
public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl) { MotherTextAreaControl = motherTextAreaControl; MotherTextEditorControl = motherTextEditorControl; Caret = new Caret(this); SelectionManager = new SelectionManager(Document, this); ClipboardHandler = new TextAreaClipboardHandler(this); ResizeRedraw = true; SetStyle(ControlStyles.OptimizedDoubleBuffer, value: true); // SetStyle(ControlStyles.AllPaintingInWmPaint, true); // SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.Opaque, value: false); SetStyle(ControlStyles.ResizeRedraw, value: true); SetStyle(ControlStyles.Selectable, value: true); TextView = new TextView(this); GutterMargin = new GutterMargin(this); FoldMargin = new FoldMargin(this); IconBarMargin = new IconBarMargin(this); leftMargins.AddRange(new AbstractMargin[] { IconBarMargin, GutterMargin, FoldMargin }); OptionsChanged(); new TextAreaMouseHandler(this).Attach(); new TextAreaDragDropHandler().Attach(this); bracketshemes.Add(new BracketHighlightingSheme(opentag: '{', closingtag: '}')); bracketshemes.Add(new BracketHighlightingSheme(opentag: '(', closingtag: ')')); bracketshemes.Add(new BracketHighlightingSheme(opentag: '[', closingtag: ']')); Caret.PositionChanged += SearchMatchingBracket; Document.TextContentChanged += TextContentChanged; Document.FoldingManager.FoldingsChanged += DocumentFoldingsChanged; }
private bool CopyTextToClipboard(string stringToCopy, bool asLine) { if (stringToCopy.Length <= 0) { return(false); } DataObject dataObject = new DataObject(); dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy); if (asLine) { MemoryStream memoryStream = new MemoryStream(1); memoryStream.WriteByte(1); dataObject.SetData("MSDEVLineSelect", false, memoryStream); } if (this.textArea.Document.HighlightingStrategy.Name != "Default") { dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(this.textArea)); } this.OnCopyText(new CopyTextEventArgs(stringToCopy)); TextAreaClipboardHandler.SafeSetClipboard(dataObject); return(true); }
public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl) { this.motherTextAreaControl = motherTextAreaControl; this.motherTextEditorControl = motherTextEditorControl; caret = new Caret(this); selectionManager = new SelectionManager(Document); this.textAreaClipboardHandler = new TextAreaClipboardHandler(this); ResizeRedraw = true; SetStyle(ControlStyles.DoubleBuffer, false); // SetStyle(ControlStyles.AllPaintingInWmPaint, true); // SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.Opaque, false); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.Selectable, true); textView = new TextView(this); gutterMargin = new GutterMargin(this); foldMargin = new FoldMargin(this); iconBarMargin = new IconBarMargin(this); leftMargins.AddRange(new AbstractMargin[] { iconBarMargin, gutterMargin, foldMargin }); OptionsChanged(); new TextAreaMouseHandler(this).Attach(); new TextAreaDragDropHandler().Attach(this); bracketshemes.Add(new BracketHighlightingSheme('{', '}')); bracketshemes.Add(new BracketHighlightingSheme('(', ')')); bracketshemes.Add(new BracketHighlightingSheme('[', ']')); caret.PositionChanged += new EventHandler(SearchMatchingBracket); Document.TextContentChanged += new EventHandler(TextContentChanged); Document.FoldingManager.FoldingsChanged += new EventHandler(DocumentFoldingsChanged); }