Programming Reference for VirtualLab Fusion  2022.1
Static Public Member Functions | List of all members
FileHandlingSupport Class Reference

This class is subject to change. Programs using this class may require changes with a new version of VirtualLab.
Class providing support methods for loading & importing of files. More...

Static Public Member Functions

static string AddExtension (string fileName, string extension)
 Adds an extension to the given file name. More...
 
static string AppendDateTimeToFileName (string fileName)
 Appends the date and the time to the end of the given file name. More...
 
static IStorableOnHDD GenericLoad (string fileName, out ListOfSavedViewSettings viewSettings)
 Loads an object from HDD. More...
 
static Bitmap GetImageForDocumentType (DocumentType documentType)
 Gets the type of the image matching the given document type. More...
 
static void ImportAndShowFile (string fileName, DocumentType? documentType=null)
 Method to import various file types and show the imported data as new document. This method is not thread-safe. More...
 
static bool IsDoumentsWithoutViewSettingsSaveMechanism (Type typeOfFormDcoument)
 Method which defined which types of document windows shall not use the saving algorithm for view settings More...
 
static IDocument LoadDocument (string fileName)
 Loads a document, but not the corresponding view settings. More...
 
static IDocument LoadDocument (string fileName, out ListOfSavedViewSettings viewSettings)
 Loads a document. More...
 
static FormDocument LoadDocument_GUISupport (string fileName, string documentName="", bool addToRecentFileList=true)
 Loads a document to the GUI. This method does the following steps: More...
 
static string MakeFileNameValid (string fileName)
 Makes the given file name valid, i.e. all characters not allowed in file names are replaced by an underscore. More...
 
static void OpenFolderInExplorer (string folder)
 Opens the given folder in Windows File Explorer. More...
 
static void SaveCompressed (IStorableOnHDD documentToSave, string filePath, ListOfSavedViewSettings viewSettings=null)
 Saves the given file as a zip file. More...
 

Detailed Description

This class is subject to change. Programs using this class may require changes with a new version of VirtualLab.
Class providing support methods for loading & importing of files.

Member Function Documentation

◆ AddExtension()

static string AddExtension ( string  fileName,
string  extension 
)
static

Adds an extension to the given file name.

Parameters
fileNameThe file name.
extensionThe extension.
Returns
The file name with the added extension. If the extension does not contain a leading period (.), a period is added. In contrast to Path.ChangeExtension, "filename.3" + ".ext" becomes "filename.3.ext", not "filename.ext". If the file name already ends with the given extension, it is not added anew.

◆ AppendDateTimeToFileName()

static string AppendDateTimeToFileName ( string  fileName)
static

Appends the date and the time to the end of the given file name.

Parameters
fileNameThe file name including path and extension.
Returns
The altered file name with the date and time added in brackets and in ISO format, e.g. (C:\myfile (2018-11-09T134257).txt").

◆ GenericLoad()

static IStorableOnHDD GenericLoad ( string  fileName,
out ListOfSavedViewSettings  viewSettings 
)
static

Loads an object from HDD.

Parameters
fileNameThe file name of the object to load. It is checked whether the file exists and whether the extension of that file is a supported document type of VirtualLab.
viewSettingsOut parameter to return the view settings (e.g. size of the document window) saved together with the actual document.
Returns
The loaded document. Can be null if no view settings were stored alongside the actual object.

◆ GetImageForDocumentType()

static Bitmap GetImageForDocumentType ( DocumentType  documentType)
static

Gets the type of the image matching the given document type.

Parameters
documentTypeThe document type for which the matching image shall be returned.
Returns
Retrieves the correct image matching the given document type.
Exceptions
System.ArgumentExceptionNo suitable image could be found for the given document type.

◆ ImportAndShowFile()

static void ImportAndShowFile ( string  fileName,
DocumentType?  documentType = null 
)
static

Method to import various file types and show the imported data as new document. This method is not thread-safe.

Parameters
fileNameThe full name including the path of the file to be imported.
documentTypeOptional parameter to indicate that the import shall be done into a specific document type. Currently used to indicate that bitmaps shall be imported into a ChromaticFieldSset instead of a HarmonicFieldsSet.
Exceptions
FileLoadExceptionFile format unsupported

◆ IsDoumentsWithoutViewSettingsSaveMechanism()

static bool IsDoumentsWithoutViewSettingsSaveMechanism ( Type  typeOfFormDcoument)
static

Method which defined which types of document windows shall not use the saving algorithm for view settings

Parameters
typeOfFormDcoumentThe type of the corresponding document window.
Returns
True for IFTA Optimization and module documents as these do not support the view settings mechanism.

◆ LoadDocument() [1/2]

static IDocument LoadDocument ( string  fileName)
static

Loads a document, but not the corresponding view settings.

Parameters
fileNameThe file name of the document to load. It is checked whether the file exists and whether the extension of that file is a supported document type of VirtualLab.
Returns
The loaded document.

◆ LoadDocument() [2/2]

static IDocument LoadDocument ( string  fileName,
out ListOfSavedViewSettings  viewSettings 
)
static

Loads a document.

Parameters
fileNameThe file name of the document to load. It is checked whether the file exists and whether the extension of that file is a supported document type of VirtualLab.
viewSettingsOut parameter to return the view settings (e.g. size of the document window) saved together with the actual document.
Returns
The loaded document.

◆ LoadDocument_GUISupport()

static FormDocument LoadDocument_GUISupport ( string  fileName,
string  documentName = "",
bool  addToRecentFileList = true 
)
static

Loads a document to the GUI. This method does the following steps:

  1. Enable the hour glass cursor.
  2. Load the file.
  3. Add the file to the "Recent Files" list.
  4. Displays the document window (including the loaded view settings, if applicable)
  5. Disable the hourglass cursor.
Parameters
fileNameThe file name of the document to load. It is checked whether the file exists and whether the extension of that file is a supported document type of VirtualLab.
documentNameIf this optional parameter is specified it gives the caption of the document. Otherwise the file name is used to this end.
addToRecentFileListBy default the loaded document is added to the list of recently used files. However if you set this optional parameter to false, this is not the case.
Returns
The shown document window.
Exceptions
ArgumentExceptionNo main form is given.

◆ MakeFileNameValid()

static string MakeFileNameValid ( string  fileName)
static

Makes the given file name valid, i.e. all characters not allowed in file names are replaced by an underscore.

Parameters
fileNameThe file name to make valid.
Returns
The changed file name.

◆ OpenFolderInExplorer()

static void OpenFolderInExplorer ( string  folder)
static

Opens the given folder in Windows File Explorer.

Parameters
folderThe folder to open.

◆ SaveCompressed()

static void SaveCompressed ( IStorableOnHDD  documentToSave,
string  filePath,
ListOfSavedViewSettings  viewSettings = null 
)
static

Saves the given file as a zip file.

Parameters
documentToSaveThe document to save.
filePathThe file path under which the document shall be saved.
viewSettingsIf this optional parameter is set, the given view settings are also stored in the compressed file.