Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Add Back/Forward commands to file explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
typetrait committed Jun 4, 2019
1 parent 1e51ab6 commit 645c8e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Pace.Server/View/FileExplorerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<DockPanel>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar Style="{DynamicResource MaterialDesignToolBar}" ClipToBounds="False" >
<Button>
<Button Command="{Binding NavigateBackCommand}">
<materialDesign:PackIcon Kind="ArrowLeft" />
</Button>
<Button>
<Button Command="{Binding NavigateForwardCommand}">
<materialDesign:PackIcon Kind="ArrowRight" />
</Button>
<Button Command="{Binding NavigateUpCommand}">
Expand Down
23 changes: 23 additions & 0 deletions Pace.Server/ViewModel/FileExplorerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Pace.Common.Network.Packets.Server;
using Pace.Server.Model;
using Pace.Server.Network;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Input;
Expand All @@ -12,6 +13,9 @@ namespace Pace.Server.ViewModel
{
public class FileExplorerViewModel : ViewModelBase
{
private int navigationHistoryIndex;
private List<FileSystemEntry> navigationHistory;

public ObservableCollection<FileSystemEntry> Files { get; set; }

public string Path { get; set; }
Expand Down Expand Up @@ -41,6 +45,8 @@ public FileSystemEntry SelectedFile
public ICommand NavigateCommand { get; set; }
public ICommand NavigateSelectedCommand { get; set; }
public ICommand NavigateUpCommand { get; set; }
public ICommand NavigateForwardCommand { get; set; }
public ICommand NavigateBackCommand { get; set; }
public ICommand DeleteFileCommand { get; set; }

public ClientInfo Client { get; set; }
Expand All @@ -49,6 +55,9 @@ public FileExplorerViewModel(PaceServer server, ClientInfo client)
{
Files = new ObservableCollection<FileSystemEntry>();

navigationHistoryIndex = 0;
navigationHistory = new List<FileSystemEntry>();

server.PacketChannel.RegisterHandler<GetDirectoryResponsePacket>(HandleGetDirectory);
server.PacketChannel.RegisterHandler<NotifyStatusPacket>(HandleNotifyStatus);

Expand All @@ -62,6 +71,8 @@ public FileExplorerViewModel(PaceServer server, ClientInfo client)
NavigateCommand = new RelayCommand<string>(Navigate);
NavigateSelectedCommand = new RelayCommand<string>(NavigateSelected);
NavigateUpCommand = new RelayCommand<string>(NavigateUp);
NavigateForwardCommand = new RelayCommand<string>(NavigateForward);
NavigateBackCommand = new RelayCommand<string>(NavigateBack);
DeleteFileCommand = new RelayCommand<string>(DeleteFile);
}

Expand All @@ -76,6 +87,8 @@ private void HandleGetDirectory(IPacket packet)

CurrentDirectory = new FileSystemEntry(directoryResponse.Name, directoryResponse.Path, 0, FileType.Directory);

navigationHistory.Add(CurrentDirectory);

for (int i = 0; i < directoryResponse.Folders.Length; i++)
{
Application.Current.Dispatcher.Invoke(() =>
Expand Down Expand Up @@ -129,6 +142,16 @@ private void NavigateUp(string s)
Navigate(System.IO.Path.Combine(CurrentDirectory.Path, ".."));
}

private void NavigateForward(string s)
{
MessageBox.Show("Forward");
}

private void NavigateBack(string s)
{
MessageBox.Show("Back");
}

private void DeleteFile(string s)
{
var result = MessageBox.Show($"Delete {SelectedFile.Name}?", "File deletion", MessageBoxButton.YesNo, MessageBoxImage.Warning);
Expand Down

0 comments on commit 645c8e8

Please sign in to comment.