visual basic .net barcode generator SILVERLIGHT in C#.NET

Print DataMatrix in C#.NET SILVERLIGHT

CHAPTER 35 SILVERLIGHT
Data Matrix Creator In Visual C#.NET
Using Barcode printer for .NET Control to generate, create DataMatrix image in .NET applications.
www.OnBarcode.com
Recognizing Data Matrix ECC200 In Visual C#.NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Figure 35-12. The adjusted layout Using layout controls lets you organize regular controls relative to one another, and this tends to give greater flexibility for change. For a simple project like our example, absolute and relative layouts end up working out pretty much the same, but when you have a complex interface, you ll find that the flexibility inherent in relative layouts can save you a lot of time when you need to make changes or corrections.
UPCA Creator In Visual C#.NET
Using Barcode creation for .NET Control to generate, create UPC A image in VS .NET applications.
www.OnBarcode.com
Encode GTIN - 13 In Visual C#.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create EAN-13 Supplement 5 image in .NET applications.
www.OnBarcode.com
Wiring the Button
Code39 Printer In C#
Using Barcode drawer for VS .NET Control to generate, create ANSI/AIM Code 39 image in .NET applications.
www.OnBarcode.com
Paint 1D In Visual C#
Using Barcode maker for .NET Control to generate, create Linear image in .NET framework applications.
www.OnBarcode.com
The only control we need to wire in our Silverlight application is the Button. We don t have Menu or StatusBar controls in Silverlight the way that we do in WPF. To wire the Button, double-click the control in the design surface to generate the handler method for the Click event, and update the code-behind file to match Listing 35-1, which contains the same set of calculations that we have used in each chapter of this part of the book. Listing 35-1. Handing the Button Click Event using System.Text; using System.Windows; using System.Windows.Controls; namespace SwimCalculator { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void convertButton Click(object sender, RoutedEventArgs e) { // extract the values from the controls int minutesCompleted = int.Parse(minutesTextBox.Text); int lapsCompleted = int.Parse(lapsTextBox.Text); int lapLength = int.Parse(lengthTextBox.Text); int caloriesPerHour = int.Parse(caloriesTextBox.Text);
Generating GS1 128 In Visual C#.NET
Using Barcode generator for VS .NET Control to generate, create GS1-128 image in .NET framework applications.
www.OnBarcode.com
Print MSI Plessey In C#
Using Barcode drawer for .NET Control to generate, create MSI Plessey image in VS .NET applications.
www.OnBarcode.com
CHAPTER 35 SILVERLIGHT
DataMatrix Drawer In None
Using Barcode drawer for Online Control to generate, create Data Matrix 2d barcode image in Online applications.
www.OnBarcode.com
Draw Data Matrix 2d Barcode In Java
Using Barcode maker for Android Control to generate, create Data Matrix 2d barcode image in Android applications.
www.OnBarcode.com
// ensure that we have values that are greater than zero if (minutesCompleted <= 0 || lapsCompleted <= 0 || lapLength <= 0 || caloriesPerHour <= 0) { // we cannot proceed - we have one or more bad values return; } // perform the calculations we need for the results float distance = (lapsCompleted * lapLength) * 0.00062137119223733f; float caloriesBurned = (minutesCompleted / 60f) * caloriesPerHour; float pace = (minutesCompleted * 60) / lapsCompleted; StringBuilder resultBuilder = new StringBuilder(); resultBuilder.AppendFormat("Distance completed: {0:F2} miles\n", distance); resultBuilder.AppendFormat("Calories burned: {0:F0} calories\n", caloriesBurned); resultBuilder.AppendFormat("Average pace: {0:F0} seconds/lap", pace); // compose and set the results resultsTextBlock.Text = resultBuilder.ToString(); } } }
Paint Barcode In Visual Basic .NET
Using Barcode encoder for .NET framework Control to generate, create Barcode image in .NET applications.
www.OnBarcode.com
Scanning UCC - 12 In VB.NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Adding a Child Window
Painting USS-128 In None
Using Barcode creator for Online Control to generate, create GS1 128 image in Online applications.
www.OnBarcode.com
Code 128B Creator In Objective-C
Using Barcode maker for iPhone Control to generate, create Code 128 Code Set C image in iPhone applications.
www.OnBarcode.com
If you select Start Without Debugging from the Visual Studio Debug menu, you can see that we have a working Silverlight application, as shown in Figure 35-13.
Encode QR-Code In Java
Using Barcode printer for Android Control to generate, create QR Code 2d barcode image in Android applications.
www.OnBarcode.com
Recognizing Quick Response Code In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Figure 35-13. The working Silverlight application We don t have any way to tell the user if they provide a value that we can t process. We don t have a StatusBar control as we did for the WPF version of this program, for example. We could use the TextBlock to display errors as well as results, but a more elegant solution is to add a pop-up dialog box to our Silverlight application, which is what we will do in this section.
Encode Barcode In Visual Studio .NET
Using Barcode creation for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Creating PDF 417 In None
Using Barcode creation for Font Control to generate, create PDF 417 image in Font applications.
www.OnBarcode.com
CHAPTER 35 SILVERLIGHT
UPC Code Scanner In C#.NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Creating Code 128C In Objective-C
Using Barcode creator for iPad Control to generate, create Code 128B image in iPad applications.
www.OnBarcode.com
Start by right-clicking the Silverlight project in the Solution Explorer (the one called SwimCalculator if you followed my example), and select Add New Item from the pop-up menu. Select the Silverlight Child Window template, and give the item the name ErrorWindow.xaml, as shown in Figure 35-14.
Figure 35-14. Creating a child window item The Child Window template is a preconfigured pop-up window for Silverlight. It has an OK button and a Cancel button by default. We want to display a message, so we are going to remove the Cancel button and add a TextBlock to contain the error description. I am not going to walk through the steps to do this. You have seen enough layout examples to be able to do this yourself, and it doesn t matter if you end up with a slightly different result to mine. However, make sure you set the name of your TextBlock control to be errorMessageTextBlock. My design surface is shown in Figure 35-15.
Figure 35-15. The edited child window design surface
CHAPTER 35 SILVERLIGHT
We don t need to change the code-behind file for the child window. The OK button is already wired and dismisses the dialog box for us. We can now edit our program logic to display an error message if we can t process the values in the TextBox controls. Listing 35-2 shows the modified MainPage.xaml.cs file. Listing 35-2. Adding Support for the Child Window using System.Text; using System.Windows; using System.Windows.Controls; namespace SwimCalculator { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void convertButton Click(object sender, RoutedEventArgs e) { // extract the values from the controls int minutesCompleted = int.Parse(minutesTextBox.Text); int lapsCompleted = int.Parse(lapsTextBox.Text); int lapLength = int.Parse(lengthTextBox.Text); int caloriesPerHour = int.Parse(caloriesTextBox.Text); // ensure that we have values that are greater than zero if (minutesCompleted <= 0 || lapsCompleted <= 0 || lapLength <= 0 || caloriesPerHour <= 0) { // we cannot proceed - we have one or more bad values ErrorWindow myErrorWindow = new ErrorWindow(); myErrorWindow.errorMessageTextBlock.Text = "Cannot calculate - use values greater than zero"; myErrorWindow.Show(); return; } // perform the calculations we need for the results float distance = (lapsCompleted * lapLength) * 0.00062137119223733f; float caloriesBurned = (minutesCompleted / 60f) * caloriesPerHour; float pace = (minutesCompleted * 60) / lapsCompleted; StringBuilder resultBuilder = new StringBuilder(); resultBuilder.AppendFormat("Distance completed: {0:F2} miles\n", distance); resultBuilder.AppendFormat("Calories burned: {0:F0} calories\n", caloriesBurned); resultBuilder.AppendFormat("Average pace: {0:F0} seconds/lap", pace); // compose and set the results resultsTextBlock.Text = resultBuilder.ToString(); } } }
Copyright © OnBarcode.com . All rights reserved.