private void animationTimerTick(object sender, System.EventArgs e)
{
switch(currentState)
{
case SplitterState.Collapsing:
if(this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
{
// vertical splitter
if(controlToHide.Width > animationStep)
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Width -= animationStep;
}
controlToHide.Width -= animationStep;
}
else
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Width = parentFormWidth;
}
controlToHide.Visible = false;
animationTimer.Enabled = false;
controlToHide.Width = controlWidth;
currentState = SplitterState.Collapsed;
this.Invalidate();
}
}
else
{
// horizontal splitter
if(controlToHide.Height > animationStep)
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Height -= animationStep;
}
controlToHide.Height -= animationStep;
}
else
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Height = parentFormHeight;
}
controlToHide.Visible = false;
animationTimer.Enabled = false;
controlToHide.Height = controlHeight;
currentState = SplitterState.Collapsed;
this.Invalidate();
}
}
break;
case SplitterState.Expanding:
if(this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
{
// vertical splitter
if(controlToHide.Width < (controlWidth - animationStep))
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Width += animationStep;
}
controlToHide.Width += animationStep;
}
else
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Width = parentFormWidth;
}
controlToHide.Width = controlWidth;
controlToHide.Visible = true;
animationTimer.Enabled = false;
currentState = SplitterState.Expanded;
this.Invalidate();
}
}
else
{
// horizontal splitter
if(controlToHide.Height < (controlHeight - animationStep))
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Height += animationStep;
}
controlToHide.Height += animationStep;
}
else
{
if(expandParentForm && parentForm.WindowState != FormWindowState.Maximized
&& parentForm != null)
{
parentForm.Height = parentFormHeight;
}
controlToHide.Height = controlHeight;
controlToHide.Visible = true;
animationTimer.Enabled = false;
currentState = SplitterState.Expanded;
this.Invalidate();
}
}
break;
}
}