FileUtility

References
public class FileUtility
This class maintains all information and functionality regarding document files.

Constructors

FileUtility

#
public FileUtility(Document document)
Construct a new document file state class.
document (Document)Document that owns this instance.

Properties

AutoSaveFilePath

#
public string AutoSaveFilePath { get; }
Gets the file path to the autosave file, or null if that's currently not possible.

BackupMethod

#
public BackupMethod BackupMethod { get; set; }
Gets or sets the backup behaviour for this document.

BackupTimestamp

#
public string BackupTimestamp { get; set; }
Gets or sets the timestamp formatting to be used when backing up files which are about to be overwritten due to a Save operation.

BackupTimestampWithFallback

#
public string BackupTimestampWithFallback { get; }
Gets the user overridden time stamp format, or the default if the value has not been overridden.

BackupUserFolder

#
public string BackupUserFolder { get; set; }
Gets or sets the backup folder for when the BackupMethod equals BackupMethod.UserFolder.

Directory

#
public string Directory { get; }
Gets the directory of the current path, if any.

DisplayText

#
public string DisplayText { get; }
Gets the text used to describe this document. The DisplayText may contain the filename and the saved state, as well as hierarchical clues.

FallbackName

#
public string FallbackName { get; set; }
Gets or sets the fallback name. If the file is otherwise unsaved, the fallback name (if set) will be used instead of "unnamed".

FileName

#
public string FileName { get; }
Gets the filename (without the extension) of the current path, if any.

FileOverwriteWarning

#
public string FileOverwriteWarning { get; set; }
When a warning is set, saving a file requires an additional mouse click. The warning is not serialised. Typically backup and autosave files will have this warning set to avoid them being summarily overwritten.

HasPath

#
public bool HasPath { get; }
Gets a value indicating whether the file path has been set.

Path

#
public string Path { get; set; }
Gets the filepath that this document is associated with. Not every document is associated with a file, so this field may be null or empty. Assigning a new path to a file does not trigger a save action.

Thumbnail

#
public Bitmap Thumbnail { get; set; }
Gets or sets the thumbnail image for this document. The getter is lazy: if no thumbnail has been assigned yet it will attempt to generate one via TryCreateThumbnail() on first access.

Methods

AutoSave

#
public AutoSaveResult AutoSave(AutoSaveReason reason, Guid processId)
Perform an autosave operation.
reason (AutoSaveReason)Reason for autosave.
processId (Guid)Id associated with request. Subsequent requests with identical IDs are ignored.

AutoSave

#
public AutoSaveResult AutoSave(AutoSaveReason reason)
Perform an autosave operation.
reason (AutoSaveReason)

CreatePreview

#
public Bitmap CreatePreview(float scale, int padding = 10)
Create a preview image of the entire document at a fixed scale. Unlike TryCreateThumbnail(), the result is not fit-to-bounds; the bitmap is sized to the document's ObjectList.AttributeBounds multiplied by scale.
scale (float)Render scale (1.0 for 100%, 2.0 for 200%, etc.).
padding (int = 10)Pixel padding around all four sides of the bitmap. May be negative to crop.
A new bitmap, or null if the document contains no laid-out objects.

DeleteAutoSaveFile

#
public bool DeleteAutoSaveFile()
Try and remove the autosave file.
True if a file was deleted.

PickNewSaveBackupFolder

#
public bool PickNewSaveBackupFolder()
Ask the user to specify a new folder location for the BackupUserFolder. This method must be called on the UI thread.
True if a new folder was picked, false if otherwise.

SpecifyNewTimestampFormat

#
public bool SpecifyNewTimestampFormat()
Display the UI needed to set a new backup timestamping format.
True if a new format was set.