WPF Container & Controls In Gupta TD 6

Transcription

DOCUMENT TYPE Title HereWPF Container &Controls in Gupta TD 6OpenText Gupta Team DeveloperAbstractWindows Presentation Foundation (WPF) is a framework for building rich Windows applications. Thiswhite paper will show you how to create amazing Gupta Team Developer WPF applications using .NETWPF controls.

WHITEPAPER WPF Container & Controls in TD 6Table of Contents. 1Abstract . 1Overview . 3OpenText Gupta Team Developer 6 new feature: WPF Container . 3WPF container versus ActiveX container in OpenText Gupta Team Developer . 3Creation of a WPF control in OpenText GuptaTeam Developer . 3Instantiating a WPF container . 5XAML - what is it? . 5Invoking methods in a WPF control . 6How to SET and GET properties in a WPF control . 8Handling events in a WPF control . 11Enrich your application using .NET WPF controls . 11Native .NET WPF controls . 11MAPs in Team Developer! . 15Acrobat Reader in OpenText Gupta Team Developer . 17Report Builder CQT preview . 19Current limitations . 20Conclusion. 21About OpenText. 22OPENTEXT GUPTA TEAM DEVELOPER2

WHITEPAPER WPF Container & Controls in TD 6OverviewGupta Team Developer now supports .NET! This unleashes tremendous power and flexibility, allowingyou to create rich GUI application and more:You can now create a WPF application directly in Team Developer using SAL. See: Creating a .Net WPF application from scratchYou can also create and import .NET assemblies as well as creating and consuming Web Services. See: Importing .Net classes into TD6.0Finally, you can consume any of the .NET WPF controls currently available on the internet, dramaticallyenriching your application. That is what this document will cover.OpenText Gupta Team Developer 6 newfeature: WPF ContainerWPF container versus ActiveX container in OpenText Gupta TeamDeveloperWPF applications are not WIN32 applications. The same is true for WPF control versus ActiveX controls.However, they do share in common the feature to expose visual components in a “container” hosted by atop level window (i.e. a Team Developer form). The interaction between the application and the containeris performed through Methods, Properties and Events. In that respect WPF controls are similar to visualActiveX controls, the underlying technology being very different though. In that respect WPF controls aresimilar to visual ActiveX controls, the underlying technology being very different though.Consequently, an ActiveX control can no longer be used “directly” in a .NET Gupta Team Developerapplication. During the migration of a Gupta Team Developer application to WPF you will have to replaceyour ActiveX by a similar WPF control if it exists. The same is true for custom controls; an equivalent ofActiveX controls yet another technology.If you are familiar with ActiveX control in TD, you should be at home in consuming WPF controls, hencereplacing ActiveX by WPF controls.Creation of a WPF control in OpenText GuptaTeam DeveloperThe process is relatively similar to the creation of an ActiveX control, where you generally drop theActiveX control of your choice from the toolbox to the form. At this point, Team Developer generates thefunctional class, a binding to the ActiveX control. Using this interface bound to the control you can startcalling methods, setting properties, handling events; in a word, consuming the ActiveX control.It is roughly the same with WPF Controls. You now use the WPF container object from the TeamDeveloper toolbox and drop it on your form. If you do this now and have a good knowledge of ActiveX inTD, this might confuse you since there will be no: Specific controls or objects listed in the toolbox as there is with ActiveXOPENTEXT GUPTA TEAM DEVELOPER3

WHITEPAPER WPF Container & Controls in TD 6 As we could not choose any specific controls from the toolbox, other than our WPF container,nothing will show inside the WPF control.There is no APL interface to bind the object.ActiveX instantiated and APL interfaceUn-instantiated WPF control.What is going on?If you used ActiveX in Gupta Team Developer, you might recall that you could also just drop an ActiveXcontainer on the form (without choosing any specific control from the toolbox). At this point TeamDeveloper would ask you to choose an object type. You could still ignore the selection of object and atthis stage you are left with an empty un-instantiated ActiveX control. Since you are proficient in usingActiveX control in Team Developer you further know that you could still dynamically instantiate theActiveX control through the SalActiveX API.Image showing an ActiveX container un-instantiated with no APL interface generatedOPENTEXT GUPTA TEAM DEVELOPER4

