Table of Contents

GUI File Path Assignment

See the remarks of MakeXmlSource(string, string, bool) to know the design pattern of file path treatment.

if the assigned file path is descendent of the configuration directory, it is straight forward that set the baseDirectory to the configuration directory and apply relative path to relFile; if not, set baseDirectory to null and set relFile to absolute path.

GUI that needs to assign file generally requires a code-behind BaseDirectory property as assistent model. The property is assigned by the parent model from the parent GUI.

In most cases, the first BaseDirectory is the project directory if the project has assigned (created or loaded).

Portability

To maintain For the portability of project or the other folder-based unit, if the sub-item is loaded by absolute path outside the folder-based unit directory, redirect the saving path to the folder-based unit directory, i.e. the SubItemFile below.

Note

You have no need to do an additional action to create a duplicate in the folder-based unit directory. Since the file-writing pattern of MakeXmlSource(string, string, bool) create files when user call to save. In other perspective, if user does not call to save, the local duplicate should be created.

The design pattern is usually saw in the HiAPI program, a object contains the properties:

  • object SubItem;
  • string SubItemFile;

Then you should keep the Protability.

File Path of Load Button and Save Button

A Load or Save button opens the browser at one of three roots:

  • Admin Directory
  • Project Directory
  • Resource Directory

The Resource Directory and Project Directory are generally under the Admin Directory, and the admin directory is generally set in the appsettings.json file. The kinds of button are not exclusive — several may sit on the same tool bar — and a button that opens the Resource root has to say so in its label.

If the selected file path is under the project directory, apply the relative path from the project: baseDirectory is the project directory and relFile is the relative path.

Tip

Always preserve an empty filter ( * . * ) for the browser.

Typical Action if exhibitionOnly false

On IMakeXmlSource.MakeXmlSource(string, string, bool) with exhibitionOnly false, the argument (baseDirectory and relFile) should be the same from object's host (if exist) XML output function.