forked from dropsonic/FinancistoAdapter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make WizardWindow wider and re-sizable (#17)
* Make WizardWindow wider and re sizable * Show version * Replace Mvvm.Async
- Loading branch information
Showing
25 changed files
with
307 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Windows.Input; | ||
|
||
namespace Financier.Common | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class AsyncCommand : ICommand, IAsyncCommand | ||
{ | ||
private readonly Func<Task> _action; | ||
private readonly SynchronizationContext _context; | ||
private readonly Func<bool> _predicate; | ||
public AsyncCommand(Func<Task> action, Func<bool> predicate = null) | ||
{ | ||
_action = action; | ||
_predicate = predicate; | ||
_context = SynchronizationContext.Current; | ||
} | ||
|
||
event EventHandler ICommand.CanExecuteChanged | ||
{ | ||
add { _canExecuteChanged += value; } | ||
remove { _canExecuteChanged -= value; } | ||
} | ||
|
||
private event EventHandler _canExecuteChanged; | ||
public bool CanExecute() | ||
{ | ||
return _predicate == null || _predicate(); | ||
} | ||
|
||
// ----- Implement ICommand | ||
bool ICommand.CanExecute(object parameter) | ||
{ | ||
return CanExecute(); | ||
} | ||
|
||
async void ICommand.Execute(object parameter) | ||
{ | ||
await ExecuteAsync(); | ||
} | ||
|
||
public async Task ExecuteAsync() | ||
{ | ||
if (CanExecute()) | ||
{ | ||
await _action(); | ||
} | ||
} | ||
public void RaiseCanExecuteChanged() | ||
{ | ||
if (_context != null) | ||
{ | ||
_context.Post(state => OnCanExecuteChanged(), null); | ||
} | ||
else | ||
{ | ||
OnCanExecuteChanged(); | ||
} | ||
} | ||
private void OnCanExecuteChanged() | ||
{ | ||
var handler = _canExecuteChanged; | ||
if (handler != null) | ||
handler(this, EventArgs.Empty); | ||
} | ||
} | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class AsyncCommand<T> : ICommand, IAsyncCommand<T> | ||
{ | ||
private readonly Predicate<T> _canExecute; | ||
private readonly SynchronizationContext _context; | ||
private readonly Func<T, Task> _parameterizedAction; | ||
public AsyncCommand(Func<T, Task> parameterizedAction, Predicate<T> canExecute = null) | ||
{ | ||
_parameterizedAction = parameterizedAction; | ||
_canExecute = canExecute; | ||
_context = SynchronizationContext.Current; | ||
} | ||
|
||
event EventHandler ICommand.CanExecuteChanged | ||
{ | ||
add { _canExecuteChanged += value; } | ||
remove { _canExecuteChanged -= value; } | ||
} | ||
|
||
private event EventHandler _canExecuteChanged; | ||
public bool CanExecute(T parameter) | ||
{ | ||
return _canExecute == null || _canExecute(parameter); | ||
} | ||
|
||
// ----- Explicit implementations | ||
bool ICommand.CanExecute(object parameter) | ||
{ | ||
return CanExecute((T)parameter); | ||
} | ||
|
||
async void ICommand.Execute(object parameter) | ||
{ | ||
await ExecuteAsync((T)parameter); | ||
} | ||
|
||
public async Task ExecuteAsync(T parameter) | ||
{ | ||
if (CanExecute(parameter)) | ||
{ | ||
await _parameterizedAction(parameter); | ||
} | ||
} | ||
public void RaiseCanExecuteChanged() | ||
{ | ||
if (_context != null) | ||
{ | ||
_context.Post(state => OnCanExecuteChanged(), null); | ||
} | ||
else | ||
{ | ||
OnCanExecuteChanged(); | ||
} | ||
} | ||
private void OnCanExecuteChanged() | ||
{ | ||
var handler = _canExecuteChanged; | ||
if (handler != null) | ||
handler(this, EventArgs.Empty); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Financier.Common | ||
{ | ||
public interface IAsyncCommand | ||
{ | ||
Task ExecuteAsync(); | ||
bool CanExecute(); | ||
void RaiseCanExecuteChanged(); | ||
} | ||
|
||
public interface IAsyncCommand<in T> | ||
{ | ||
Task ExecuteAsync(T parameter); | ||
bool CanExecute(T parameter); | ||
void RaiseCanExecuteChanged(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using Mvvm.Async; | ||
|
||
namespace Financier.Common | ||
namespace Financier.Common | ||
{ | ||
public interface IDataRefresh | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//2022.6.21.6 | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyCompany("Financier.Desktop")] | ||
[assembly: AssemblyProduct("Financier.Desktop")] | ||
[assembly: AssemblyTitle("Financier.Desktop")] | ||
[assembly: AssemblyConfiguration("Release")] | ||
[assembly: AssemblyFileVersion("2022.6.21.6")] | ||
[assembly: AssemblyVersion("2022.6.21.6")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.