Skip to content

Commit

Permalink
Update MainWindow
Browse files Browse the repository at this point in the history
Signed-off-by: singleNeuron <[email protected]>
  • Loading branch information
Cryolitia committed Feb 9, 2022
1 parent 812a3c2 commit 911a251
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
19 changes: 13 additions & 6 deletions DotNet/PhotoTimeFix/Window/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@
</Grid.RowDefinitions>
<materialDesign:Card Padding="20" Margin="10" Grid.Row="0" Grid.ColumnSpan="3" Grid.Column="0" Height="auto"
Name="SelectCard">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Name="SelectStackPanel" >
<TextBox AllowDrop="True" PreviewDragOver="Grid_DragEnter" PreviewDrop="Grid_Drop"
<Grid HorizontalAlignment="Center" Name="SelectStackPanel">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" AllowDrop="True" PreviewDragOver="Grid_DragEnter" PreviewDrop="Grid_Drop"
materialDesign:HintAssist.Hint="{x:Static res:Resource.MainWindow_FolderFilePath}" TextWrapping="Wrap" Cursor="IBeam"
TextChanged="PathTextBox_OnTextChanged" Name="PathTextBox" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalScrollBarVisibility="Hidden" Width="295">
TextChanged="PathTextBox_OnTextChanged" Name="PathTextBox"
HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch"
HorizontalScrollBarVisibility="Hidden" MinWidth="200" MaxWidth="1000">
<TextBox.Text>
<Binding
Path="FilePath"
Expand All @@ -51,13 +58,13 @@
</Binding>
</TextBox.Text>
</TextBox>
<Button Click="FileButton_OnClick" Cursor="Hand" Margin="10,0,10,0">
<Button Grid.Column="1" Click="FileButton_OnClick" Cursor="Hand" Margin="10,0,10,0">
<materialDesign:PackIcon Kind="FileImage" />
</Button>
<Button Click="DictionaryButton_OnClick" Cursor="Hand">
<Button Grid.Column="2" Click="DictionaryButton_OnClick" Cursor="Hand">
<materialDesign:PackIcon Kind="Folder" />
</Button>
</StackPanel>
</Grid>
</materialDesign:Card>
<StackPanel Grid.Row="1" Grid.Column="0" Grid.RowSpan="2">
<materialDesign:Card Margin="10" Padding="10" Visibility="{Binding Path=PathExist}">
Expand Down
45 changes: 24 additions & 21 deletions DotNet/PhotoTimeFix/Window/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,32 +154,35 @@ private void Grid_OnLayoutUpdated(object sender, EventArgs e)

private async void PathTextBox_OnTextChanged(object sender, TextChangedEventArgs e)
{
await ProcessBarWindow.StartTask(action =>
var value = PathTextBox.Text;
if (File.Exists(value))
{
Dispatcher.Invoke(async () =>
await ProcessBarWindow.StartTask(action =>
{
await UpdateCurrentTime(true, action);
var value = PathTextBox.Text;
if (File.Exists(value))
Dispatcher.Invoke(async () =>
{
_binding.IsFile = Visibility.Visible;
_binding.PathExist = Visibility.Visible;
await UpdateExif(value);
DetailListBox.SelectAll();
if (_setting.ShowMedia) ShowImage(value);
}
else
{
if (Directory.Exists(value))
await UpdateCurrentTime(true, action);
if (File.Exists(value))
{
_binding.IsFile = Visibility.Visible;
_binding.PathExist = Visibility.Visible;
else
_binding.PathExist = Visibility.Collapsed;
_binding.IsFile = Visibility.Collapsed;
ExifInfos = new Dictionary<string, string>();
DetailTextBox.Text = "";
}
await UpdateExif(value);
DetailListBox.SelectAll();
if (_setting.ShowMedia) ShowImage(value);
}
});
});
});
}
else
{
if (Directory.Exists(value))
_binding.PathExist = Visibility.Visible;
else
_binding.PathExist = Visibility.Collapsed;
_binding.IsFile = Visibility.Collapsed;
ExifInfos = new Dictionary<string, string>();
DetailTextBox.Text = "";
}
}

private async Task UpdateCurrentTime(bool resetNow = true, Action action = null)
Expand Down

0 comments on commit 911a251

Please sign in to comment.