Windows Programming Using C# Printing, Documentation, & Deployment.

Slides:



Advertisements
Similar presentations
Computer Basics Hit List of Items to Talk About ● What and when to use left, right, middle, double and triple click? What and when to use left, right,
Advertisements

Creating and Editing a Web Page Using Inline Styles
1 CA202 Spreadsheet Application Combining Data from Multiple Sources Lecture # 6.
Dialog Boxes and Menus. Menus Menu Bar Contains menus which drop down to display list of menu items Each item has a name and text property Each item has.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
Microsoft Windows Vista Chapter 6 Customizing Your Computer Using the Control Panel.
Chapter 5 Using Business Information Sets
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Creating a Console Application with Visual Studio
Lesson 46: Using Information From the Web copy and paste information from a Web site print a Web page download information from a Web site customize Web.
1 Windows Printing. 2 Objectives You will be able to Output text and graphics to a printer. Print multipage documents. Use the standard Windows print.
1 ADVANCED MICROSOFT WORD Lesson 15 – Creating Forms and Working with Web Documents Microsoft Office 2003: Advanced.
Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 3 Windows File Management 1 Morrison / Wells / Ruffolo.
How to Download and Install a Sharp Print Driver on a Mac.
Getting Started with Expression Web 3
Prerequisites Essentials of Microsoft Windows By Robert T. Grauer Maryann Barber.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
1 Lesson 6 Exploring Microsoft Office 2007 Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
© Ms. Masihi.  The Dreamweaver Welcome Screen first opens when you start Dreamweaver.  This screen gives you quick access to previously opened files,
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Introducing Dreamweaver MX 2004
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 26 – CheckWriter Application Introducing Graphics.
IT 211 Project Integration and Deployment Lab #11.
Chapter 7 Lists, Loops, and Printing Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
STIP Chapter#10 Mastering Windows Forms Created By, Vishwesh Patel.
Programming in HTML.  Programming Language  Used to design/create web pages  Hyper Text Markup Language  Markup Language  Series of Markup tags 
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Web Feature Data Access Pages.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
HTML Hyper Text Markup Language A simple introduction.
15.1 Fundamentals of HTML.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Computing Fundamentals Module Lesson 3 — Changing Settings and Customizing the Desktop Computer Literacy BASICS.
Word 2010 Vocabulary List 1. Click and Type - A feature that allows you to double-click a blank area of a document to position the cursor in that location,
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
Lesson 11: Looking at Files and Folders what a file or folder is on the computer how to recognize a file or folder on the desktop how to recognize the.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
1 Project 7: Northwind Traders Order Entry. 2 Northwind Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders.
JavaScript - A Web Script Language Fred Durao
XP New Perspectives on Windows 2000 Professional Windows 2000 Tutorial 2 1 Microsoft Windows 2000 Professional Tutorial 2 – Working With Files.
Using Advanced Options Lesson 14 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft Word 2013.
1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.
Lesson No: 6 Introduction to Windows XP CHBT-01 Basic Micro process & Computer Operation.
Microsoft® Excel Key and format dates and times. 1 Use Date & Time functions. 2 Use date and time arithmetic. 3 Use the IF function. 4 Create.
Key Applications Module Lesson 17 — Organizing Worksheets Computer Literacy BASICS.
1 Project 5: Printing Address Labels. 2 Assignment Write a Windows forms program to display and print a set of address labels. Input from a csv file.
Package & Deploy. OBJECTIVES Package Deploy Way to package.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
Creating and Editing a Web Page
List Boxes and Combo Boxes Provides a list of items to select from Various styles — choose based on Space available Need to select from an existing list.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
1 Printing a Document. 2 Objectives You will be able to print a real multipage document.
Creating and Editing a Web Page Using Inline Styles
Hands-On Microsoft Windows Server 2008 Chapter 5 Configuring Windows Server 2008 Printing.
Microsoft Office 2008 for Mac – Illustrated Unit D: Getting Started with Safari.
Printing Petzold, Chapter 21
Packaging and Deploying Windows Applications
Chapter 1: An Introduction to Visual Basic .NET
Computer Fundamentals
Computer Literacy BASICS
Key Applications Module Lesson 17 — Organizing Worksheets
Using a template to create a document
Microsoft Windows 2000 Professional
New Perspectives on Windows XP
Accessing Databases with ADO.NET, Handling Exceptions, and Printing
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

