コード例 #1
0
        public async Task <IActionResult> SetBlobSpecialValue([FromBody] SetSpecialValueRequest request)
        {
            if (!SpecialValues.ContainsKey(request.Key))
            {
                SpecialValues.Add(request.Key, null);
            }

            var mainWindow = Electron.WindowManager.BrowserWindows.First();
            var options    = new OpenDialogOptions
            {
                Properties = new OpenDialogProperty[] {
                    OpenDialogProperty.openFile
                }
            };

            request.Value = (await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options)).FirstOrDefault();
            if (System.IO.File.Exists(request.Value))
            {
                SpecialValues[request.Key] = Convert.ToBase64String(System.IO.File.ReadAllBytes(request.Value));
                BroadcastValueChanged(request.Key);
                return(Json(true));
            }
            else
            {
                // Show dialog
                return(Json(false));
            }
        }
コード例 #2
0
 public IActionResult SetStringSpecialValue([FromBody] SetSpecialValueRequest request)
 {
     if (!SpecialValues.ContainsKey(request.Key))
     {
         SpecialValues.Add(request.Key, null);
     }
     SpecialValues[request.Key] = request.Value;
     BroadcastValueChanged(request.Key, request.KeepListen);
     return(Json(true));
 }