-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnilibriaAppTizen.cs
103 lines (89 loc) · 3.21 KB
/
AnilibriaAppTizen.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using System.Diagnostics;
using AnilibriaAppTizen.Services;
using AnilibriaAppTizen.Views;
namespace AnilibriaAppTizen
{
internal class Program : NUIApplication
{
private ApiService _apiService;
private FileService _fileService;
private ImageService _imageService;
private LocalSettingsService _localSettingsService;
private UserService _userService;
private Main _main;
private Release _release;
/// <summary>
/// Initialize application
/// </summary>
async void Initialize()
{
// Add custom fonts
FontClient.Instance.AddCustomFontDirectory(DirectoryInfo.SharedResource + "fonts/");
// Add main key event
Window.Instance.KeyEvent += OnKeyEvent;
// Create services
_apiService = new ApiService();
_fileService = new FileService();
_imageService = new ImageService();
_localSettingsService = new LocalSettingsService(_fileService);
_userService = new UserService(_localSettingsService, _apiService);
// Views
_release = new Release(_apiService, _imageService);
_main = new Main(_apiService, _imageService, _userService, _release);
// Init user session
await _userService.InitializeAsync();
// Init views
_main.Initialize();
_release.Initialize();
FocusManager.Instance.FocusIndicator = new View();
FocusManager.Instance.FocusChanged += FocusManager_FocusChanged;
FocusManager.Instance.SetCurrentFocusView(_main.ActiveMenuButton.View);
}
/// <summary>
/// The method called when key pressed down
/// </summary>
/// <param name="sender">Key instance</param>
/// <param name="e">Key's args</param>
private void OnKeyEvent(object sender, Window.KeyEventArgs e)
{
if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "Escape" || e.Key.KeyPressedName == "XF86Back"))
{
if (_release.IsActive)
_release.Dispose();
else
Exit();
}
}
/// <summary>
/// The method called when focus changed
/// </summary>
/// <param name="sender">FocusManager instance</param>
/// <param name="e">FocusManager's args</param>
private void FocusManager_FocusChanged(object sender, FocusManager.FocusChangedEventArgs e)
{
if (e.NextView != null)
{
Debug.WriteLine($"{e.NextView.Name}");
}
}
/// <summary>
/// The method called when application created
/// </summary>
protected override void OnCreate()
{
base.OnCreate();
Initialize();
}
/// <summary>
/// Main function.
/// </summary>
/// <param name="args">arguments of Main (entry point)</param>
static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
}