Windows Programming Using C# Printing, Documentation, & Deployment

2 Contents Printing Documentation Deployment

3 Printing Windows supports a sophisticated printing model Each printer has a device driver which is able to render GDI Printer manufacturers provide the drivers for popular operating systems.NET provides full access to the underlying printing system

4 Device Independence The beauty of the Windows printing model is its device independence Each printer page has a Graphics object, as does every window To print a window, simply issue the same drawing commands to the page graphics object as you did to the graphics object for the window The only change needed might be scaling

5 PrintDocument The main object is the PrintDocument This represents  An interface to a printer  A set of PrinterSettings that determine how the printer is configured Properties  DocumentName – name of the document being printed which is displayed in printing dialogs

6 PrintDocument Methods  Print – call this when you want to start printing Events  PrintPage – this is fired when the current page is needed for printing  BeginPrint – just before the first page prints  EndPrint – after the last page has printed

7 Using PrintDocument You usually create one PrintDocument for your aplication In Visual Studio, place one on your form and it will be displayed in the tray under the form When your document is ready to print, call PrintDocument.Print()

8 Using PrintDocument Of course, PrintDocument has no idea of what to print It has to ask the application It does this by raising a PrintPage event The application must have a handler for this event This handler will print the content of the page

9 PrintPage Event Handler This has the signature  PrintPage(object sender, PrintPageEventArgs e) PrintPageEventArgs contains  Graphics – the graphics object for the page  Cancel – get/set a Boolean indicating print job should be cancelled  HasMorePages – set to true if there are more pages to print. Default is false.

10 PrintPageEventArgs MarginBounds – rectangle representing area within the margins  The X, Y show the location of the area within the margins and the width and height the size PageBounds – the size of the physical page PageSettings – detailed settings of the page

11 PrintPage Event Handler The event handler must  Extract the graphics object from the arguments  Perform any necessary scaling from the window to the page  Issue the draw commands to the graphics object for the page  Set HasMorePages to tell the printing system whether more pages are to follow

12 Scaling The size of a figure in a window is not always the size it should be printed We can do some simple scaling to fix this First, we assume that screen resolution is approximately printer resolution The PageSettings in the arguments contains the actual resolution of the printer if more accurate calculations are needed

13 Scaling The Margins object has the information we need We will just use the same scale factor for the X and Y axes to preserve the aspect ratio First, get the size of the print area within the margins int printAreaWd = e.MarginBounds.Width; int printAreaHt = e.MarginBounds.Height;

14 Scaling Then, compute a scale factor by dividing the print area by the window size double scale = 1.0; if (printAreaWd < printAreaHt) { scale = printAreaWd / this.Width; } else { scale = printAreaHt / this.Height; }

15 Scaling Now, to draw a line from (x,y) to (x1, y1) Margins m = e.Margins; e.Graphics.DrawLine(pen, (int)(x * scaleFactor + m.X), (int)(y * scaleFactor + m.Y), (int)(x1 * scaleFactor + m.X), (int)(y1 * scaleFactor + m.Y));

16 PrintDialog So far, we have been printing to the default printer with no options To change anything, we use the PrintDialog To create a PrintDialog  drag it to your form  Set the Document property to the PrintDocument you want to print The dialog will configure the printer settings in the PrintDocument

17 PrintDialog To show it, check the result, and print DialogResult r = printDialog1.ShowDialog(); if (r == DialogResult.OK) { printDocument1.Print(); }

