コード例 #1
0
        /// <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();
        }
コード例 #2
0
        void Initialize()
        {
            _bufferGraph = _factoryService.BufferGraphFactoryService.CreateBufferGraph(this.TextViewModel.VisualBuffer);

            _editorFormatMap = _factoryService.EditorFormatMapService.GetEditorFormatMap(this);

            _baseLayer    = new ViewStack(_factoryService.OrderedViewLayerDefinitions, this);
            _overlayLayer = new ViewStack(_factoryService.OrderedOverlayLayerDefinitions, this, isOverlayLayer: true);

            // Create selection and make sure it's created before the caret as the caret relies on the selection being
            // available in its constructor
            _selection = new SkiaTextSelection(this, _editorFormatMap, _factoryService.GuardedOperations);

            // Create caret
            _caretElement = new SkiaTextCaret(this, _selection,
                                              _factoryService.SmartIndentationService,
                                              _editorFormatMap,
                                              _factoryService.GuardedOperations);
        }