Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

//

//
//
//
//
//

Name: GuideLines
Author: xod
Submenu: Render
URL:
Title: GuideLines
CodeLab 2.12

#region UICode
ListBoxControl Amount1 = 0; // Line Style and Color|Solid|Dash|Dash-Dot|Dash-Dot-Dot|Dot
ColorWheelControl Amount2 = ColorBgra.FromBgr(0,0,0); //
IntSliderControl Amount3 = 1; // [1,1000] Line Width
ListBoxControl Amount4 = 0; // Axes|None
|Vertical|Horizontal|Both
ListBoxControl Amount5 = 0; // Diagonals|None
|First|Second|Both
ListBoxControl Amount6 = 0; // Half to corners|None
|Horiz Left|Horiz
Right|Horiz Both|Vert Up|Vert Down|Vert Both|H and V Both
ListBoxControl Amount7 = 0; // Half to half|None
|Horiz Left|Horiz
Right|Both|Vert Up|Vert Down
ListBoxControl Amount8 = 0; // Options|None|Move X, Y|Axes Offset = X|Borders Offset =
Y|Both Offsets X, Y|VLineSpace = X|HLineSpace = Y|Grid X, Y
IntSliderControl Amount9 = 20; // [0,11811] X
IntSliderControl Amount10 = 20; // [0,11811] Y
#endregion
void Render(Surface dst, Surface src, Rectangle rect)
{
Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
dst.CopySurface(src,rect.Location,rect); // copy surface quicker than looping through
byte penstyle = (byte)(Amount1);
ColorBgra pencol = Amount2;
float penW = Amount3;
float sTop = selection.Top;
float sBot = selection.Bottom;
float sLeft = selection.Left;
float sRite = selection.Right;
float H = selection.Height;
float midH = (H/2) - 0.5f;
float W = selection.Width;
float midW = (W/2) - 0.5f;
byte TypeAxe = (byte)(Amount4);
byte TypeDiag = (byte)(Amount5);
byte TyHaCo = (byte)(Amount6);
byte TyHaHa = (byte)(Amount7);
byte Options = (byte)(Amount8);
using (RenderArgs ra = new RenderArgs(dst))
{
Graphics graf = ra.Graphics;
graf.Clip = new Region(rect);
graf.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
using(Pen colpen = new Pen(pencol))
{
colpen.Width = penW;
switch(penstyle)
{
case 0:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; break;
case 1:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; break;
case 2:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; break;
case 3:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; break;
case 4:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; break;
}
//*************************************************************************
switch(TypeAxe) // Draw Axes
{
case 0: //none
break;

case 1: //vertical
PointF topmid = new PointF(sLeft + midW, sTop - 1f);
PointF botmid = new PointF(sLeft + midW, sBot);
graf.DrawLine(colpen, topmid, botmid);
break;
case 2: //horizontal
PointF leftmid = new PointF(sLeft - 1f, sTop + midH);
PointF ritemid = new PointF(sRite, sTop + midH);
graf.DrawLine(colpen, leftmid, ritemid);
break;
case 3: //vertical & horizontal
PointF topmid1 = new PointF(sLeft + midW, sTop - 1f); //vertical & horizontal
PointF botmid1 = new PointF(sLeft + midW, sBot);
graf.DrawLine(colpen, topmid1, botmid1);
PointF leftmid1 = new PointF(sLeft - 1f, sTop + midH);
PointF ritemid1 = new PointF(sRite, sTop + midH);
graf.DrawLine(colpen, leftmid1, ritemid1);
break;
}
//*************************************************************************
switch(TypeDiag) // Draw Diagonals
{
case 0: //none
break;
case 1: //1st diag.
PointF topleft = new PointF(sLeft, sTop);
PointF botrite = new PointF(sRite, sBot - 0.5f);
graf.DrawLine(colpen, topleft, botrite);
break;
case 2: //2nd diag.
PointF toprite = new PointF(sRite, sTop - 1f);
PointF botleft = new PointF(sLeft, sBot - 1f);
graf.DrawLine(colpen, botleft, toprite);
break;
case 3: //first & second
PointF topleft1 = new PointF(sLeft, sTop);
PointF botrite1 = new PointF(sRite, sBot - 0.5f);
PointF toprite1 = new PointF(sRite, sTop - 1f);
PointF botleft1 = new PointF(sLeft, sBot - 1f);
graf.DrawLine(colpen, topleft1, botrite1);
graf.DrawLine(colpen, botleft1, toprite1);
break;
}
//**********************************************************************
switch(TyHaCo) // Draw Half to corners
{
case 0: //none
break;
case 1: //Horiz Left
PointF leftmid = new PointF(sLeft - 1f, sTop + midH);
PointF toprite = new PointF(sRite, sTop - 1f);
PointF botrite = new PointF(sRite, sBot - 0.5f);
graf.DrawLine(colpen, leftmid, toprite );
graf.DrawLine(colpen, leftmid, botrite);
break;
case 2: //Horiz Right
PointF ritemid = new PointF(sRite, sTop + midH);
PointF topleft = new PointF(sLeft, sTop);
PointF botleft = new PointF(sLeft, sBot - 1f);
graf.DrawLine(colpen, ritemid, topleft );
graf.DrawLine(colpen, ritemid, botleft);
break;

case 3: //Horiz Both


PointF leftmid1 = new
PointF toprite1 = new
PointF botrite1 = new
graf.DrawLine(colpen,
graf.DrawLine(colpen,
PointF ritemid1 = new
PointF topleft1 = new
PointF botleft1 = new
graf.DrawLine(colpen,
graf.DrawLine(colpen,
break;

PointF(sLeft - 1f, sTop + midH);


PointF(sRite, sTop - 1f);
PointF(sRite, sBot - 0.5f);
leftmid1, toprite1 );
leftmid1, botrite1);
PointF(sRite, sTop + midH);
PointF(sLeft, sTop);
PointF(sLeft, sBot - 1f);
ritemid1, topleft1 );
ritemid1, botleft1);

case 4: //Vert Up
PointF topmid = new PointF(sLeft + midW, sTop - 1f);
PointF botleft2 = new PointF(sLeft, sBot - 1f);
PointF botrite2 = new PointF(sRite, sBot - 0.5f);
graf.DrawLine(colpen, topmid, botleft2);
graf.DrawLine(colpen, topmid, botrite2);
break;
case 5: //Vert Down
PointF botmid = new PointF(sLeft + midW, sBot);
PointF toprite2 = new PointF(sRite, sTop - 1f);
PointF topleft2 = new PointF(sLeft, sTop);
graf.DrawLine(colpen, botmid, toprite2);
graf.DrawLine(colpen, botmid, topleft2);
break;
case 6: //Vert. Both
PointF topmid1 = new PointF(sLeft + midW, sTop - 1f);
PointF botleft3 = new PointF(sLeft, sBot - 1f);
PointF botrite3 = new PointF(sRite, sBot - 0.5f);
graf.DrawLine(colpen, topmid1, botleft3);
graf.DrawLine(colpen, topmid1, botrite3);
PointF botmid1 = new PointF(sLeft + midW, sBot);
PointF toprite3 = new PointF(sRite, sTop - 1f);
PointF topleft3 = new PointF(sLeft, sTop);
graf.DrawLine(colpen, botmid1, toprite3);
graf.DrawLine(colpen, botmid1, topleft3);
break;
case 7: //Horiz. & Vert. Both
PointF leftmid2 = new PointF(sLeft - 1f, sTop + midH);
PointF toprite4 = new PointF(sRite, sTop - 1f);
PointF botrite4 = new PointF(sRite, sBot - 0.5f);
graf.DrawLine(colpen, leftmid2, toprite4);
graf.DrawLine(colpen, leftmid2, botrite4);
PointF ritemid2 = new
PointF topleft4 = new
PointF botleft4 = new
graf.DrawLine(colpen,
graf.DrawLine(colpen,

PointF(sRite, sTop + midH);


PointF(sLeft, sTop);
PointF(sLeft, sBot - 1f);
ritemid2, topleft4);
ritemid2, botleft4);

PointF topmid2 = new PointF(sLeft + midW, sTop - 1f);


PointF botleft5 = new PointF(sLeft, sBot - 1f);
PointF botrite5 = new PointF(sRite, sBot - 0.5f);
graf.DrawLine(colpen, topmid2, botleft5);
graf.DrawLine(colpen, topmid2, botrite5);
PointF botmid2 = new PointF(sLeft + midW, sBot);
PointF toprite5 = new PointF(sRite, sTop - 1f);
PointF topleft5 = new PointF(sLeft, sTop);
graf.DrawLine(colpen, botmid2, toprite5);
graf.DrawLine(colpen, botmid2, topleft5);
break;
}

//************************************************************************
switch(TyHaHa) // Draw Half to Half
{
case 0: //none
break;
case 1: // Oriz.Left
PointF leftmid = new PointF(sLeft - 1f, sTop + midH);
PointF topmid = new PointF(sLeft + midW, sTop - 1f);
PointF botmid = new PointF(sLeft + midW, sBot);
graf.DrawLine(colpen, leftmid, topmid);
graf.DrawLine(colpen, leftmid, botmid);
break;
case 2: // Oriz.Right
PointF ritemid = new PointF(sRite, sTop + midH);
PointF topmid1 = new PointF(sLeft + midW, sTop - 1f);
PointF botmid1 = new PointF(sLeft + midW, sBot);
graf.DrawLine(colpen, ritemid, topmid1);
graf.DrawLine(colpen, ritemid, botmid1);
break;
case 3: // Oriz.Both
PointF leftmid1 = new PointF(sLeft - 1f, sTop + midH);
PointF topmid2 = new PointF(sLeft + midW, sTop - 1f);
PointF botmid2 = new PointF(sLeft + midW, sBot);
graf.DrawLine(colpen, leftmid1, topmid2);
graf.DrawLine(colpen, leftmid1, botmid2);
PointF ritemid1 = new PointF(sRite, sTop + midH);
PointF topmid3 = new PointF(sLeft + midW, sTop - 1f);
PointF botmid3 = new PointF(sLeft + midW, sBot);
graf.DrawLine(colpen, ritemid1, topmid3);
graf.DrawLine(colpen, ritemid1, botmid3);
break;
case 4: // Vert.Up
PointF topmid4 = new PointF(sLeft + midW, sTop - 1f);
PointF leftmid2 = new PointF(sLeft - 1f, sTop + midH);
PointF ritemid2 = new PointF(sRite, sTop + midH);
graf.DrawLine(colpen, topmid4, leftmid2);
graf.DrawLine(colpen, topmid4, ritemid2);
break;
case 5: // Vert.Down
PointF botmid4 = new PointF(sLeft + midW, sBot);
PointF leftmid3 = new PointF(sLeft - 1f, sTop + midH);
PointF ritemid3 = new PointF(sRite, sTop + midH);
graf.DrawLine(colpen, botmid4, leftmid3);
graf.DrawLine(colpen, botmid4, ritemid3);
break;
}
//***************************************************************
switch(Options)
{
case 0: //none
break;
case 1: // Move Lines
PointF left = new PointF(sLeft - 1f, sTop + Amount9);
PointF rite = new PointF(sRite, sTop + Amount9);
PointF top = new PointF(Amount10 + sLeft, sTop - 1f);
PointF bot = new PointF(Amount10 + sLeft, sBot);
graf.DrawLine(colpen,top,bot);
graf.DrawLine(colpen,left,rite);
break;
case 2: // Axes Offsets
PointF topmid = new PointF(Amount9 + sLeft + midW, sTop - 1f);
PointF botmid = new PointF(Amount9 + sLeft + midW, sBot);

PointF leftmid = new PointF(sLeft - 1f, sTop + midH + Amount9);


PointF ritemid = new PointF(sRite, sTop + midH + Amount9);
graf.DrawLine(colpen,topmid,botmid);
graf.DrawLine(colpen,leftmid,ritemid);
PointF topmid1 = new PointF(sLeft + midW
PointF botmid1 = new PointF(sLeft + midW
PointF leftmid1 = new PointF(sLeft - 1f,
PointF ritemid1 = new PointF(sRite, sTop
graf.DrawLine(colpen,topmid1,botmid1);
graf.DrawLine(colpen,leftmid1,ritemid1);
break;

- Amount9, sTop - 1f);


- Amount9, sBot);
sTop + midH - Amount9);
+ midH - Amount9);

case 3: // Borders Offsets


PointF top1 = new PointF(Amount10 + sLeft, sTop - 1f);
PointF bot1 = new PointF(Amount10 + sLeft, sBot);
PointF left1 = new PointF(sLeft - 1f, sTop + Amount10);
PointF rite1 = new PointF(sRite, sTop + Amount10);
graf.DrawLine(colpen,top1,bot1);
graf.DrawLine(colpen,left1,rite1);
PointF top2 = new PointF(sRite - Amount10, sTop - 1f);
PointF bot2 = new PointF(sRite - Amount10, sBot);
PointF left2 = new PointF(sLeft - 1f, sBot - Amount10);
PointF rite2 = new PointF(sRite, sBot - Amount10);
graf.DrawLine(colpen,top2,bot2);
graf.DrawLine(colpen,left2,rite2);
break;
case 4: // Axes + Borders Offsets
PointF topmid2 = new PointF(Amount9 + sLeft + midW, sTop - 1f);
PointF botmid2 = new PointF(Amount9 + sLeft + midW, sBot);
PointF leftmid2 = new PointF(sLeft - 1f, sTop + midH + Amount9);
PointF ritemid2 = new PointF(sRite, sTop + midH + Amount9);
graf.DrawLine(colpen,topmid2,botmid2);
graf.DrawLine(colpen,leftmid2,ritemid2);
PointF topmid3 = new PointF(sLeft + midW
PointF botmid3 = new PointF(sLeft + midW
PointF leftmid3 = new PointF(sLeft - 1f,
PointF ritemid3 = new PointF(sRite, sTop
graf.DrawLine(colpen,topmid3,botmid3);
graf.DrawLine(colpen,leftmid3,ritemid3);

- Amount9, sTop - 1f);


- Amount9, sBot);
sTop + midH - Amount9);
+ midH - Amount9);

PointF top3 = new PointF(Amount10 + sLeft, sTop - 1f);


PointF bot3 = new PointF(Amount10 + sLeft, sBot);
PointF left3 = new PointF(sLeft - 1f, sTop + Amount10);
PointF rite3 = new PointF(sRite, sTop + Amount10);
graf.DrawLine(colpen,top3,bot3);
graf.DrawLine(colpen,left3,rite3);
PointF top4 = new PointF(sRite - Amount10, sTop - 1f);
PointF bot4 = new PointF(sRite - Amount10, sBot);
PointF left4 = new PointF(sLeft - 1f, sBot - Amount10);
PointF rite4 = new PointF(sRite, sBot - Amount10);
graf.DrawLine(colpen,top4,bot4);
graf.DrawLine(colpen,left4,rite4);
break;
case 5: //Vertical lines: X = identation
for ( int x = 0; x < sRite; x++)
{
int step = x * Amount9;
graf.DrawLine(colpen, step, sTop, step, sBot);
}
break;
case 6: //Horizontal lines: Y = identation
for (int y = 0; y < sBot; y++)
{

int step = y * Amount10;


graf.DrawLine(colpen, sLeft, step, sRite, step);
}
break;
case 7: //GridLines: X, Y = identation
for (int x = 0; x < sRite; x++)
{
int step = x * Amount9;
graf.DrawLine(colpen, step, sTop, step, sBot);
}
for (int y = 0; y < sBot; y++)
{
int step = y * Amount10;
graf.DrawLine(colpen, sLeft, step, sRite, step);
}
break;
}
}
}
}

You might also like