Skip to content

Commit bceb264

Browse files
committed
do not show app loading banner in parameterized start;
fix opening image sometimes falsely trigger navigation on view window; add event for main window navigation; bump version number;
1 parent 1d0cf71 commit bceb264

File tree

4 files changed

+58
-28
lines changed

4 files changed

+58
-28
lines changed

App.xaml.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,17 @@ private void App_Startup(object sender, StartupEventArgs e) {
9898
var viewWin = new ViewWindow(objInfo.ContainerPath, objInfo.FileName);
9999
viewWin.Closing += (sender1, e1) => {
100100
//load mainwindow
101-
NormalStart(initialPath);
101+
PostInit(initialPath);
102102
};
103103
viewWin.Show();
104104
return;
105105
}
106+
else {
107+
var mainWin = new MainWindow() { InitialPath = initialPath };
108+
mainWin.Navigate += postInitOnce;
109+
mainWin.Show();
110+
return;
111+
}
106112
}
107113
}
108114
catch (Exception ex) {
@@ -111,7 +117,15 @@ private void App_Startup(object sender, StartupEventArgs e) {
111117
Current.Shutdown();
112118
}
113119

114-
NormalStart(initialPath);
120+
PostInit(initialPath);
121+
}
122+
123+
private void postInitOnce(object sender, (string Path, short? Direction) e)
124+
{
125+
if (sender is MainWindow mainWin) {
126+
PostInit(createMainWindow: false);
127+
mainWin.Navigate -= postInitOnce;
128+
}
115129
}
116130

117131
private void Setting_StaticPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
@@ -250,24 +264,29 @@ private void Init()
250264
fa_image = GetFaIcon(EFontAwesomeIcon.Solid_FileImage, fa_brush);
251265
}
252266

