Esempio n. 1
0
        private void UpdateBlinkTimer()
        {
            this.Opacity = 1.0;

            if (_blinkTimer != null)
            {
                int blinkInterval = CaretBlinkTimeManager.GetCaretBlinkTime();
                if (_wpfTextView.IsVisible && blinkInterval > 0)
                {
                    if (_blinkInterval != blinkInterval)
                    {
                        // Setting this value may cause a context switch.  Only set it if the blink
                        // interval has changed.
                        _blinkTimer.Interval = new TimeSpan(0, 0, 0, 0, blinkInterval);
                        _blinkInterval       = blinkInterval;
                    }
                    _blinkTimer.Start();
                }
                else
                {
                    DisableBlinkTimer();
                }
                _newOpacity = 1.0;
            }
        }
Esempio n. 2
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();
        }