Skip to content

Commit

Permalink
image history and file dialogs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mythter committed Jun 1, 2023
1 parent e4749f9 commit 1f8d92f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion PicEdit/PicEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<PackageReference Include="FontAwesome.Sharp" Version="6.3.0" />
<PackageReference Include="FontAwesome5" Version="2.1.11" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.11.0" />
<PackageReference Include="Microsoft.VisualStudio.Imaging" Version="17.5.33428.366" />
<PackageReference Include="Microsoft.VisualStudio.Imaging" Version="17.6.36389" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
</ItemGroup>

Expand Down
24 changes: 15 additions & 9 deletions PicEdit/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using PicEdit.ViewModels.Base;
using System;
using System.Windows;
using Forms = System.Windows.Forms;
using EditingMode = System.Windows.Controls.InkCanvasEditingMode;
using System.Windows.Input;
using System.Windows.Media.Imaging;
Expand Down Expand Up @@ -643,10 +642,10 @@ private void OnCloseApplicationCommandExecuted(object p)

private void OnOpenImageCommandExecuted(object p)
{
Forms.OpenFileDialog open = new Forms.OpenFileDialog();
var open = new Microsoft.Win32.OpenFileDialog();
open.Title = "Open an image";
open.Filter = "Image Files(*.BMP;*.JPG;*.JPEG;*.GIF;*.PNG;*.TIFF;*.ICO)|*.BMP;*.JPG;*.JPEG;*.GIF;*.PNG;*.TIFF;*.ICO";
if (open.ShowDialog() == Forms.DialogResult.OK)
if (open.ShowDialog() == true)
{
_imageStream = new System.IO.MemoryStream(File.ReadAllBytes(open.FileName));
string format = open.FileName.Substring(open.FileName.LastIndexOf('.') + 1);
Expand All @@ -661,12 +660,19 @@ private void OnOpenImageCommandExecuted(object p)
bitmap.Freeze();
Image = bitmap;

_obCollection.Clear();
_obStrokeCollection.Clear();
_obStrokeCollection.Add(new StrokeCollection());
position = -1;
strPos = -1;

_obCollection.Add(Image);
++position;

OnPropertyChanged(nameof(Image));
}
ZoomValue = 0.7;

ZoomValue = 0.7;
}
}
#endregion

Expand All @@ -688,7 +694,7 @@ private void OnChangeSaveImageFormatCommandExecuted(object p)

private void OnConvertImageCommandExecuted(object p)
{
Forms.SaveFileDialog save = new Forms.SaveFileDialog();
var save = new Microsoft.Win32.SaveFileDialog();
save.Title = "Save image as ...";
save.Filter = "PNG File(*.png)|*.png|" +
"JPG File(*.jpg)|*.jpg|" +
Expand Down Expand Up @@ -725,7 +731,7 @@ private void OnConvertImageCommandExecuted(object p)
break;
}

if (save.ShowDialog() == Forms.DialogResult.OK)
if (save.ShowDialog() == true)
{
string fileName = save.FileName;
string chosenFormat = fileName.Substring(fileName.LastIndexOf(".") + 1);
Expand All @@ -743,7 +749,7 @@ private void OnConvertImageCommandExecuted(object p)

private void OnSaveAsCommandExecuted(object p)
{
Forms.SaveFileDialog save = new Forms.SaveFileDialog();
var save = new Microsoft.Win32.SaveFileDialog();
save.Title = "Save image as ...";
save.Filter = "PNG File(*.png)|*.png|" +
"JPG File(*.jpg)|*.jpg|" +
Expand All @@ -754,7 +760,7 @@ private void OnSaveAsCommandExecuted(object p)
save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
save.FileName = "Untitled1";

if (save.ShowDialog() == Forms.DialogResult.OK)
if (save.ShowDialog() == true)
{
string fileName = save.FileName;
string chosenFormat = fileName.Substring(fileName.LastIndexOf(".") + 1);
Expand Down

0 comments on commit 1f8d92f

Please sign in to comment.