253-
private void NormalStart(string initialPath)
267+
private void PostInit(string initialPath = null, bool createMainWindow = true, bool checkDB = true, bool checkUpdate = true)
254268
{
269+
if (!createMainWindow && !checkDB && !checkUpdate) return;
270+
255271
//normal start and load MainWindow
256272
var bw = new BlockWindow(autoClose: true) { MessageTitle = $"{GetRes("ttl_AppStarting")}..." };
257273
bw.TB_Message.HorizontalAlignment = HorizontalAlignment.Center;
258274
bw.TB_Message.VerticalAlignment = VerticalAlignment.Center;
259275
bw.Work = () => {
260276
try {
261-
//make sure thumbs db is correct
262-
Dispatcher.Invoke(() => bw.MessageBody = $"{GetRes("ttl_Checking")} database...");
263-
CheckThumbsDB();
264-
265-
Dispatcher.Invoke(() => {
277+
if (checkDB) {
278+
//make sure thumbs db is correct
279+
Dispatcher.Invoke(() => bw.MessageBody = $"{GetRes("ttl_Checking")} database...");
280+
CheckThumbsDB();
281+
}
282+
283+
if (createMainWindow) Dispatcher.Invoke(() => {
266284
//show mainwindow if no cmdline args
267285
new MainWindow() { InitialPath = initialPath }.Show();
268286
});
287+
269288

270-
Task.Run(() => {
289+
if (checkUpdate) Task.Run(() => {
271290
//check for updates
272291
var _ = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
273292
var localVer = new Version(_.Major, _.Minor, _.Build);

MainWindow.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<DataTemplate x:Key="ThumbDataTemplate" DataType="{x:Type local:ObjectInfo}">
2121
<StackPanel x:Name="SP1" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" UseLayoutRounding="True">
22-
<local:Thumbnail x:Name="TN1" RenderTransformOrigin="0.5 0.5" Panel.ZIndex="1" PreviewMouseDown="TN1_Click"
22+
<local:Thumbnail x:Name="TN1" RenderTransformOrigin="0.5 0.5" Panel.ZIndex="1" PreviewMouseUp="TN1_Click"
2323
ObjectInfo="{Binding Mode=OneTime}" Margin="10"
2424
Width="{Binding ElementName=MainWin, Path=ThumbRealWidth, Mode=OneWay}"
2525
Height="{Binding ElementName=MainWin, Path=ThumbRealHeight, Mode=OneWay}">
@@ -86,7 +86,7 @@
8686
</Border.Effect>
8787
<Border.Resources>
8888
<Style TargetType="fa:FontAwesome" BasedOn="{StaticResource S_DropShadow}">
89-
<EventSetter Event="MouseDown" Handler="Sidebar_Click"/>
89+
<EventSetter Event="MouseUp" Handler="Sidebar_Click"/>
9090
<Setter Property="Width" Value="48"/>
9191
<Setter Property="FontSize" Value="42"/>
9292
<Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
@@ -136,7 +136,7 @@
136136
</Border>
137137
</Border>
138138

139-
<vir:VirtualizingItemsControl x:Name="TV1" MouseDown="TV1_MouseDown"
139+
<vir:VirtualizingItemsControl x:Name="TV1" MouseUp="TV1_Click" MouseDoubleClick="TV1_DoubleClick"
140140
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"
141141
ItemsSource="{Binding Source={StaticResource ObjectListViewSource}, Mode=OneTime}"
142142
ItemTemplate="{StaticResource ThumbDataTemplate}">

MainWindow.xaml.cs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public partial class MainWindow : BorderlessWindow, INotifyPropertyChanged
2323
{
2424
public event PropertyChangedEventHandler PropertyChanged;
2525

26+
public event EventHandler<(string Path, short? Direction)> Navigate;
27+
2628
public ObservableKeyedCollection<string, ObjectInfo> ObjectList { get; } = new ObservableKeyedCollection<string, ObjectInfo>(o => o.VirtualPath);
2729

2830
private DpiScale DpiScale;
@@ -129,7 +131,8 @@ private void MainWin_Drop(object sender, DragEventArgs e)
129131
{
130132
var paths = (string[])e.Data.GetData(DataFormats.FileDrop);
131133
if (paths == null || paths.Length == 0) return;
132-
134+
135+
Navigate?.Invoke(this, (paths[0], null));
133136
Task.Run(() => LoadPath(paths[0]));
134137
}
135138

@@ -144,30 +147,40 @@ private void MainWin_KeyDown(object sender, KeyEventArgs e) {
144147
}
145148
}
146149

147-
private void TV1_MouseDown(object sender, MouseButtonEventArgs e) {
150+
private void TV1_Click(object sender, MouseButtonEventArgs e) {
148151
if (!e.Source.Equals(sender)) return;
149152
switch (e.ChangedButton) {
150-
case MouseButton.Left when e.ClickCount == 2:
151-
openFolderPrompt();
152-
e.Handled = true;
153-
break;
154-
case MouseButton.Right when e.ClickCount == 1:
155-
Nav_Up(null, null);
153+
case MouseButton.Right:
154+
var parentPath = Path.GetDirectoryName(CurrentPath);
155+
Navigate?.Invoke(this, (parentPath, -1));
156+
Task.Run(() => LoadPath(parentPath));
156157
e.Handled = true;
157158
break;
158-
case MouseButton.Middle when e.ClickCount == 1:
159+
case MouseButton.Middle:
159160
Close();
160161
break;
161162
}
162163
}
163164

165+
private void TV1_DoubleClick(object sender, MouseButtonEventArgs e)
166+
{
167+
if (!e.Source.Equals(sender)) return;
168+
if (e.ChangedButton == MouseButton.Left) {
169+
openFolderPrompt();
170+
e.Handled = true;
171+
}
172+
}
173+
164174
#endregion
165175

166176

167177
#region Private Helper Methods
168178

169179
private void openFolderPrompt() {
170-
OpenFolderDialog(this, path => Task.Run(() => LoadPath(path)));
180+
OpenFolderDialog(this, path => {
181+
Navigate?.Invoke(this, (path, null));
182+
Task.Run(() => LoadPath(path));
183+
});
171184
}
172185

173186
/// <summary>
@@ -302,6 +315,8 @@ private void TN1_Click(object sender, MouseButtonEventArgs e) {
302315
var objInfo = tn.ObjectInfo;
303316
switch (e.ChangedButton) {
304317
case MouseButton.Left:
318+
if (objInfo.IsContainer)
319+
Navigate?.Invoke(this, (objInfo.FileSystemPath, 1));
305320
Task.Run(() => LoadPath(objInfo));
306321
break;
307322
case MouseButton.Right:
@@ -316,10 +331,6 @@ private void TN1_Click(object sender, MouseButtonEventArgs e) {
316331
}
317332
}
318333

319-
private void Nav_Up(object sender, RoutedEventArgs e) {
320-
Task.Run(() => LoadPath(Path.GetDirectoryName(CurrentPath)));
321-
}
322-
323334
private void Sidebar_Click(object sender, MouseButtonEventArgs e) {
324335
switch (((FrameworkElement)sender).Name) {
325336
case nameof(HY_Open):

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.2.3.0")]
55-
[assembly: AssemblyFileVersion("1.2.3.0")]
54+
[assembly: AssemblyVersion("1.2.4.0")]
55+
[assembly: AssemblyFileVersion("1.2.4.0")]

0 commit comments

Comments
 (0)