Exemplo n.º 1
0
        /// <summary>
        /// 現在のキャレット位置の領域を返す
        /// </summary>
        /// <returns>矩形領域を表すRectangle</returns>
        public Rectangle GetCurrentCaretRect()
        {
            ITextLayout layout = this.LayoutLines.GetLayout(this.Document.CaretPostion.row);
            double      width  = layout.GetWidthFromIndex(this.Document.CaretPostion.col);

            if (width == 0.0)
            {
                width = this.CaretWidthOnInsertMode;
            }
            double    height     = this.LayoutLines.GetLineHeight(this.Document.CaretPostion);
            Rectangle updateRect = new Rectangle(
                this.CaretLocation.X,
                this.CaretLocation.Y,
                width,
                height);

            return(updateRect);
        }
Exemplo n.º 2
0
        bool DrawCaret()
        {
            if (this.HideCaret || !this.IsFocused)
            {
                return(false);
            }

            long diff      = DateTime.Now.Ticks - this.tickCount;
            long blinkTime = this.To100nsTime(this.CaretBlinkTime);

            if (this.CaretBlink && diff % blinkTime >= blinkTime / 2)
            {
                return(false);
            }

            Rectangle CaretRect = new Rectangle();

            IEditorRender render = (IEditorRender)base.render;

            int         row        = this.Document.CaretPostion.row;
            ITextLayout layout     = this.LayoutLines.GetLayout(row);
            double      lineHeight = render.emSize.Height;
            double      charWidth  = layout.GetWidthFromIndex(this.Document.CaretPostion.col);

            if (this.InsertMode || charWidth == 0)
            {
                CaretRect.Size     = new Size(CaretWidthOnInsertMode, lineHeight);
                CaretRect.Location = new Point(this.CaretLocation.X, this.CaretLocation.Y);
                render.FillRectangle(CaretRect, FillRectType.InsertCaret);
            }
            else
            {
                double height = lineHeight / 3;
                CaretRect.Size     = new Size(charWidth, height);
                CaretRect.Location = new Point(this.CaretLocation.X, this.CaretLocation.Y + lineHeight - height);
                render.FillRectangle(CaretRect, FillRectType.OverwriteCaret);
            }
            return(true);
        }