added new items to main menu.

This commit is contained in:
morkt 2014-08-02 12:59:01 +04:00
parent f6bb4716a6
commit 1f6df25f6c
8 changed files with 265 additions and 37 deletions

View File

@ -53,19 +53,28 @@
<value>True</value>
</setting>
<setting name="appImageFormat" serializeAs="String">
<value/>
<value />
</setting>
<setting name="appTextEncoding" serializeAs="String">
<value>UTF-8</value>
</setting>
<setting name="appLastDirectory" serializeAs="String">
<value/>
<value />
</setting>
<setting name="appArchiveFormat" serializeAs="String">
<value/>
<value />
</setting>
<setting name="appLastCreatedArchive" serializeAs="String">
<value/>
<value />
</setting>
<setting name="winMenuBarVisibility" serializeAs="String">
<value>Visible</value>
</setting>
<setting name="winToolBarVisibility" serializeAs="String">
<value>Visible</value>
</setting>
<setting name="winStatusBarVisibility" serializeAs="String">
<value>Visible</value>
</setting>
</GARbro.GUI.Properties.Settings>
</userSettings>

View File

@ -13,12 +13,17 @@
Width="{Binding Source={x:Static p:Settings.Default}, Path=winWidth, Mode=TwoWay}"
WindowState="{Binding Source={x:Static p:Settings.Default}, Path=winState, Mode=TwoWay}">
<Window.Resources>
<!-- alternate colors for directory view -->
<SolidColorBrush x:Key="AlternateColor1" Color="#f2f5f9" />
<SolidColorBrush x:Key="AlternateColor2" Color="White" />
<!-- toolbar icons -->
<BitmapImage x:Key="Icon32x32Back" UriSource="Images/32x32/back button.png"/>
<BitmapImage x:Key="Icon32x32Forward" UriSource="Images/32x32/forward button.png"/>
<BitmapImage x:Key="Icon32x32Help" UriSource="Images/32x32/help.png"/>
<BitmapImage x:Key="Icon48x48Refresh" UriSource="Images/48x48/refresh.png"/>
<!-- directory view internals -->
<CollectionViewSource x:Key="ListViewSource" Source="{Binding}"/>
<local:BooleanToCollapsedVisibilityConverter x:Key="booleanToCollapsedVisibilityConverter" />
<local:EntryTypeConverter x:Key="entryTypeConverter"/>
@ -40,9 +45,27 @@
<DataTemplate x:Key="SortArrowNone">
<TextBlock Margin="5,0,5,0" Text="{Binding}"/>
</DataTemplate>
<Style x:Key="DefaultMenuItemStyle" TargetType="{x:Type MenuItem}">
<Setter Property="FontWeight" Value="Bold" />
</Style>
<!-- Sort-by submenu -->
<MenuItem x:Key="sortByMenu" Header="{x:Static s:guiStrings.CtxMenuSortBy}">
<MenuItem Header="{x:Static s:guiStrings.CtxMenuSortByName}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsSortByName, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}" CommandParameter="Name"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuSortByType}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsSortByType, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}" CommandParameter="Type"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuSortBySize}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsSortBySize, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}" CommandParameter="Size"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuUnsorted}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsUnsorted, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}"/>
</MenuItem>
<!-- Default listview context menu -->
<ContextMenu x:Key="lvDirContextMenu">
<MenuItem Header="{x:Static s:guiStrings.CtxMenuOpen}" InputGestureText="Enter"
Style="{StaticResource DefaultMenuItemStyle}"
@ -94,30 +117,63 @@
</Window.Resources>
<DockPanel LastChildFill="True">
<Menu x:Name="MainMenuBar" DockPanel.Dock="Top" IsMainMenu="True" Visibility="Visible"
Background="{DynamicResource {x:Static SystemColors.MenuBrushKey}}">
<MenuItem Header="{x:Static s:guiStrings.MenuFile}">
<MenuItem Header="{x:Static s:guiStrings.MenuOpen}" Command="{x:Static local:Commands.OpenFile}" InputGestureText="Ctrl+O"/>
<MenuItem Header="{x:Static s:guiStrings.MenuRecent}" x:Name="RecentFilesMenu">
<MenuItem.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header" Value="{Binding Path=Item2}"/>
<Setter Property="Command" Value="{x:Static local:Commands.OpenRecent}"/>
<Setter Property="CommandParameter" Value="{Binding Path=Item1}"/>
</Style>
</MenuItem.ItemContainerStyle>
<StackPanel x:Name="MainMenuBar" DockPanel.Dock="Top" Orientation="Vertical"
Visibility="{Binding Source={x:Static p:Settings.Default}, Path=winMenuBarVisibility, Mode=TwoWay}">
<Menu IsMainMenu="True" Background="{DynamicResource {x:Static SystemColors.MenuBrushKey}}">
<MenuItem Header="{x:Static s:guiStrings.MenuFile}">
<MenuItem Header="{x:Static s:guiStrings.MenuOpen}" Command="{x:Static local:Commands.OpenFile}" InputGestureText="Ctrl+O"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuCreate}" InputGestureText="F3"
Command="{x:Static local:Commands.CreateArchive}" />
<MenuItem Header="{x:Static s:guiStrings.MenuRecent}" x:Name="RecentFilesMenu">
<MenuItem.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header" Value="{Binding Path=Item2}"/>
<Setter Property="Command" Value="{x:Static local:Commands.OpenRecent}"/>
<Setter Property="CommandParameter" Value="{Binding Path=Item1}"/>
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<Separator/>
<MenuItem Header="{x:Static s:guiStrings.MenuExit}" Command="{x:Static local:Commands.Exit}" InputGestureText="Ctrl+Q"/>
</MenuItem>
<Separator/>
<MenuItem Header="{x:Static s:guiStrings.MenuExit}" Command="{x:Static local:Commands.Exit}" InputGestureText="Ctrl+Q"/>
</MenuItem>
<MenuItem Header="{x:Static s:guiStrings.MenuHelp}">
<MenuItem Header="{x:Static s:guiStrings.MenuAbout}" Command="{x:Static local:Commands.About}"/>
</MenuItem>
</Menu>
<MenuItem Header="{x:Static s:guiStrings.MenuView}">
<MenuItem Header="{x:Static s:guiStrings.MenuToggleToolBar}" InputGestureText="Alt+Shift+T"
Command="{x:Static local:Commands.HideToolBar}"/>
<MenuItem Header="{x:Static s:guiStrings.MenuToggleMenuBar}" InputGestureText="Alt+Shift+M"
Command="{x:Static local:Commands.HideMenuBar}"/>
<MenuItem Header="{x:Static s:guiStrings.MenuToggleStatusBar}" InputGestureText="Alt+Shift+S"
Command="{x:Static local:Commands.HideStatusBar}"/>
<Separator/>
<MenuItem Header="{x:Static s:guiStrings.MenuFitWindow}" InputGestureText="Ctrl+H"
Command="{x:Static local:Commands.FitWindow}"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuRefresh}" InputGestureText="F5"
Command="{x:Static local:Commands.Refresh}"/>
<Separator/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuSortBy}">
<MenuItem Header="{x:Static s:guiStrings.CtxMenuSortByName}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsSortByName, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}" CommandParameter="Name"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuSortByType}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsSortByType, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}" CommandParameter="Type"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuSortBySize}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsSortBySize, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}" CommandParameter="Size"/>
<MenuItem Header="{x:Static s:guiStrings.CtxMenuUnsorted}" IsCheckable="True"
IsChecked="{Binding ElementName=AppWindow, Path=IsUnsorted, Mode=OneWay}"
Command="{x:Static local:Commands.SortBy}"/>
</MenuItem>
</MenuItem>
<MenuItem Header="{x:Static s:guiStrings.MenuHelp}">
<MenuItem Header="{x:Static s:guiStrings.MenuAbout}" Command="{x:Static local:Commands.About}"/>
</MenuItem>
</Menu>
<Separator Height="1" Margin="0"/>
</StackPanel>
<Menu Visibility="Collapsed" x:Name="HelperMenuBar"/>
<Separator DockPanel.Dock="Top" Height="1" Margin="0"/>
<DockPanel Background="{Binding Path=Background, ElementName=HelperMenuBar}" x:Name="MainToolBar"
HorizontalAlignment="Stretch" DockPanel.Dock="Top">
<DockPanel x:Name="MainToolBar" Background="{Binding Path=Background, ElementName=HelperMenuBar}"
HorizontalAlignment="Stretch" DockPanel.Dock="Top"
Visibility="{Binding Source={x:Static p:Settings.Default}, Path=winToolBarVisibility, Mode=TwoWay}">
<DockPanel.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
<Setter Property="ToolTipService.ShowOnDisabled" Value="True"/>
@ -155,6 +211,7 @@
</Style.Triggers>
</Style>
</DockPanel.Resources>
<Separator DockPanel.Dock="Bottom" Height="1" Margin="0"/>
<Button x:Name="ButtonBack" ToolTip="{x:Static s:guiStrings.TooltipBack}" Margin="5,2,0,2"
Command="{x:Static local:Commands.GoBack}">
<Image Source="{StaticResource Icon32x32Back}"/>
@ -178,13 +235,15 @@
</Button>
<TextBlock Visibility="Hidden"/>
</DockPanel>
<Separator DockPanel.Dock="Top" Height="1" Margin="0"/>
<StatusBar DockPanel.Dock="Bottom" x:Name="AppStatusBar">
<StatusBarItem>
<TextBlock x:Name="appStatusText"/>
</StatusBarItem>
</StatusBar>
<Separator DockPanel.Dock="Bottom" Height="1" Margin="0"/>
<StackPanel DockPanel.Dock="Bottom" x:Name="AppStatusBar"
Visibility="{Binding Source={x:Static p:Settings.Default}, Path=winStatusBarVisibility, Mode=TwoWay}">
<Separator Height="1" Margin="0"/>
<StatusBar>
<StatusBarItem>
<TextBlock x:Name="appStatusText"/>
</StatusBarItem>
</StatusBar>
</StackPanel>
<Grid x:Name="ContentGrid" DockPanel.Dock="Left" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" ShowGridLines="False">
<Grid.ColumnDefinitions>
@ -294,6 +353,9 @@
<KeyBinding Gesture="Backspace" Command="{x:Static local:Commands.GoBack}"/>
<KeyBinding Gesture="Alt+Left" Command="{x:Static local:Commands.GoBack}"/>
<KeyBinding Gesture="Alt+Right" Command="{x:Static local:Commands.GoForward}"/>
<KeyBinding Gesture="Alt+Shift+M" Command="{x:Static local:Commands.HideMenuBar}"/>
<KeyBinding Gesture="Alt+Shift+T" Command="{x:Static local:Commands.HideToolBar}"/>
<KeyBinding Gesture="Alt+Shift+S" Command="{x:Static local:Commands.HideStatusBar}"/>
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="{x:Static local:Commands.OpenItem}" Executed="OpenItemExec" CanExecute="CanExecuteOnSelected"/>
@ -309,6 +371,9 @@
<CommandBinding Command="{x:Static local:Commands.GoForward}" Executed="GoForwardExec" CanExecute="CanExecuteGoForward"/>
<CommandBinding Command="{x:Static local:Commands.Refresh}" Executed="RefreshExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.FitWindow}" Executed="FitWindowExec" CanExecute="CanExecuteFitWindow"/>
<CommandBinding Command="{x:Static local:Commands.HideStatusBar}" Executed="HideStatusBarExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.HideMenuBar}" Executed="HideMenuBarExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.HideToolBar}" Executed="HideToolBarExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.About}" Executed="AboutExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.Exit}" Executed="ExitExec" CanExecute="CanExecuteAlways"/>
</Window.CommandBindings>

