205 lines
5.8 KiB
C#
205 lines
5.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using CPF.ReoGrid.Core;
|
|
|
|
namespace CPF.ReoGrid.Outline
|
|
{
|
|
public class ColumnOutline : ReoGridOutline, IColumnRange
|
|
{
|
|
internal ColumnOutline(Worksheet grid, int start, int count) : base(grid, start, count)
|
|
{
|
|
}
|
|
|
|
public override void Collapse()
|
|
{
|
|
OutlineCollection<ReoGridOutline> outlines = base.sheet.GetOutlines(RowOrColumn.Column);
|
|
bool flag = outlines == null;
|
|
if (!flag)
|
|
{
|
|
bool flag2 = !this.RaiseBeforeCollapseEvent();
|
|
if (!flag2)
|
|
{
|
|
int groupIndex;
|
|
int groupIndex2;
|
|
for (groupIndex = 0; groupIndex < outlines.Count - 1; groupIndex = groupIndex2 + 1)
|
|
{
|
|
OutlineGroup<ReoGridOutline> outlineGroup = outlines[groupIndex];
|
|
bool flag3 = outlineGroup.Contains(this);
|
|
if (flag3)
|
|
{
|
|
break;
|
|
}
|
|
groupIndex2 = groupIndex;
|
|
}
|
|
base.sheet.SetColumnsWidth(base.Start, base.Count, delegate(int c)
|
|
{
|
|
Func<ReoGridOutline, bool> callFunc = null;
|
|
for (int i = groupIndex + 1; i < outlines.Count - 1; i++)
|
|
{
|
|
OutlineGroup<ReoGridOutline> outlineGroup2 = outlines[i];
|
|
IEnumerable<ReoGridOutline> source = outlineGroup2;
|
|
Func<ReoGridOutline, bool> predicate;
|
|
if ((predicate = callFunc) == null)
|
|
{
|
|
predicate = (callFunc = ((ReoGridOutline o) => o.InternalCollapsed && o != this && o.Start <= c && o.End > c));
|
|
}
|
|
ReoGridOutline reoGridOutline = source.FirstOrDefault(predicate);
|
|
bool flag4 = reoGridOutline != null;
|
|
if (flag4)
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
return 0;
|
|
}, false, true);
|
|
base.CollapseInnerOutlines(outlines, groupIndex);
|
|
base.InternalCollapsed = true;
|
|
this.RaiseAfterCollapseEvent();
|
|
}
|
|
}
|
|
}
|
|
|
|
internal override bool RaiseBeforeCollapseEvent()
|
|
{
|
|
BeforeOutlineCollapseEventArgs beforeOutlineCollapseEventArgs = new BeforeOutlineCollapseEventArgs(this);
|
|
bool flag = this.BeforeCollapse != null;
|
|
if (flag)
|
|
{
|
|
this.BeforeCollapse(this, beforeOutlineCollapseEventArgs);
|
|
}
|
|
base.sheet.RaiseBeforeOutlineCollapseEvent(beforeOutlineCollapseEventArgs);
|
|
return !beforeOutlineCollapseEventArgs.IsCancelled;
|
|
}
|
|
|
|
internal override void RaiseAfterCollapseEvent()
|
|
{
|
|
AfterOutlineCollapseEventArgs afterOutlineCollapseEventArgs = new AfterOutlineCollapseEventArgs(this);
|
|
bool flag = this.AfterCollapse != null;
|
|
if (flag)
|
|
{
|
|
this.AfterCollapse(this, afterOutlineCollapseEventArgs);
|
|
}
|
|
base.sheet.RaiseAfterOutlineCollapseEvent(afterOutlineCollapseEventArgs);
|
|
}
|
|
|
|
public override void Expand()
|
|
{
|
|
OutlineCollection<ReoGridOutline> outlines = base.sheet.GetOutlines(RowOrColumn.Column);
|
|
bool flag = outlines == null;
|
|
if (!flag)
|
|
{
|
|
bool flag2 = !this.RaiseBeforeExpandingEvent();
|
|
if (!flag2)
|
|
{
|
|
int groupIndex;
|
|
int groupIndex2;
|
|
for (groupIndex = 0; groupIndex < outlines.Count - 1; groupIndex = groupIndex2 + 1)
|
|
{
|
|
OutlineGroup<ReoGridOutline> outlineGroup = outlines[groupIndex];
|
|
bool flag3 = outlineGroup.Contains(this);
|
|
if (flag3)
|
|
{
|
|
break;
|
|
}
|
|
groupIndex2 = groupIndex;
|
|
}
|
|
base.ExpandOuterOutlines(outlines, groupIndex);
|
|
base.sheet.SetColumnsWidth(base.Start, base.Count, delegate(int r)
|
|
{
|
|
Func<ReoGridOutline, bool> callFunc = null;
|
|
for (int i = groupIndex + 1; i < outlines.Count - 1; i++)
|
|
{
|
|
OutlineGroup<ReoGridOutline> outlineGroup2 = outlines[i];
|
|
IEnumerable<ReoGridOutline> source = outlineGroup2;
|
|
Func<ReoGridOutline, bool> predicate;
|
|
if ((predicate = callFunc) == null)
|
|
{
|
|
predicate = (callFunc = ((ReoGridOutline o) => o.Start <= r && o.End > r));
|
|
}
|
|
ReoGridOutline reoGridOutline = source.FirstOrDefault(predicate);
|
|
bool flag4 = reoGridOutline != null && reoGridOutline.InternalCollapsed;
|
|
if (flag4)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
ColumnHeader columnHeader = this.sheet.RetrieveColumnHeader(r);
|
|
return (int)(columnHeader.IsVisible ? columnHeader.InnerWidth : columnHeader.LastWidth);
|
|
}, false, true);
|
|
base.InternalCollapsed = false;
|
|
this.RaiseAfterExpandingEvent();
|
|
}
|
|
}
|
|
}
|
|
|
|
public int Col
|
|
{
|
|
get
|
|
{
|
|
return base.Start;
|
|
}
|
|
set
|
|
{
|
|
base.Start = value;
|
|
}
|
|
}
|
|
|
|
public int Cols
|
|
{
|
|
get
|
|
{
|
|
return base.Count;
|
|
}
|
|
set
|
|
{
|
|
base.Count = value;
|
|
}
|
|
}
|
|
|
|
public int EndCol
|
|
{
|
|
get
|
|
{
|
|
return base.End;
|
|
}
|
|
}
|
|
|
|
internal override bool RaiseBeforeExpandingEvent()
|
|
{
|
|
BeforeOutlineExpandingEventArgs beforeOutlineExpandingEventArgs = new BeforeOutlineExpandingEventArgs(this);
|
|
bool flag = this.BeforeExpand != null;
|
|
if (flag)
|
|
{
|
|
this.BeforeExpand(this, beforeOutlineExpandingEventArgs);
|
|
}
|
|
base.sheet.RaiseBeforeOutlineExpandEvent(beforeOutlineExpandingEventArgs);
|
|
return !beforeOutlineExpandingEventArgs.IsCancelled;
|
|
}
|
|
|
|
internal override void RaiseAfterExpandingEvent()
|
|
{
|
|
AfterOutlineExpandingEventArgs afterOutlineExpandingEventArgs = new AfterOutlineExpandingEventArgs(this);
|
|
bool flag = this.AfterExpand != null;
|
|
if (flag)
|
|
{
|
|
this.AfterExpand(this, afterOutlineExpandingEventArgs);
|
|
}
|
|
base.sheet.RaiseAfterOutlineExpandEvent(afterOutlineExpandingEventArgs);
|
|
}
|
|
|
|
//[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
public override event EventHandler<BeforeOutlineCollapseEventArgs> BeforeCollapse;
|
|
|
|
//[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
public override event EventHandler<AfterOutlineCollapseEventArgs> AfterCollapse;
|
|
|
|
//[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
public override event EventHandler<BeforeOutlineExpandingEventArgs> BeforeExpand;
|
|
|
|
//[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
public override event EventHandler<AfterOutlineExpandingEventArgs> AfterExpand;
|
|
}
|
|
}
|