Class SaveFilePropertyToFile
A view command that prompts the user for a file and saves the specified data to it. For example:
byte[] myFileData = GetMyFileData();
var store = new SaveFilePropertyToFile(View.Displayer,
() => myFileData,
() => true,
new LemonEdge.Core.Client.CommandDecriptor("Save File", Images.ImageType.Download, "Save a copy of file.", Images.ImageType.AddIn),
new(string, string)[] { (".net Dlls", "*.dll"), ("All Files", "*.*") },
() => "DefaultFileName.dll");
Inheritance
Implements
Inherited Members
Namespace: LemonEdge.Client.Core.Commands.ViewCommands
Assembly: LemonEdge.ClientCore.dll
Syntax
public class SaveFilePropertyToFile : ViewCommand, IHasChildren<EPCommandWithDescriptor>, IHasChildren, IDisposable, IEPCommandWithDescriptor, IEPCommand, ICommand, ICommandDescriptor
Constructors
SaveFilePropertyToFile(IRootController, IModelLayoutDisplayer, Func<Task<byte[]>>, Func<bool>, ICommandDescriptor, (string FileTypeName, string fileType)[], Func<string>)
Creates a new SaveFilePropertyToFile
Declaration
public SaveFilePropertyToFile(IRootController root, IModelLayoutDisplayer owner, Func<Task<byte[]>> getData, Func<bool> canExecute, ICommandDescriptor descriptor, (string FileTypeName, string fileType)[] fileTypes, Func<string> defaultFileName)
Parameters
Type | Name | Description |
---|---|---|
IRootController | root | The root controller, for service access. |
IModelLayoutDisplayer | owner | The owning host context for this command |
Func<Task<byte[]>> | getData | A function that returns the data to be written to the file as a byte array |
Func<bool> | canExecute | A function that returns true if this command can be executed |
ICommandDescriptor | descriptor | A descriptor to use for the title, icon, etc and other attributes of this command |
(string FileTypeName, string fileType)[] | fileTypes | An array of valid file types that can be selected |
Func<string> | defaultFileName | The default file name to use when prompting to save the file data |
Properties
Description
A user friendly description of this command
Declaration
public override string Description { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
IconID
Declaration
public override Guid IconID { get; }
Property Value
Type | Description |
---|---|
Guid |
Overrides
OverlayIconID
On some clients another image can be overlayed on the bottom right of the main icon (for indicating add, remove, etc)
This optional overlay image can be specified here, either a ImageType or ImageID
Declaration
public override Guid? OverlayIconID { get; }
Property Value
Type | Description |
---|---|
Guid? |
Overrides
Title
The title of this command
Declaration
public override string Title { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
ToolTip
A user friendly tool tip for this command functionality, by default the Description
Declaration
public override string ToolTip { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
Methods
InternalCanExecute(object)
Returns if this command can be executed or not from the client application UI
You must override InternalCanExecute(object?) or InternalCanExecuteAsync(object?) in order to implement if it can be executed
Declaration
public override bool InternalCanExecute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
Returns
Type | Description |
---|---|
bool | If this command can be executed or not from the client application UI |
Overrides
InternalExecuteAsync(object)
Prompts the user for a file and writes the file data to it
Declaration
public override Task InternalExecuteAsync(object parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |