本文整理汇总了C#中ICSharpCode.AvalonEdit.TextEditor类的典型用法代码示例。如果您正苦于以下问题:C# TextEditor类的具体用法?C# TextEditor怎么用?C# TextEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextEditor类属于ICSharpCode.AvalonEdit命名空间,在下文中一共展示了TextEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AvalonEditTextContainer
public AvalonEditTextContainer(TextEditor editor)
{
_editor = editor;
_currentText = SourceText.From(_editor.Text);
_editor.Document.Changed += DocumentOnChanged;
}
示例2: MainViewContent
public MainViewContent(string fileName, IWorkbenchWindow workbenchWindow)
{
codeEditor = new CodeEditor();
textEditor = new TextEditor();
textEditor.FontFamily = new FontFamily("Consolas");
textEditor.TextArea.TextEntering += TextAreaOnTextEntering;
textEditor.TextArea.TextEntered += TextAreaOnTextEntered;
textEditor.ShowLineNumbers = true;
var ctrlSpace = new RoutedCommand();
ctrlSpace.InputGestures.Add(new KeyGesture(Key.Space, ModifierKeys.Control));
var cb = new CommandBinding(ctrlSpace, OnCtrlSpaceCommand);
// this.CommandBindings.Add(cb);
adapter = new SharpSnippetTextEditorAdapter(textEditor);
this.WorkbenchWindow = workbenchWindow;
textEditor.TextArea.TextView.Services.AddService(typeof (ITextEditor), adapter);
LoadFile(fileName);
iconBarManager = new IconBarManager();
textEditor.TextArea.LeftMargins.Insert(0, new IconBarMargin(iconBarManager));
var textMarkerService = new TextMarkerService(textEditor.Document);
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
textEditor.TextArea.TextView.Services.AddService(typeof (ITextMarkerService), textMarkerService);
textEditor.TextArea.TextView.Services.AddService(typeof (IBookmarkMargin), iconBarManager);
}
示例3: GoToLineDialog
public GoToLineDialog(TextEditor textEditor) {
InitializeComponent();
this.textEditor = textEditor;
lowerLimit = 1;
upperLimit = textEditor.LineCount;
lineNumberLabel.Text = string.Format("Line Number ({0}-{1}):", lowerLimit, upperLimit);
}
示例4: Processe
/// <summary>
/// 取得配置后的处理工厂对象
/// </summary>
/// <param name="serviceType">指定为哪类服务器类型配置消息处理工厂</param>
/// <returns></returns>
public static void Processe(TextEditor rtb, EMark mark)
{
if (_procs.ContainsKey(mark))
{
_procs[mark].Process(rtb, mark);
}
}
示例5: FindTextInTextEditor
public int FindTextInTextEditor(TextEditor te, int ofst, string whatfind, ref int cor)
{
if (ofst < 0) return -1;
string searchtext = whatfind;
if (cbMatchCase.IsChecked == false) searchtext = searchtext.ToLower();
int lenst = searchtext.Length;
string tetext = "";
{
while (true)
{
if (ofst < 0) return -1;
if (cbFindUp.IsChecked == false)
{ if (ofst + lenst > te.Document.TextLength) { return -2; } }
else
{
if (ofst < 0) { return -1; }
if (ofst > te.Document.TextLength - lenst) ofst = ofst - lenst;
}
tetext = te.Document.GetText(ofst, lenst);
if (cbMatchCase.IsChecked == false) tetext = tetext.ToLower();
if (searchtext == tetext)
{
cor = tetext.Length;
return ofst;
}
if (cbFindUp.IsChecked == false) ofst++; else ofst--;
}
}
}//func
示例6: CurrentLineHighlightRenderer
public CurrentLineHighlightRenderer(TextEditor editor, ProjectItemCodeDocument projectitem)
{
_editor = editor;
_projectitem = projectitem;
_editor.TextArea.Caret.PositionChanged += (s, e) => Invalidate();
}
示例7: CodeControl
/// <summary>
/// Initializes a new instance of class CodeControl
/// </summary>
/// <param name="content">Base64 content of the web resource</param>
/// <param name="type">Web resource type</param>
public CodeControl(string content, Enumerations.WebResourceType type)
{
InitializeComponent();
textEditor = new TextEditor
{
ShowLineNumbers = true,
FontSize = 12,
FontFamily = new System.Windows.Media.FontFamily("Consolas"),
//Focusable = true,
//IsHitTestVisible = true
};
var wpfHost = new ElementHost
{
Child = textEditor,
Dock = DockStyle.Fill,
BackColorTransparent = true,
};
Controls.Add(wpfHost);
if (!string.IsNullOrEmpty(content))
{
// Converts base64 content to string
byte[] b = Convert.FromBase64String(content);
innerContent = System.Text.Encoding.UTF8.GetString(b);
originalContent = innerContent;
innerType = type;
}
}
示例8: MainForm
public MainForm() {
InitializeComponent();
// 初始化编辑器。
codeEditor = new ICSharpCode.AvalonEdit.TextEditor();
codeEditorHost.Child = codeEditor;
codeEditor.FontFamily = new System.Windows.Media.FontFamily("Consolas");
codeEditor.FontSize = 14;
codeEditor.ShowLineNumbers = true;
codeEditor.SyntaxHighlighting = syntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".js");
codeEditor.WordWrap = true;
foldingManager = FoldingManager.Install(codeEditor.TextArea);
codeEditor.TextChanged += codeEditor_TextChanged;
//codeEditor.TextArea.AddHandler(System.Windows.DataObject.PastingEvent, new System.Windows.DataObjectPastingEventHandler(codeEditor_Paste));
textMarkerService = new TextMarkerService(codeEditor);
TextView textView = codeEditor.TextArea.TextView;
textView.BackgroundRenderers.Add(textMarkerService);
textView.LineTransformers.Add(textMarkerService);
textView.Services.AddService(typeof(TextMarkerService), textMarkerService);
textView.MouseHover += MouseHover;
textView.MouseHoverStopped += codeEditorMouseHoverStopped;
textView.MouseHover += MouseHover;
textView.MouseHoverStopped += codeEditorMouseHoverStopped;
textView.VisualLinesChanged += VisualLinesChanged;
}
示例9: E2Editor
public E2Editor()
{
_settings = MainWindow.Settings ?? new Settings();
_textEditor = new TextEditor
{
SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("Expression2"),
Background = new SolidColorBrush(Color.FromRgb(0x1A, 0x1A, 0x1A)),
Foreground = new SolidColorBrush(Color.FromRgb(0xE0, 0xE0, 0xE0)),
FontFamily = _settings.Font,
ShowLineNumbers = true,
Options = {ConvertTabsToSpaces = true},
};
if (_settings.AutoIndentEnabled)
{
_textEditor.TextArea.IndentationStrategy = new E2IndentationStrategy(_textEditor.Options);
_textEditor.TextArea.TextEntered += AutoIndent_OnTextEntered;
}
try
{
using (Stream s = Resource.GetResource("E2.Functions"))
_functionData = Function.LoadData(s);
_textEditor.TextArea.TextView.LineTransformers.Add(new E2Colorizer(_functionData));
_textEditor.TextArea.TextEntered += IntelliSense_OnTextEntered;
_textEditor.TextArea.TextEntered += Insight_OnTextEntered;
}
catch (Exception)
{
if (!DesignerProperties.GetIsInDesignMode(this)) MessageBox.Show("Unable to load function data.");
//Debugger.Break();
}
AddChild(_textEditor);
}
示例10: GetPositionFromOffset
public Point GetPositionFromOffset(TextEditor editor, VisualYPosition position, int offset)
{
var startLocation = editor.TextArea.TextView.Document.GetLocation(offset);
var point = editor.TextArea.TextView.GetVisualPosition(new TextViewPosition(startLocation), position);
return new Point(Math.Round(point.X), Math.Round(point.Y));
}
示例11: SetUpFixture
public void SetUpFixture()
{
resourceWriter = new MockResourceWriter();
resourceService = new MockResourceService();
resourceService.SetResourceWriter(resourceWriter);
AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
PythonParser parser = new PythonParser();
ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text);
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(499, 309);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter adapter = new AvalonEditDocumentAdapter(document, null);
MockTextEditorOptions options = new MockTextEditorOptions();
PythonDesignerGenerator generator = new PythonDesignerGenerator(options);
generator.Merge(host, adapter, compilationUnit, serializationManager);
}
}
}
示例12: Page
public Page(string path, TextEditor viewer, WebBrowser webviewer) {
Viewer = viewer;
WebViewer = webviewer;
Root = path;
if (File.Exists(Root + @"\__page.cfg")) {
try
{
Config = JObject.Parse(File.ReadAllText(Root + @"\__page.cfg", Encoding.UTF8));
Title = (string) Config["title"] ?? path.Split('\\').Last();
}catch(Exception)
{
Config = new JObject();
Title = path.Split('\\').Last();
}
}
else
{
Config = new JObject();
Title = path.Split('\\').Last();
}
Childs = new List<Page>();
Item = new TreeViewItem { Header = Title };
Item.Selected += Click;
foreach (var dir in Directory.EnumerateDirectories(Root)) {
var p = new Page(dir, viewer, webviewer);
Childs.Add(p);
Item.Items.Add(p.Item);
}
}
示例13: AvalonEditTextEditorAdapter
public AvalonEditTextEditorAdapter(TextEditor textEditor)
{
if (textEditor == null)
throw new ArgumentNullException("textEditor");
this.textEditor = textEditor;
this.Options = new OptionsAdapter(textEditor.Options);
}
示例14: SetUpFixture
public void SetUpFixture()
{
AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
RubyParser parser = new RubyParser();
ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text);
using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
UserControl userControl = (UserControl)host.RootComponent;
userControl.ClientSize = new Size(489, 389);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(userControl, "userControl1");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
RubyDesignerGenerator generator = new RubyDesignerGenerator(new MockTextEditorOptions());
generator.Merge(host, docAdapter, compilationUnit, serializationManager);
}
}
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:26,代码来源:NoNewLineAfterInitializeComponentMethodTestFixture.cs
示例15: InvokeCompletionWindow
public static void InvokeCompletionWindow(TextEditor textEditor)
{
completionWindow = new CompletionWindow(textEditor.TextArea);
completionWindow.Closed += delegate
{
completionWindow = null;
};
var text = textEditor.Text;
var offset = textEditor.TextArea.Caret.Offset;
var completedInput = CommandCompletion.CompleteInput(text, offset, null, PSConsolePowerShell.PowerShellInstance);
// var r = CommandCompletion.MapStringInputToParsedInput(text, offset);
"InvokeCompletedInput".ExecuteScriptEntryPoint(completedInput.CompletionMatches);
if (completedInput.CompletionMatches.Count > 0)
{
completedInput.CompletionMatches.ToList()
.ForEach(record =>
{
completionWindow.CompletionList.CompletionData.Add(
new CompletionData
{
CompletionText = record.CompletionText,
ToolTip = record.ToolTip,
Resultype = record.ResultType,
ReplacementLength = completedInput.ReplacementLength
});
});
completionWindow.Show();
}
}