private void DrawHorizontalSplit(RenderContext context, PaletteState drawState)
{
// We need the rectangle that represents just the split area
int partialWidth = (ClientWidth / 3 * 2);
Rectangle splitRectangle = _controller.SplitRectangle;
Rectangle beforeSplitRect = new Rectangle(ClientLocation, new Size(splitRectangle.X - ClientLocation.X, ClientHeight));
Rectangle splitterRect = new Rectangle(splitRectangle.Location, new Size(1, ClientHeight));
Rectangle afterSplitRect = new Rectangle(splitRectangle.X, ClientLocation.Y , splitRectangle.Width, ClientHeight);
bool splitWithFading = SplitWithFading(drawState);
switch (drawState)
{
case PaletteState.Normal:
// Draw the entire border around the button
if (_constantBorder)
{
DrawBackground(_paletteBack, context, ClientRectangle, PaletteState.Normal);
DrawBorder(_paletteBorder, context, ClientRectangle, PaletteState.Normal);
}
break;
case PaletteState.Tracking:
// Draw the background for the click and split areas
if (_controller.MouseInSplit)
{
using (Clipping clipToSplitter = new Clipping(context.Graphics, afterSplitRect))
if (splitWithFading)
{
if (_drawNonTrackingAreas)
DrawBackground(_paletteBackLight, context, ClientRectangle, PaletteState.Tracking);
}
else
DrawBackground(_paletteBackDraw, context, ClientRectangle, PaletteState.Normal);
Rectangle afterSplitRect1 = new Rectangle(afterSplitRect.X + 1, afterSplitRect.Y, afterSplitRect.Width - 1, afterSplitRect.Height);
using (Clipping clipToSplitter = new Clipping(context.Graphics, afterSplitRect1))
DrawBackground(_paletteBack, context, ClientRectangle, PaletteState.Tracking);
using (Clipping clipToSplitter = new Clipping(context.Graphics, beforeSplitRect))
if (splitWithFading)
{
if (_drawNonTrackingAreas)
DrawBackground(_paletteBackLight, context, ClientRectangle, PaletteState.Tracking);
}
else
DrawBackground(_paletteBackDraw, context, ClientRectangle, PaletteState.Normal);
}
else
{
using (Clipping clipToSplitter = new Clipping(context.Graphics, beforeSplitRect))
DrawBackground(_paletteBack, context, ClientRectangle, PaletteState.Tracking);
using (Clipping clipToSplitter = new Clipping(context.Graphics, afterSplitRect))
if (splitWithFading)
{
if (_drawNonTrackingAreas)
DrawBackground(_paletteBackLight, context, ClientRectangle, PaletteState.Tracking);
}
else
DrawBackground(_paletteBackDraw, context, ClientRectangle, PaletteState.Normal);
}
// Draw the single pixel splitter line
using (Clipping clipToSplitter = new Clipping(context.Graphics, splitterRect))
DrawBorder(_paletteBorderAll, context, new Rectangle(splitRectangle.X, splitRectangle.Y, 2, splitRectangle.Height), PaletteState.Tracking);
// Draw the entire border around the button
if (_constantBorder)
DrawBorder(_paletteBorder, context, ClientRectangle, PaletteState.Normal);
// If the border is not constant, drawn it now
if (!_constantBorder)
{
// Draw the entire border around the button
DrawBorder(_paletteBorder, context, ClientRectangle, PaletteState.Tracking);
}
break;
case PaletteState.Pressed:
// Draw the background for the click and split areas
if (_controller.MouseInSplit)
{
using (Clipping clipToSplitter = new Clipping(context.Graphics, afterSplitRect))
if (splitWithFading)
{
if (_drawNonTrackingAreas)
DrawBackground(_paletteBackLight, context, ClientRectangle, PaletteState.Pressed);
}
else
DrawBackground(_paletteBackDraw, context, ClientRectangle, PaletteState.Normal);
Rectangle afterSplitRect1 = new Rectangle(afterSplitRect.X + 1, afterSplitRect.Y, afterSplitRect.Width - 1, afterSplitRect.Height);
using (Clipping clipToSplitter = new Clipping(context.Graphics, afterSplitRect1))
DrawBackground(_paletteBack, context, ClientRectangle, PaletteState.Pressed);
using (Clipping clipToSplitter = new Clipping(context.Graphics, beforeSplitRect))
if (splitWithFading)
{
if (_drawNonTrackingAreas)
DrawBackground(_paletteBackLight, context, ClientRectangle, PaletteState.Tracking);
}
else
DrawBackground(_paletteBackDraw, context, ClientRectangle, PaletteState.Normal);
}
else
{
using (Clipping clipToSplitter = new Clipping(context.Graphics, beforeSplitRect))
DrawBackground(_paletteBack, context, ClientRectangle, PaletteState.Pressed);
using (Clipping clipToSplitter = new Clipping(context.Graphics, afterSplitRect))
if (splitWithFading)
{
if (_drawNonTrackingAreas)
DrawBackground(_paletteBackLight, context, ClientRectangle, PaletteState.Tracking);
}
else
DrawBackground(_paletteBackDraw, context, ClientRectangle, PaletteState.Normal);
}
// Draw the single pixel splitter line
using (Clipping clipToSplitter = new Clipping(context.Graphics, splitterRect))
DrawBorder(_paletteBorderAll, context, new Rectangle(splitRectangle.X, splitRectangle.Y, 2, splitRectangle.Height), PaletteState.Pressed);
// Draw the entire border around the button
if (_constantBorder)
DrawBorder(_paletteBorder, context, ClientRectangle, PaletteState.Normal);
// If the border is not constant, drawn it now
if (!_constantBorder)
{
// Draw the entire border around the button
DrawBorder(_paletteBorder, context, ClientRectangle, PaletteState.Tracking);
// Draw the border for the click and split areas
if (_controller.MouseInSplit)
using (Clipping clipToSplitter = new Clipping(context.Graphics, afterSplitRect))
DrawBorder(_paletteBorder, context, ClientRectangle, PaletteState.Pressed);
else
using (Clipping clipToSplitter = new Clipping(context.Graphics, beforeSplitRect))
DrawBorder(_paletteBorder, context, ClientRectangle, PaletteState.Pressed);
}
break;
default:
// Should never happen
Debug.Assert(false);
break;
}
}