• No results found

GTPUFileDialog

5.3 Building the user interface

5.3.13 GTPUFileDialog

© Copyri ght 200 7 - 2009 ABB . All ri ghts res erved.

5.3.13. GTPUFileDialog

Overview

The FlexPendant SDK provides a number of file dialogs used by the end-user to interact with the file system of the robot controller. These controls all inherit the abstract class

GTPUFileDialog and belong to the namespace ABB.Robotics.Tps.Windows.Forms.

File dialog types

There are three different types of file dialog controls:

NOTE!

The Open/Save/Browse file dialogs represent a convenient way for the user to specify folder and filename for a file operation. You should know, however, that the dialogs themselves do not perform any file operation, they only provide the controller file system path to be used by your application.

CAUTION!

When added to the VS Designer from the Toolbox, these controls will be placed in the components pane. They must be explicitly removed by a call to their Dispose method, e.g. in the Dispose method of the class that created them.

Illustration

Below is an illustration of the GTPUSaveFileDialog. The other file dialogs have almost the same appearance and the way they work is very similar. Using the icons of the command bar you create new folders and browse the controller file system. Together with the list and the

Use... when you want to...

GTPUOpenFileDialog Enable the user to specify a file to be retrieved from the

controller file system.

GTPUSaveFileDialog Enable the user to specify a file to be saved to the

controller file system.

GTPUFolderBrowserDialog Enable the user to specify a folder on the controller file system.

5.3.13. GTPUFileDialog © Copyri ght 200 7 - 2009 ABB . All ri ghts res erved.

textbox, you specify a remote path. The FileName property should be read to retrieve this path. It returns the complete path to the controller file system, even though only the file name is visible in the File name textbox

6.3.13_1

Note! The button after the File name textbox opens the virtual keyboard, enabling the user

to change the name of the file to be saved. The Filter property of the control is set to TEXT(*.txt)|*.txt. The first part of the setting is displayed in the filter textbox.

This is the Properties window of this dialog:

6.3.13_2

Continued

5.3.13. GTPUFileDialog © Copyri ght 200 7 - 2009 ABB . All ri ghts res erved. Implementation details

The Properties window gives a clear description of a selected property, as can be seen in the figure above. Here only a few important properties will be detailed:

NOTE!

For your program to be able to use the controller path selected by the end user, you need to read the FileName property at the Closing/Closed event of the file dialog.

Example

This piece of code sets InitialDirectory and FileName, then sets up a subscription to the Closed event and finally displays the GTPUSaveFileDialog

saveFileDialog.InitialDirectory = initialDir; saveFileDialog.FileName = programName;

saveFileDialog.Closed += new

EventHandler(SaveProgram_FileDialog_EventHandler); saveFileDialog.ShowMe(_parent);

The code of the SaveProgram_FileDialog_EventHandler method retrieves the specified path of the remote file system, including the file name, by reading the FileName

property:

string remotePath = saveFileDialog.Filename;

NOTE!

The file has not yet been saved to the robot controller. To do that you should call

FileSystem.PutFile using the retrieved path as the remoteFile argument. Likewise, to load a specified remote file to the FlexPendant file system you should use the retrieved path in the call to FileSystem.GetFile.

Property Details

Filter Carefully observe the string format when you set this

property, e.g.: Program Files (*.pgf)|*.pgf

The first part is displayed in the combo box and the second part is used by the SDK to retrieve the correct files to be displayed in the list. You can also specify several filters, which the user can choose from.

Program Files (*.pgf)|*.pgf|All Files (*.*)|*.*; FileName Cannot be accessed in design-time by using the

Properties window, but should be manually coded when the file dialog is launched if it is a save file dialog. When the dialog is closed, you should read this property. It holds the remote path and file name of the file to be opened, or the remote path and file name of the file to be saved.

Note! Remember that remote refers to the controller file system and local to the FlexPendant file system.

InitialDirectory Cannot be accessed in design-time by using the

Properties window. Specifies the initial directory to be displayed by the file dialog box.

5.3.14. DataBinding of RAPID data and IO signals © Copyri ght 200 7 - 2009 ABB . All ri ghts res erved.

5.3.14. DataBinding of RAPID data and IO signals

What is databinding?

Databinding is the process of binding a property of a GUI control to a data source, so that the property automatically reflects the value of the data source. In .NET CF 2.0 this functionality was simplified thanks to the new BindingSource class. This class encapsulates the complexity related to setting up and managing databinding.

FlexPendant SDK classes to be used as binding sources

In the FlexPendant SDK there are two classes that inherit .NET BindingSource:

RapidDataBindingSource and SignalBindingSource.These classes enable binding to

RAPID data and IO signals respectively. They belong to the ABB.Robotics.DataBinding

namespace and the assembly you need to reference is ABB.Robotics.DataBinding.dll.

RapidDataBindingSource

By using RapidDataBindingSource an automatic update of the bound GUI control takes place when the value of the specified RAPID data source in the controller has changed, or when the control is repainted.

SignalBindingSource

By using SignalBindingSource an automatic update of the bound GUI control takes place when the value of the specified IO signal in the controller has changed, or when the control is repainted.

NOTE!

It is only possible to use persistent RAPID data (PERS) as data source. NOTE!

If you want to let users modify RAPID data, launching the standard FlexPendant application Program Data from your application is probably the best alternative. See Using standard dialogs to modify data on page 131 for information about how to do it.

GUI example

Many different controls can be used with binding sources, e.g. TpsLabel, TextBox,

ListView etc. The figure below shows two System.Windows.Forms.DataGrid controls that each bind to several objects defined in a RapidDataBindingSource and a