Skip to content

Commit

Permalink
Add initial directory to the file open dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiIsait committed May 29, 2024
1 parent 06f80ef commit 7f5462c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

using Image2Icon.Models;
using Image2Icon.Utils;

Expand Down Expand Up @@ -34,6 +35,10 @@ private void OpenImageFile() {
OpenFileDialog openFileDialog = new() {
Filter = "Image files (*.png;*.jpeg;*.jpg)|*.png;*.jpeg;*.jpg|All files (*.*)|*.*"
};
if (File.Exists(ImagePath)) {
openFileDialog.InitialDirectory = Path.GetDirectoryName(ImagePath);
openFileDialog.FileName = ImagePath;
}
if (openFileDialog.ShowDialog() != true) {
return;
}
Expand All @@ -48,6 +53,7 @@ private void Convert() {
}
SaveFileDialog saveFileDialog = new() {
Filter = "Icon files (*.ico)|*.ico|All files (*.*)|*.*",
InitialDirectory = Path.GetDirectoryName(ImagePath),
FileName = Path.GetFileNameWithoutExtension(ImagePath)
};
if (saveFileDialog.ShowDialog() != true) {
Expand Down

0 comments on commit 7f5462c

Please sign in to comment.