172 lines
3.4 KiB
C#
172 lines
3.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
|
|
namespace GoldPrinter
|
|
{
|
|
public class DrawRectangle : DrawBase
|
|
{
|
|
private BordersEdgeFlag _borderEdge;
|
|
|
|
private Color _backColor;
|
|
|
|
public BordersEdgeFlag BordersEdge
|
|
{
|
|
get
|
|
{
|
|
return this._borderEdge;
|
|
}
|
|
set
|
|
{
|
|
this._borderEdge = value;
|
|
}
|
|
}
|
|
|
|
public Color BackColor
|
|
{
|
|
get
|
|
{
|
|
return this._backColor;
|
|
}
|
|
set
|
|
{
|
|
this._backColor = value;
|
|
}
|
|
}
|
|
|
|
public DrawRectangle()
|
|
{
|
|
this._borderEdge = BordersEdgeFlag.FourEdge;
|
|
this._backColor = Color.White;
|
|
}
|
|
|
|
public override void Draw()
|
|
{
|
|
switch (this.BordersEdge)
|
|
{
|
|
case BordersEdgeFlag.Left:
|
|
this.DrawLeftLine();
|
|
break;
|
|
case BordersEdgeFlag.Right:
|
|
this.DrawRightLine();
|
|
break;
|
|
case BordersEdgeFlag.Top:
|
|
this.DrawTopLine();
|
|
break;
|
|
case BordersEdgeFlag.Bottom:
|
|
this.DrawBottomLine();
|
|
break;
|
|
case BordersEdgeFlag.DiagonalDown:
|
|
this.DrawDiagonalDownLine();
|
|
break;
|
|
case BordersEdgeFlag.DiagonalUp:
|
|
this.DrawDiagonalUpLine();
|
|
break;
|
|
default:
|
|
this.Draw(base.Graphics, base.Pen, base.Rectangle);
|
|
break;
|
|
}
|
|
if (this.BackColor != Color.White)
|
|
{
|
|
this.FillRectangle();
|
|
}
|
|
}
|
|
|
|
public void FillRectangle()
|
|
{
|
|
Pen pen = new Pen(this.BackColor);
|
|
base.Brush = pen.Brush;
|
|
this.DrawBackColor(base.Graphics, base.Brush, base.Rectangle);
|
|
}
|
|
|
|
public void DrawLeftLine()
|
|
{
|
|
this.DrawLeftLine(base.Graphics, base.Pen, base.Rectangle);
|
|
}
|
|
|
|
public void DrawRightLine()
|
|
{
|
|
this.DrawRightLine(base.Graphics, base.Pen, base.Rectangle);
|
|
}
|
|
|
|
public void DrawTopLine()
|
|
{
|
|
this.DrawTopLine(base.Graphics, base.Pen, base.Rectangle);
|
|
}
|
|
|
|
public void DrawBottomLine()
|
|
{
|
|
this.DrawBottomLine(base.Graphics, base.Pen, base.Rectangle);
|
|
}
|
|
|
|
public void DrawDiagonalDownLine()
|
|
{
|
|
this.DrawDiagonalDownLine(base.Graphics, base.Pen, base.Rectangle);
|
|
}
|
|
|
|
public void DrawDiagonalUpLine()
|
|
{
|
|
this.DrawDiagonalUpLine(base.Graphics, base.Pen, base.Rectangle);
|
|
}
|
|
|
|
protected void Draw(Graphics g, Pen pen, Rectangle rec)
|
|
{
|
|
g.DrawRectangle(pen, rec.X, rec.Y, rec.Width, rec.Height);
|
|
}
|
|
|
|
protected void DrawLeftLine(Graphics g, Pen pen, Rectangle rec)
|
|
{
|
|
int left = rec.Left;
|
|
int top = rec.Top;
|
|
int bottom = rec.Bottom;
|
|
g.DrawLine(pen, left, top, left, bottom);
|
|
}
|
|
|
|
protected void DrawRightLine(Graphics g, Pen pen, Rectangle rec)
|
|
{
|
|
int right = rec.Right;
|
|
int top = rec.Top;
|
|
int bottom = rec.Bottom;
|
|
g.DrawLine(pen, right, top, right, bottom);
|
|
}
|
|
|
|
protected void DrawTopLine(Graphics g, Pen pen, Rectangle rec)
|
|
{
|
|
int left = rec.Left;
|
|
int right = rec.Right;
|
|
int top = rec.Top;
|
|
g.DrawLine(pen, left, top, right, top);
|
|
}
|
|
|
|
protected void DrawBottomLine(Graphics g, Pen pen, Rectangle rec)
|
|
{
|
|
int left = rec.Left;
|
|
int right = rec.Right;
|
|
int bottom = rec.Bottom;
|
|
g.DrawLine(pen, left, bottom, right, bottom);
|
|
}
|
|
|
|
protected void DrawDiagonalDownLine(Graphics g, Pen pen, Rectangle rec)
|
|
{
|
|
int x = rec.X;
|
|
int y = rec.Y;
|
|
int right = rec.Right;
|
|
int bottom = rec.Bottom;
|
|
g.DrawLine(pen, x, y, right, bottom);
|
|
}
|
|
|
|
protected void DrawDiagonalUpLine(Graphics g, Pen pen, Rectangle rec)
|
|
{
|
|
int x = rec.X;
|
|
int bottom = rec.Bottom;
|
|
int right = rec.Right;
|
|
int top = rec.Top;
|
|
g.DrawLine(pen, x, bottom, right, top);
|
|
}
|
|
|
|
protected void DrawBackColor(Graphics g, Brush brush, Rectangle rec)
|
|
{
|
|
g.FillRectangle(brush, rec);
|
|
}
|
|
}
|
|
}
|