private async void MovingDirectoryToServer_Click(object sender, RoutedEventArgs e) { if (await ConnectionAvailable() == true) { var currentDirectories = api.GetDirectories(); MovingToDirectory window = new MovingToDirectory(currentDirectories); var selectItem = TableDirectoriesServer.SelectedItem; DirectoryFromServer selectDirectory = (DirectoryFromServer)selectItem; if (window.ShowDialog() == true) { foreach (var element in currentDirectories) { if (element.NameDirectory == window.SelectedDirectoryFromDropDown) { var moving = api.MovingDirectory(element.Id, selectDirectory.Id); break; } } TableDirectoriesServer.ItemsSource = null; TableDirectoriesServer.ItemsSource = api.GetDirectories(); } } }
private void UpdateListFiles() { var selectItem = TableDirectoriesServer.SelectedItem; DirectoryFromServer currentDirectory = (DirectoryFromServer)selectItem; TableFilesFromDirectory.IsEnabled = true; TableFilesFromDirectory.AutoGenerateColumns = false; TableFilesFromDirectory.Columns.Clear(); TableFilesFromDirectory.Columns.Add(new DataGridTextColumn { Header = "Название", Binding = new Binding("Name"), }); TableFilesFromDirectory.Columns.Add(new DataGridTextColumn { Header = "Размер (КБ)", Binding = new Binding("SizeInMB"), }); TableFilesFromDirectory.Columns.Add(new DataGridTextColumn { Header = "Дата загрузки", Binding = new Binding("DateCreate"), }); TableFilesFromDirectory.Columns.Add(new DataGridTextColumn { Header = "Тип", Binding = new Binding("Type"), }); TableFilesFromDirectory.Columns.Add(new DataGridTextColumn { Header = "Публичная ссылка", Binding = new Binding("PublicLink"), }); TableFilesFromDirectory.Columns.Add(new DataGridTextColumn { Header = "Прямая ссылка", Binding = new Binding("DirectLink"), }); var listFiles = api.GetFilesInDirectory(currentDirectory.Id); TableFilesFromDirectory.ItemsSource = listFiles; }
private async void UploadToServer_Click(object sender, RoutedEventArgs e) { if (await ConnectionAvailable() == true) { DirectoryFromServer selectDirectory = (DirectoryFromServer)TableDirectoriesServer.SelectedItem; if (selectDirectory == null) { MessageBox.Show("Выберите одну директорию"); return; } var dialog = new OpenFileDialog(); if (dialog.ShowDialog() == true) { String pathToFile = dialog.FileName; var upload = await api.UploadFile(selectDirectory.Id, pathToFile); MessageBox.Show(upload); } } }
private async void RenameDirectoryToServer_Click(object sender, RoutedEventArgs e) { if (await ConnectionAvailable() == true) { var selectItem = TableDirectoriesServer.SelectedItem; DirectoryFromServer currentDirectory = (DirectoryFromServer)selectItem; if (currentDirectory == null) { MessageBox.Show("Выберите директорию!"); return; } NameForDirectory window = new NameForDirectory(); if (window.ShowDialog() == true) { var resultRename = api.RenameDirectory(window.NameDirectory.Text, Convert.ToInt32(currentDirectory.Id)); TableDirectoriesServer.ItemsSource = null; TableDirectoriesServer.ItemsSource = api.GetDirectories(); } } }