예제 #1
0
        /// <summary>
        /// Dialog for save files.
        /// </summary>
        /// <param name="browserWindow">The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.</param>
        /// <param name="options"></param>
        /// <returns>Returns String, the path of the file chosen by the user, if a callback is provided it returns an empty string.</returns>
        public Task <string> ShowSaveDialogAsync(BrowserWindow browserWindow, SaveDialogOptions options)
        {
            var    taskCompletionSource = new TaskCompletionSource <string>(TaskCreationOptions.RunContinuationsAsynchronously);
            string guid = Guid.NewGuid().ToString();

            BridgeConnector.On <string>("showSaveDialogComplete" + guid, (filename) =>
            {
                BridgeConnector.Off("showSaveDialogComplete" + guid);

                taskCompletionSource.SetResult(filename);
            });

            BridgeConnector.Emit("showSaveDialog", browserWindow, options, guid);

            return(taskCompletionSource.Task);
        }
예제 #2
0
        /// <summary>
        /// Dialog for save files.
        /// </summary>
        /// <param name="browserWindow">The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.</param>
        /// <param name="options"></param>
        /// <returns>Returns String, the path of the file chosen by the user, if a callback is provided it returns an empty string.</returns>
        public Task <string> ShowSaveDialogAsync(BrowserWindow browserWindow, SaveDialogOptions options)
        {
            var taskCompletionSource = new TaskCompletionSource <string>();

            BridgeConnector.Socket.On("showSaveDialogComplete", (filename) =>
            {
                BridgeConnector.Socket.Off("showSaveDialogComplete");

                taskCompletionSource.SetResult(filename.ToString());
            });

            BridgeConnector.Socket.Emit("showSaveDialog",
                                        JObject.FromObject(browserWindow, _jsonSerializer),
                                        JObject.FromObject(options, _jsonSerializer));

            return(taskCompletionSource.Task);
        }