-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigModel.cs
105 lines (82 loc) · 2.97 KB
/
ConfigModel.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
104
105
using ImageService.Communication;
using ImageService.Communication.Enums;
using ImageService.Communication.Modal;
using ImageService.Modal;
using Newtonsoft.Json;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
namespace ImageServiceWeb.Models
{
public class ConfigModel
{
private ClientWebSingleton singleton_client;
private Setting the_settings;
/// <summary>
/// Constructor
/// </summary>
public ConfigModel()
{
//Creates new settings and client singleton instance
the_settings = new Setting();
singleton_client = ClientWebSingleton.getInstance;
singleton_client.CommandReceivedEvent += settingsOnCommand;
//Create new event data
CommandReceivedEventArgs event_data = new CommandReceivedEventArgs(
(int)CommandEnum.GetConfigCommand, null, null);
WriteToClient(event_data);
singleton_client.wait();
}
/// <summary>
/// Command settings
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">args</param>
private void settingsOnCommand(object sender, ClientArgs e)
{
//Checks if the id is get config
if (e.CommandID == (int)CommandEnum.GetConfigCommand)
{
//Sets the settings, dir, sourcename and mroe
the_settings = JsonConvert.DeserializeObject<Setting>(e.Args);
SourceName = the_settings.SourceName;
LogName = the_settings.LogName;
OutPutDir = the_settings.OutPutDir;
ThumbnailSize = the_settings.ThumbnailSize;
HandlersArr = the_settings.ArrHandlers;
}
//Remove the data from hadnlers array
else if (e.CommandID == (int)CommandEnum.RemoveHandler)
{
HandlersArr.Remove(e.Args);
}
}
/// <summary>
/// Writes to client the data
/// </summary>
/// <param name="e">event data</param>
public void WriteToClient(CommandReceivedEventArgs e)
{
singleton_client.write(e);
}
[Required]
[DataType(DataType.Text)]
[Display(Name = "ThumbnailSize:")]
public int ThumbnailSize { get; set; }
[Required]
[DataType(DataType.Text)]
[Display(Name = "HandlersArr:")]
public ObservableCollection<string> HandlersArr { get; set; }
[Required]
[DataType(DataType.Text)]
[Display(Name = "SourceName:")]
public string SourceName { get; set; }
[Required]
[DataType(DataType.Text)]
[Display(Name = "OutPutDir:")]
public string OutPutDir { get; set; }
[Required]
[DataType(DataType.Text)]
[Display(Name = "LogName:")]
public string LogName { get; set; }
}
}