51
Create App Configuration Utility Longflow Enterprises Ltd. Page 1 Create App Configuration Utility Contents Introduction .................................................................................................................................................. 2 Sample UI ...................................................................................................................................................... 2 Select Program .............................................................................................................................................. 3 Use OpenFileDialog ................................................................................................................................... 3 Launch OpenFileDialog ............................................................................................................................. 4 Apply program selection ........................................................................................................................... 6 Assign selected program to Application Configuration ........................................................................ 7 Show selected program ...................................................................................................................... 12 Enable configuration buttons ............................................................................................................. 14 Show Type of Configuration Set.......................................................................................................... 18 Show name of configuration set ......................................................................................................... 21 Make Configurations to Selected Program ................................................................................................. 25 Create Configuration Sets ....................................................................................................................... 25 Launch dialogue .................................................................................................................................. 25 Show type of configuration set ........................................................................................................... 27 Show name of configuration set ......................................................................................................... 29 Select Configuration Set.......................................................................................................................... 32 Launch dialogue .................................................................................................................................. 32 Show type of configuration set ........................................................................................................... 34 Show name of configuration set ......................................................................................................... 35 Set Configuration Values......................................................................................................................... 36 Copy configuration file ............................................................................................................................ 38 Test.............................................................................................................................................................. 40 Select a program ..................................................................................................................................... 40 Create configuration set ......................................................................................................................... 42 Select configuration set .......................................................................................................................... 44 Set configuration values ......................................................................................................................... 45

Create App Configuration Utility - Limnor · Create App Configuration Utility Longflow Enterprises Ltd. Page 3 Select Program If you develop a configuration utility for a specific

Embed Size (px)

Citation preview

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 1

Create App Configuration Utility

Contents Introduction .................................................................................................................................................. 2

Sample UI ...................................................................................................................................................... 2

Select Program .............................................................................................................................................. 3

Use OpenFileDialog ................................................................................................................................... 3

Launch OpenFileDialog ............................................................................................................................. 4

Apply program selection ........................................................................................................................... 6

Assign selected program to Application Configuration ........................................................................ 7

Show selected program ...................................................................................................................... 12

Enable configuration buttons ............................................................................................................. 14

Show Type of Configuration Set .......................................................................................................... 18

Show name of configuration set ......................................................................................................... 21

Make Configurations to Selected Program ................................................................................................. 25

Create Configuration Sets ....................................................................................................................... 25

Launch dialogue .................................................................................................................................. 25

Show type of configuration set ........................................................................................................... 27

Show name of configuration set ......................................................................................................... 29

Select Configuration Set .......................................................................................................................... 32

Launch dialogue .................................................................................................................................. 32

Show type of configuration set ........................................................................................................... 34

Show name of configuration set ......................................................................................................... 35

Set Configuration Values ......................................................................................................................... 36

Copy configuration file ............................................................................................................................ 38

Test .............................................................................................................................................................. 40

Select a program ..................................................................................................................................... 40

Create configuration set ......................................................................................................................... 42

Select configuration set .......................................................................................................................... 44

Set configuration values ......................................................................................................................... 45

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 2

Run program ........................................................................................................................................... 46

Distribute desired configurations ........................................................................................................... 49

Feedback ..................................................................................................................................................... 51

Introduction The sample project created in this document can be downloaded from

http://www.limnor.com/studio/ConfigUtil.zip.

Application Configuration component can be used to remember user preferences and settings. See

http://www.limnor.com/support/UseAppConfig.pdf and

http://www.limnor.com/support/UseAppConfigForBranding.pdf. In those samples, runtime

configuration operations are provided within the program to be configured. Runtime configuration

operations may also be programmed into a separate utility program. Thus you have an option to not

allow the users to change the configurations. You may make the configurations and distribute the

configuration file together with the program to the users. This document shows a sample of such usages.

The functionality of this sample project has been built into the newer versions (build # 5.6.1.637 or

higher) of Limnor Studio. You may access it by menu “Tools | Application Configuration Utility”.

Sample UI A very simply UI is shown below. It uses an OpenFileDialog component for selecting a program to do

configurations. It uses a set of buttons for setting configuration values; creating new set of

configurations; selecting a set of configurations to be used when the program starts. It uses an

Application Configuration component to form configuration operations.

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 3

Select Program If you develop a configuration utility for a specific program then you may hard-code the program name.

We develop this utility program for performing configurations for all programs which use Application

Configuration component. So, we need to allow the user to select the program to be configured.

Use OpenFileDialog

We use an OpenFileDialog for the user to select a program to be configured.

Set properties, DefaultExt, Filter, and Title, for the OpenFileDialog:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 4

Launch OpenFileDialog

We use a button to launch the OpenFileDialog:

Select ShowDialog method:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 5

Select the current form as the dialogue box owner:

Click OK:

The action is created and assigned to the button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 6

Apply program selection

When the user makes a program selection, event FileOK of the OpenFileDialog occurs. We may handle

this event to apply program selection. Right-click the OpenFileDialog; choose “Assign Action”; select

“FileOK” event:

Choose “New event handler method for FileOK”:

A Method Editor appears for developing the event handler:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 7

Assign selected program to Application Configuration

Create a SetApplicationFullPath action to use the selected program:

Use the file selection for “exePath”:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 8

Click OK:

The action is created and appears in the Action Pane:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 9

Add a Condition action to check the execution result of the above action:

Link the output of the above action to the new Condition action:

Rename the Condition action:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 10

Add a message box to show execution failure:

Use the current form as the owner of the message box:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 11

