100 lines
2.6 KiB
C#
100 lines
2.6 KiB
C#
using System;
|
|
using CPF.Drawing;
|
|
using CPF.Input;
|
|
using CPF.ReoGrid.Interaction;
|
|
using CPF.ReoGrid.Outline;
|
|
|
|
namespace CPF.ReoGrid.Views
|
|
{
|
|
internal abstract class OutlineView : Viewport
|
|
{
|
|
public RowOrColumn Flag { get; set; }
|
|
|
|
public OutlineView(IViewportController vc, RowOrColumn flag) : base(vc)
|
|
{
|
|
this.Flag = flag;
|
|
}
|
|
|
|
protected ReoGridOutline OutlineButtonHittest(OutlineCollection<ReoGridOutline> outlines, Point location)
|
|
{
|
|
foreach (OutlineGroup<ReoGridOutline> outlineGroup in outlines)
|
|
{
|
|
foreach (ReoGridOutline reoGridOutline in outlineGroup)
|
|
{
|
|
bool flag = reoGridOutline.ToggleButtonBounds.Contains(location);
|
|
if (flag)
|
|
{
|
|
return reoGridOutline;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public override Point PointToView(Point p)
|
|
{
|
|
float num = p.X + (base.ScrollViewLeft * this.scaleFactor - this.bounds.X);
|
|
float num2 = p.Y + (base.ScrollViewTop * this.scaleFactor - this.bounds.Y);
|
|
return new Point(ref num, ref num2);
|
|
}
|
|
|
|
public override bool OnMouseDown(Point location, MouseButtons buttons, InputModifiers modifiers)
|
|
{
|
|
bool flag = this.sheet.outlines != null;
|
|
if (flag)
|
|
{
|
|
OutlineCollection<ReoGridOutline> outlineCollection = this.sheet.outlines[this.Flag];
|
|
bool flag2 = outlineCollection != null;
|
|
if (flag2)
|
|
{
|
|
ReoGridOutline reoGridOutline = this.OutlineButtonHittest(outlineCollection, location);
|
|
bool flag3 = reoGridOutline != null;
|
|
if (flag3)
|
|
{
|
|
bool internalCollapsed = reoGridOutline.InternalCollapsed;
|
|
if (internalCollapsed)
|
|
{
|
|
reoGridOutline.Expand();
|
|
return true;
|
|
}
|
|
reoGridOutline.Collapse();
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return base.OnMouseDown(location, buttons, modifiers);
|
|
}
|
|
|
|
public override void UpdateView()
|
|
{
|
|
OutlineCollection<ReoGridOutline> outlines = this.sheet.GetOutlines(this.Flag);
|
|
bool flag = outlines != null;
|
|
if (flag)
|
|
{
|
|
float num = Math.Min(this.scaleFactor, 1f);
|
|
int num2 = (int)Math.Round((double)(13f * this.scaleFactor));
|
|
bool flag2 = num2 > 13;
|
|
if (flag2)
|
|
{
|
|
num2 = 13;
|
|
}
|
|
for (int i = 0; i < outlines.Count; i++)
|
|
{
|
|
int loc = (int)Math.Round((double)((float)(16 * i) * num));
|
|
OutlineGroup<ReoGridOutline> outlineGroup = outlines[i];
|
|
bool flag3 = i < outlines.Count - 1;
|
|
if (flag3)
|
|
{
|
|
foreach (ReoGridOutline reoGridOutline in outlineGroup)
|
|
{
|
|
reoGridOutline.ToggleButtonBounds = this.CreateToggleButtonRect(loc, reoGridOutline.End, num2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected abstract Rect CreateToggleButtonRect(int loc, int pos, int buttonSize);
|
|
}
|
|
}
|