private void Init() { fileBrowser = new FileBrowserViewModel(); Contents.Add(fileBrowser); settingsVm = new SettingsViewModel(); settingsVm.RecordEdited += SettingsVm_RecordEdited; Contents.Add(settingsVm); settingsDetail = new SettingsDetailViewModel(); settingsDetail.NewRecordAdded += SettingsDetail_NewRecordAdded; Contents.Add(settingsDetail); fileBrowser.ShowBusy += FileBrowser_ShowBusy; fileBrowser.StopBusy += FileBrowser_StopBusy; settingsVm.ShowBusy += FileBrowser_ShowBusy; settingsVm.StopBusy += FileBrowser_StopBusy; settingsDetail.ShowBusy += FileBrowser_ShowBusy; settingsDetail.StopBusy += FileBrowser_StopBusy; CurrentContent = Contents.FirstOrDefault(); isShowBusy = false; RaisePropertyChanged("IsShowBusy"); }
public JsonResult GetDirElements(string path) { FileBrowserViewModel model = new FileBrowserViewModel(); if (path == "root") { model.ChildDirs = FM.GetRootDirs(); model.ChildFiles = new List <FileInfo>(); model.CurrentDir = new FileInfo() { Name = "Root", FullPath = "root" }; } else { FM.SetPath(path); model.ChildDirs = FM.GetChildDirs(); model.ChildFiles = FM.GetChildFiles(); model.CurrentDir = new FileInfo() { Name = FM.GetDirName(), FullPath = path }; } return(Json(model)); }
public FileBrowser() { InitializeComponent(); BindingContext = _viewModel = new FileBrowserViewModel(); LoadFiles = new Command(async(path) => await _viewModel.GetFiles((string)path)); LoadFolders = new Command(async(path) => await _viewModel.GetFolders((string)path)); }
private async Task SaveAsync() { var fileSelection = new FileBrowserViewModel(this.ViewFacade, FileSelectionMode.Save, Environment.SpecialFolder.Desktop.Directory().CombineFile("WeatherData.json")); await fileSelection.Select.ExecuteAsync(); fileSelection.SelectedFile?.WriteContent(JsonConvert.SerializeObject(this.WeatherData)); }
public FileBrowserPage() { InitializeComponent(); BindingContext = viewModel = new FileBrowserViewModel(); listView.RefreshCommand = new Command(async() => { await viewModel.UpdateDirectory(); listView.IsRefreshing = false; }); }
public ActionResult Upload(HttpPostedFileBase file) { var fileBrowserActions = IoC.Resolve <IFileBrowserAction>(); var model = new FileBrowserViewModel { Ident = Request.Form["Ident"] }; // test content length if (file.ContentLength > FileBrowserViewModel.MaxFileSize) { ModelState.AddModelError <FileBrowserViewModel>(item => item.Ident, string.Format(vlko.BlogModule.ModelResources.FileTooBigError, FileBrowserViewModel.MaxFileSize)); } else { // test if ident specified if (string.IsNullOrWhiteSpace(model.Ident)) { ModelState.AddModelError <FileBrowserViewModel>(item => item.Ident, vlko.BlogModule.ModelResources.FileIdentRequireError); } else { // get new ident based on user ident and uploaded file extension string fileIdent = model.Ident + Path.GetExtension(file.FileName); // check if file exists var existingItem = fileBrowserActions.GetFileInfo(UserInfo.Name, fileIdent); if (existingItem != null) { ModelState.AddModelError <FileBrowserViewModel>(item => item.Ident, string.Format(vlko.BlogModule.ModelResources.FileIdentExistsError, fileIdent)); } else { // Save file if (!fileBrowserActions.SaveFile(UserInfo.Name, fileIdent, file.InputStream)) { ModelState.AddModelError(string.Empty, vlko.BlogModule.ModelResources.FileUploadFailedError); } else { model.Ident = null; } } } } // load user files model.UserFiles = fileBrowserActions.GetAllUserFileInfos(UserInfo.Name); // return normal view, for ajax we have iframe technique so normal result is needed return(View("Index", model)); }
public PartialViewResult Invoke(FileBrowserViewModel viewModel) { try { PSRemoting ps = new PSRemoting(viewModel.ComputerName, config.FALCON_FORENSICS_USERNAME, config.FALCON_FORENSICS_PASSWORD, config.FALCON_FORENSICS_DOMAIN); FileSystemBrowser browser = new FileSystemBrowser(ps); List <FileMetadata> model = browser.GetDirectoryContent(@"'" + viewModel.Directory + "'"); return(PartialView("_DirectoryListing", model)); } catch (Exception e) { return(PartialView("_Error", e.Message)); } }
public JsonResult FileBrowser(string id = null) { var result = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet }; string directory = id != null?Server.MapPath("~" + ContentGlobals.IMAGEUPLOADDIRECTORY + "\\" + id) : null; var model = new FileBrowserViewModel(directory); string partialHtml = ControllerContext.RenderPartialToString("~/Areas/Admin/Views/Shared/Partials/FileBrowserPartial.cshtml", model); result.Data = new { success = true, html = partialHtml }; return(result); }
public FileBrowser() { ViewModel = new FileBrowserViewModel(); InitializeComponent(); FileTreeView.ItemsSource = ViewModel.FileSystemNodes; this.WhenActivated(reg => { this.BindCommand( ViewModel, vm => vm.DebugAddNode, v => v.AddNodeBtn ).DisposeWith(reg); MessageBus.Current.Listen <Events.DiscoveredGameFilePath>() .Subscribe(OnDiscoveredGameFilePath) .DisposeWith(reg); }); }
public IActionResult FileBrowser(FileBrowserRequest request) { FileBrowserViewModel browserModel = new FileBrowserViewModel() { }; // Get the blog that is for this controller instance if (Current != null) { // Set the browser templates browserModel.Templates = Current.Templates.ContainsKey(BlogControllerView.FileBrowser) ? Current.Templates[BlogControllerView.FileBrowser] : new BlogViewTemplates(); // Get the blog item IBlogItem blogItem = Current.Get(new BlogHeader() { Id = Current.Parameters.Provider.DecodeId(request.id) }); if (blogItem != null) { // Set the blog item for the returning view model browserModel.Item = blogItem; // Which editor was requested? switch (request.Source) { // Was CK Editor being used? If so set certain properties of the view model case "CKEditor": break; } } } return(View(this.ViewLocation("filebrowser"), browserModel)); }
public virtual Task <FileBrowserResult> BrowseFileAsync(FileBrowserViewModel fileBrowserModel) { if (LogRequests) { Logger.Trace("A browse file dialog was opened with the title of: {0}", fileBrowserModel.Title); } return(Application.Current.Dispatcher.Invoke(() => { // Create the dialog OpenFileDialog openFileDialog = new OpenFileDialog() { CheckFileExists = true, FileName = fileBrowserModel.DefaultName, Filter = fileBrowserModel.ExtensionFilter, InitialDirectory = fileBrowserModel.DefaultDirectory, Multiselect = fileBrowserModel.MultiSelection, Title = fileBrowserModel.Title ?? "Select a file" }; // Show the dialog and get the result bool canceled = openFileDialog.ShowDialog() != true; Logger.Trace(canceled ? "The browse file dialog was canceled by the user" : $"The browse file dialog returned the selected file paths {openFileDialog.FileNames.JoinItems(", ")}"); // Return the result return Task.FromResult(new FileBrowserResult() { CanceledByUser = canceled, SelectedFile = openFileDialog.FileName, SelectedFiles = openFileDialog.FileNames.Select(x => new FileSystemPath(x)) }); })); }
public FileBrowserPage() { InitializeComponent(); BindingContext = new FileBrowserViewModel(); }