This repository has been archived by the owner on Sep 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
61 lines (53 loc) · 1.9 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using TP2_AnimateursWPF_AP.Converters.Json;
using TP2_AnimateursWPF_AP.Models;
namespace TP2_AnimateursWPF_AP
{
/// <summary>
/// Logique d'interaction pour App.xaml
/// </summary>
public partial class App : Application
{
public bool IsDirty { get; private set; }
public App()
{
IsDirty = false;
}
/// <summary>Enregistre les changements s'il y a lieu.</summary>
/// <param name="animators">Tous les animateurs.</param>
/// <param name="abilities">Toutes les habiletés.</param>
/// <param name="races">Toutes les races.</param>
/// <remarks>
/// Même si <paramref cref="races"/> n'est pas sauvegardé et <paramref cref="abilities"/> n'est pas utilisé directement,
/// forcer l'interface permet de limiter les changements au code.
/// </remarks>
public void SaveChanges(IEnumerable<Animateur> animators, IEnumerable<Ability> abilities, IEnumerable<Race> races)
{
Animateur.EnregistrerListeAnimateurs(animators.ToList());
Ability.Save();
IsDirty = false;
}
#region Event Handlers
public void Application_DetectedChange(object sender, EventArgs e)
{
IsDirty = true;
}
private void Application_Startup(object sender, StartupEventArgs e)
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters = new List<JsonConverter>
{
new AbilityJsonConverter(),
new PhoneNumberJsonConverter(),
new RaceJsonConverter()
}
};
}
#endregion
}
}