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


C# ITextEditor.GetService方法代码示例

本文整理汇总了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;
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:27,代码来源:XamlLanguageBinding.cs

示例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;
			}
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:30,代码来源:CSharpTextEditorExtension.cs

示例3: ModuleOutlineControl

        void ITextEditorExtension.Attach(ITextEditor editor)
        {
            _outlineContent = new ModuleOutlineControl(editor);

            _textView = editor.GetService(typeof(TextView)) as TextView;
            _textView.Services.AddService(typeof(IOutlineContentHost), _outlineContent);
        }
开发者ID:mks786,项目名称:vb6leap,代码行数:7,代码来源:VbpTextEditorExtension.cs

示例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();
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:32,代码来源:ContextActionsPopupBase.cs

示例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)));
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:8,代码来源:CreatePropertiesCommand.cs

示例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;
     }
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:8,代码来源:SearchOptions.cs

示例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;
                 }
 }
开发者ID:voland,项目名称:ViSD,代码行数:10,代码来源:main.cs

示例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);
			}
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:10,代码来源:EmbeddedImageTextEditorExtension.cs

示例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);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:12,代码来源:XmlLanguageBinding.cs

示例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);
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:13,代码来源:SnippetCompletionItem.cs

示例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);
		}
开发者ID:GMRyujin,项目名称:SharpDevelop,代码行数:16,代码来源:CodeManipulation.cs

示例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);
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:16,代码来源:CaretReferenceHighlightRenderer.cs

示例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);
		}
开发者ID:siegfriedpammer,项目名称:SharpDevelop,代码行数:19,代码来源:PinningBinding.cs

示例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);
		}
开发者ID:Inzaghi2012,项目名称:SharpDevelop,代码行数:22,代码来源:CaretReferenceHighlightRenderer.cs

示例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;
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:23,代码来源:ContextActionsPopup.cs


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