// This method should only be called once (it is normally called from the ctor unless we're using // ITextEditorFactoryService2.CreateTextViewHostWithoutInitialization on the factory to delay initialization). internal void Initialize() { if (_hasInitializeBeenCalled) { throw new InvalidOperationException("Attempted to Initialize a WpfTextViewHost twice"); } _hasInitializeBeenCalled = true; var documentFactoryService = CompositionManager.GetExportedValue <Microsoft.VisualStudio.Text.ITextDocumentFactoryService>(); var contentTypeRegistryService = CompositionManager.GetExportedValue <Microsoft.VisualStudio.Utilities.IContentTypeRegistryService>(); var contentType = contentTypeRegistryService.GetContentType("Text"); var textBuffer = PlatformCatalog.Instance.TextBufferFactoryService.CreateTextBuffer(@" class Test { public static void Main (string[] args) { } } ", contentType); var document = documentFactoryService.CreateTextDocument(textBuffer, "/a.cs"); var dataModel = new VacuousTextDataModel(document.TextBuffer); var viewModel = new VacuousTextViewModel(dataModel); var textFactory = (TextEditorFactoryService)PlatformCatalog.Instance.TextEditorFactoryService; TextView = new SkiaTextView(viewModel, textFactory.AllPredefinedRoles, textFactory.EditorOptionsFactoryService.GlobalOptions, textFactory); }
public AdornmentLayer(SkiaTextView view, string name, bool isOverlayLayer = false) { _view = view; _elements = new List <AdornmentAndData>(); _name = name; //An adornment in the overlay layer only supports adornments with the OwnerControlled behavior _isOverlayLayer = isOverlayLayer; }
/// <summary> /// Constructs a new selection Element that is bound to the specified editor canvas /// </summary> /// <param name="wpfTextView"> /// The WPF Text View that hosts this caret /// </param> public SkiaTextCaret( SkiaTextView wpfTextView, SkiaTextSelection selection, ISmartIndentationService smartIndentationService, IEditorFormatMap editorFormatMap, //IClassificationFormatMap classificationFormatMap, GuardedOperations guardedOperations) { // Verify Debug.Assert(wpfTextView != null); _regularBrush = new SKPaint() { Color = SKColors.Red, Typeface = wpfTextView.Typeface, TextSize = 24, LcdRenderText = true, IsAntialias = true, SubpixelText = true }; _wpfTextView = wpfTextView; _selection = selection; _guardedOperations = guardedOperations; _smartIndentationService = smartIndentationService; // Set up initial values _caretAffinity = PositionAffinity.Successor; _insertionPoint = new VirtualSnapshotPoint(new SnapshotPoint(_wpfTextView.TextSnapshot, 0)); //// Set the regular caret brush //_editorFormatMap = editorFormatMap; //// store information related to classifications //_classificationFormatMap = classificationFormatMap; this.SubscribeEvents(); this.UpdateDefaultBrushes(); this.UpdateRegularCaretBrush(); this.UpdateOverwriteCaretBrush(); //Set the default values for the caret to be what they should be for a hidden caret that is not in overwrite mode. _caretBrush = _regularBrush; // Get the caret blink time from the system. If the caret is set not to flash, the return value // will be -1 _blinkInterval = CaretBlinkTimeManager.GetCaretBlinkTime(); if (_blinkInterval > 0) { _blinkTimer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, _blinkInterval), OnTimerElapsed); } this.UpdateBlinkTimer(); }
/// <summary> /// Constructs a new selection Element /// </summary> public SkiaTextSelection(SkiaTextView wpfTextView, IEditorFormatMap editorFormatMap, GuardedOperations guardedOperations) { // Verify Debug.Assert(wpfTextView != null); _wpfTextView = wpfTextView; _editorFormatMap = editorFormatMap; ActivationTracksFocus = true; // Initialize members _activePoint = _anchorPoint = new VirtualSnapshotPoint(_wpfTextView.TextSnapshot, 0); _selectionMode = TextSelectionMode.Stream; _selectionAdornmentLayer = _wpfTextView.GetAdornmentLayer(PredefinedAdornmentLayers.Selection); _guardedOperations = guardedOperations; this.CreateAndSetPainter("Selected Text", ref _focusedPainter, SKColors.Blue.WithAlpha(80)); this.CreateAndSetPainter("Inactive Selected Text", ref _unfocusedPainter, SKColors.Gray.WithAlpha(80)); this.Painter.Activate(); SubscribeToEvents(); }
public SkiaViewScroller(SkiaTextView textView) { this.textView = textView; }