/// <summary> /// Performs console redraw /// </summary> public static void Refresh() { if (_prevent) { return; } if (_refreshing) { _fault = true; return; } _refreshing = true; _discardCount = 0; _fault = false; try { if (Provider == null) { return; } do { Provider.CursorVisible = false; Provider.Clear(_background); foreach (var window in Windows.OrderBy(x => FocusedWindow == x ? int.MaxValue : Windows.IndexOf(x))) { DrawingContext dc = new RealDrawingContext(window != FocusedWindow); var wid = window.ActualWidth; var hei = window.ActualHeight; dc = dc.Shrink( new Rectangle( window.HorizontalAlignment == Alignment.Center ? (WindowWidth - wid) / 2 : window.HorizontalAlignment == Alignment.End ? WindowWidth - wid : 0, window.VerticalAlignment == Alignment.Center ? (WindowHeight - hei) / 2 : window.VerticalAlignment == Alignment.End ? WindowHeight - hei : 0, wid, hei)); dc.Clear(Background); window.OnRenderInternal(dc); } _discardCount++; } while (_fault && _discardCount < 3); Provider.Refresh(); } finally { _refreshing = false; } }