mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
changes to MainWindow.
(ResumeWatchDirectoryChanges): new method. made current position methods public. (CanExecuteExtract): new code-behind method for xaml widgets. (CanExecuteDelete): renamed into CanExecuteOnPhysicalFile. (ExtAutoCompleteBox.OnPopulating): capture trown exceptions.
This commit is contained in:
parent
a8a6f31efa
commit
8a32395c44
@ -238,6 +238,11 @@ namespace GARbro.GUI
|
||||
m_watcher.EnableRaisingEvents = false;
|
||||
}
|
||||
|
||||
void ResumeWatchDirectoryChanges ()
|
||||
{
|
||||
m_watcher.EnableRaisingEvents = true;
|
||||
}
|
||||
|
||||
private void InvokeRefreshView (object source, FileSystemEventArgs e)
|
||||
{
|
||||
var watcher = source as FileSystemWatcher;
|
||||
@ -495,17 +500,17 @@ namespace GARbro.GUI
|
||||
|
||||
#region Navigation history implementation
|
||||
|
||||
private string CurrentPath { get { return ViewModel.Path; } }
|
||||
internal string CurrentPath { get { return ViewModel.Path; } }
|
||||
|
||||
HistoryStack<DirectoryPosition> m_history = new HistoryStack<DirectoryPosition>();
|
||||
|
||||
DirectoryPosition GetCurrentPosition ()
|
||||
public DirectoryPosition GetCurrentPosition ()
|
||||
{
|
||||
var evm = CurrentDirectory.SelectedItem as EntryViewModel;
|
||||
return new DirectoryPosition (ViewModel, evm);
|
||||
}
|
||||
|
||||
bool SetCurrentPosition (DirectoryPosition pos)
|
||||
public bool SetCurrentPosition (DirectoryPosition pos)
|
||||
{
|
||||
var vm = TryCreateViewModel (pos.Path);
|
||||
if (null == vm)
|
||||
@ -525,7 +530,7 @@ namespace GARbro.GUI
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveCurrentPosition ()
|
||||
public void SaveCurrentPosition ()
|
||||
{
|
||||
m_history.Push (GetCurrentPosition());
|
||||
}
|
||||
@ -821,7 +826,26 @@ namespace GARbro.GUI
|
||||
e.CanExecute = !ViewModel.IsArchive;
|
||||
}
|
||||
|
||||
private void CanExecuteDelete (object sender, CanExecuteRoutedEventArgs e)
|
||||
private void CanExecuteExtract (object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
if (ViewModel.IsArchive)
|
||||
{
|
||||
e.CanExecute = true;
|
||||
return;
|
||||
}
|
||||
else if (CurrentDirectory.SelectedIndex != -1)
|
||||
{
|
||||
var entry = CurrentDirectory.SelectedItem as EntryViewModel;
|
||||
if (entry != null && !entry.IsDirectory)
|
||||
{
|
||||
e.CanExecute = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.CanExecute = false;
|
||||
}
|
||||
|
||||
private void CanExecuteOnPhysicalFile (object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
if (!ViewModel.IsArchive && CurrentDirectory.SelectedIndex != -1)
|
||||
{
|
||||
@ -892,6 +916,8 @@ namespace GARbro.GUI
|
||||
protected override void OnPopulating (PopulatingEventArgs e)
|
||||
{
|
||||
var candidates = new List<string>();
|
||||
try
|
||||
{
|
||||
string dirname = Path.GetDirectoryName (this.Text);
|
||||
if (!string.IsNullOrEmpty (this.Text) && Directory.Exists (dirname))
|
||||
{
|
||||
@ -902,6 +928,11 @@ namespace GARbro.GUI
|
||||
}
|
||||
}
|
||||
this.ItemsSource = candidates;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore filesystem errors
|
||||
}
|
||||
base.OnPopulating (e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user