Click or drag to resize

GTPUFileDialog

Overview

The FlexPendant SDK provides a number of file dialog box 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:

Use...

when you want to...

GTPUOpenFileDialog

Enables you to specify a file to be retrieved from the controller file system.

GTPUSaveFileDialog

Enables you to specify a file to be saved to the controller file system.

GTPUFolderBrowserDialog

Enables you to specify a folder on the controller file system.

Note Note

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

Caution note Caution

When added to the Visual Studio 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, for example in the Dispose method of the class that created them.

Illustration

The following is a screenshot of the GTPUSaveFileDialog. The other file dialog box 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 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.

file dialog 1

Note Note
The button after the File name textbox opens the virtual keyboard, enabling you 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:

file dialog 2

Implementation details

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

Property

Details

Filter

Carefully observe the string format when you set this property, for example: 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 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.

Note Note

For your program 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 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