generating labels with barcode in c# using crystal reports Backgrounds for Controls Using Brushes in Visual Basic .NET

Creation QR in Visual Basic .NET Backgrounds for Controls Using Brushes

Backgrounds for Controls Using Brushes
Paint QR Code ISO/IEC18004 In VB.NET
Using Barcode creator for .NET framework Control to generate, create QR Code 2d barcode image in Visual Studio .NET applications.
www.OnBarcode.com
QR Code Recognizer In Visual Basic .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
A control element can have its own individual background. This section demonstrates how to paint backgrounds using brushes and presents the different types of brushes supported by the .NET Micro Framework.
Print UPC Code In VB.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create GTIN - 12 image in .NET applications.
www.OnBarcode.com
Encoding Data Matrix In Visual Basic .NET
Using Barcode generation for .NET Control to generate, create Data Matrix image in .NET applications.
www.OnBarcode.com
CHAPTER 11 GRA PHICS AN D G RAPHIC AL US ER INTERFA CES
QR Code Printer In VB.NET
Using Barcode printer for .NET Control to generate, create QR Code JIS X 0510 image in Visual Studio .NET applications.
www.OnBarcode.com
Painting Barcode In VB.NET
Using Barcode creation for VS .NET Control to generate, create Barcode image in .NET applications.
www.OnBarcode.com
The Control class provides the Background, Foreground, and Font properties. The Background and Foreground properties are of the type Brush. Specifying a background brush allows a control to fill its background. The Foreground property cannot be used with any built-in controls, though you can use it with your custom controls. Every control can have its own individual background that is filled entirely white by default. If you set a background to null, there will be no background drawn for the control (it is transparent), and you will see the background of its parent control. The .NET Micro Framework provides the following classes that descend from Control: Window, Border, ListBox, ListBoxItem, ScrollViewer, and ContentControl (see the class hierarchy in Figure 11-21).
EAN128 Drawer In VB.NET
Using Barcode creation for .NET framework Control to generate, create EAN 128 image in VS .NET applications.
www.OnBarcode.com
USS ITF 2/5 Encoder In VB.NET
Using Barcode encoder for .NET framework Control to generate, create USS ITF 2/5 image in VS .NET applications.
www.OnBarcode.com
Brushes
Printing QR Code JIS X 0510 In None
Using Barcode creator for Word Control to generate, create QR image in Microsoft Word applications.
www.OnBarcode.com
Reading QR Code 2d Barcode In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Brushes can be used to fill a rectangular area, such as the background of a control, or to fill a shape element, such as a rectangle. There are three kinds of brushes that descend from the abstract Brush class in the Microsoft.Presentation.Media namespace: SolidColorBrush, LinearGradientBrush, and ImageBrush. The Brush class provides an Opacity property that allows you to control how the underlying pixels are blended with the new ones.
USS-128 Drawer In VS .NET
Using Barcode printer for Reporting Service Control to generate, create GS1 128 image in Reporting Service applications.
www.OnBarcode.com
Encoding EAN13 In None
Using Barcode maker for Office Excel Control to generate, create EAN13 image in Excel applications.
www.OnBarcode.com
SolidColorBrush
Generating PDF 417 In .NET
Using Barcode maker for Reporting Service Control to generate, create PDF 417 image in Reporting Service applications.
www.OnBarcode.com
Painting Barcode In C#
Using Barcode creator for .NET framework Control to generate, create Barcode image in VS .NET applications.
www.OnBarcode.com
The simplest brush is the SolidColorBrush, which only accepts a color value and inherits the Opacity property from the Brush class. This brush will fill the entire background of a control with the selected color. If we take the code from Listing 11-20, where some elements were placed on a canvas, and add the instruction mainWindow.Background = new SolidColorBrush(Colors.Gray); , then we will get the main window with a background entirely filled with gray, as shown in Figure 11-29. The child elements of the canvas Text, Image, and Rectangle are not controls, so they cannot have individual backgrounds. The Colors class resides in the Microsoft.SPOT.Presentation. Media namespace in the Microsoft.SPOT.TinyCore.dll assembly, and provides the predefined colors Black, White, Gray, Red, Green, and Blue.
Drawing Barcode In Visual Studio .NET
Using Barcode creation for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
UCC.EAN - 128 Drawer In None
Using Barcode printer for Word Control to generate, create GS1-128 image in Word applications.
www.OnBarcode.com
Figure 11-29. Main window with a gray background
Drawing Denso QR Bar Code In Java
Using Barcode printer for BIRT reports Control to generate, create QR-Code image in BIRT applications.
www.OnBarcode.com
Barcode Scanner In Java
Using Barcode Control SDK for BIRT reports Control to generate, create, read, scan barcode image in BIRT reports applications.
www.OnBarcode.com
C HAPT ER 11 GRAPHICS AND GRA PHICA L USE R IN TERFA CES
Drawing Code 3/9 In None
Using Barcode generator for Font Control to generate, create ANSI/AIM Code 39 image in Font applications.
www.OnBarcode.com
Read Code 128B In .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
LinearGradientBrush
It is also possible to render the background of a control or window with a color gradient; color gradients were discussed earlier in this chapter. The LinearGradientBrush accepts a start and end color and also the gradient start and end positions. Now, the following instruction is added to the code in Listing 11-20: mainWindow.Background = new LinearGradientBrush(Colors.White, Colors.Red, 0, 0, SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight ); The display is shown in Figure 11-30.
// // // // // //
start color end color start x start y end x end y
Figure 11-30. Main window with a color gradient background
ImageBrush
The ImageBrush allows you to fill a rectangular area with a bitmap. The bitmap can either be stretched to fit the rectangle s entire area or drawn unscaled and aligned with the top-left corner of the rectangle. The Stretch property allows you to control whether or not the bitmap should be stretched. By default, the bitmap will be stretched. Now, we add the following code to Listing 11-20: ImageBrush imageBrush = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Racer)); imageBrush.Stretch = Stretch.Fill; mainWindow.Background = imageBrush; You can see the stretched background image in Figure 11-31, and in Figure 11-32, the unscaled image using imageBrush.Stretch = Stretch.None;.
CHAPTER 11 GRA PHICS AN D G RAPHIC AL US ER INTERFA CES
Figure 11-31. A stretched background image
Figure 11-32. An unscaled background image
Drawing Borders Around Elements
No element comes with direct support for drawing a border around it. However, the Border class, which is derived from ContentControl, displays a border around specific content. You can embed an element in a border control, and the Border control will then draw the border around the child element for you. The Border content control can contain only one discrete child element. To draw a border around more than one element, you need to add a panel element (Panel, StackPanel, or Canvas) to the border element as a child and then place multiple child elements within that panel element. Listing 11-21 demonstrates how to draw a border around your window. The code in Listing 11-21 adds a Border control to a window as a child and then embeds a text element into the border; Figure 11-33 shows a border for the window. You can use any brush to draw the border. In this example, a linear gradient brush (LinearGradientBrush) from white to blue was used. The border thickness can be set with the SetBorderThickness method; you can set either equal values for the left, right, top, and bottom borders or each border thickness individually with the four-parameter overload of the method.
Copyright © OnBarcode.com . All rights reserved.