WHITEPAPER WPF Container & Controls in TD 6At this point ActiveX versus WPF container are similar: you have a un-instantiated ActiveX container,same as our WPF container from the screenshot above.Instantiating a WPF containerSince you are in charge of instantiating the control, you obviously have to know what you would like touse and from what source! Currently in Gupta Team Developer there are no functionalities to explore theavailable list of controls on your machine as it is the case with the Team Developer Toolbox or theActiveX explorer. You might use any of the .NET “native” WPF control (from the .NET framework) or lookfor any third party free or commercial controls. Needless to say that Team Developer already exposessome of the most used and needed WPF controls but the list is endless!Once you know what you like to consume, it is a simple matter to actually initialize the new Gupta TeamDeveloper WPF container object. You do this in the properties of the WPF container entering a XAMLsnippet for the WPF Container in the attribute inspector.Screen shot showing the wpf1 container XAML snippet set to use the .NET framework WebBrowserobject. Note that at this point, the control is NOT instantiated at design time, it is onlydone at run-time.XAML - what is it?It means, Extensible Application Markup Language. It is a declarative XML-based language created byMicrosoft which is used to initialize structured values and objects.The word “initialize” and “objects” is all that we want to know for the moment and for the remainder of thiswhite paper. So we will not cover XAML here since it is far beyond the scope of this document and we willredirect you to further references, as WPF uses it extensively XAML. See:http://en.wikipedia.org/wiki/Extensible Application Markup LanguageOPENTEXT GUPTA TEAM DEVELOPER5

WHITEPAPER WPF Container & Controls in TD 6So we have learned how to initialize our WPF container through the TD attribute inspector XAMLproperty. If you just drop the WPF container on your form and set its XAML property to WebBrowser/ and execute the application, you would see this:Design timeRuntimeWell, that’s rather simple and useless you would say and you are right as far as the snapshot isconcerned. But you just learned how to initialize a Web Browser in a .NET Team Developer 6.0 WPFapplication using a XAML snippet! If you used the Microsoft ActiveX Web Browser object, dropping it onthe form and running the application, you would see almost the same:Design timeRuntimeInvoking methods in a WPF controlNow that we know how to initialize a Web Browser object, we would like to do a bit more and display aWeb page from a URL. When using ActiveX we used the Navigate() method. In the same way, usingWPF you will need to invoke a method to interact with it.Because there isn’t any APL interface generated for a WPF container, the Active coding assistant willshow nothing. You will not know directly what method to invoke. You can find methods of the object bysearching the internet (MSDN) or directly in Visual Studio .NET.Here we will be using the "Navigate" method from the WPF WebBrowser object which takes as anargument a string containing our URL, notice it is the same as with ActiveX:Set sParam[0] ”http://www.guptatechnologies.com"Call SalWPFInvokeMethod( wpf1, "Navigate", sParam, sReturn )OPENTEXT GUPTA TEAM DEVELOPER6

WHITEPAPER WPF Container & Controls in TD 6Result of the above call The .NET WPF WebBrowser object exposes many more methods like Navigate() which takes an objecttype Uri, so you can navigate directly to the Web page.From the above call, we just learned about a new function in Team Developer to invoke a WPF controlmethods; SalWPFInvokeMethod().Here is the online help of the function:SalWPFInvokeMethodbOk SalWPFInvokeMethod ( hWnd, strFunc, strArgs, strReturn )Invokes a method pertaining to a WPF control.ParametershWnd Window Handle. The handle for the custom WPF control.strFunc String. The name of the function.strArgs String Array. The function arguments. Pass a string representation of any argument (e.g. '546.98'or '25 September 2010').strReturn Receive String. The return value of the function. If the function's return type is not a string, astring representation will be used.Return ValuebOk is true if the function succeeds, false if it fails.OPENTEXT GUPTA TEAM DEVELOPER7

