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:
morkt 2014-07-29 07:12:10 +04:00
parent a8a6f31efa
commit 8a32395c44

View File

@ -238,6 +238,11 @@ namespace GARbro.GUI
m_watcher.EnableRaisingEvents = false; m_watcher.EnableRaisingEvents = false;
} }
void ResumeWatchDirectoryChanges ()
{
m_watcher.EnableRaisingEvents = true;
}
private void InvokeRefreshView (object source, FileSystemEventArgs e) private void InvokeRefreshView (object source, FileSystemEventArgs e)
{ {
var watcher = source as FileSystemWatcher; var watcher = source as FileSystemWatcher;
@ -495,17 +500,17 @@ namespace GARbro.GUI
#region Navigation history implementation #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>(); HistoryStack<DirectoryPosition> m_history = new HistoryStack<DirectoryPosition>();
DirectoryPosition GetCurrentPosition () public DirectoryPosition GetCurrentPosition ()
{ {
var evm = CurrentDirectory.SelectedItem as EntryViewModel; var evm = CurrentDirectory.SelectedItem as EntryViewModel;
return new DirectoryPosition (ViewModel, evm); return new DirectoryPosition (ViewModel, evm);
} }
bool SetCurrentPosition (DirectoryPosition pos) public bool SetCurrentPosition (DirectoryPosition pos)
{ {
var vm = TryCreateViewModel (pos.Path); var vm = TryCreateViewModel (pos.Path);
if (null == vm) if (null == vm)
@ -525,7 +530,7 @@ namespace GARbro.GUI
} }
} }
private void SaveCurrentPosition () public void SaveCurrentPosition ()
{ {
m_history.Push (GetCurrentPosition()); m_history.Push (GetCurrentPosition());
} }
@ -821,7 +826,26 @@ namespace GARbro.GUI
e.CanExecute = !ViewModel.IsArchive; 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) if (!ViewModel.IsArchive && CurrentDirectory.SelectedIndex != -1)
{ {
@ -892,6 +916,8 @@ namespace GARbro.GUI
protected override void OnPopulating (PopulatingEventArgs e) protected override void OnPopulating (PopulatingEventArgs e)
{ {
var candidates = new List<string>(); var candidates = new List<string>();
try
{
string dirname = Path.GetDirectoryName (this.Text); string dirname = Path.GetDirectoryName (this.Text);
if (!string.IsNullOrEmpty (this.Text) && Directory.Exists (dirname)) if (!string.IsNullOrEmpty (this.Text) && Directory.Exists (dirname))
{ {
@ -902,6 +928,11 @@ namespace GARbro.GUI
} }
} }
this.ItemsSource = candidates; this.ItemsSource = candidates;
}
catch
{
// ignore filesystem errors
}
base.OnPopulating (e); base.OnPopulating (e);
} }
} }