示例#1
0
        /// <summary>
        /// ヒットテストを行う
        /// </summary>
        /// <param name="x">x座標</param>
        /// <param name="row">行</param>
        /// <returns>ヒットした場合はFoldingDataオブジェクトが返され、そうでない場合はnullが返る</returns>
        public FoldingItem HitFoldingData(double x, int row)
        {
            IEditorRender render = (IEditorRender)base.render;

            if (render == null)
            {
                return(null);
            }

            if (x >= this.GetRealtiveX(AreaType.FoldingArea) && x <= this.GetRealtiveX(AreaType.FoldingArea) + render.FoldingWidth)
            {
                int         lineHeadIndex = this.LayoutLines.GetIndexFromLineNumber(row);
                int         lineLength    = this.LayoutLines.GetLengthFromLineNumber(row);
                FoldingItem foldingData   = this.LayoutLines.FoldingCollection.Get(lineHeadIndex, lineLength);
                if (foldingData != null && foldingData.IsFirstLine(this.LayoutLines, row))
                {
                    return(foldingData);
                }
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// キャレットを指定した位置に移動させる
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="autoExpand">折り畳みを展開するなら真</param>
        public void JumpCaret(int row, int col, bool autoExpand = true)
        {
            if (autoExpand)
            {
                int         lineHeadIndex = this.LayoutLines.GetIndexFromLineNumber(row);
                int         lineLength    = this.LayoutLines.GetLengthFromLineNumber(row);
                FoldingItem foldingData   = this.LayoutLines.FoldingCollection.Get(lineHeadIndex, lineLength);
                if (foldingData != null)
                {
                    if (this.LayoutLines.FoldingCollection.IsParentHidden(foldingData) || !foldingData.IsFirstLine(this.LayoutLines, row))
                    {
                        this.LayoutLines.FoldingCollection.Expand(foldingData);
                    }
                }
            }

            //イベント呼び出しの再入防止のため
            this.Document.SetCaretPostionWithoutEvent(new TextPoint(row, col));
        }
示例#3
0
        /// <summary>
        /// Rectで指定された範囲にドキュメントを描く
        /// </summary>
        /// <param name="updateRect">描写する範囲</param>
        /// <param name="force">キャッシュした内容を使用しない場合は真を指定する</param>
        /// <remarks>描写する範囲がPageBoundより小さい場合、キャッシュされた内容を使用することがあります。なお、レタリング後にrender.CacheContent()を呼び出さなかった場合は更新範囲にかかわらずキャッシュを使用しません</remarks>
        public override void Draw(Rectangle updateRect, bool force = false)
        {
            if (this.LayoutLines.Count == 0)
            {
                return;
            }

            IEditorRender render = (IEditorRender)base.render;

            if (render == null)
            {
                return;
            }

            if ((updateRect.Height < this.PageBound.Height ||
                 updateRect.Width < this.PageBound.Width) &&
                render.IsVaildCache() &&
                !force)
            {
                render.DrawCachedBitmap(updateRect, updateRect);
            }
            else
            {
                Rectangle background = this.PageBound;
                render.FillBackground(background);

                if (this.Document.HideRuler == false)
                {
                    this.DrawRuler();
                }

                double endposy = this.render.TextArea.Bottom;
                Point  pos     = this.render.TextArea.TopLeft;
                pos.X -= this.Src.X;
                //画面上では行をずらして表示する
                pos.Y += this.Src.OffsetY;

                this.render.BeginClipRect(this.render.TextArea);

                for (int i = this.Src.Row; i < this.LayoutLines.Count; i++)
                {
                    int         lineIndex  = this.LayoutLines.GetIndexFromLineNumber(i);
                    int         lineLength = this.LayoutLines.GetLengthFromLineNumber(i);
                    ITextLayout layout     = this.LayoutLines.GetLayout(i);

                    if (pos.Y > endposy)
                    {
                        break;
                    }

                    FoldingItem foldingData = this.LayoutLines.FoldingCollection.Get(lineIndex, lineLength);

                    if (foldingData != null)
                    {
                        if (this.LayoutLines.FoldingCollection.IsHidden(lineIndex))
                        {
                            continue;
                        }
                    }

                    this.render.DrawOneLine(this.Document, this.LayoutLines, i, pos.X, pos.Y);

                    pos.Y += layout.Height;
                }

                this.render.EndClipRect();

                //リセットしないと行が正しく描けない
                pos = this.render.TextArea.TopLeft;
                //画面上では行をずらして表示する
                pos.Y += this.Src.OffsetY;

                Size lineNumberSize = new Size(this.render.LineNemberWidth, this.render.TextArea.Height);

                for (int i = this.Src.Row; i < this.LayoutLines.Count; i++)
                {
                    int         lineIndex  = this.LayoutLines.GetIndexFromLineNumber(i);
                    int         lineLength = this.LayoutLines.GetLengthFromLineNumber(i);
                    ITextLayout layout     = this.LayoutLines.GetLayout(i);

                    if (pos.Y > endposy)
                    {
                        break;
                    }

                    FoldingItem foldingData = this.LayoutLines.FoldingCollection.Get(lineIndex, lineLength);

                    if (foldingData != null)
                    {
                        if (this.LayoutLines.FoldingCollection.IsHidden(lineIndex))
                        {
                            continue;
                        }
                        if (foldingData.IsFirstLine(this.LayoutLines, i) && foldingData.End >= lineIndex + lineLength)
                        {
                            render.DrawFoldingMark(foldingData.Expand, this.PageBound.X + this.GetRealtiveX(AreaType.FoldingArea), pos.Y);
                        }
                    }

                    if (this.Document.DrawLineNumber)
                    {
                        this.render.DrawString((i + 1).ToString(), this.PageBound.X + this.GetRealtiveX(AreaType.LineNumberArea), pos.Y, StringAlignment.Right, lineNumberSize, StringColorType.LineNumber);
                    }

                    DrawUpdateArea(i, pos.Y);

                    if (i == this.Document.CaretPostion.row)
                    {
                        this.DrawLineMarker(pos, layout);
                    }

                    pos.Y += layout.Height;
                }

                this.Document.SelectGrippers.BottomLeft.Draw(this.render);
                this.Document.SelectGrippers.BottomRight.Draw(this.render);

                render.CacheContent();
            }

            this.DrawInsertPoint();

            this.DrawCaret();
        }