View File

@ -64,7 +64,7 @@ namespace GARbro.GUI
if (null == Settings.Default.appRecentFiles)
Settings.Default.appRecentFiles = new StringCollection();
m_recent_files = new LinkedList<string> (Settings.Default.appRecentFiles.Cast<string>());
m_recent_files = new LinkedList<string> (Settings.Default.appRecentFiles.Cast<string>().Take (MaxRecentFiles));
RecentFilesMenu.ItemsSource = RecentFiles;
FormatCatalog.Instance.ParametersRequest += OnParametersRequest;
@ -145,7 +145,7 @@ namespace GARbro.GUI
Dispatcher.Invoke (() => MessageBox.Show (this, message, title, MessageBoxButton.OK, MessageBoxImage.Error));
}
const int MaxRecentFiles = 10;
const int MaxRecentFiles = 9;
LinkedList<string> m_recent_files;
// Item1 = file name, Item2 = menu item string
@ -154,7 +154,7 @@ namespace GARbro.GUI
get
{
int i = 1;
return m_recent_files.Select (f => new Tuple<string,string> (f, string.Format ("{0} {1}", i++, f)));
return m_recent_files.Select (f => new Tuple<string,string> (f, string.Format ("_{0} {1}", i++, f)));
}
}
@ -165,7 +165,7 @@ namespace GARbro.GUI
return;
if (null == node)
{
if (MaxRecentFiles == m_recent_files.Count)
while (MaxRecentFiles < m_recent_files.Count)
m_recent_files.RemoveLast();
m_recent_files.AddFirst (file);
}
@ -631,6 +631,10 @@ namespace GARbro.GUI
SetStatusText (m_app.CurrentArchive.Description);
lv_SelectItem (0);
}
catch (OperationCanceledException X)
{
SetStatusText (X.Message);
}
catch (Exception X)
{
PopupError (string.Format("{0}:\n{1}", filename, X.Message), guiStrings.MsgErrorOpening);
@ -997,6 +1001,33 @@ namespace GARbro.GUI
{
e.CanExecute = PreviewPane.Source != null;
}
private void HideStatusBarExec (object sender, ExecutedRoutedEventArgs e)
{
var status = AppStatusBar.Visibility;
if (Visibility.Visible == status)
AppStatusBar.Visibility = Visibility.Collapsed;
else
AppStatusBar.Visibility = Visibility.Visible;
}
private void HideMenuBarExec (object sender, ExecutedRoutedEventArgs e)
{
var status = MainMenuBar.Visibility;
if (Visibility.Visible == status)
MainMenuBar.Visibility = Visibility.Collapsed;
else
MainMenuBar.Visibility = Visibility.Visible;
}
private void HideToolBarExec (object sender, ExecutedRoutedEventArgs e)
{
var status = MainToolBar.Visibility;
if (Visibility.Visible == status)
MainToolBar.Visibility = Visibility.Collapsed;
else
MainToolBar.Visibility = Visibility.Visible;
}
}
/// <summary>
@ -1093,5 +1124,8 @@ namespace GARbro.GUI
public static readonly RoutedCommand Refresh = new RoutedCommand();
public static readonly RoutedCommand Browse = new RoutedCommand();
public static readonly RoutedCommand FitWindow = new RoutedCommand();
public static readonly RoutedCommand HideStatusBar = new RoutedCommand();
public static readonly RoutedCommand HideMenuBar = new RoutedCommand();
public static readonly RoutedCommand HideToolBar = new RoutedCommand();
}
}

