本文整理汇总了C#中ITextEditor.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# ITextEditor.GetService方法的具体用法?C# ITextEditor.GetService怎么用?C# ITextEditor.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextEditor
的用法示例。
在下文中一共展示了ITextEditor.GetService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Attach
public override void Attach(ITextEditor editor)
{
base.Attach(editor);
// try to access the ICSharpCode.AvalonEdit.Rendering.TextView
// of this ITextEditor
this.textView = editor.GetService(typeof(TextView)) as TextView;
// if editor is not an AvalonEdit.TextEditor
// GetService returns null
if (textView != null) {
if (SD.Workbench != null) {
// if (XamlBindingOptions.UseAdvancedHighlighting) {
// colorizer = new XamlColorizer(editor, textView);
// // attach the colorizer
// textView.LineTransformers.Add(colorizer);
// }
// add the XamlOutlineContentHost, which manages the tree view
contentHost = new XamlOutlineContentHost(editor);
textView.Services.AddService(typeof(IOutlineContentHost), contentHost);
}
// add ILanguageBinding
textView.Services.AddService(typeof(XamlTextEditorExtension), this);
}
SD.ParserService.ParseInformationUpdated += ParseInformationUpdated;
}
示例2: Attach
public void Attach(ITextEditor editor)
{
this.editor = editor;
inspectionManager = new IssueManager(editor);
codeManipulation = new CodeManipulation(editor);
renderer = new CaretReferenceHighlightRenderer(editor);
// Patch editor options (indentation) to project-specific settings
if (!editor.ContextActionProviders.IsReadOnly) {
contextActionProviders = AddInTree.BuildItems<IContextActionProvider>("/SharpDevelop/ViewContent/TextEditor/C#/ContextActions", null);
editor.ContextActionProviders.AddRange(contextActionProviders);
}
// Create instance of options adapter and register it as service
var formattingPolicy = CSharpFormattingPolicies.Instance.GetProjectOptions(SD.ProjectService.FindProjectContainingFile(editor.FileName));
var textEditor = editor.GetService<TextEditor>();
if (textEditor != null) {
options = new CodeEditorFormattingOptionsAdapter(textEditor.Options, editor.Options, formattingPolicy.OptionsContainer);
var textViewServices = textEditor.TextArea.TextView.Services;
// Unregister any previous ITextEditorOptions instance from editor, if existing, register our impl.
textViewServices.RemoveService(typeof(ITextEditorOptions));
textViewServices.AddService(typeof(ITextEditorOptions), options);
// Set TextEditor's options to same object
originalEditorOptions = textEditor.Options;
textEditor.Options = options.TextEditorOptions;
}
}
示例3: ModuleOutlineControl
void ITextEditorExtension.Attach(ITextEditor editor)
{
_outlineContent = new ModuleOutlineControl(editor);
_textView = editor.GetService(typeof(TextView)) as TextView;
_textView.Services.AddService(typeof(IOutlineContentHost), _outlineContent);
}
示例4: OpenAtPosition
protected void OpenAtPosition(ITextEditor editor, int line, int column, bool openAtWordStart)
{
var editorUIService = editor == null ? null : editor.GetService(typeof(IEditorUIService)) as IEditorUIService;
if (editorUIService != null) {
var document = editor.Document;
int offset = document.PositionToOffset(line, column);
if (openAtWordStart) {
int wordStart = document.FindPrevWordStart(offset);
if (wordStart != -1) {
var wordStartLocation = document.OffsetToPosition(wordStart);
line = wordStartLocation.Line;
column = wordStartLocation.Column;
}
}
this.Placement = PlacementMode.Absolute;
try
{
var caretScreenPos = editorUIService.GetScreenPosition(line, column);
this.HorizontalOffset = caretScreenPos.X;
this.VerticalOffset = caretScreenPos.Y;
}
catch
{
this.Placement = PlacementMode.MousePoint;
}
} else {
// if no editor information, open at mouse positions
this.Placement = PlacementMode.MousePoint;
}
this.Open();
}
示例5: Run
protected override void Run(ITextEditor textEditor, RefactoringProvider provider)
{
new Snippet {
Elements = {
new InlineRefactorSnippetElement(context => CreateProperties.CreateDialog(context), "")
}
}.Insert((TextArea)textEditor.GetService(typeof(TextArea)));
}
示例6: Attach
public void Attach(ITextEditor editor)
{
TextArea textArea = editor.GetService(typeof(TextArea)) as TextArea;
if (textArea != null) {
panel = SearchPanel.Install(textArea);
panel.SearchOptionsChanged += SearchOptionsChanged;
}
}
示例7: Attach
public override void Attach(ITextEditor editor)
{
base.Attach(editor);
te = editor.GetService(typeof(TextEditor)) as TextEditor;
if ( te !=null){
ta = te.TextArea;
vh = new VimHandler(ta, editor.FileName);
ta.ActiveInputHandler = vh;
}
}
示例8: Attach
public void Attach(ITextEditor editor)
{
// ITextEditor is SharpDevelop's abstraction of the text editor.
// We use GetService() to get the underlying AvalonEdit instance.
textView = editor.GetService(typeof(TextView)) as TextView;
if (textView != null) {
g = new ImageElementGenerator(Path.GetDirectoryName(editor.FileName));
textView.ElementGenerators.Add(g);
}
}
示例9: Attach
public override void Attach(ITextEditor editor)
{
// HACK: disable SharpDevelop's built-in folding
codeEditorView = editor.GetService(typeof(AvalonEdit.TextEditor)) as AvalonEdit.AddIn.CodeEditorView;
DisableParseInformationFolding();
foldingManager = new XmlFoldingManager(editor);
foldingManager.UpdateFolds();
foldingManager.Start();
base.Attach(editor);
}
示例10: SnippetCompletionItem
public SnippetCompletionItem(ITextEditor textEditor, CodeSnippet codeSnippet)
{
if (textEditor == null)
throw new ArgumentNullException("textEditor");
if (codeSnippet == null)
throw new ArgumentNullException("codeSnippet");
this.textEditor = textEditor;
this.textArea = textEditor.GetService(typeof(TextArea)) as TextArea;
if (textArea == null)
throw new ArgumentException("textEditor must be an AvalonEdit text editor");
this.codeSnippet = codeSnippet;
this.Priority = CodeCompletionDataUsageCache.GetPriority("snippet" + codeSnippet.Name, true);
}
示例11: CodeManipulation
public CodeManipulation(ITextEditor editor)
{
this.editor = editor;
this.editor.SelectionChanged += CodeManipulationSelectionChanged;
TextArea area = (TextArea)editor.GetService(typeof(TextArea));
bindings = new List<CommandBinding> {
new CommandBinding(ExtendSelectionCommand, ExtendSelectionExecuted),
new CommandBinding(ShrinkSelectionCommand, ShrinkSelectionExecuted),
new CommandBinding(MoveStatementUpCommand, MoveStatementUpExecuted),
new CommandBinding(MoveStatementDownCommand, MoveStatementDownExecuted)
};
area.DefaultInputHandler.CommandBindings.AddRange(bindings);
}
示例12: CaretReferenceHighlightRenderer
public CaretReferenceHighlightRenderer(ITextEditor editor)
{
if (editor == null)
throw new ArgumentNullException("editor");
this.editor = editor;
this.textView = editor.GetService<TextView>();
this.borderPen = new Pen(new SolidColorBrush(DefaultBorderColor), borderThickness);
this.backgroundBrush = new SolidColorBrush(DefaultFillColor);
this.borderPen.Freeze();
this.backgroundBrush.Freeze();
editor.Caret.LocationChanged += CaretLocationChanged;
textView.VisualLinesChanged += VisualLinesChanged;
SD.ParserService.ParseInformationUpdated += ParseInformationUpdated;
SD.ParserService.LoadSolutionProjectsThread.Finished += LoadSolutionProjectsThreadFinished;
this.textView.BackgroundRenderers.Add(this);
}
示例13: Attach
public override void Attach(ITextEditor editor)
{
if (editor == null)
return;
var textEditor = editor.GetService(typeof(TextEditor)) as TextEditor;
if (textEditor != null) {
pinLayer = new PinLayer(textEditor.TextArea);
textEditor.TextArea.TextView.InsertLayer(
pinLayer,
KnownLayer.Caret,
LayerInsertionPosition.Above);
}
_editor = editor;
CreatePins(_editor);
base.Attach(editor);
}
示例14: CaretReferenceHighlightRenderer
public CaretReferenceHighlightRenderer(ITextEditor editor)
{
if (editor == null)
throw new ArgumentNullException("editor");
this.editor = editor;
this.textView = editor.GetService<TextView>();
this.borderPen = new Pen(new SolidColorBrush(DefaultBorderColor), borderThickness);
this.backgroundBrush = new SolidColorBrush(DefaultFillColor);
this.borderPen.Freeze();
this.backgroundBrush.Freeze();
this.timer = new DispatcherTimer {
Interval = TimeSpan.FromMilliseconds(500)
};
timer.Tick += (sender, e) => ResolveAtCaret();
editor.Caret.LocationChanged += CaretLocationChanged;
editor.Document.ChangeCompleted += DocumentChanged;
textView.VisualLinesChanged += VisualLinesChanged;
SD.ParserService.ParseInformationUpdated += ParseInformationUpdated;
SD.ParserService.LoadSolutionProjectsThread.Finished += LoadSolutionProjectsThreadFinished;
this.textView.BackgroundRenderers.Add(this);
}
示例15: SetPosition
public static void SetPosition(Popup popup, ITextEditor editor, int line, int column, bool openAtWordStart = false)
{
var editorUIService = editor == null ? null : editor.GetService(typeof(IEditorUIService)) as IEditorUIService;
if (editorUIService != null) {
var document = editor.Document;
int offset = document.GetOffset(line, column);
if (openAtWordStart) {
int wordStart = document.FindPrevWordStart(offset);
if (wordStart != -1) {
var wordStartLocation = document.GetLocation(wordStart);
line = wordStartLocation.Line;
column = wordStartLocation.Column;
}
}
var caretScreenPos = editorUIService.GetScreenPosition(line, column);
popup.HorizontalOffset = caretScreenPos.X;
popup.VerticalOffset = caretScreenPos.Y;
popup.Placement = PlacementMode.Absolute;
} else {
// if no editor information, open at mouse positions
popup.Placement = PlacementMode.MousePoint;
}
}