using System; using System.Diagnostics; using System.Linq; using CPF.Drawing; using CPF.ReoGrid.Drawing; using CPF.ReoGrid.Graphics; using CPF.ReoGrid.Main; using CPF.ReoGrid.Outline; using CPF.ReoGrid.Rendering; namespace CPF.ReoGrid.Views { internal class ColumnOutlinePart : OutlineView { public ColumnOutlinePart(IViewportController vc) : base(vc, RowOrColumn.Column) { this.ScrollableDirections = ScrollDirection.Horizontal; } public override void Draw(CellDrawingContext dc) { IGraphics graphics = dc.Graphics; ControlAppearanceStyle controlStyle = this.sheet.workbook.controlAdapter.ControlStyle; graphics.FillRectangle(this.bounds.X, this.bounds.Y, this.bounds.Width + 1f, this.bounds.Height, controlStyle[ControlAppearanceColors.OutlinePanelBackground]); base.Draw(dc); graphics.DrawLine(this.bounds.Left, this.bounds.Bottom, this.bounds.Right, this.bounds.Bottom, controlStyle[ControlAppearanceColors.OutlinePanelBorder]); } public override void DrawView(CellDrawingContext dc) { IGraphics graphics = dc.Graphics; ControlAppearanceStyle controlStyle = this.sheet.workbook.controlAdapter.ControlStyle; Stopwatch stopwatch = Stopwatch.StartNew(); OutlineCollection outlineCollection = this.sheet.outlines[RowOrColumn.Column]; bool flag = outlineCollection != null; if (flag) { CPFPen pen = dc.Renderer.GetPen(controlStyle[ControlAppearanceColors.OutlineButtonBorder]); float num = Math.Min(this.scaleFactor, 1f); float num2 = 6.5f * num; for (int i = 0; i < outlineCollection.Count; i++) { OutlineGroup outlineGroup = null; bool flag2 = i < outlineCollection.Count - 1; if (flag2) { outlineGroup = outlineCollection[i]; foreach (ReoGridOutline reoGridOutline in outlineGroup) { ColumnHeader columnHeader = this.sheet.cols[reoGridOutline.End]; bool flag3 = !columnHeader.IsVisible; if (!flag3) { bool flag4 = this.scaleFactor > 0.5f; if (flag4) { pen.Width = 2f; } Rect toggleButtonBounds = reoGridOutline.ToggleButtonBounds; float num3 = toggleButtonBounds.X + toggleButtonBounds.Width / 2f; float num4 = toggleButtonBounds.Y + toggleButtonBounds.Height / 2f; bool internalCollapsed = reoGridOutline.InternalCollapsed; if (internalCollapsed) { graphics.DrawLine(pen, num3, toggleButtonBounds.Top + 3f, num3, toggleButtonBounds.Bottom - 2f); } else { ColumnHeader columnHeader2 = this.sheet.cols[reoGridOutline.Start]; float num5 = (float)columnHeader2.Left * this.scaleFactor; graphics.DrawLine(pen, num5, toggleButtonBounds.Bottom - 1f, num5, num4); graphics.DrawLine(pen, num5 - 1f, num4, toggleButtonBounds.Left, num4); } graphics.DrawLine(pen, toggleButtonBounds.Left + 3f, num4, toggleButtonBounds.Right - 2f, num4); pen.Width = 1f; graphics.DrawRectangle(pen, toggleButtonBounds.X, toggleButtonBounds.Y, toggleButtonBounds.Width, toggleButtonBounds.Height); } } } OutlineGroup outlineGroup2 = (i <= 0) ? null : outlineCollection[i - 1]; bool flag5 = outlineGroup2 != null; if (flag5) { int num6 = (int)Math.Round((double)((float)(16 * i) * num)); foreach (ReoGridOutline reoGridOutline2 in outlineGroup2) { bool flag6 = !reoGridOutline2.InternalCollapsed; if (flag6) { int r2; int r; for (r = reoGridOutline2.Start; r < reoGridOutline2.End; r = r2 + 1) { bool flag7 = outlineGroup == null || !outlineGroup.Any((ReoGridOutline o) => o.Start <= r && o.End >= r); if (flag7) { ColumnHeader columnHeader3 = this.sheet.cols[r]; bool isVisible = columnHeader3.IsVisible; if (isVisible) { float num7 = (float)(columnHeader3.Left + (int)(columnHeader3.InnerWidth / 2)) * this.scaleFactor; graphics.DrawLine(pen, num7 - 1f, (float)num6 + num2, num7 - 1f, (float)num6 + num2 + 1f); graphics.DrawLine(pen, num7, (float)num6 + num2, num7, (float)num6 + num2 + 1f); } } r2 = r; } } } } } } stopwatch.Stop(); long elapsedMilliseconds = stopwatch.ElapsedMilliseconds; bool flag8 = elapsedMilliseconds > 10L; if (flag8) { Debug.WriteLine("draw column outlines takes " + elapsedMilliseconds.ToString() + " ms."); } } protected override Rect CreateToggleButtonRect(int loc, int pos, int buttonSize) { ColumnHeader columnHeader = this.sheet.cols[pos]; float num = (float)columnHeader.Left * this.scaleFactor; float num2 = ((float)columnHeader.InnerWidth * this.scaleFactor - (float)buttonSize) / 2f; int num3 = (int)Math.Round((double)(num + num2)); float num4 = (float)num3; float num5 = (float)(loc + 1); float num6 = (float)buttonSize; float num7 = (float)buttonSize; return new Rect(ref num4, ref num5, ref num6, ref num7); } } }