1110: The DotControl Class in .NET

Generating Code 128 Code Set A in .NET 1110: The DotControl Class
Listing 1110: The DotControl Class
Generate Code 128 In Visual Studio .NET
Using Barcode creation for Visual Studio .NET Control to generate, create USS Code 128 image in .NET applications.
public class DotControl : SystemWindowsFormsControl { private FormMain formParent; private Brush m_brPlayer1; private Brush m_brPlayer2; private Squares sq; public DotControl(FormMain form) { formParent = form; formParentControlsAdd(this); thisPaint += new PaintEventHandler(thisDotControl_Paint); thisMouseDown += new MouseEventHandler(thisDotControl_MouseDown); thisLeft = 0; thisTop = 64; thisWidth = 240; thisHeight = 240; sq = new Squares(this); } public bool SetGridSize(int cxWidth, int cyHeight) { return sqSetGridSize(cxWidth, cyHeight); } public bool SetPlayerColors(Color clr1, Color clr2) { m_brPlayer1 = new SolidBrush(clr1); m_brPlayer2 = new SolidBrush(clr2); return sqSetPlayerBrushes(m_brPlayer1, m_brPlayer2); }
Scanning USS Code 128 In .NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET framework applications.
private void DotControl_MouseDown(object sender, MouseEventArgs e) { // Check result
Bar Code Printer In .NET
Using Barcode generation for Visual Studio .NET Control to generate, create barcode image in .NET applications.
114 Vector Graphics
Barcode Scanner In .NET Framework
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications.
int iResult = sqHitTest(eX, eY, formParentCurrentPlayer); // Click on the available line, no score if(iResult == 1) { formParentNextPlayer(); } // Click on the available line, score if (iResult == 2) { int iScore1 = sqGetScore(1); formParentDisplayScore(1, iScore1); int iScore2 = sqGetScore(2); formParentDisplayScore(2, iScore2); int count = sqHeight * sqWidth; if (iScore1 + iScore2 == count) { string strResult = null; if (iScore1 > iScore2) strResult = "Player 1 wins! "; else if (iScore1 < iScore2) strResult = "Player 2 wins! "; else strResult = "Tie Game! "; MessageBoxShow(strResult, "JaspersDots"); } } } private void DotControl_Paint(object sender, PaintEventArgs e) { // Fill squares which players now own sqFillSquares(eGraphics); // Draw lines which players have selected sqDrawLines(eGraphics); // Draw dots in grid sqDrawDots(eGraphics); } } // class
Code 128 Code Set C Creator In Visual C#
Using Barcode printer for Visual Studio .NET Control to generate, create Code 128 image in .NET framework applications.
Creating Graphical Output
Paint Code 128C In .NET
Using Barcode generator for ASP.NET Control to generate, create Code128 image in ASP.NET applications.
The DotControl class handles two events: MouseDown and Paint Most of the work for these events is done by a helper class named Squares The source code for the Squares class appears in Listing 1111
Code 128 Code Set B Printer In VB.NET
Using Barcode printer for .NET framework Control to generate, create Code 128B image in VS .NET applications.
Listing 1111: The Squares Class
GTIN - 12 Maker In .NET Framework
Using Barcode printer for .NET framework Control to generate, create UPC-A image in Visual Studio .NET applications.
public class Squares { public int Width { get { return cxWidth; } } public int Height { get { return cyHeight; } } private int cxLeft = 15; private int cyTop = 15; private int cxWidth; private int cyHeight; const int cxLine = 20; const int cyLine = 20; const int cxyDelta = 5; private Square [,] m_asq; private Control m_ctrlParent; private Brush m_brPlayer1; private Brush m_brPlayer2; private Brush m_brBackground = new _ SolidBrush(SystemColorsWindow); private Brush hbrBlack = new SolidBrush(ColorBlack); private Point ptTest = new Point(0,0); Rectangle rc = new Rectangle(0, 0, 0, 0); private Size szDot = new Size(4,4); Pen penLine = new Pen(ColorBlack); public Squares(Control ctrlParent) { m_ctrlParent = ctrlParent; } // Squares() public bool SetGridSize( int cxNewWidth, // Width of array int cyNewHeight // Height of array ) { // Temporary scratch space
Bar Code Printer In Visual Studio .NET
Using Barcode generation for Visual Studio .NET Control to generate, create barcode image in .NET framework applications.
114 Vector Graphics
EAN-13 Creation In .NET Framework
Using Barcode encoder for Visual Studio .NET Control to generate, create EAN-13 image in .NET applications.
Rectangle rcTemp = new Rectangle(0,0,0,0); Point ptTemp = new Point(0,0); Size szTemp = new Size(0,0); // Set up an array to track squares cxWidth = cxNewWidth; cyHeight = cyNewHeight; m_asq = new Square[cxWidth, cyHeight]; if (m_asq == null) return false; int x, y; for (x = 0; x < cxWidth; x++) { for (y = 0; y < cyHeight; y++) { m_asq[x,y]iOwner = 0; // No owner int xLeft = cxLeft + x * cxLine; int yTop = cyTop + y * cyLine; int xRight = cxLeft + (x+1) * cxLine; int yBottom = cyTop + (y+1) * cyLine; int cxTopBottom = cxLine - (2 * cxyDelta); int cyTopBottom = cxyDelta * 2; int cxLeftRight = cxyDelta * 2; int cyLeftRight = cxLine - (2 * cxyDelta); // Main rectangle ptTempX = xLeft + 1; ptTempY = yTop + 1; szTempWidth = xRight - xLeft - 1; szTempHeight = yBottom - yTop - 1; rcTempLocation = ptTemp; rcTempSize = szTemp; m_asq[x,y]rcMain = rcTemp; // Top hit rectangle m_asq[x,y]rcTop = new Rectangle(xLeft + cxyDelta, yTop - cxyDelta, cxTopBottom, cyTopBottom); m_asq[x,y]bTop = false; // Right hit rectangle m_asq[x,y]rcRight = new Rectangle(xRight - cxyDelta, yTop + cxyDelta, cxLeftRight, cyLeftRight); m_asq[x,y]bRight = false;
Generating Bar Code In .NET Framework
Using Barcode generator for Visual Studio .NET Control to generate, create barcode image in VS .NET applications.
Creating Graphical Output
Create Delivery Point Barcode (DPBC) In Visual Studio .NET
Using Barcode printer for Visual Studio .NET Control to generate, create USPS POSTNET Barcode image in .NET applications.
// Bottom hit rectangle m_asq[x,y]rcBottom = new Rectangle(xLeft + cxyDelta, yBottom - cxyDelta, cxTopBottom, cyTopBottom); m_asq[x,y]bBottom = false; // Left hit rectangle m_asq[x,y]rcLeft = new Rectangle(xLeft - cxyDelta, yTop + cxyDelta, cxLeftRight, cyLeftRight); m_asq[x,y]bLeft = false; } // for y } // for x return true; } public bool SetPlayerBrushes( Brush br1, // Brush color for player 1 Brush br2 // Brush color for player 2 ) { m_brPlayer1 = br1; m_brPlayer2 = br2; return true; } //-------------------------------------------------------public void FillOneSquare(Graphics g, int x, int y) { Brush brCurrent = m_brBackground; if (m_asq[x,y]iOwner == 1) brCurrent = m_brPlayer1; else if (m_asq[x,y]iOwner == 2) brCurrent = m_brPlayer2; gFillRectangle(brCurrent, m_asq[x,y]rcMain); } continues continued // FillSquares -- Fill owned squares with a player's color //
Making Bar Code In Java
Using Barcode maker for Java Control to generate, create barcode image in Java applications.
GTIN - 12 Decoder In VS .NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
UPC-A Supplement 2 Encoder In .NET
Using Barcode generation for ASP.NET Control to generate, create UCC - 12 image in ASP.NET applications.
Barcode Drawer In VB.NET
Using Barcode creator for VS .NET Control to generate, create barcode image in VS .NET applications.
Bar Code Creation In Visual C#.NET
Using Barcode printer for .NET framework Control to generate, create bar code image in .NET applications.