Пример #1
0
        public static void MarkReceiveData(InvalidatedRegion region)
        {
            _receiveDataCount++;
            long now = DateTime.Now.Ticks;

            if (_lastReceivedTime != 0)
            {
                if (now - _lastReceivedTime < 10 * 1000 * 100)
                {
                    _shortReceiveTimeCount++;
                }
            }
            _lastReceivedTime = now;

            if (region.InvalidatedAll)
            {
                _fullInvalidateCount++;
            }
            else
            {
                _partialInvalidateCount++;
                _totalInvalidatedLineCount += region.LineIDEnd - region.LineIDStart + 1;
                if (region.LineIDStart == region.LineIDEnd)
                {
                    _invalidate1LineCount++;
                }
            }
        }
        //_documentの更新状況を見て適切な領域のControl.Invalidate()を呼ぶ。
        //また、コントロールを所有していないスレッドから呼んでもOKなようになっている。
        protected void InvalidateEx()
        {
            if (this.IsDisposed)
            {
                return;
            }
            bool      full_invalidate = true;
            Rectangle r = new Rectangle();

            if (_document != null)
            {
                if (_document.InvalidatedRegion.IsEmpty)
                {
                    return;
                }
                InvalidatedRegion rgn = _document.InvalidatedRegion.GetCopyAndReset();
                if (rgn.IsEmpty)
                {
                    return;
                }
                if (!rgn.InvalidatedAll)
                {
                    full_invalidate = false;
                    r.X             = 0;
                    r.Width         = this.ClientSize.Width;
                    int           topLine = GetTopLine().ID;
                    int           y1      = rgn.LineIDStart - topLine;
                    int           y2      = rgn.LineIDEnd + 1 - topLine;
                    RenderProfile prof    = GetRenderProfile();
                    r.Y      = BORDER + (int)(y1 * (prof.Pitch.Height + prof.LineSpacing));
                    r.Height = (int)((y2 - y1) * (prof.Pitch.Height + prof.LineSpacing)) + 1;
                }
            }

            if (this.InvokeRequired)
            {
                if (full_invalidate)
                {
                    this.BeginInvoke((MethodInvoker) delegate(){ Invalidate(); });
                }
                else
                {
                    this.BeginInvoke((MethodInvoker) delegate(){ Invalidate(r); });
                }
            }
            else
            {
                if (full_invalidate)
                {
                    Invalidate();
                }
                else
                {
                    Invalidate(r);
                }
            }
        }