private void ExecuteAddImagesCommand() { var openFileDialog = new OpenFileDialog { Filter = "所有文件|*.png;*.jpg;*.jpeg|PNG文件|*.png|JPG文件|*.jpg;*.jpeg", Multiselect = true }; var dialogResult = openFileDialog.ShowDialog(); if (dialogResult == null || !dialogResult.Value) { return; } if (openFileDialog.FileNames == null) { return; } foreach (var fileItem in openFileDialog.FileNames) { var model = new FileInfoObject { FileName = Path.GetFileName(fileItem), FilePath = fileItem, IsUploading = false }; Images[CurrentIndex].Add(model); } CalcTotalCount(); }
private void ExecuteOpenFileCommand(FileInfoObject file) { try { //Process.Start(file.FilePath); UIManager.OpenDefaultBrower(file.FilePath); } catch (Exception e) { Logger.WriteLog(LogType.ERROR, "加载图片出错,地址:" + file.FilePath, e); } }
private void ExecuteDeleteImageCommand(FileInfoObject file) { if (_currentIndex < 0) { return; } if (_images[_currentIndex].Contains(file)) { _images[_currentIndex].Remove(file); } CalcTotalCount(); }
public static void UserInfoResultTest() { const bool ok = true; const string fileId = "fileId"; const int fileSize = 123456; const string filePath = "/file/path"; JObject fileInfo = FileInfoObject.GetObject(fileId, fileSize, filePath); dynamic fileInfoResultObject = FileInfoResultObject.GetObject(ok, fileInfo); FileInfoResult fileInfoResult = new FileInfoResult(fileInfoResultObject.ToString()); Assert.AreEqual(ok, fileInfoResult.Ok); Assert.AreEqual(fileId, fileInfoResult.Result.FileId); Assert.AreEqual(fileSize, fileInfoResult.Result.FileSize); Assert.AreEqual(filePath, fileInfoResult.Result.FilePath); }
public async Task <Result <FileInfoObject> > AddFiles() { FileInfoObject toReturn = null; var form = await Request.ReadFormAsync(); var fullRelativeUrl = form.Keys.FirstOrDefault(); List <MessageInfo> messages = new List <MessageInfo>(); foreach (var file in form.Files) { var parsedContentDisposition = ContentDispositionHeaderValue.Parse(file.ContentDisposition); using (var stream = file.OpenReadStream()) { var fileContent = stream.ReadFully(); try { toReturn = fileService.AddFile(fullRelativeUrl, parsedContentDisposition.FileName.Replace("\"", ""), fileContent); } catch (AppValidationException ex) { messages.AddRange(ex.Messages); } catch (Exception ex) { this.logger.LogError(ex.ToString()); } } } if (messages.Count > 0) { throw new AppValidationException(messages); } return(toReturn); }
private bool CanExecuteOpenFileCommand(FileInfoObject file) { var can = file != null && !String.IsNullOrWhiteSpace(file.FilePath); return(can); }
private bool CanExecuteDeleteImageCommand(FileInfoObject file) { return(file != null && _canSubmit); }
public Result <bool> DeleteFile([FromBody] FileInfoObject model) { return(fileService.DeleteFile(model.FullRelativeName)); }
public static void DoNppDocumentSwitched(bool initiating = false) { // update current file info IsPreviousFileProgress = IsCurrentFileProgress; IsCurrentFileProgress = Abl.IsCurrentProgressFile; CurrentFilePath = Npp.GetCurrentFilePath(); CurrentFileObject = FilesInfo.GetFileInfo(CurrentFilePath); // accept advanced notifications only if the current file is a progress file CurrentFileAllowed = IsCurrentFileProgress; // update current scintilla Npp.UpdateScintilla(); // Apply options to npp and scintilla depending if we are on a progress file or not ApplyOptionsForScintilla(); // close popups.. ClosePopups(); // Update info on the current file FilesInfo.UpdateErrorsInScintilla(); // refresh file explorer currently opened file FileExplorer.RedrawFileExplorerList(); if (!initiating) { if (Config.Instance.CodeExplorerAutoHideOnNonProgressFile) { CodeExplorer.Toggle(IsCurrentFileProgress); } if (Config.Instance.FileExplorerAutoHideOnNonProgressFile) { FileExplorer.Toggle(IsCurrentFileProgress); } } else { // make sure to use the ProEnvironment and colorize the error counter FilesInfo.UpdateFileStatus(); ProEnvironment.Current.ReComputeProPath(); } if (IsCurrentFileProgress) { // Need to compute the propath again, because we take into account relative path ProEnvironment.Current.ReComputeProPath(); // rebuild lines info (MANDATORY) Npp.RebuildLinesInfo(); } // Parse the document ParserHandler.ParseCurrentDocument(true); // publish the event if (OnDocumentChangedEnd != null) { OnDocumentChangedEnd(); } }