vb.net print barcode free The initStatusBar method in Visual C#.NET

Generate Data Matrix ECC200 in Visual C#.NET The initStatusBar method

Listing 7.13 The initStatusBar method
Draw ECC200 In C#
Using Barcode encoder for .NET Control to generate, create Data Matrix 2d barcode image in VS .NET applications.
www.OnBarcode.com
Data Matrix Scanner In Visual C#.NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
private void initStatusBar() { statusBarPanel = new StatusBarPanel(); statusBarPanel.BorderStyle = StatusBarPanelBorderStyle.Sunken;
Print Barcode In Visual C#
Using Barcode printer for .NET framework Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Barcode Printer In C#
Using Barcode creator for .NET framework Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
WINPOK: THE WINDOWS FORMS-BASED POKER GAME
Linear Creator In Visual C#.NET
Using Barcode creation for VS .NET Control to generate, create 1D image in VS .NET applications.
www.OnBarcode.com
PDF417 Encoder In Visual C#
Using Barcode drawer for VS .NET Control to generate, create PDF-417 2d barcode image in .NET applications.
www.OnBarcode.com
statusBarPanel.AutoSize = StatusBarPanelAutoSize.Spring; statusBarPanel.Alignment = HorizontalAlignment.Center; StatusBar s = new StatusBar(); s.ShowPanels = true; s.Font = new Font("Verdana", 8f, FontStyle.Bold); s.Panels.AddRange(new StatusBarPanel[]{statusBarPanel}); Controls.Add(s); }
Make USS Code 128 In C#
Using Barcode drawer for .NET framework Control to generate, create Code 128 Code Set A image in VS .NET applications.
www.OnBarcode.com
Generate Code11 In C#.NET
Using Barcode maker for VS .NET Control to generate, create Code11 image in .NET applications.
www.OnBarcode.com
A status bar can contain one or more panels. To create a status bar, you create an array of panels and add them to the status bar. In this case, we create just one StatusBarPanel called statusBarPanel and set its BorderStyle to StatusBarPanelBorderStyle.Sunken. We also set its AutoSize property to StatusBarPanelAutoSize.Spring to enable it to share space with other panels, although we have just one here, and we set the Alignment property to center the panel in the status bar. Next, we create the status bar, s, and add the panel to it. We set the status bar s ShowPanels property to true to enable panel display. Then we call s.Panels.AddRange and pass an array of panels to be displayed. In this case the array contains just one panel. Note that we hold on to a reference to the status bar panel in the private statusBarPanel field. This will allow other methods to update the message displayed there. We ll use the following helper method to display status information:
Data Matrix ECC200 Creator In Visual C#
Using Barcode drawer for VS .NET Control to generate, create Data Matrix 2d barcode image in .NET framework applications.
www.OnBarcode.com
ECC200 Creation In Java
Using Barcode creation for Android Control to generate, create DataMatrix image in Android applications.
www.OnBarcode.com
private void showStatus(string s) { statusBarPanel.Text = s; }
Reading Code 128 In VS .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Make UCC-128 In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create EAN 128 image in ASP.NET applications.
www.OnBarcode.com
Creating picture boxes All that remains is to set up the cards display. In listing 7.14 we show how to do this using picture boxes.
Barcode Encoder In .NET
Using Barcode maker for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Generating Barcode In None
Using Barcode creator for Software Control to generate, create Barcode image in Software applications.
www.OnBarcode.com
Listing 7.14 The initCards method
Linear Creation In .NET
Using Barcode generation for ASP.NET Control to generate, create Linear 1D Barcode image in ASP.NET applications.
www.OnBarcode.com
UPCA Encoder In Objective-C
Using Barcode creator for iPad Control to generate, create Universal Product Code version A image in iPad applications.
www.OnBarcode.com
private void initCards() { card1 = new PictureBox(); card1.Location = new Point(8, 104); card1.Size = new Size(72, 96); Controls.Add(card1); card2 = new PictureBox(); card2.Location = new Point(96, 104); card2.Size = new Size(72, 96); Controls.Add(card2); card3 = new PictureBox(); card3.Location = new Point(184, 104);
Generating UPCA In Java
Using Barcode printer for Android Control to generate, create GTIN - 12 image in Android applications.
www.OnBarcode.com
Barcode Generation In VS .NET
Using Barcode drawer for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
CREATING THE WINDOWS FORMS USER INTERFACE
Data Matrix ECC200 Generation In None
Using Barcode printer for Software Control to generate, create ECC200 image in Software applications.
www.OnBarcode.com
Generate Denso QR Bar Code In None
Using Barcode generation for Microsoft Word Control to generate, create Denso QR Bar Code image in Office Word applications.
www.OnBarcode.com
card3.Size = new Size(72, 96); Controls.Add(card3); card4 = new PictureBox(); card4.Location = new Point(272, 104); card4.Size = new Size(72, 96); Controls.Add(card4); card5 = new PictureBox(); card5.Location = new Point(360, 104); card5.Size = new Size(72, 96); Controls.Add(card5); }
You can download the card images, along with all of the code for this book, from http://www.manning.com/grimes. To display a hand of cards during play, we ll need to set the Image property for each picture box. The following helper function will do that for us:
private void showCards(Hand h) { card1.Image = getImage(h.CardName(1)); card2.Image = getImage(h.CardName(2)); card3.Image = getImage(h.CardName(3)); card4.Image = getImage(h.CardName(4)); card5.Image = getImage(h.CardName(5)); } pause(); pause(); pause(); pause(); pause();
The getImage helper method simply retrieves a GIF file from disk and returns an Image reference:
private Image getImage(string imgName) { string fileName = @"..\images\" + imgName + ".GIF"; try { return Image.FromFile(fileName); } catch (Exception e) { MessageBox.Show( "Error loading card image file: " + e.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } }
If the image file is missing, an error message box will be displayed. If you dismiss it, you ll be able to continue playing, but you won t be able to see the cards! We pause as each card is displayed to add suspense. This is implemented as:
private void pause() { pause(200); } private void pause(int n) {
WINPOK: THE WINDOWS FORMS-BASED POKER GAME
Application.DoEvents(); Thread.Sleep(n); }
The default pause is 200 milliseconds. Visual Basic programmers will be familiar with the DoEvents call which allows event processing to proceed before putting the thread to sleep. To hide a hand of cards, we ll display a GIF image of the card back, cb.gif, in each picture box. We ll use the following two helper methods:
private void hideCards() { // display the backs of the cards... card1.Image = card2.Image = card3.Image = card4.Image = card5.Image = getImage("CB"); Application.DoEvents(); } private void hideCard(PictureBox card) { card.Image = getImage("CB"); }
Starting play Now that we ve looked at the code to set up the user interface and handle events, we take a look at how play begins. Recall that the form s constructor in listing 7.5 calls newGame immediately after the user interface is initialized. The newGame method is shown in listing 7.15.
Copyright © OnBarcode.com . All rights reserved.