WHITEPAPER WPF Container & Controls in TD 6How to SET and GET properties in a WPF controlJust as ActiveX uses PropSet/ProGet calls to deal with the properties of an ActiveX object, Gupta TeamDeveloper provides a new set of functions for dealing with WPF properties. Like ActiveX and propertiesthat you can set at design time (in the attribute inspector), you can also set properties of a WPF controldirectly in the XAML snippet. There are currently no functionalities to list the properties exposed bya .NET control as it is the case for ActiveX through the generated interface and the Active CodingAssistant.We will see an example of interacting with properties later in some samples but here is a XAML snippetsetting properties for the WPF Slider controlHere is the online help describing the Set/GetWPF calls:SalWPFGetBoolPropertybOk SalWPFGetBoolProperty(hWnd, strProp, bValue)Gets a boolean property of a WPF control.ParametershWnd The handle for the custom WPF control.strProp String. The name of the property. The function will get the value of this property.bValue Receive Boolean. The value of the property.Return ValuebOk is true if the function succeeds, false if it fails.SalWPFGetDatePropertybOk SalWPFGetDateProperty(hWnd, strProp, dateValue)Gets a date property of a WPF control.OPENTEXT GUPTA TEAM DEVELOPER8

WHITEPAPER WPF Container & Controls in TD 6ParametershWnd The handle for the custom WPF control.strProp String. The name of the property. The function will get the value of this property.dateValue Receive Date. The value of the property.Return ValuebOk is true if the function succeeds, false if it fails.SalWPFGetNumericPropertybOk SalWPFGetNumericProperty(hWnd, strProp, numValue)Gets a number property of a WPF control.ParametershWnd The handle for the custom WPF control.strProp String. The name of the property. The function will get the value of this property.numValue Receive Number. The value of the property.Return ValuebOk is true if the function succeeds, false if it fails.SalWPFGetStrPropertybOk SalWPFGetStrProperty(hWnd, strProp, strValue)Gets a string property of a WPF control.ParametershWnd The handle for the custom WPF control.strProp String. The name of the property. The function will get the value of this property.strValue Receive String. The value of the property.Return ValuebOk is true if the function succeeds, false if it fails.SalWPFSetBoolPropertybOk SalWPFSetBoolProperty(hWnd, strProp, bValue)Sets a boolean property for a WPF control.ParametershWnd The handle for the custom WPF control.strProp String. The name of the property whose value should be set.bValue Boolean. The new value.Return ValueOPENTEXT GUPTA TEAM DEVELOPER9

WHITEPAPER WPF Container & Controls in TD 6bOk is true if the property exists, if it is writeable, and if the new value can be converted to the type of theproperty.SalWPFSetDatePropertybOk SalWPFSetDateProperty(hWnd, strProp, DateValue)Sets a string property for a WPF control.ParametershWnd The handle for the custom WPF control.strProp String. The name of the property whose value should be set.DateValue Date. The new value.Return ValuebOk is true if the property exists, if it is writeable, and if the new value can be converted to the type of theproperty.SalWPFSetNumPropertybOk SalWPFSetNumProperty(hWnd, strProp, numValue)Sets a number property for a WPF control.ParametershWnd The handle for the custom WPF control.strProp String. The name of the property whose value should be set.numValue Number. The new value.Return ValuebOk is true if the property exists, if it is writeable, and if the new value can be converted to the type of theproperty.SalWPFSetStrPropertybOk SalWPFSetStrProperty(hWnd, strProp, StrValue)Sets a string property for a WPF control.Note: This function can be used to set any property that is settable from xaml.ParametershWnd The handle for the custom WPF control.strProp String. The name of the property whose value should be set.strValue String. The new value.Return ValuebOk is true if the property exists, if it is writeable, and if the new value can be converted to the type of theproperty.OPENTEXT GUPTA TEAM DEVELOPER10

