예제 #1
0
        private async void ShowStorageButton_Click(object sender, RoutedEventArgs e)
        {
            HttpResponseMessage responseMessage = null;

            try
            {
                responseMessage = await ClientService.GetInstance().ShowStorage();
            }
            catch (HttpRequestException ex)
            {
                Extensions.ShowMsgBox(ex.Message);
                return;
            }

            if (ResponseChecker.CheckResponse(responseMessage, out string msg))
            {
                CurrentPath = "";
                CurrentPathTextBox.Content = "root\\";
                FilesListBox.Fill(await responseMessage.Content.ReadAsStringAsync());
                Console.WriteLine(msg);
            }
            else
            {
                Extensions.ShowMsgBox(msg);
            }
        }
예제 #2
0
        private async void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            if (FilesListBox.SelectedItem != null)
            {
                string toDelete = CurrentPath + FilesListBox.SelectedItem;
                HttpResponseMessage responseMessage = null;
                try
                {
                    responseMessage = await ClientService.GetInstance().Delete(toDelete);
                }
                catch (HttpRequestException ex)
                {
                    Extensions.ShowMsgBox(ex.Message);
                    return;
                }

                if (ResponseChecker.CheckResponse(responseMessage, out string msg))
                {
                    await Update();

                    Console.WriteLine(msg);
                }
                else
                {
                    Extensions.ShowMsgBox(msg);
                }
            }
        }
예제 #3
0
        private async void Back_OnClick(object sender, RoutedEventArgs e)
        {
            CurrentPath = Extensions.GetParentDir(CurrentPath);
            if (CurrentPath.Length > 0)
            {
                CurrentPath += '\\';
            }
            CurrentPathTextBox.Content = "root\\" + CurrentPath;
            HttpResponseMessage responseMessage = null;

            try
            {
                responseMessage = await ClientService.GetInstance().Open(CurrentPath);
            }
            catch (HttpRequestException ex)
            {
                Extensions.ShowMsgBox(ex.Message);
                return;
            }

            if (ResponseChecker.CheckResponse(responseMessage, out string msg))
            {
                FilesListBox.Fill(await responseMessage.Content.ReadAsStringAsync());
                await Update();
            }
            else
            {
                Extensions.ShowMsgBox(msg);
            }
        }
예제 #4
0
        private async void FilesListBox_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            string filename = FilesListBox.SelectedItem?.ToString();

            if (filename == null)
            {
                return;
            }
            HttpResponseMessage responseMessage = null;

            try
            {
                responseMessage = await ClientService.GetInstance().Open(CurrentPath + filename);
            }
            catch (HttpRequestException ex)
            {
                Extensions.ShowMsgBox(ex.Message);
                return;
            }

            if (ResponseChecker.CheckResponse(responseMessage, out string msg))
            {
                if (responseMessage.Headers.TryGetValues("isDir", out var value))
                {
                    if (bool.TryParse(value.First(), out bool isDir))
                    {
                        if (isDir)
                        {
                            CurrentPath += filename + '\\';
                            CurrentPathTextBox.Content = "root\\" + CurrentPath;
                            FilesListBox.Fill(await responseMessage.Content.ReadAsStringAsync());
                        }
                        else
                        {
                            OpenFileWindow window = new OpenFileWindow();
                            window.Title = filename;
                            window.ContentTextBox.Text = await responseMessage.Content.ReadAsStringAsync();

                            window.Show();

                            await Update();
                        }
                    }
                    else
                    {
                        Extensions.ShowMsgBox(msg);
                    }
                }
                else
                {
                    Extensions.ShowMsgBox("Header \'isDir\' was not found");
                }
            }
            else
            {
                Extensions.ShowMsgBox(msg);
            }
        }
        private async void CreateButton_OnClick(object sender, RoutedEventArgs e)
        {
            HttpResponseMessage responseMessage;

            if (IsFolderCheckBox.IsChecked == false)
            {
                responseMessage = await ClientService.GetInstance().AddFile(FileNameTextBox.Text,
                                                                            new StringContent(ContentTextBox.Text, Encoding.UTF8));
            }
            else
            {
                responseMessage = await ClientService.GetInstance().AddFolder(FileNameTextBox.Text);
            }
            Close();
            MainWindow main = (MainWindow)this.Owner;

            if (!ResponseChecker.CheckResponse(responseMessage, out string msg))
            {
                Extensions.ShowMsgBox(msg);
            }
            await main.Update();
        }
예제 #6
0
        public async Task Update()
        {
            HttpResponseMessage responseMessage = null;

            try
            {
                responseMessage = await ClientService.GetInstance().Update();
            }
            catch (HttpRequestException ex)
            {
                Extensions.ShowMsgBox(ex.Message);
                return;
            }

            if (ResponseChecker.CheckResponse(responseMessage, out string msg))
            {
                FilesListBox.Fill(await responseMessage.Content.ReadAsStringAsync());
            }
            else
            {
                Extensions.ShowMsgBox(msg);
            }
        }
        private async void AppendButton_OnClick(object sender, RoutedEventArgs e)
        {
            MainWindow          main            = (MainWindow)this.Owner;
            HttpResponseMessage responseMessage = null;

            try
            {
                responseMessage = await ClientService.GetInstance()
                                  .AppendFile(MainWindow.CurrentPath + Title, new StringContent(ContentTextBox.Text));
            }
            catch (HttpRequestException ex)
            {
                Extensions.ShowMsgBox(ex.Message);
                return;
            }

            Close();
            if (!ResponseChecker.CheckResponse(responseMessage, out string msg))
            {
                Extensions.ShowMsgBox(msg);
            }

            await main.Update();
        }