View File

@ -261,5 +261,41 @@ namespace GARbro.GUI.Properties {
this["appLastCreatedArchive"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Visible")]
public global::System.Windows.Visibility winMenuBarVisibility {
get {
return ((global::System.Windows.Visibility)(this["winMenuBarVisibility"]));
}
set {
this["winMenuBarVisibility"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Visible")]
public global::System.Windows.Visibility winToolBarVisibility {
get {
return ((global::System.Windows.Visibility)(this["winToolBarVisibility"]));
}
set {
this["winToolBarVisibility"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Visible")]
public global::System.Windows.Visibility winStatusBarVisibility {
get {
return ((global::System.Windows.Visibility)(this["winStatusBarVisibility"]));
}
set {
this["winStatusBarVisibility"] = value;
}
}
}
}

View File

@ -62,5 +62,14 @@
<Setting Name="appLastCreatedArchive" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="winMenuBarVisibility" Type="System.Windows.Visibility" Scope="User">
<Value Profile="(Default)">Visible</Value>
</Setting>
<Setting Name="winToolBarVisibility" Type="System.Windows.Visibility" Scope="User">
<Value Profile="(Default)">Visible</Value>
</Setting>
<Setting Name="winStatusBarVisibility" Type="System.Windows.Visibility" Scope="User">
<Value Profile="(Default)">Visible</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -330,6 +330,15 @@ namespace GARbro.GUI.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to Fit preview _window to image.
/// </summary>
public static string MenuFitWindow {
get {
return ResourceManager.GetString("MenuFitWindow", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Help.
/// </summary>
@ -357,6 +366,42 @@ namespace GARbro.GUI.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to Show/hide main _menu bar.
/// </summary>
public static string MenuToggleMenuBar {
get {
return ResourceManager.GetString("MenuToggleMenuBar", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show/hide _status bar.
/// </summary>
public static string MenuToggleStatusBar {
get {
return ResourceManager.GetString("MenuToggleStatusBar", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show/hide _toolbar.
/// </summary>
public static string MenuToggleToolBar {
get {
return ResourceManager.GetString("MenuToggleToolBar", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _View.
/// </summary>
public static string MenuView {
get {
return ResourceManager.GetString("MenuView", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Choose files to extract.
/// </summary>

View File

@ -363,4 +363,19 @@ Overwrite?</value>
<data name="MsgDeletedItems2" xml:space="preserve">
<value>Deleted {0} files</value>
</data>
<data name="MenuFitWindow" xml:space="preserve">
<value>Fit preview _window to image</value>
</data>
<data name="MenuToggleMenuBar" xml:space="preserve">
<value>Show/hide main _menu bar</value>
</data>
<data name="MenuToggleStatusBar" xml:space="preserve">
<value>Show/hide _status bar</value>
</data>
<data name="MenuToggleToolBar" xml:space="preserve">
<value>Show/hide _toolbar</value>
</data>
<data name="MenuView" xml:space="preserve">
<value>_View</value>
</data>
</root>

View File

@ -381,4 +381,19 @@
<data name="MsgDeletedItems3" xml:space="preserve">
<value>Удалено {0} файлов</value>
</data>
<data name="MenuFitWindow" xml:space="preserve">
<value>Подогнать размер окна под изображение</value>
</data>
<data name="MenuToggleMenuBar" xml:space="preserve">
<value>Вкл/выкл главное меню</value>
</data>
<data name="MenuToggleStatusBar" xml:space="preserve">
<value>Вкл/выкл полосу статуса</value>
</data>
<data name="MenuToggleToolBar" xml:space="preserve">
<value>Вкл/выкл панель инструментов</value>
</data>
<data name="MenuView" xml:space="preserve">
<value>Просмотр</value>
</data>
</root>