WHITEPAPER WPF Container & Controls in TD 6Handling events in a WPF controlNow we will talk about events, which are also very similar to ActiveX. You handle the events directly atthe action level of the WPF container. There is only one SAM message to catch the event to deal with it: \On SAM WPFEventWhen this event is caught you can work on the particular event fired by the control using the systemvariable wpfEventName. You can only use On SAM WPFEvent and its wpfEventName system variableon the level of the WPF container.Here is an example dealing with a WPF Slider eventAs for Methods and Properties, there is currently no list of events available for the initialized WPF control.Enrich your application using .NET WPFcontrolsHere we will show some of the samples provided in this white paper. You already learned about the TeamDeveloper WPF container; how to instantiate the container through XAML, how to consume it by invokingmethods, setting and getting properties and handling events using the new SalWPF API.So, let’s see practical examples. All those samples are based on the work of the .NET community. WithTeam Developer 6 and .NET you do not only rely on the Team Developer community alone. You just stepin the future of development!Native .NET WPF controlsThe screenshot below shows you the toolbox of Team Developer and Visual Studio 2010 for WPFapplication. Team developer has many controls, some new one like the Navigation pane. There isn’t, forexample, a Slider control. This sample will show you how to actually use the WPF Slider control in TeamDeveloper and also transform a picture control so you can rotate the image, skew it etc.OPENTEXT GUPTA TEAM DEVELOPER11

WHITEPAPER WPF Container & Controls in TD 6Using the .NET Slider is as simple as dropping a WPF container on a TD form, initializing the container inthe XAML snippet and additionally setting some specific properties for the control as shown below. In thesample, a Navigation pane is used to apply some transformation to the picture.The picture control is not a Gupta TD control, nor a WPF native control; it is a WPF user control written inC# Visual Studio 2010 which hosts a native WPF control containing a rectangle and at its turn an image.Note that it should be possible to apply directly transformation on Team Developer WPF control.This snapshots show the initialization of a WPF container to hold a Slider control that sets additionalproperties. You also could set the properties using SalWPFGetNumericProperty() for the ranges of theSlider. Here we do it directly in the XAML snippet.OPENTEXT GUPTA TEAM DEVELOPER12

WHITEPAPER WPF Container & Controls in TD 6Since currently Team Developer does not expose the list of available methods, properties and events,you have to find them out. You can use MSDN, but using Visual studio .NET will help you. s below shows a Visual Studio XAML snippet that defines a rectangle and a slider with additional setsof properties that are not set in the previous Gupta Team Developer screenshot.It is up to you to use them if they are needed. Window x:Class "WpfApplication1.MainWindow"xmlns ntationxmlns:x http://schemas.microsoft.com/winfx/2006/xamlTitle "MainWindow" Height "350" Width "525" Grid Rectangle Height "77" HorizontalAlignment "Left" Margin "38,12,0,0" Name "rectangle1"Stroke "Black" VerticalAlignment "Top" Width "109" / Slider Height "25" HorizontalAlignment "Left" Margin "120,172,0,0" Name "slider1"VerticalAlignment "Top" Width "317" ValueChanged "slider1 ValueChanged" Delay "700"IsDirectionReversed "True" IsMoveToPointEnabled "True" IsSelectionRangeEnabled "True"IsSnapToTickEnabled "True" / /Grid /Window Here Visual Studio Intellisense would reveal to you the methods, properties and events available for theobject.OPENTEXT GUPTA TEAM DEVELOPER13

WHITEPAPER WPF Container & Controls in TD 6The sample uses a Dock Dialog dlgTransform that hosts a Team Developer Navigation Pane to interactwith the control. Here you see the use of SalWPFGetNumericProperty() and SalWPFInvokeMethod()Here is the result of the Gupta Team Developer sample that allows you to transform an image.The example can be found in the \WPF container White Paper\tdTransform\tdtransform.apt. Asmentioned, the picture displayed in the Team Developer Form is a WPF user control not a TeamDeveloper control. The binary assembly is in tdTransformation.dll and the resulting source in \WPFcontainer White Paper\tdTransform.OPENTEXT GUPTA TEAM DEVELOPER14

