Skip to content

Commit

Permalink
Merge pull request #10 from softawaregmbh/net8-sample
Browse files Browse the repository at this point in the history
Updated sample app to .NET 8, add source link to class library, impro…
  • Loading branch information
doerrD authored Apr 16, 2024
2 parents a9a12b4 + 4699c39 commit 173cf77
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 199 deletions.
21 changes: 7 additions & 14 deletions Smartcrop.Sample.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace Smartcrop.Sample.Wpf
namespace Smartcrop.Sample.Wpf;

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
41 changes: 20 additions & 21 deletions Smartcrop.Sample.Wpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
using System.Windows;
using Microsoft.Win32;

namespace Smartcrop.Sample.Wpf
namespace Smartcrop.Sample.Wpf;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public MainWindow()
{
public MainWindow()
{
this.InitializeComponent();
this.InitializeComponent();

this.DataContext = new ViewModel(this.SelectFile);
}
this.DataContext = new ViewModel(this.SelectFile);
}

private string SelectFile()
private string SelectFile()
{
var dialog = new OpenFileDialog()
{
var dialog = new OpenFileDialog()
{
Filter = "Image Files | *.bmp; *.png; *.jpg; *.jpeg;"
};

if (dialog.ShowDialog() == true)
{
return dialog.FileName;
}
Filter = "Image Files | *.bmp; *.png; *.jpg; *.jpeg;"
};

return null;
if (dialog.ShowDialog() == true)
{
return dialog.FileName;
}

return null;
}
}
20 changes: 7 additions & 13 deletions Smartcrop.Sample.Wpf/SimpleCommand.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
using System;
using System.Windows.Input;

namespace Smartcrop.Sample.Wpf
{
public class SimpleCommand : ICommand
{
private readonly Action executeAction;
namespace Smartcrop.Sample.Wpf;

public SimpleCommand(Action executeAction)
{
this.executeAction = executeAction ?? throw new ArgumentNullException(nameof(executeAction));
}
public class SimpleCommand(Action executeAction) : ICommand
{
private readonly Action executeAction = executeAction ?? throw new ArgumentNullException(nameof(executeAction));

public event EventHandler CanExecuteChanged;
public event EventHandler CanExecuteChanged;

public bool CanExecute(object parameter) => true;
public bool CanExecute(object parameter) => true;

public void Execute(object parameter) => this.executeAction();
}
public void Execute(object parameter) => this.executeAction();
}
4 changes: 2 additions & 2 deletions Smartcrop.Sample.Wpf/Smartcrop.Sample.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>

Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 173cf77

Please sign in to comment.