private void addLines() { Dispatcher.Invoke(new Action(delegate { double top = (_fd.Blocks.Count * _metrics.FontSize.Height) + 1; while (_fd.Blocks.Count < _metrics.Rows) { { ZParagraph p = new ZParagraph(this, _currentDisplay); p.LineHeight = _metrics.FontSize.Height; _fd.Blocks.Add(p); } } // Reset the top on all the lines to make sure they are correct double newTop = 0; foreach (ZParagraph zp in _fd.Blocks) { zp.Top = newTop; if (zp.Top == 0) { zp.Top = 1; } newTop += _metrics.FontSize.Height; } SetCurrentParagraph(); })); }
private void addLines() { Dispatcher.Invoke(new Action(delegate { double top = (_fd.Blocks.Count * _metrics.FontSize.Height) + 1; while (_fd.Blocks.Count < _metrics.Rows) { { ZParagraph p = new ZParagraph(this, _currentDisplay); p.LineHeight = _metrics.FontSize.Height; _fd.Blocks.Add(p); } } // Reset the top on all the lines to make sure they are correct double newTop = 0; foreach (ZParagraph zp in _fd.Blocks) { zp.Top = newTop; if (zp.Top == 0) zp.Top = 1; newTop += _metrics.FontSize.Height; } SetCurrentParagraph(); })); }
public ZTextControl() { InitializeComponent(); _currentDisplay = new CharDisplayInfo(ZFont.TEXT_FONT, ZStyles.NORMAL_STYLE, 1, 1); _currentParagraph = new ZParagraph(this, _currentDisplay); _adorner = new OverlayAdorner(rtb); this.Loaded += new RoutedEventHandler(ZTextControl_Loaded); }
private void SetCurrentParagraph() { ZParagraph temp = null; Dispatcher.Invoke(new Action(delegate { foreach (ZParagraph zp in _fd.Blocks) { // TODO This might be a bug somewhere // For some reason, _cursorY is fluctuating by 1 if (Math.Abs(zp.Top - _cursorY) <= 1) { temp = zp; } } if (_currentParagraph == temp) { _currentParagraph.SetCursorXPosition(_cursorX); return; } if (temp != null) { if (_currentParagraph != null) { _currentParagraph.Flush(); } _currentParagraph = temp; _currentParagraph.SetCursorXPosition(_cursorX); _currentParagraph.SetDisplayInfo(_currentDisplay); } })); if (temp == null) { System.Diagnostics.Debug.WriteLine("Not matching an existing paragraph:" + _cursorY + ":" + _metrics.FontSize.Height + ":" + _metrics.WindowSize.Height); } }
internal void ScrollLines(int top, int height, int numlines) { Dispatcher.Invoke(new Action(delegate { _adorner.ScrollLines(top, height, numlines); _currentParagraph.Flush(); _currentParagraph = null; // _cursorY = -1; List <ZParagraph> toRemove = new List <ZParagraph>(); foreach (ZParagraph zp in _fd.Blocks) { if (zp.Top >= top && zp.Top < top + numlines) { toRemove.Add(zp); } } foreach (ZParagraph zp in toRemove) { _fd.Blocks.Remove(zp); } addLines(); double newTop = 1; foreach (ZParagraph zp in _fd.Blocks) { zp.Top = newTop; newTop += _metrics.FontSize.Height; } })); SetCurrentParagraph(); }
private void SetCurrentParagraph() { ZParagraph temp = null; Dispatcher.Invoke(new Action(delegate { foreach (ZParagraph zp in _fd.Blocks) { // TODO This might be a bug somewhere // For some reason, _cursorY is fluctuating by 1 if (Math.Abs(zp.Top - _cursorY) <= 1) { temp = zp; } } if (_currentParagraph == temp) { _currentParagraph.SetCursorXPosition(_cursorX); return; } if (temp != null) { if (_currentParagraph != null) _currentParagraph.Flush(); _currentParagraph = temp; _currentParagraph.SetCursorXPosition(_cursorX); _currentParagraph.SetDisplayInfo(_currentDisplay); } })); if (temp == null) { System.Diagnostics.Debug.WriteLine("Not matching an existing paragraph:" + _cursorY + ":" + _metrics.FontSize.Height + ":" + _metrics.WindowSize.Height); } }
internal void ScrollLines(int top, int height, int numlines) { Dispatcher.Invoke(new Action(delegate { _adorner.ScrollLines(top, height, numlines); _currentParagraph.Flush(); _currentParagraph = null; // _cursorY = -1; List<ZParagraph> toRemove = new List<ZParagraph>(); foreach (ZParagraph zp in _fd.Blocks) { if (zp.Top >= top && zp.Top < top + numlines) { toRemove.Add(zp); } } foreach (ZParagraph zp in toRemove) { _fd.Blocks.Remove(zp); } addLines(); double newTop = 1; foreach (ZParagraph zp in _fd.Blocks) { zp.Top = newTop; newTop += _metrics.FontSize.Height; } })); SetCurrentParagraph(); }