WHITEPAPER WPF Container & Controls in TD 6MAPs in Team Developer!The example below might look complex as it integrates maps in a Gupta Team Developer application.Actually it is not, thanks to the amazing free WPF user control from http://greatmaps.codeplex.com/. Youcan just directly use it, no need of registration and no need of any web server to host the service. Youcould use also Google maps directly in WPF. hmapinwpf.html.OPENTEXT GUPTA TEAM DEVELOPER15

WHITEPAPER WPF Container & Controls in TD 6Here are the highlights of this Gupta Team Developer application. You can find this in \WPF containerWhite Paper\gMapTD\gmap.aptHere is a snapshot showing a form Window with a WPF container initialized to use the GMapControl witha single property set to Render GoogleHybrid type map.Here we setup the size of the WPF container (on 0x0005 WM SIZE message) to tile to its parent window.Currently there is no Tile to parent properties for the WPF container object.Here we have a dock dialog that actually allows rendering the map from an address, zoom, etc. This iswhere the application interacts with the object. Here you can see how simple this is to actually invoke themethod of the control that will render the map from an address contained in a multi-line edit field ml1.OPENTEXT GUPTA TEAM DEVELOPER16

WHITEPAPER WPF Container & Controls in TD 6The example is provided in the \WPF container White Paper\gMapTD\ folder and it also contains thesource of the WPF control. The assemblies for these objects are If you want to further explore methods, properties and events that the object exposes, you will have toconsult the source or the web site of the control provider.Acrobat Reader in OpenText Gupta Team DeveloperIt is perfectly possible to use ActiveX controls in an WPF application. Currently a Team Developer 6.0WPF targeted application cannot use an ActiveX control directly. Since Gupta Team Developer allowsyou to consume a WPF control, you have a means to actually make a wrapper to the ActiveX control youwant to use. A WinForm application (yet another type of .NET application) allows you through theSystem.Windows.Forms assembly to use an activeX control and, thanks to the WPF .NETWindowsFormsIntegration, you can host a Windows Form in your WPF control thus using ActiveXcontrols.You can therefore use all the ActiveX visual controls, but this needs to be an in process (.DLL) type ofcontrol. For example, MSOFFICE ActiveX control i.e.: Microsoft Excel Worksheet/Chart, Microsoft officeWord Document showing as ActiveX objects in the Gupta Team Developer toolbox would not workdirectly and this is true even in Visual Studio. One way to expose this special kind of ActiveX in a WPFapplication is to use the WPF WebBrowser control to render them. MSOffice application supports that.There can be other object types like Report Builder that will not support it; ie having Report Builderembedded in a Gupta Team Developer or using Report builder in Visual studio and embed it in a WPFwindow. Fortunately, there are ways around this as you will see in the next sample.So the example below is simply demonstrating how to embed the Acrobat PDF reader. The sample islocated in \WPF container White Paper\acrobat reader. The source of the controls (there are actually 2controls), a WindowForm control and a WPF user control, are located in \WPF container WhitePaper\acrobat reader\AcroCTL.OPENTEXT GUPTA TEAM DEVELOPER17

WHITEPAPER WPF Container & Controls in TD 6The initialization of the WPF control is rather simple:The example only calls one method to open the selected PDF. This method is a wrapper implemented inWPF user control Visual Studio solution (see the source).As in the previous example, the WPF container is tiled to its parent form so that when you resize the formthe PDF document extends with it.Here is a snapshot of the running sample.OPENTEXT GUPTA TEAM DEVELOPER18

