mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
(MainWindow): various tweaks.
- set ImageData default DPI to desktop resolution. - display menubar on ALT keypress when it's hidden. - tweaked filename lookup on keypress logic (search should start from the current position, not from beginning).
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
xmlns:p="clr-namespace:GARbro.GUI.Properties"
|
xmlns:p="clr-namespace:GARbro.GUI.Properties"
|
||||||
Title="GARbro" MinHeight="250" ResizeMode="CanResizeWithGrip"
|
Title="GARbro" MinHeight="250" ResizeMode="CanResizeWithGrip"
|
||||||
Loaded="WindowLoaded"
|
Loaded="WindowLoaded"
|
||||||
|
KeyDown="WindowKeyDown"
|
||||||
Top="{Binding Source={x:Static p:Settings.Default}, Path=winTop, Mode=TwoWay}"
|
Top="{Binding Source={x:Static p:Settings.Default}, Path=winTop, Mode=TwoWay}"
|
||||||
Left="{Binding Source={x:Static p:Settings.Default}, Path=winLeft, Mode=TwoWay}"
|
Left="{Binding Source={x:Static p:Settings.Default}, Path=winLeft, Mode=TwoWay}"
|
||||||
Height="{Binding Source={x:Static p:Settings.Default}, Path=winHeight, Mode=TwoWay}"
|
Height="{Binding Source={x:Static p:Settings.Default}, Path=winHeight, Mode=TwoWay}"
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ namespace GARbro.GUI
|
|||||||
{
|
{
|
||||||
lv_SetSortMode (Settings.Default.lvSortColumn, Settings.Default.lvSortDirection);
|
lv_SetSortMode (Settings.Default.lvSortColumn, Settings.Default.lvSortDirection);
|
||||||
Dispatcher.InvokeAsync (WindowRendered, DispatcherPriority.ContextIdle);
|
Dispatcher.InvokeAsync (WindowRendered, DispatcherPriority.ContextIdle);
|
||||||
|
ImageData.SetDefaultDpi (Desktop.DpiX, Desktop.DpiY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowRendered ()
|
void WindowRendered ()
|
||||||
@@ -96,6 +97,24 @@ namespace GARbro.GUI
|
|||||||
SetStatusText (guiStrings.MsgReady);
|
SetStatusText (guiStrings.MsgReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowKeyDown (object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (MainMenuBar.Visibility != Visibility.Visible && Key.System == e.Key)
|
||||||
|
{
|
||||||
|
MainMenuBar.Visibility = Visibility.Visible;
|
||||||
|
MainMenuBar.IsKeyboardFocusWithinChanged += HideMenuBar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HideMenuBar (object sender, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!MainMenuBar.IsKeyboardFocusWithin)
|
||||||
|
{
|
||||||
|
MainMenuBar.IsKeyboardFocusWithinChanged -= HideMenuBar;
|
||||||
|
MainMenuBar.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Save settings when main window is about to close
|
/// Save settings when main window is about to close
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -168,7 +187,7 @@ namespace GARbro.GUI
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
int i = 1;
|
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 => Tuple.Create (f, string.Format ("_{0} {1}", i++, f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,20 +564,22 @@ namespace GARbro.GUI
|
|||||||
if (m_current_input.Mismatch)
|
if (m_current_input.Mismatch)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var items = source.Cast<EntryViewModel>();
|
if (!(1 == m_current_input.Phrase.Length && m_current_input.Phrase[0] == key[0]))
|
||||||
if (1 == m_current_input.Phrase.Length && m_current_input.Phrase[0] == key[0])
|
|
||||||
{
|
|
||||||
// same key repeats, lookup by first letter only
|
|
||||||
int current = CurrentDirectory.SelectedIndex;
|
|
||||||
if (current != -1 && current+1 < source.Count)
|
|
||||||
{
|
|
||||||
items = items.Skip (current+1).Concat (items.Take (current+1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
m_current_input.Phrase.Append (key);
|
m_current_input.Phrase.Append (key);
|
||||||
}
|
}
|
||||||
|
int start_index = CurrentDirectory.SelectedIndex;
|
||||||
|
if (1 == m_current_input.Phrase.Length)
|
||||||
|
{
|
||||||
|
// lookup starting from the next item
|
||||||
|
if (start_index != -1 && start_index+1 < source.Count)
|
||||||
|
++start_index;
|
||||||
|
}
|
||||||
|
var items = source.Cast<EntryViewModel>();
|
||||||
|
if (start_index > 0)
|
||||||
|
{
|
||||||
|
items = items.Skip (start_index).Concat (items.Take (start_index));
|
||||||
|
}
|
||||||
string input = m_current_input.Phrase.ToString();
|
string input = m_current_input.Phrase.ToString();
|
||||||
var matched = items.Where (e => e.Name.StartsWith (input, StringIgnoreCase)).FirstOrDefault();
|
var matched = items.Where (e => e.Name.StartsWith (input, StringIgnoreCase)).FirstOrDefault();
|
||||||
if (null != matched)
|
if (null != matched)
|
||||||
|
|||||||
Reference in New Issue
Block a user