electron#SaveDialogOptions TypeScript Examples
The following examples show how to use
electron#SaveDialogOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewerHandler.ts From viewer with MIT License | 6 votes |
/**
* Save file dialog
* @param options
* @returns
*/
public async saveFile(
options: SaveDialogOptions
): Promise<SaveDialogReturnValue> {
return dialog.showSaveDialog(options);
}
Example #2
Source File: ITwinViewerApp.ts From viewer with MIT License | 6 votes |
public static async saveBriefcase(
iModelName?: string
): Promise<string | undefined> {
const options: SaveDialogOptions = {
title: ITwinViewerApp.translate("saveBriefcase"),
defaultPath: `${this._getFileName(iModelName)}.bim`,
filters: [{ name: "iModels", extensions: ["ibim", "bim"] }],
};
const val = await ITwinViewerApp.ipcCall.saveFile(options);
return val.canceled || !val.filePath ? undefined : val.filePath;
}
Example #3
Source File: useWriteIpc.tsx From Account-Manager with MIT License | 5 votes |
function useWriteIpc({
channel,
downloadOptions,
extension,
failCallback,
payload,
postSendCallback,
successCallback,
}: {
channel: IpcChannel;
extension: 'json' | 'txt';
downloadOptions: DownloadOptions;
failCallback: GenericVoidFunction;
payload: string;
postSendCallback?: GenericVoidFunction;
successCallback: GenericVoidFunction;
}) {
useIpcEffect(getSuccessChannel(channel), successCallback);
useIpcEffect(getFailChannel(channel), failCallback);
const options: SaveDialogOptions = useMemo(
() => ({
buttonLabel: downloadOptions.buttonLabel,
defaultPath: downloadOptions.defaultPath,
filters: [
{extensions: [extension], name: extension},
{extensions: ['*'], name: 'All Files'},
],
title: downloadOptions.title,
}),
[downloadOptions.buttonLabel, downloadOptions.defaultPath, downloadOptions.title, extension],
);
return useCallback(async (): Promise<void> => {
remote.dialog.showSaveDialog(options).then(({canceled, filePath}) => {
if (canceled) return;
ipcRenderer.send(channel, {filePath, payload});
postSendCallback?.();
});
}, [channel, options, payload, postSendCallback]);
}