//描画の本体 protected override sealed void OnPaint(PaintEventArgs e) { #if ONPAINT_TIME_MEASUREMENT Stopwatch onPaintSw = (_onPaintTimeObserver != null) ? Stopwatch.StartNew() : null; #endif base.OnPaint(e); try { if (_document != null) { ShowVScrollBar(); } else { HideVScrollBar(); } if (_enabled && !this.DesignMode) { Rectangle clip = e.ClipRectangle; Graphics g = e.Graphics; RenderProfile profile = GetRenderProfile(); int paneheight = GetHeightInLines(); // determine background color of the view Color backColor; if (_document.IsApplicationMode) { backColor = _document.ApplicationModeBackColor; if (backColor.IsEmpty) { backColor = profile.BackColor; } } else { backColor = profile.BackColor; } if (this.BackColor != backColor) { this.BackColor = backColor; // set background color of the view } // draw background image if it is required. if (!_document.IsApplicationMode) { Image img = profile.GetImage(); if (img != null) { DrawBackgroundImage(g, img, profile.ImageStyle, clip); } } //描画用にテンポラリのGLineを作り、描画中にdocumentをロックしないようにする //!!ここは実行頻度が高いのでnewを毎回するのは避けたいところだ RenderParameter param = new RenderParameter(); _caret.Enabled = _caret.Enabled && this.Focused; //TODO さらにIME起動中はキャレットを表示しないように. TerminalControlだったらAdjustCaretでIMEをみてるので問題はない lock (_document) { CommitTransientScrollBar(); BuildTransientDocument(e, param); } DrawLines(g, param, backColor); if (_caret.Enabled && (!_caret.Blink || _caret.IsActiveTick)) //点滅しなければEnabledによってのみ決まる { if (_caret.Style == CaretType.Line) { DrawBarCaret(g, param, _caret.X, _caret.Y); } else if (_caret.Style == CaretType.Underline) { DrawUnderLineCaret(g, param, _caret.X, _caret.Y); } } } //マークの描画 _splitMark.OnPaint(e); } catch (Exception ex) { if (!_errorRaisedInDrawing) //この中で一度例外が発生すると繰り返し起こってしまうことがままある。なので初回のみ表示してとりあえず切り抜ける { _errorRaisedInDrawing = true; RuntimeUtil.ReportException(ex); } } #if ONPAINT_TIME_MEASUREMENT if (onPaintSw != null) { onPaintSw.Stop(); if (_onPaintTimeObserver != null) { _onPaintTimeObserver(onPaintSw); } } #endif }
//描画の本体 protected override sealed void OnPaint(PaintEventArgs e) { base.OnPaint(e); try { if (_document != null) { ShowVScrollBar(); } else { HideVScrollBar(); } if (_enabled && !this.DesignMode) { Rectangle clip = e.ClipRectangle; Graphics g = e.Graphics; RenderProfile profile = GetRenderProfile(); int paneheight = GetHeightInLines(); if (_document.BackColor != profile.BackColor) { if (_document.IsApplicationMode) { if (this.BackColor != _document.BackColor) { this.BackColor = _document.BackColor; _drawbgImage = false; } } else { this.BackColor = profile.BackColor; _document.BackColor = profile.BackColor; _drawbgImage = true; } } if (_drawbgImage) { Image img = profile.GetImage(); if (img != null) { DrawBackgroundImage(g, img, profile.ImageStyle, clip); } } //描画用にテンポラリのGLineを作り、描画中にdocumentをロックしないようにする //!!ここは実行頻度が高いのでnewを毎回するのは避けたいところだ RenderParameter param = new RenderParameter(); _caret.Enabled = _caret.Enabled && this.Focused; //TODO さらにIME起動中はキャレットを表示しないように. TerminalControlだったらAdjustCaretでIMEをみてるので問題はない lock (_document) { CommitTransientScrollBar(); BuildTransientDocument(e, param); } DrawLines(g, param); if (_caret.Enabled && (!_caret.Blink || _caret.IsActiveTick)) //点滅しなければEnabledによってのみ決まる { if (_caret.Style == CaretType.Line) { DrawBarCaret(g, param, _caret.X, _caret.Y); } else if (_caret.Style == CaretType.Underline) { DrawUnderLineCaret(g, param, _caret.X, _caret.Y); } else if (_caret.Style == CaretType.BoldUnderline) { DrawBoldUnderlineCaret(g, param, _caret.X, _caret.Y); } } } //マークの描画 _splitMark.OnPaint(e); } catch (Exception ex) { if (!_errorRaisedInDrawing) //この中で一度例外が発生すると繰り返し起こってしまうことがままある。なので初回のみ表示してとりあえず切り抜ける { _errorRaisedInDrawing = true; RuntimeUtil.ReportException(ex); } } }