119 lines
3.3 KiB
C#
119 lines
3.3 KiB
C#
![]() |
using System;
|
|||
|
using CPF.Drawing;
|
|||
|
using CPF.Input;
|
|||
|
using CPF.ReoGrid.Drawing;
|
|||
|
using CPF.ReoGrid.Interaction;
|
|||
|
using CPF.ReoGrid.Main;
|
|||
|
using CPF.ReoGrid.Outline;
|
|||
|
using CPF.ReoGrid.Rendering;
|
|||
|
|
|||
|
namespace CPF.ReoGrid.Views
|
|||
|
{
|
|||
|
internal class OutlineHeaderPart : View
|
|||
|
{
|
|||
|
public RowOrColumn Flag { get; set; }
|
|||
|
|
|||
|
public OutlineHeaderPart(IViewportController vc, RowOrColumn flag) : base(vc)
|
|||
|
{
|
|||
|
this.sheet = vc.Worksheet;
|
|||
|
this.Flag = flag;
|
|||
|
}
|
|||
|
|
|||
|
public override void Draw(CellDrawingContext dc)
|
|||
|
{
|
|||
|
IRenderer renderer = dc.Renderer;
|
|||
|
ControlAppearanceStyle controlStyle = this.sheet.workbook.controlAdapter.ControlStyle;
|
|||
|
OutlineCollection<ReoGridOutline> outlineCollection = this.sheet.outlines[this.Flag];
|
|||
|
renderer.BeginDrawHeaderText(1f);
|
|||
|
CPFPen pen = dc.Renderer.GetPen(controlStyle[ControlAppearanceColors.OutlinePanelBorder]);
|
|||
|
Brush brush = dc.Renderer.GetBrush(controlStyle[ControlAppearanceColors.OutlineButtonText]);
|
|||
|
dc.Graphics.FillRectangle(this.bounds, controlStyle[ControlAppearanceColors.OutlinePanelBackground]);
|
|||
|
bool flag = outlineCollection != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
for (int i = 0; i < outlineCollection.Count; i++)
|
|||
|
{
|
|||
|
OutlineGroup<ReoGridOutline> outlineGroup = outlineCollection[i];
|
|||
|
Rect numberButtonBounds = outlineGroup.NumberButtonBounds;
|
|||
|
bool flag2 = this.pressedIndex == i;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
numberButtonBounds.Offset(1f, 1f);
|
|||
|
}
|
|||
|
renderer.DrawRectangle(pen, numberButtonBounds);
|
|||
|
renderer.DrawHeaderText((i + 1).ToString(), brush, numberButtonBounds);
|
|||
|
}
|
|||
|
}
|
|||
|
renderer.DrawLine(pen, this.bounds.Right, this.bounds.Top, this.bounds.Right, this.bounds.Bottom);
|
|||
|
renderer.DrawLine(pen, this.bounds.X, this.bounds.Bottom, this.bounds.Right, this.bounds.Bottom);
|
|||
|
}
|
|||
|
|
|||
|
public override Point PointToView(Point p)
|
|||
|
{
|
|||
|
return p;
|
|||
|
}
|
|||
|
|
|||
|
public override bool OnMouseDown(Point location, MouseButtons buttons, InputModifiers modifiers)
|
|||
|
{
|
|||
|
bool flag = this.bounds.Contains(location);
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
OutlineCollection<ReoGridOutline> outlineCollection = this.sheet.outlines[this.Flag];
|
|||
|
bool flag2 = outlineCollection != null;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
for (int i = 0; i < outlineCollection.Count; i++)
|
|||
|
{
|
|||
|
OutlineGroup<ReoGridOutline> outlineGroup = outlineCollection[i];
|
|||
|
bool flag3 = outlineGroup.NumberButtonBounds.Contains(location);
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
outlineGroup.CollapseAll();
|
|||
|
this.pressedIndex = i;
|
|||
|
for (i--; i >= 0; i--)
|
|||
|
{
|
|||
|
outlineCollection[i].ExpandAll();
|
|||
|
}
|
|||
|
this.SetFocus();
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public override bool OnMouseUp(Point location, MouseButtons buttons, InputModifiers modifiers)
|
|||
|
{
|
|||
|
this.FreeFocus();
|
|||
|
bool flag = this.pressedIndex >= 0;
|
|||
|
bool result;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.pressedIndex = -1;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
result = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
result = base.OnMouseUp(location, buttons, modifiers);
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
public override bool OnMouseMove(Point location, MouseButtons buttons)
|
|||
|
{
|
|||
|
IControlAdapter controlAdapter = this.sheet.controlAdapter;
|
|||
|
if (controlAdapter != null)
|
|||
|
{
|
|||
|
controlAdapter.ChangeCursor(CursorStyle.Selection);
|
|||
|
}
|
|||
|
return base.OnMouseMove(location, buttons);
|
|||
|
}
|
|||
|
|
|||
|
protected Worksheet sheet;
|
|||
|
|
|||
|
private int pressedIndex = -1;
|
|||
|
}
|
|||
|
}
|