Set other properties of the action and rename the action. Click OK:

Link the new action to the No port of the Condition action:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 12

Show selected program

We want to show the file selection on the text box for program name. Right-click the text box; choose

“Create Set Property action”; select Text property of the text box:

For “value” of the action, choose Filename property of the OpenFileDialog:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 13

Click OK:

The action is created and appears in the Action Pane. Link it to the Yes port of the Condition action:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 14

Enable configuration buttons

Initially all configuration buttons are disabled. On applying the selected program to the Application

Configuration component, we need to enable these buttons.

Set “value” to True:

Click OK:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 15

Link the new action to the last action:

Do the same for the other 2 buttons.

Let’s group the actions into an action list to take less space:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 16

Now it looks cleaner:

You may edit the action list:

Add a new action to the list:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 17

We want to enable the copy button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 18

Show Type of Configuration Set

Once a program is selected, we may show the type of its current configuration set. We may do it by

adding a new action into the action list:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 19

Select the Text property of the text box for configuration type:

Select property ProfileType of the Application Configuraton component:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 20

Click OK:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 21

The action is created and added to the action list:

Show name of configuration set

Once a program is selected, we may show the name of its current configuration set, if it is a named

configuration set. We may do it by adding a new action into the action list:

Select the Text property of the text box for showing the name of configuration set:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 22

Select ProfileName property of the Application Configuration component:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 23

Click OK:

The action is created and added to the action list:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 24

This is our event handler for event FileOK.

On event FileOK, this event handler will be executed:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 25

Make Configurations to Selected Program

Once a program is selected, we can make configurations to it.

Create Configuration Sets

In other documents, a set of configuration values is called a “Profile” or a “Brand”. Multiple sets of

configuration values may co-exist for an application. An application may switch between sets of

configuration values.

Launch dialogue

We use a button for creating new sets of configuration values:

Choose CreateProfile method:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 26

Use the current form as the dialogue box owner:

Click OK:

The action is created and assigned to the button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 27

Show type of configuration set

Newly created configuration set will be the current configuration set. Let’s show its type after the

dialogue box is closed.

Choose the Text property of the text box for the type of the configuration set:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 28

Select ProfileType property of the Application Configuration component:

Click OK:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 29

The action is created and assigned to the button:

Show name of configuration set

Newly created configuration set will be the current configuration set. Let’s show its name after the

dialogue box is closed.

Choose the Text property of the text box for showing the name of the configuration set:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 30

Select ProfileName property of the Application Configuration component:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 31

Click OK:

The action is created and assigned to the button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 32

Select Configuration Set

Configuration values are used and modified for the current selected configuration set. We need to let

the user to select configuration set.

Launch dialogue

We use a button for selecting a set of configurations. The selected set of configurations will be used

when the selected program is started. Configuration value modifications will be applied to the selected

set of configurations.

Choose LogOnProfileWithUI method:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 33

The action will launch a dialogue box. Use the current form as the owner of the dialogue box:

Click OK:

The action is created and assigned to the button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 34

Show type of configuration set

After selecting configuration set, we need to show the type of the selected configuration set:

Select the action, TextBoxConfigSetType.SetText2, we created previously:

The action is assigned to the button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 35

Show name of configuration set

After selecting configuration set, we need to show the type of the selected configuration set:

Select the actions, TextBoxConfigSetName.SetText2, we created previously:

The action is assigned to the button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 36

Set Configuration Values

We may use a button to launch a dialogue to modify configuration values. The modifications will be

applied to the selected set of configurations.

Select method SetValues:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 37

The action will launch a dialogue box. Use the current form as the owner of the dialogue box:

Click OK:

The action is created and assigned to the button:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 38

Copy configuration file

You may copy current configuration file to a specified folder. This feature is a convenient way for you to

distribute a desired set of configuration values to your users as the factory settings.

Select CopyProfile method:

Use current form as the dialogue box owner:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 39

Click OK to finish creating the action:

The action is created and assigned to the button:

In the Test chapter below we will show you how this feature helps you to distribute desired

configurations to your users as the factory settings.

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 40

Test

Run the program to start testing:

Select a program

Click “…” to select a program:

Select a program which has Application Configurations enabled:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 41

The program is applied to the configuration component:

We can see that its current configuration set is user-specific because the type of the current

configuration set is User.

The 3 buttons for performing configurations are enabled. Now we can do configurations for the selected

program.

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 42

Create configuration set

Note that the new configuration set becomes the current configuration set:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 43

We may create more if we want:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 44

Select configuration set

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 45

Set configuration values

Make modifications to configuration values:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 46

Finish the editing:

Run program

Now we run the program:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 47

We can see that this program is changed by our configuration utility.

Let’s close the program and select a different set of configuration using our utility:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 48

The default profile is the named profile with empty name.

Now run the program. We can see the default configurations are used:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 49

Distribute desired configurations

Click button “Copy configuration file”:

A dialogue box appears. Click “…” to select Copy-to folder:

Select a folder:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 50

Click Copy button to copy the file:

The file is copied to the selected folder:

Create App Configuration Utility ����

Longflow Enterprises Ltd. Page 51

Note that the copied file is named as {EXE file name}.cfg. This naming is for the factory settings. For

example, we developed the program named AppWithBranding (see

http://www.limnor.com/support/UseAppConfigForBranding.pdf), the files to be distributed to our users

are in folder Release:

The file AppWithBranding.exe.cfg in the folder is the factory settings. Replace this file to give the users

the factory settings we want. You may backup the file being replaced and restore it when needed.

Feedback

Please send your feedback and suggestions to [email protected]