sicpaconnexions / SICPA_Connexions / Services / LoadingIndicatorService.cs @ 03682d21
Historique | Voir | Annoter | Télécharger (1,385 ko)
1 |
using System.ComponentModel; |
---|---|
2 |
using System.Runtime.CompilerServices; |
3 |
|
4 |
namespace SICPA_Connexions.Services |
5 |
{ |
6 |
public class LoadingIndicatorService : INotifyPropertyChanged |
7 |
{ |
8 |
private bool isBusy; |
9 |
private string message; |
10 |
private string title; |
11 |
|
12 |
public bool IsBusy |
13 |
{ |
14 |
get => isBusy; |
15 |
set => SetProperty(ref isBusy, value); |
16 |
} |
17 |
|
18 |
public string Message |
19 |
{ |
20 |
get { return message; } |
21 |
set |
22 |
{ |
23 |
SetProperty(ref message, value); |
24 |
OnPropertyChanged(nameof(IsVisibleMessage)); |
25 |
} |
26 |
} |
27 |
|
28 |
public string Title |
29 |
{ |
30 |
get { return title; } |
31 |
set { SetProperty(ref title, value); } |
32 |
} |
33 |
|
34 |
public bool IsVisibleMessage => !string.IsNullOrEmpty(Message); |
35 |
|
36 |
#region INPC |
37 |
public event PropertyChangedEventHandler PropertyChanged; |
38 |
|
39 |
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyname = null) |
40 |
{ |
41 |
if (Equals(storage, value)) return false; |
42 |
|
43 |
storage = value; |
44 |
OnPropertyChanged(propertyname); |
45 |
return true; |
46 |
} |
47 |
|
48 |
protected void OnPropertyChanged(string propertyName) |
49 |
{ |
50 |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
51 |
} |
52 |
#endregion |
53 |
} |
54 |
} |