Professional Documents
Culture Documents
Guidelines Code
Guidelines Code
//
//
//
//
//
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 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,
//************************************************************************
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);