TEAM DEVELOPER Your First.NET/WPF Application Product Version 6.3
Team Developer : Your First.NET/WPF Application, Product Version 6.3 The software described in this book is furnished under a license agreement and may be used only in accordance with the terms of the agreement. Last updated: November 12, 2014. Legal Notice Copyright 2014-2015 Gupta Technologies, Inc. All rights reserved. Gupta, Gupta Technologies, the Gupta logo, Gupta Powered, the Gupta Powered logo, ACCELL, Centura, Centura Ranger, the Centura logo, Centura Web Developer, Component Development Kit, Connectivity Administrator, DataServer, DBIntegrator, Development Kit, ewave, Fast Facts, NXJ, Object Nationalizer, Quest, Quest/Web, QuickObjects, RDM, Report Builder, RPT Report Writer, RPT/Web, SQL/API, SQLBase, SQLBase Exchange, SQLBase Resource Manager, SQLConsole, SQLGateway, SQLHost, SQLNetwork, SQLRouter, SQLTalk, Team Developer, Team Object Manager, TD Mobile, Velocis, VISION, Web Developer and WebNow! are trademarks of Gupta Technologies and may be registered in the United States of America and/or other countries. SQLWindows is a registered trademark and TeamWindows, ReportWindows and EditWindows are trademarks exclusively used and licensed by Gupta Technologies. The product described in this document is distributed under licenses restricting its use, copying, distribution, and decompilation/reverse engineering. No part of this document may be reproduced in any form by any means without prior written authorization of Gupta Technologies Corporation and its licensors, if any. THE DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. GUPTA TECHNOLOGIES, INC. SHALL NOT BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH THE FURNISHING, PERFORMANCE, OR USE OF THIS DOCUMENTATION. THE INFORMATION CONTAINED IN THIS DOCUMENTATION IS SUBJECT TO CHANGE WITHOUT NOTICE. This document may describe features and/or functionality not present in your software or your service agreement. Contact your account representative to learn more about what is available with this Gupta Technologies product. Gupta Technologies, Inc. 1420 Rocky Ridge Drive, Suite 380 Roseville, CA 95661 Gupta Technologies.com 2
Table of Contents INTRODUCTION... 4 REQUIREMENTS... 4 WRITING A.NET WPF DESKTOP APPLICATION... 5 RUNNING YOUR APPLICATION IN.NET WPF DESKTOP MODE... 9 DEPLOYING YOUR.NET WPF DESKTOP APPLICATION... 10 RUNNING YOUR APPLICATION IN.NET WPF BROWSER MODE... 11 PUBLISHING YOUR.NET WPF BROWSER APPLICATION... 12 3
Introduction With Team Developer v6.0 you now have the ability to write applications which utilize the Microsoft.NET Framework and Windows Presentation Foundation (WPF) graphical subsystem. This Framework is supported by multiple languages, including TD v6. Included in.net is a large library of coded solutions and a common language infrastructure which manages the execution of applications written specifically for this Framework. You define that your Team Developer v6 application can be saved and run in one of two.n ET WPF modes: Desktop (EXE) application Web Browser (XBAP) application You are most familiar with running your application as a Desktop application because, prior to Team Developer v6.0, the default option for running an executable (EXE) application was Standard EXE. Later, when you wanted an executable created for your application, you clicked menu Project/Build: <> (which displayed the executable name) and your executable was created. This executable would then run as a Win32 Desktop application. Now with Team Developer v6, when you define the Build Settings for your application, you can specify that the Build Target will be a Win32, i.e., Standard EXE, application. The same output and Windows runtime environment as defined in prior versions of Team Developer. Alternatively, you can define the Build Target to be a.net application, where your application will take advantage of the.net/wpf subsystem features and run in one of two modes: Either in the Windows.NET subsystem as a Desktop application; or as an XBAP (pronounced ex-bap ) Web Browser application, hosted and run inside a web browser. This white paper will describe how to write a small database application using a Form Window with Tab Bar, Child Grid and Rich Text controls, and how to save and run as either a.net Desktop or Web Browser application. For further details about.net and WPF in Team Developer v6.0, be sure to read the Gupta book DotNet.PDF. Requirements The application demonstrated in this document requires that you have: Installed Team Developer 6.0 Access to the SQLBase ISLAND database. This database is installed by default when you install Team Developer v6.0 The demonstration application is called: FirstTDv6WPFApp.app 4
Writing a.net WPF Desktop Application This will not be a complex TD v6 application, though it will use several v6 controls: the Tab Bar, a Child Grid, and a Rich Text Control. For demonstration purposes, the application will connect to the demo database, SQLBase ISLAND, and query the COMPANY table. The completed application form window will consist of a Tab Bar with 2 pages. The Tab Bar s page one contains the Child Grid: After clicking on a row (either in a column or on the left side row header), Tab Bar s page two contains a Rich Text Control displaying an address label: The Rich Text Control allows you to change text font, font size, add bold, change format, and so on, and print out the address label directly from the RTC. On the next pages we will add the Form, child controls and code to provide the functionality shown above. 5
Steps to writing the application: Open TD, click File/New and leave Project/Build Settings set to Win32 Application while we write the application. Add a Form Window, title it First WPF Application In the outline, navigate to the Global Declarations/Window Defaults section (shown below) and change font size to 8 for the Form Window and child items text: Add variables and SAM_Create code to establish a DB connection: Add SAM_Destroy code to disconnect from the DB on application exit, as shown on page 5. 6
Add to the Form a Tab Bar and a Child Grid; name them as shown here. Note Tab Bar s Tab Child defined to contain: cgcompany: In the form window, size the Tab Bar large enough to contain the Child Grid, per the screen shot shown on page 4. Position and size the Child Grid as necessary. The Child Grid contains 6 columns, a local function for formatting a company s address information and updating the Rich Text Control, a window variable, and traps 3 Team Developer SAM messages: SAM_Click calls updatertcaddresslabel() when the user clicks on a column. SAM_Create populates the Child Grid with some of the COMPANY table data and has a While loop to disable editing of the grid columns. SAM_RowHeaderClick calls updatertcaddresslabel() when the user clicks on the row header square to the left of each grid row. 7
Add to the Tab Bar a second page and a Rich Text Control and associate the RTC with the Tab Bar s page2. Position and size the RTC so it fits within the Tab Bar s page2: Title Tab Bar s page1 and page2 per the screen shot shown in the document on page 4. Sample FirstTDv6WPFApp.app contains the completed code with comments. When you have completed the code, save your application, then, as a test run using TD s menu Debug/Go, compile and run it in Win32 mode. The application will connect to ISLAND, and when the form appears, the Child Grid will be populated with COMPANY data. If you click on the second tab, you will see the Rich Text Control with address information of the first company listed in the Child Grid. If you click on another row in the grid, then click tab page 2, that company s data will appear in the Tab s page 2 Rich Text Control. If your application does that, you are successful. Congratulations! Now let s change the Build Settings so we can execute the application in.net WPF Desktop or Web Browser mode. 8
Running Your Application in.net WPF Desktop Mode Our application is written so that it will run in either as a Win32 application, or as a NET/WPF application. Now, to change the application s setting, we need to display the Build Settings dialog box. To access that dialog box, click the TD menu Project/Build Settings The Build Settings dialog is displayed, showing our current Build Target as Win32 Application with Target Type: Standard EXE. Change that setting by clicking the radio button.net Application and set the.net Target Type to.net WPF Desktop (EXE), like this: Type in the Target Name: FirstTDv6WPFAppD.exe A D is added to the name, standing for Desktop, to keep the Win32 and.net versions as separate EXE names. Click OK to complete the change. Now run the application in WPF/Desktop mode from the Team Developer IDE. 9
Your application will look similar to this running in WPF/Desktop mode: The application s functionality is the same as in Win32 mode. Click on a company row or row header in the Child Grid, then click the Address Label tab and the Rich Text Control will display that company s mailing information in address label format. Building an executable of your application: Click TD menu Project/Build: FirstTDv6WPFAppD.exe Once the executable is built, look in your application s folder. You will see several new DLLs have been written by Team Developer v6: IBM.Data.Informix.dll Oracle.DataAccess.dll Sybase.Data.AseClient.dll Gupta.SQLBase.Data.dll These are used for database access for your.net Desktop application and all 4 of the DLLs must be available when you run your TD v6 executable in.net WPF Desktop mode. Even though this application only connects to a SQLBase database, all 4 DLLs are still required for your application to start successfully. If any are missing, TD will display a runtime error. So, in addition to the standard set of TD deploy runtime files, these 4 DLLs must also be included as part of deploying a TD v6.0 executable when you build it as a.net WPF Desktop application. Deploying Your.NET WPF Desktop Application To deploy your Desktop application for your users, you will need to create an Installer. For details on how to do this, read the section titled Deploying WPF Desktop Applications in the Gupta book DotNet.PDF. 10
Running Your Application in.net WPF Browser Mode To change the application s setting, we need to display the Build Settings dialog box again and change the.net Application setting NET Target Type to.net WPF Browser (XBAP), like this: Type in the Target Name: FirstTDv6WPFAppX.exe An X has been added to the name, standing for XBAP, to keep the Win32 and.net Desktop versions as separate EXE names. Click OK to complete the change. To build it, click TD menu Project/Build: FirstTDv6WPFAppX.exe 11
Once the executable is built, look in your application s folder. You will see several more new files have been written by Team Developer v6: The 4 database DLLs as were written in WPF Desktop mode A copy of Team Developer v6 sql.ini Xbap_key.pfx FirstTDv6WPFAppX.xbap FirstTDv6WPFAppX.exe.config FirstTDv6WPFAppX.exe.manifest As with the.net Desktop application, all these files are necessary to run your.net WPF Browser application. So, in addition to the standard set of TD deploy runtime files, these additional files must also be included as part of publishing a TD v6.0 executable when you build it as a.net WPF Browser application. Publishing Your.NET WPF Browser Application FirstTDv6WPFAppX.xbap This is the.net WPF Browser executable used for running your application in a web browser. Double-click on that file name to run in your web browser. For details on publishing your Browser application for your users, read the section titled Publishing XBAP Applications in WPF Browser in the Gupta book DotNet.PDF. Additionally, depending on which web browser you will be using, Gupta book DotNet.PDF has details for those browsers in the sections titled WPF Browser Applications in FireFox and in WPF Browser Applications in Internet Explorer. 12