WHITEPAPER WPF Container & Controls in TD 6Report Builder CQT previewGupta Report builder when targeting for a WIN32 type application supports both the Quick Object andActiveX interface. Quick Object can no longer be used in a Team Developer WPF application, so you willhave to use its ActiveX interface. As mentioned previously, you still can use certain ActiveX control in aWPF application but other types as out process ActiveX controls are challenging.The goal of those 2 interfaces (Quick Object and ActiveX) to report builder is to do some automation(creation of report from scratch, displaying a preview, etc.). You can do this either with report builderhidden from the UI, or outside the application (out process) or report builder embedded in a Form(generally called in process since most of those ActiveX are DLLs that share the same address space).The approach and functionality when you use report builder in a form or outside a form is somewhatdifferent. This is also the same for Word or Excel in place or out place. Some automation functionalitiesare not available when using the ActiveX embedded in the form. When you have such an objectembedded in a form generally you use its Document(s) interface, while the Application interface is usuallynot used.Net WPF applications also cannot directly use Excel or Word embedded in a form. However, if the objectsupports it, you can expose it through the .NET WPF WebBrowser object. This is not the case for reportbuilder.In order to get this to work in a Team Developer WPF application as well as a full .NET application withoutresorting to the WebBrowser object, you actually have to do a “mix of automation” as well as exposingsome server UI inside a WindowsForm hosted in a WPF control.OPENTEXT GUPTA TEAM DEVELOPER19

WHITEPAPER WPF Container & Controls in TD 6There are couple examples of this on the internet. Here is one for your inwordcontrol.aspx?msg 2185867The example provided here allows you to open a CQT file in a Team Developer WPF Desktop or Browserapplication, display its preview and navigate through the report pages. There is much more you can dousing Report Builder Automation in the .NET control that acts as a wrapper.The source of the application is located in\WPF container White Paper\WPF Report Builder Preview\rbPreviewInWPFControl.aptAll that has been covered related to calling methods, setting and getting properties applies here in the TDapplication so we will not further describe it. All the work is done in the source of both controls: the Winform control : \WPF container White Paper\WPF Report BuilderPreview\WpfRBPreviewCTL (SLNs)\WinRBPreviewCTLthe WPF control : \WPF Report Builder Preview\WpfRBPreviewCTL (SLNs)\WpfRBPreviewCTCurrent limitations The invoke property methods will only work on the first child of the WPF containerNo complex data type can be passed or returned currently in the invoke and property functionsand eventsThere are no Team Developer generated interface .APL for the WPF container that holds aninstance of a WPF control, hence no list of methods, properties and event are exposed in theActive Coding Assistant.OPENTEXT GUPTA TEAM DEVELOPER20

WHITEPAPER WPF Container & Controls in TD 6ConclusionAs mentioned in the overview of this document, Team Developer finally made it in the .NET world. Youcan now create WPF desktop and browser applications.Today not only you can target your Team Developer application to .NET but you also can consume all theplethora of free and commercial third party controls available on .Net.The WPF container is the first step to further open OpenText Gupta Team Developer to .Net allowing youto join the growing community of .NET users and enrich your win32 application by migrating your legacyapplication to Team Developer 6.0 WPF.OPENTEXT GUPTA TEAM DEVELOPER21

WHITEPAPER WPF Container & Controls in TD 6About OpenTextOpenText provides Enterprise Information Management software that enables companies of all sizes andindustries to manage, secure and leverage their unstructured business information, either in their datacenter or in the cloud. Over 50,000 companies already use OpenText solutions to unleash the power oftheir information. To learn more about OpenText (NASDAQ: OTEX; TSX: OTC), pleasevisit www.opentext.com.www.opentext.comNORTH AMERICA 800 499 6544 UNITED STATES 1 847 267 9330 GERMANY 49 89 4629 0UNITED KINGDOM 44 0 1189 848 000 AUSTRALIA 61 2 9026 3400Copyright 2015-2016 Open Text CorporationOpenText is a trademark or registered trademark of Open Text SA and/or Open Text ULC. The list of trademarks is not exhaustive of other trademarks, registered trademarks, product names, company names, brands and servicenames mentioned herein are property of Open Text SA or other respective owners. All rights reserved. For more information, visit: ml SKU#

In that respect WPF controls are similar to visual ActiveX controls, the underlying technology being very different though. In that respect WPF controls are . for any third party free or commercial controls. Needless to say that Team Developer already exposes some of the most used and needed WPF controls but the list is endless! .