18 PrintPreviewDialog To preview the document, use a PrintPreviewDialog To create one  Drag one to your form and it will appear in the tray underneath the form  Set the Document property to the PrintDocument you want to preview To show the preview  printPreviewDialog1.ShowDialog();

19 PageSetupDialog If you want to set the printer settings for the preview or for printing, use the PageSetupDialog To create one  Drag one to your form and it will appear in the tray underneath the form  Set the Document property to the PrintDocument you want to preview To show the preview  pageSetupDialog1.ShowDialog(); * see WinDraw

20 Contents Printing Documentation Deployment

21 Documentation Donald Knuth had the idea of placing the documentation with the code This  Ensured the documentation would not be lost  Gave it a chance of being kept up to date Java was the first language to generate documentation from comments in code

22 C# Documentation C# continues the trend started by Java Documentation  Is placed just before the element it describes  Is marked by comments starting with three slashes  Contain well-formed XML /// My very own class public class MyClass {…}

23 Documentation Tags TagMeaning codeEnclosed text is code exampleContains an example of how to use the code exceptionUsed on methods which throw exceptions. The cref parameter is set to the fully qualified type of the exception. paraStart of paragraph paramParameter description. name property indicates which parameter remarksSupplemental explanation to summary information

24 Documentation Tags TagMeaning returnsDescribes the return value seeRefers the reader to another member. The cref attribute is set to the member name seealsoSimilar to see summaryDescription of the object typeparamType parameter description. name property indicates which parameter valueDescribes the value of a property

25 Generating Documentation The first step is to bring up the project properties Under the build tab, check XML Documentation File

26 The Output The output is generated when the project is next built The output format is XML WinDraw A strongly-typed resource class, for looking up localized strings, etc.

27 Processing the Output Visual Studio used to have a command to produce web pages from the XML but it has been discontinued SourceForge has Ndoc to format documentation but it only supports.NET 1.1 Write your own XSLT program to process the XML output

28 Contents Printing Documentation Deployment

29 Deployment.NET projects do not make use of the registry This means that they are simpler to deploy than Win32 applications There are several options  Copy the assemblies to a directory  Create a cab file containing the application files  Create a setup project  Create a web setup project

30 Copying Copying the files is the easiest solution However  It only works for small projects  Becomes a lot of work to get it right for a large project  It not suitable for novices to use

31 Cab Deployment A cab file is just a zip file It is used to package ActiveX components for download to legacy web browsers  Click File | Add New Project  Select cab project

32 Cab Deployment

33 Cab Properties The new cab project appears in the solution explorer on the right Right click and select properties This will let you set the name for the output file

34 Adding Cab Content Right click on the project and select add  Project output Standard parts of a project  File Individual files

35 A Setup Deployment Project A setup deployment project will create an msi installer which will automatically deploy the application on a target computer To create  Click File | Add New Project  Select setup project This adds the project to the solution explorer

36 Setup Properties To add content  Right click on the setup project and select view | File System This will display the content that will be placed into  Application folder  User’s desktop  Users start menu

37 Setup Properties Folders are on the left and their contents are on the right Right click on a folder and select add  Folder – create a new folder  Project output – to add project output like the assembly  File – add any file  Assembly – an assembly from the GAC or file system

38 Setting Location of Application Directory Click on the Application Folder A property sheet is displayed for it in the lower right of Visual Studio The value for Default Location is  [ProgramFilesFolder]\[Manufacturer]\[Product Name]  Manufacturer & Product name are properties which are set in the project property page  ProgramFilesFolder is the Program Files folder on the target machine  You can also edit the string

39 Creating Shortcuts Create a shortcut to the primary output by right clicking on it Drag shortcut to user’s desktop To add to program menu  Optionally right on program menu and add new folder  Drag shortcut to program menu or new folder

40 Configuring the User Interface Right click on project and select View | User Interface This displays all the screens for the install dialog Clicking on each lets you set properties for it You can also delete steps if they are not needed