Articles

Affichage des articles du juillet, 2008

Printing and Graphics

Drawing and Printing in C# By James Foxall , Wendy Haro-Chun Date: Feb 15, 2002 Sample Chapter is provided courtesy of Sams . Return to the article C# provides an amazingly powerful array of drawing capabilities. In this "one-hour" excerpt by James Foxall and Wendy Haro-Chun, you learn the basic skills for drawing shapes and text to a form or other graphical surface. C# provides an amazingly powerful array of drawing capabilities. However, this power comes at the price of a steep learning curve. Drawing isn't intuitive; you can't sit down for a few minutes with the online Help text and start drawing graphics. After you learn the basic principles involved, however, you'll find that drawing isn't that complicated. In this hour, you'll learn the basic skills for drawing shapes and text to a form or other graphical surface. You'll learn about pens, colors, and brushes. In addition, you'll learn how to persist graphics on a form—and even how

Imprimer une facture

Image
The other day, I decided to cruise ZDNET to look for a simple shareware program to make invoices. I have to say, I couldn't find what I was looking for, so I turned to C# and .NET.  This program can stand improvements but it will get you started in creating an invoice and printing it to the printer. You can customize the invoice by changing the bitmap supplied in the download to an invoice of your choice and then move the controls to fit into the proper locations on the Background bitmap.  This invoice layout was scanned in  from Intuit's, Quicken 99 and modified to add a few features. Figure 1 - The Invoice in a Windows Form Below is the design for the InvoiceMaker.NET program in UML: Figure 2 - UML Diagram of InvoiceMaker.NET reverse engineered using WithClass 2000 The program has several pieces of code probably worth discussing.  In this article we'll concentrate on printing and serialization.  If you are curious about how the printing was designed, you'll want

Impression d'un formulaire complexe

Image
Fig 1.0 - PrintPreview of the W2 Form If you are a C# programmer, before you run out and buy that latest version of your favorite tax program, you may want to consider this useful article on form creation.  This article covers a fairly practical aspect of using a computer - dealing with forms.  The concepts in this article can be used to create any Form Application so that you can design forms that you can Fill Out, Open, Save, Print and Print Preview.  Below is the simple UML design of our W2 Form Filler Application: Fig 1.1 - UML Doc/View Design of W2 Form App reverse engineered using WithClass 2000 The first step to creating the form is to scan in the Form and convert it to a .gif file.  You can also get most forms these days electronically from the .gov sites that supply them.  Once you've got the form in a .gif (or jpeg or whatever),  you can apply it to your form as an image background.   Simply set the forms BackgroundImage property to the gif or jpeg file that yo

Printing again and again

Image
If you misplaced your ruler, here's an application that will create one for you on your printer! Unfortunately, you'll still need a ruler the first time using it so that you can calibrate the measurement for your particular printer, but once you know the calibration value, you are all set with a fairly accurate ruler.  Below is the simple design of our ruler.  The ruler itself is drawn in a Form.  The only other class used is the Calibration Dialog used to enter and retrieve a calibration value: Figure 1 - Part of the ruler This design was reverse engineered using the WithClass 2000 UML Design Tool for C# The ruler is created by simply determining the resolution in pixels per inch.  This information can be retrieved from the graphics object itself: void SizeFormToRuler() { // get resolution, most screens are 96 dpi, but you never know... Graphics g = this .CreateGraphics(); this .HRes = g.DpiX; // Horizontal Resolution this .VRes = g.DpiY; // Vertical Resolution Width

DataGridView Printing

Image
Introduction Well it is that time of the year again. Time to get in shape for the summer months, and what better way to do it then through a rigid exercise program. I was never very good at tracking my progress in the gym, but thanks to .NET (and my wife),  I have a way to do just that. This program uses the DataGridView bound to a Microsoft Access Database to create a printed sheet with your latest work out plans. The workout chart includes the exercise, number of sets, number of reps, amount of weight, and most importantly, whether or not you completed the exercise. The best part of this program is that you can print out your exercise program and bring it with you to the weight room.    Figure 1 - Exercise Program New Form Capture Feature .NET comes with a new form capture feature: the ability to copy the form as you see it on the screen into a bitmap. Although not useful for controls that you need to scroll, New Form Capture Feature works if you can fit all the contents you need