public override void Draw(CellDrawingContext dc) { #if DEBUG Stopwatch sw = Stopwatch.StartNew(); #endif if (!Visible || //|| visibleGridRegion == GridRegion.Empty bounds.Width <= 0 || bounds.Height <= 0) { return; } //bool needClip = this.Parent == null // || this.bounds != this.Parent.Bounds; //bool needTranslate = this.Parent == null // || this.viewStart.X != this.Parent.ViewLeft // || this.ViewStart.Y != this.Parent.ViewTop; var g = dc.Graphics; if (PerformTransform) { g.PushClip(this.bounds); g.PushTransform(); g.TranslateTransform(bounds.Left - ScrollViewLeft * this.scaleFactor, bounds.Top - ScrollViewTop * this.scaleFactor); } DrawView(dc); if (this.PerformTransform) { g.PopTransform(); g.PopClip(); } #if VP_DEBUG #if WINFORM if (this is SheetViewport || this is ColumnHeaderView //|| this is RowHeaderView || this is RowOutlineView) { //var rect = this.bounds; //rect.Width--; //rect.Height--; //dc.Graphics.DrawRectangle(this.bounds, this is SheetViewport ? SolidColor.Blue : SolidColor.Purple); var msg = $"{ this.GetType().Name }\n" + $"{visibleRegion.ToRange()}\n" + $"{this.ViewLeft}, {this.ViewTop}, ({ScrollX}, {ScrollY}), {this.Width}, {this.Height}\n" + $"{this.ScrollableDirections}"; dc.Graphics.PlatformGraphics.DrawString(msg, System.Drawing.SystemFonts.DefaultFont, System.Drawing.Brushes.Blue, this.Left + Width / 2, Top + Height / 2); } #elif WPF var msg = string.Format("VR {0},{1}-{2},{3} VS X{4},Y{5}\nSD {6}", this.visibleRegion.startRow, this.visibleRegion.startCol, this.visibleRegion.endRow, this.visibleRegion.endCol, this.ViewLeft, this.ViewTop, this.ScrollableDirections.ToString()); var ft = new System.Windows.Media.FormattedText(msg, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new System.Windows.Media.Typeface("Arial"), 12, System.Windows.Media.Brushes.Blue, 96); dc.Graphics.PlatformGraphics.DrawText(ft, new System.Windows.Point(this.Left + 1, this.Top + ((this is CellsViewport) ? 30 : this.Height / 2))); #endif // WPF #endif // VP_DEBUG #if DEBUG sw.Stop(); if (sw.ElapsedMilliseconds > 20) { Debug.WriteLine("draw viewport takes " + sw.ElapsedMilliseconds + " ms. visible region: rows: " + visibleRegion.Rows + ", cols: " + visibleRegion.Cols); } #endif // Debug }
public override void Draw(CellDrawingContext dc) { #if DEBUG Stopwatch sw = Stopwatch.StartNew(); #endif if (!Visible || //|| visibleGridRegion == GridRegion.Empty bounds.Width <= 0 || bounds.Height <= 0) { return; } //bool needClip = this.Parent == null // || this.bounds != this.Parent.Bounds; //bool needTranslate = this.Parent == null // || this.viewStart.X != this.Parent.ViewLeft // || this.ViewStart.Y != this.Parent.ViewTop; var g = dc.Graphics; if (PerformTransform) { g.PushClip(this.bounds); g.PushTransform(); g.TranslateTransform(bounds.Left - ScrollViewLeft * this.scaleFactor, bounds.Top - ScrollViewTop * this.scaleFactor); } DrawView(dc); if (this.PerformTransform) { g.PopTransform(); g.PopClip(); } #if VP_DEBUG if (this is SheetViewport || this is ColumnHeaderView //|| this is RowHeaderView || this is RowOutlineView) { //var rect = this.bounds; //rect.Width--; //rect.Height--; //dc.Graphics.DrawRectangle(this.bounds, this is SheetViewport ? SolidColor.Blue : SolidColor.Purple); var msg = $"{ this.GetType().Name }\n" + $"{visibleRegion.ToRange()}\n" + $"{this.ViewLeft}, {this.ViewTop}, ({ScrollX}, {ScrollY}), {this.Width}, {this.Height}\n" + $"{this.ScrollableDirections}"; dc.Graphics.PlatformGraphics.DrawString(msg, System.Drawing.SystemFonts.DefaultFont, System.Drawing.Brushes.Blue, this.Left + Width / 2, Top + Height / 2); } #endif // VP_DEBUG #if DEBUG sw.Stop(); if (sw.ElapsedMilliseconds > 20) { Debug.WriteLine("draw viewport takes " + sw.ElapsedMilliseconds + " ms. visible region: rows: " + visibleRegion.Rows + ", cols: " + visibleRegion.Cols); } #endif // Debug }