using System; using CPF.Drawing; using CPF.Input; using CPF.ReoGrid.Actions; using CPF.ReoGrid.Drawing; using CPF.ReoGrid.Graphics; using CPF.ReoGrid.Interaction; using CPF.ReoGrid.Main; using CPF.ReoGrid.Rendering; namespace CPF.ReoGrid.Views { internal class RowHeaderView : HeaderView { public RowHeaderView(IViewportController vc) : base(vc) { this.ScrollableDirections = ScrollDirection.Vertical; } public override Point PointToView(Point p) { return base.PointToView(p); } public override void DrawView(CellDrawingContext dc) { IRenderer renderer = dc.Renderer; bool flag = this.bounds.Width <= 0f || this.sheet.controlAdapter == null; if (!flag) { ControlAppearanceStyle controlStyle = this.sheet.workbook.controlAdapter.ControlStyle; renderer.BeginDrawHeaderText(this.scaleFactor); CPFPen pen = dc.Renderer.GetPen(controlStyle.Colors[ControlAppearanceColors.RowHeadSplitter]); Brush brush = dc.Renderer.GetBrush(controlStyle.Colors[ControlAppearanceColors.RowHeadText]); bool flag2 = this.sheet.SelectionRange.Cols == this.sheet.ColumnCount; for (int i = this.visibleRegion.startRow; i <= this.visibleRegion.endRow; i++) { bool flag3 = i >= this.sheet.SelectionRange.Row && i <= this.sheet.SelectionRange.EndRow; RowHeader rowHeader = this.sheet.rows[i]; float num = (float)rowHeader.Top * this.scaleFactor; bool flag4 = !rowHeader.IsVisible; if (flag4) { renderer.DrawLine(pen, 0f, num - 1f, this.bounds.Width, num - 1f); } else { float num2 = 0f; float width = this.bounds.Width; float num3 = (float)rowHeader.InnerHeight * this.scaleFactor; Rect rect = new Rect(ref num2, ref num, ref width, ref num3); bool flag5 = rect.Height > 0f; if (flag5) { renderer.FillRectangle(rect, controlStyle.GetRowHeadEndColor(false, flag3, flag3 && flag2, false)); IGraphics graphics = renderer; CPFPen p = pen; num2 = 0f; Point startPoint = new Point(ref num2, ref num); width = this.bounds.Width; graphics.DrawLine(p, startPoint, new Point(ref width, ref num)); string text = (rowHeader.Text != null) ? rowHeader.Text : (rowHeader.Row + 1).ToString(); bool flag6 = !string.IsNullOrEmpty(text); if (flag6) { Brush brush2 = (rowHeader.TextColor != null) ? dc.Renderer.GetBrush(rowHeader.TextColor.Value) : brush; bool flag7 = brush2 == null; if (flag7) { brush2 = brush; } renderer.DrawHeaderText(text, brush2, rect); } bool flag8 = rowHeader.Body != null; if (flag8) { renderer.PushTransform(); renderer.TranslateTransform(rect.X, rect.Y); rowHeader.Body.OnPaint(dc, rect.Size); renderer.PopTransform(); } } } } bool flag9 = this.visibleRegion.endRow >= 0; if (flag9) { float num4 = (float)this.sheet.rows[this.visibleRegion.endRow].Bottom * this.scaleFactor; renderer.DrawLine(pen, 0f, num4, this.bounds.Width, num4); } bool flag10 = !this.sheet.HasSettings(WorksheetSettings.View_ShowGridLine); if (flag10) { dc.Graphics.DrawLine(dc.Renderer.GetPen(controlStyle.Colors[ControlAppearanceColors.RowHeadSplitter]), this.bounds.Right, this.bounds.Y, this.bounds.Right, Math.Min(((float)this.sheet.rows[this.sheet.rows.Count - 1].Bottom - base.ScrollViewTop) * this.scaleFactor + this.bounds.Top, this.bounds.Bottom)); } } } public override bool OnMouseDown(Point location, MouseButtons buttons, InputModifiers modifiers) { bool result = false; int num = -1; OperationStatus operationStatus = this.sheet.operationStatus; OperationStatus operationStatus2 = operationStatus; if (operationStatus2 == OperationStatus.Default) { bool flag = this.sheet.FindRowByPosition(location.Y, out num); bool flag2 = num >= 0 && num < this.sheet.rows.Count; if (flag2) { bool flag3 = flag && buttons == MouseButtons.Left && this.sheet.HasSettings(WorksheetSettings.Edit_AllowAdjustRowHeight); if (flag3) { this.sheet.currentRowHeightChanging = num; this.sheet.operationStatus = OperationStatus.AdjustRowHeight; this.sheet.controlAdapter.ChangeCursor(CursorStyle.ChangeRowHeight); this.sheet.RequestInvalidate(); this.headerAdjustBackup = (this.sheet.headerAdjustNewValue = (float)this.sheet.rows[this.sheet.currentRowHeightChanging].InnerHeight); this.SetFocus(); result = true; } else { bool flag4 = this.sheet.selectionMode > WorksheetSelectionMode.None; if (flag4) { bool flag5 = this.sheet.selectionMode == WorksheetSelectionMode.Range && this.sheet.selectionRange.Cols == this.sheet.cols.Count && this.sheet.selectionRange.ContainsRow(num); bool flag6 = !flag5 || buttons == MouseButtons.Left; if (flag6) { this.sheet.operationStatus = OperationStatus.FullRowSelect; this.sheet.controlAdapter.ChangeCursor(CursorStyle.FullRowSelect); this.SetFocus(); this.sheet.SelectRangeStartByMouse(this.PointToController(location), modifiers); result = true; } bool flag7 = buttons == MouseButtons.Right; if (flag7) { this.sheet.controlAdapter.ShowContextMenuStrip(ViewTypes.RowHeader, this.PointToController(location)); } } } } } return result; } public override bool OnMouseMove(Point location, MouseButtons buttons) { bool result = false; OperationStatus operationStatus = this.sheet.operationStatus; OperationStatus operationStatus2 = operationStatus; if (operationStatus2 != OperationStatus.Default) { if (operationStatus2 != OperationStatus.FullRowSelect) { if (operationStatus2 == OperationStatus.AdjustRowHeight) { bool flag = buttons == MouseButtons.Left && this.sheet.currentRowHeightChanging >= 0; if (flag) { RowHeader rowHeader = this.sheet.rows[this.sheet.currentRowHeightChanging]; this.sheet.headerAdjustNewValue = location.Y - (float)rowHeader.Top; bool flag2 = this.sheet.headerAdjustNewValue < 0f; if (flag2) { this.sheet.headerAdjustNewValue = 0f; } this.sheet.controlAdapter.ChangeCursor(CursorStyle.ChangeRowHeight); this.sheet.RequestInvalidate(); result = true; } } } else { this.sheet.SelectRangeEndByMouse(this.PointToController(location)); this.sheet.controlAdapter.ChangeCursor(CursorStyle.FullRowSelect); result = true; } } else { bool flag3 = buttons == MouseButtons.None && this.sheet.HasSettings(WorksheetSettings.Edit_AllowAdjustRowHeight); if (flag3) { int num = -1; bool flag4 = this.sheet.FindRowByPosition(location.Y, out num); bool flag5 = num >= 0; if (flag5) { this.sheet.controlAdapter.ChangeCursor(flag4 ? CursorStyle.ChangeRowHeight : ((this.sheet.selectionMode == WorksheetSelectionMode.None) ? CursorStyle.PlatformDefault : CursorStyle.FullRowSelect)); } } } return result; } public override bool OnMouseUp(Point location, MouseButtons buttons, InputModifiers modifiers) { bool result = false; switch (this.sheet.operationStatus) { case OperationStatus.FullRowSelect: case OperationStatus.FullSingleRowSelect: this.sheet.operationStatus = OperationStatus.Default; this.sheet.controlAdapter.ChangeCursor(CursorStyle.Selection); this.FreeFocus(); result = true; break; case OperationStatus.AdjustRowHeight: { bool flag = this.sheet.currentRowHeightChanging > -1; if (flag) { bool flag2 = this.sheet.selectionMode == WorksheetSelectionMode.Range && this.sheet.selectionRange.Cols == this.sheet.cols.Count && this.sheet.selectionRange.ContainsRow(this.sheet.currentRowHeightChanging); ushort num = (ushort)this.sheet.headerAdjustNewValue; bool flag3 = (float)num != this.headerAdjustBackup; if (flag3) { bool flag4 = flag2; SetRowsHeightAction action; if (flag4) { action = new SetRowsHeightAction(this.sheet.selectionRange.Row, this.sheet.selectionRange.Rows, num); } else { action = new SetRowsHeightAction(this.sheet.currentRowHeightChanging, 1, num); } this.sheet.DoAction(action); } this.sheet.currentRowHeightChanging = -1; this.sheet.operationStatus = OperationStatus.Default; this.headerAdjustBackup = (this.sheet.headerAdjustNewValue = 0f); this.sheet.RequestInvalidate(); this.FreeFocus(); result = true; } break; } } return result; } public override bool OnMouseDoubleClick(Point location, MouseButtons buttons) { int num = -1; bool flag = this.sheet.FindRowByPosition(location.Y, out num); bool flag2 = num >= 0; if (flag2) { bool flag3 = flag && buttons == MouseButtons.Left && this.sheet.HasSettings(WorksheetSettings.Edit_AllowAdjustRowHeight); if (flag3) { this.sheet.AutoFitRowHeight(num, true); return true; } } return false; } } }