127 lines
2.9 KiB
C#
127 lines
2.9 KiB
C#
using System;
|
|
using System.Linq;
|
|
using CPF.Drawing;
|
|
|
|
namespace CPF.ReoGrid.Outline
|
|
{
|
|
public abstract class ReoGridOutline : IReoGridOutline
|
|
{
|
|
public Worksheet sheet { get; set; }
|
|
|
|
internal ReoGridOutline(Worksheet sheet, int start, int count)
|
|
{
|
|
this.sheet = sheet;
|
|
this.Start = start;
|
|
this.Count = count;
|
|
}
|
|
|
|
public int Start { get; set; }
|
|
|
|
public int Count { get; set; }
|
|
|
|
public int End
|
|
{
|
|
get
|
|
{
|
|
return this.Start + this.Count;
|
|
}
|
|
}
|
|
|
|
internal bool InternalCollapsed { get; set; }
|
|
|
|
public bool Collapsed
|
|
{
|
|
get
|
|
{
|
|
return this.InternalCollapsed;
|
|
}
|
|
set
|
|
{
|
|
bool flag = !this.InternalCollapsed;
|
|
if (flag)
|
|
{
|
|
this.Collapse();
|
|
}
|
|
}
|
|
}
|
|
|
|
internal Rect ToggleButtonBounds { get; set; }
|
|
|
|
public bool Contains(ReoGridOutline outline)
|
|
{
|
|
return this.Start <= outline.Start && this.End >= outline.End;
|
|
}
|
|
|
|
public bool Contains(int index)
|
|
{
|
|
return index >= this.Start && index < this.End;
|
|
}
|
|
|
|
public bool IntersectWith(ReoGridOutline outline)
|
|
{
|
|
return this.IntersectWith(outline.Start, outline.Count);
|
|
}
|
|
|
|
public bool IntersectWith(int start, int count)
|
|
{
|
|
int num = start + count;
|
|
return (this.Start < start && this.End >= start && this.End < num) || (this.Start > start && this.Start <= num && this.End > num);
|
|
}
|
|
|
|
public abstract void Collapse();
|
|
|
|
public abstract void Expand();
|
|
|
|
protected void CollapseInnerOutlines(OutlineCollection<ReoGridOutline> outlines, int groupIndex)
|
|
{
|
|
for (int i = groupIndex + 1; i < outlines.Count - 1; i++)
|
|
{
|
|
OutlineGroup<ReoGridOutline> source = outlines[i];
|
|
foreach (ReoGridOutline reoGridOutline in from o in source
|
|
where !o.InternalCollapsed && o.Start > this.Start && o.End == this.End
|
|
select o)
|
|
{
|
|
reoGridOutline.InternalCollapsed = true;
|
|
reoGridOutline.RaiseAfterCollapseEvent();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void ExpandOuterOutlines(OutlineCollection<ReoGridOutline> outlines, int groupIndex)
|
|
{
|
|
ReoGridOutline reoGridOutline = null;
|
|
for (int i = groupIndex - 1; i >= 0; i--)
|
|
{
|
|
OutlineGroup<ReoGridOutline> source = outlines[i];
|
|
reoGridOutline = source.FirstOrDefault((ReoGridOutline o) => o.InternalCollapsed && o.Start < this.Start && o.End == this.End);
|
|
bool flag = reoGridOutline != null;
|
|
if (flag)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
bool flag2 = reoGridOutline != null;
|
|
if (flag2)
|
|
{
|
|
reoGridOutline.Expand();
|
|
}
|
|
}
|
|
|
|
internal abstract bool RaiseBeforeCollapseEvent();
|
|
|
|
internal abstract void RaiseAfterCollapseEvent();
|
|
|
|
internal abstract bool RaiseBeforeExpandingEvent();
|
|
|
|
internal abstract void RaiseAfterExpandingEvent();
|
|
|
|
public abstract event EventHandler<BeforeOutlineCollapseEventArgs> BeforeCollapse;
|
|
|
|
public abstract event EventHandler<AfterOutlineCollapseEventArgs> AfterCollapse;
|
|
|
|
public abstract event EventHandler<BeforeOutlineExpandingEventArgs> BeforeExpand;
|
|
|
|
public abstract event EventHandler<AfterOutlineExpandingEventArgs> AfterExpand;
|
|
}
|
|
}
|