mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 12:39:16 +08:00
added recent files list.
This commit is contained in:
parent
da8bdc3274
commit
49096a02c5
@ -83,7 +83,20 @@
|
||||
</ContextMenu>
|
||||
</Window.Resources>
|
||||
<DockPanel LastChildFill="True">
|
||||
<Menu x:Name="MainMenuBar" DockPanel.Dock="Top" IsMainMenu="True" Visibility="Collapsed"/>
|
||||
<Menu x:Name="MainMenuBar" DockPanel.Dock="Top" IsMainMenu="True" Visibility="Collapsed">
|
||||
<MenuItem Header="File">
|
||||
<MenuItem Header="Open..."/>
|
||||
<MenuItem Header="Recent files" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:MainWindow}, Path=RecentFiles, Mode=OneWay}">
|
||||
<MenuItem.ItemContainerStyle>
|
||||
<Style TargetType="MenuItem">
|
||||
<Setter Property="Header" Value="{Binding}"/>
|
||||
</Style>
|
||||
</MenuItem.ItemContainerStyle>
|
||||
</MenuItem>
|
||||
<Separator/>
|
||||
<MenuItem Header="Exit" Command="{x:Static local:Commands.Exit}" InputGestureText="Ctrl+Q"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<DockPanel Background="{Binding Path=Background, ElementName=MainMenuBar}" x:Name="MainToolBar"
|
||||
HorizontalAlignment="Stretch" DockPanel.Dock="Top">
|
||||
<DockPanel.Resources>
|
||||
@ -138,7 +151,7 @@
|
||||
</Button>
|
||||
<TextBlock Visibility="Hidden"/>
|
||||
</DockPanel>
|
||||
<StatusBar DockPanel.Dock="Bottom">
|
||||
<StatusBar DockPanel.Dock="Bottom" x:Name="AppStatusBar">
|
||||
<StatusBarItem>
|
||||
<TextBlock x:Name="appStatusText"/>
|
||||
</StatusBarItem>
|
||||
|
@ -40,6 +40,8 @@ using GARbro.GUI.Properties;
|
||||
using GARbro.GUI.Strings;
|
||||
using GameRes;
|
||||
using Rnd.Windows;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace GARbro.GUI
|
||||
{
|
||||
@ -59,6 +61,10 @@ namespace GARbro.GUI
|
||||
InitDirectoryChangesWatcher();
|
||||
InitPreviewPane();
|
||||
|
||||
if (null == Settings.Default.appRecentFiles)
|
||||
Settings.Default.appRecentFiles = new StringCollection();
|
||||
m_recent_files = new ObservableCollection<string> (Settings.Default.appRecentFiles.Cast<string>());
|
||||
|
||||
FormatCatalog.Instance.ParametersRequest += OnParametersRequest;
|
||||
|
||||
CurrentDirectory.SizeChanged += (s, e) => {
|
||||
@ -106,6 +112,10 @@ namespace GARbro.GUI
|
||||
else
|
||||
Settings.Default.lvSortColumn = "";
|
||||
|
||||
Settings.Default.appRecentFiles.Clear();
|
||||
foreach (var file in m_recent_files)
|
||||
Settings.Default.appRecentFiles.Add (file);
|
||||
|
||||
string cwd = CurrentPath;
|
||||
if (!string.IsNullOrEmpty (cwd))
|
||||
{
|
||||
@ -133,6 +143,27 @@ namespace GARbro.GUI
|
||||
Dispatcher.Invoke (() => MessageBox.Show (this, message, title, MessageBoxButton.OK, MessageBoxImage.Error));
|
||||
}
|
||||
|
||||
const int MaxRecentFiles = 10;
|
||||
ObservableCollection<string> m_recent_files;
|
||||
|
||||
public ObservableCollection<string> RecentFiles { get { return m_recent_files; } }
|
||||
|
||||
void PushRecentFile (string file)
|
||||
{
|
||||
var found = m_recent_files.IndexOf (file);
|
||||
if (-1 == found)
|
||||
{
|
||||
if (MaxRecentFiles == m_recent_files.Count)
|
||||
m_recent_files.RemoveAt (0);
|
||||
m_recent_files.Add (file);
|
||||
}
|
||||
else if (found+1 != m_recent_files.Count)
|
||||
{
|
||||
m_recent_files.RemoveAt (found);
|
||||
m_recent_files.Add (file);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set data context of the ListView.
|
||||
/// </summary>
|
||||
@ -152,6 +183,10 @@ namespace GARbro.GUI
|
||||
var cvs = this.Resources["ListViewSource"] as CollectionViewSource;
|
||||
cvs.Source = value;
|
||||
pathLine.Text = value.Path;
|
||||
|
||||
if (value.IsArchive)
|
||||
PushRecentFile (value.Path);
|
||||
|
||||
if (m_lvSortByColumn != null)
|
||||
lv_Sort (m_lvSortByColumn.Tag.ToString(), m_lvSortDirection);
|
||||
else
|
||||
@ -385,19 +420,6 @@ namespace GARbro.GUI
|
||||
{
|
||||
var dataView = CollectionViewSource.GetDefaultView (CurrentDirectory.ItemsSource) as ListCollectionView;
|
||||
dataView.CustomSort = new FileSystemComparer (sortBy, direction);
|
||||
/*
|
||||
using (dataView.DeferRefresh())
|
||||
{
|
||||
dataView.SortDescriptions.Clear();
|
||||
dataView.SortDescriptions.Add (new SortDescription ("Priority", ListSortDirection.Ascending));
|
||||
if (!string.IsNullOrEmpty (sortBy))
|
||||
{
|
||||
dataView.SortDescriptions.Add (new SortDescription (sortBy, direction));
|
||||
if (sortBy != "Name")
|
||||
dataView.SortDescriptions.Add (new SortDescription ("Name", ListSortDirection.Ascending));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
11
Properties/Settings.Designer.cs
generated
11
Properties/Settings.Designer.cs
generated
@ -238,5 +238,16 @@ namespace GARbro.GUI.Properties {
|
||||
this["appArchiveFormat"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public global::System.Collections.Specialized.StringCollection appRecentFiles {
|
||||
get {
|
||||
return ((global::System.Collections.Specialized.StringCollection)(this["appRecentFiles"]));
|
||||
}
|
||||
set {
|
||||
this["appRecentFiles"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,5 +56,8 @@
|
||||
<Setting Name="appArchiveFormat" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="appRecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
Loading…
x
Reference in New Issue
Block a user