本文整理汇总了C#中ICSharpCode.TextEditor.TextEditorControl类的典型用法代码示例。如果您正苦于以下问题:C# TextEditorControl类的具体用法?C# TextEditorControl怎么用?C# TextEditorControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextEditorControl类属于ICSharpCode.TextEditor命名空间,在下文中一共展示了TextEditorControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTextBox
private TextEditorControl CreateTextBox()
{
var tb = new TextEditorControl();
tb.IsReadOnly = true;
// TODO: set proper highlighting.
tb.SetHighlighting("C#");
var high = (ICSharpCode.TextEditor.Document.DefaultHighlightingStrategy)tb.Document.HighlightingStrategy;
var def = high.Rules.First();
var delim = " ,().:\t\n\r";
for(int i = 0; i < def.Delimiters.Length; ++i)
def.Delimiters[i] = delim.Contains((char)i);
tb.ShowLineNumbers = false;
tb.ShowInvalidLines = false;
tb.ShowVRuler = false;
tb.ActiveTextAreaControl.TextArea.ToolTipRequest += OnToolTipRequest;
tb.ActiveTextAreaControl.TextArea.MouseMove += OnTextAreaMouseMove;
string[] tryFonts = new[] { "Consolas", "Lucida Console" };
foreach (var fontName in tryFonts)
{
tb.Font = new Font(fontName, 9, FontStyle.Regular);
if (tb.Font.Name == fontName) break;
}
if (!tryFonts.Contains(tb.Font.Name))
tb.Font = new Font(FontFamily.GenericMonospace, 9);
return tb;
}
示例2: CreateEditor
/// <summary>
/// Creates the appropriate ITextEditor instance for the given text editor
/// </summary>
/// <param name="textEditor">The text editor instance</param>
/// <returns></returns>
public static ITextEditor CreateEditor(TextEditorControl textEditor)
{
if (Platform.IsRunningOnMono)
return new MonoCompatibleTextEditor(textEditor);
else
return new DefaultTextEditor(textEditor);
}
示例3: TextAreaControl
public TextAreaControl(TextEditorControl motherTextEditorControl)
{
this.motherTextEditorControl = motherTextEditorControl;
this.textArea = new TextArea(motherTextEditorControl, this);
Controls.Add(textArea);
vScrollBar.ValueChanged += new EventHandler(VScrollBarValueChanged);
Controls.Add(this.vScrollBar);
hScrollBar.ValueChanged += new EventHandler(HScrollBarValueChanged);
Controls.Add(this.hScrollBar);
ResizeRedraw = true;
Document.TextContentChanged += DocumentTextContentChanged;
Document.DocumentChanged += AdjustScrollBarsOnDocumentChange;
Document.UpdateCommited += DocumentUpdateCommitted;
vScrollBar.VisibleChanged += (sender, e) =>
{
if (!vScrollBar.Visible)
vScrollBar.Value = 0;
};
hScrollBar.VisibleChanged += (sender, e) =>
{
if (!hScrollBar.Visible)
hScrollBar.Value = 0;
};
}
示例4: ShowFor
public void ShowFor(TextEditorControl editor, bool replaceMode)
{
//this.Text = replaceMode ? "查找和替换" : "查找";
Editor = editor;
_search.ClearScanRegion();
SelectionManager sm = editor.ActiveTextAreaControl.SelectionManager;
if (sm.HasSomethingSelected && sm.SelectionCollection.Count == 1) {
ISelection sel = sm.SelectionCollection[0];
if (sel.StartPosition.Line == sel.EndPosition.Line)
txtLookFor.Text = sm.SelectedText;
else
_search.SetScanRegion(sel);
} else {
// Get the current word that the caret is on
Caret caret = editor.ActiveTextAreaControl.Caret;
int start = TextUtilities.FindWordStart(editor.Document, caret.Offset);
int endAt = TextUtilities.FindWordEnd(editor.Document, caret.Offset);
txtLookFor.Text = editor.Document.GetText(start, endAt - start);
}
ReplaceMode = replaceMode;
this.Owner = (Form)editor.TopLevelControl;
this.Show();
txtLookFor.SelectAll();
txtLookFor.Focus();
}
示例5: EditValue
/// <inheritdoc/>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
#region Sanity checks
if (context == null) throw new ArgumentNullException(nameof(context));
if (provider == null) throw new ArgumentNullException(nameof(provider));
#endregion
var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (editorService == null) return value;
var editorControl = new TextEditorControl {Text = value as string, Dock = DockStyle.Fill};
var form = new Form
{
FormBorderStyle = FormBorderStyle.SizableToolWindow,
ShowInTaskbar = false,
Controls = {editorControl}
};
var fileType = context.PropertyDescriptor.Attributes.OfType<FileTypeAttribute>().FirstOrDefault();
if (fileType != null)
{
editorControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(fileType.FileType);
form.Text = fileType.FileType + " Editor";
}
else form.Text = "Editor";
editorService.ShowDialog(form);
return editorControl.Text;
}
示例6: SetContent
/// <summary>
/// Sets a new text to be edited.
/// </summary>
/// <param name="text">The text to set.</param>
/// <param name="format">The format named used to determine the highlighting scheme (e.g. XML).</param>
public void SetContent(string text, string format)
{
var textEditor = new TextEditorControl
{
Location = new Point(0, 0),
Size = Size - new Size(0, statusStrip.Height),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
TabIndex = 0,
ShowVRuler = false,
Document =
{
TextContent = text,
HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(format)
}
};
textEditor.TextChanged += TextEditor_TextChanged;
textEditor.Validating += TextEditor_Validating;
Controls.Add(textEditor);
if (TextEditor != null)
{
Controls.Remove(TextEditor);
TextEditor.Dispose();
}
TextEditor = textEditor;
SetStatus(ImageResources.Info, "OK");
}
示例7: SetLine
public static void SetLine(TextEditorControl tec, int line)
{
TextArea textArea = tec.ActiveTextAreaControl.TextArea;
textArea.Caret.Column = 0;
textArea.Caret.Line = line;
textArea.Caret.UpdateCaretPosition();
}
示例8: IncrementalSearch
/// <summary>
/// Creates an incremental search for the specified text editor.
/// </summary>
/// <param name="textEditor">The text editor to search in.</param>
/// <param name="forwards">Indicates whether the search goes
/// forward from the cursor or backwards.</param>
public IncrementalSearch(TextEditorControl textEditor, bool forwards)
{
this.forwards = forwards;
if (forwards) {
incrementalSearchStartMessage = StringParser.Parse("${res:ICSharpCode.SharpDevelop.DefaultEditor.IncrementalSearch.ForwardsSearchStatusBarMessage} ");
} else {
incrementalSearchStartMessage = StringParser.Parse("${res:ICSharpCode.SharpDevelop.DefaultEditor.IncrementalSearch.ReverseSearchStatusBarMessage} ");
}
this.textEditor = textEditor;
// Disable code completion.
codeCompletionEnabled = CodeCompletionOptions.EnableCodeCompletion;
CodeCompletionOptions.EnableCodeCompletion = false;
AddFormattingStrategy();
TextArea.KeyEventHandler += TextAreaKeyPress;
TextArea.DoProcessDialogKey += TextAreaProcessDialogKey;
TextArea.LostFocus += TextAreaLostFocus;
TextArea.MouseClick += TextAreaMouseClick;
EnableIncrementalSearchCursor();
// Get text to search and initial search position.
text = textEditor.Document.TextContent;
startIndex = TextArea.Caret.Offset;
originalStartIndex = startIndex;
GetInitialSearchText();
ShowTextFound(searchText.ToString());
}
示例9: DiffPanel
public DiffPanel(IViewContent viewContent)
{
this.viewContent = viewContent;
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
textEditor = new TextEditorControl();
textEditor.Dock = DockStyle.Fill;
diffViewPanel.Controls.Add(textEditor);
textEditor.TextEditorProperties = SharpDevelopTextEditorProperties.Instance;
textEditor.Document.ReadOnly = true;
textEditor.Enabled = false;
textEditor.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("Patch");
ListViewItem newItem;
newItem = new ListViewItem(new string[] { "Base", "", "", "" });
newItem.Tag = Revision.Base;
leftListView.Items.Add(newItem);
newItem.Selected = true;
newItem = new ListViewItem(new string[] { "Work", "", "", "" });
newItem.Tag = Revision.Working;
rightListView.Items.Add(newItem);
}
示例10: FdoSqlQueryCtl
public FdoSqlQueryCtl()
{
InitializeComponent();
_editor = new TextEditorControl();
_editor.Dock = DockStyle.Fill;
_editor.SetHighlighting("SQL");
this.Controls.Add(_editor);
}
示例11: GetEditor
public override System.Windows.Forms.Control GetEditor()
{
//return base.GetEditor();
if (textEditor == null)
textEditor = new TextEditorControl();
return textEditor;
}
示例12: Goto
public Goto(TextEditorControl editor)
{
InitializeComponent();
Editor = editor;
Editor.TextChanged += Editor_TextChanged;
UpdateMaximumLine();
numericUpDown.Select(0, numericUpDown.Value.ToString().Length);
}
示例13: IdeBridgeCodeCompletionWindow
protected IdeBridgeCodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth)
: base(completionDataProvider, completionData, parentForm, control, showDeclarationWindow, fixedListViewWidth)
{
TopMost = true;
declarationViewWindow.Dispose();
declarationViewWindow = new DeclarationViewWindow(null);
declarationViewWindow.TopMost = true;
SetDeclarationViewLocation();
}
示例14: Test_DeleteNotEmptyAt0
public void Test_DeleteNotEmptyAt0()
{
ICSharpCode.TextEditor.TextEditorControl textEditorControl = new ICSharpCode.TextEditor.TextEditorControl();
textEditorControl.Text = "test content";
textEditorTextContext = new TextEditorTextContext(textEditorControl);
DeleteOperation delete = new DeleteOperation(0);
textEditorTextContext.Delete(null, delete);
Assert.AreEqual("est content", textEditorTextContext.Data, "Inconsistent state after deletion!");
}
示例15: Ast_CSharp_ShowDetailsInViewer
public Ast_CSharp_ShowDetailsInViewer(TextEditorControl _textEditorControl, TabControl _tabControl)
{
/*sourceCodeEditor = _sourceCodeEditor;
tabControl = (TabControl)sourceCodeEditor.field("tcSourceInfo");
* */
tabControl = _tabControl;
textEditorControl = _textEditorControl;
createGUI();
}