private async void newFolder() { var result = await((MetroWindow)System.Windows.Application.Current.MainWindow).ShowInputAsync("Input the folder's name", ""); if (result == null || result.Length == 0) { return; } int currentFolder = NavFolder.ElementAt(NavFolder.Count - 1).Key; int resultCode = await Utils.NetUtils.createNewFolder(result, currentFolder); if (resultCode == -1) { await((MetroWindow)System.Windows.Application.Current.MainWindow).ShowMessageAsync("", "Error"); } else { await((MetroWindow)System.Windows.Application.Current.MainWindow).ShowMessageAsync("", "Success!"); UserFileModel model = new UserFileModel(); model.file_name = result; model.id = resultCode; model.created_at = DateTime.Now.ToString(); FolderData.Add(model); Data.Add(model); } }
private async void changeFolder(UserFileModel file) { NavFolder.Add(new KeyValuePair <int, string>(file.id, file.file_name)); Data = await Utils.NetUtils.GetFilesAndFoldersById(file.id); spliteData(); }
private async void refresh() { int id = NavFolder.Last().Key; Data = await Utils.NetUtils.GetFilesAndFoldersById(id); spliteData(); }
private async void back() { if (NavFolder.Count <= 1) { return; } NavFolder.RemoveAt(NavFolder.Count - 1); Data = await Utils.NetUtils.GetFilesAndFoldersById(NavFolder.Last().Key); spliteData(); }
private async void initData() { App.InitData(); Data = await Utils.NetUtils.GetRoot(); NavFolder.Clear(); NavFolder.Add(App.GetCurrentFolder()); spliteData(); OnPropertyChanged("Data"); OnPropertyChanged("FolderData"); OnPropertyChanged("FileData"); OnPropertyChanged("NavFolder"); OnPropertyChanged("IsSettingOpen"); }
private async void upload() { OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == DialogResult.OK) { Stream stream = dialog.OpenFile(); if (stream == null) { return; } using (stream) { FileInfo fileInfo = new FileInfo(dialog.FileName); var length = string.Format("{0}", fileInfo.Length); var streamContent = new StreamContent(stream); var fileName = fileInfo.Name; streamContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "\"file\"", FileName = string.Format("{0}", fileName)// fileName }; var lengthContent = new StringContent(length, Encoding.UTF8); int result = await Utils.NetUtils.uplaodFile(streamContent, lengthContent, NavFolder.Last().Key, fileInfo.Name); log(fileInfo.Name); if (result == -1) { showAlertDialog("UPLAOD FAILED"); } else { showSuccessDialog(""); refresh(); } } } }