-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathAppSettings.cs
More file actions
294 lines (239 loc) · 11 KB
/
AppSettings.cs
File metadata and controls
294 lines (239 loc) · 11 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
using Avalonia;
using Avalonia.Media;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualBasic.FileIO;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
namespace Dynaframe3
{
/// <summary>
/// Source: https://stackoverflow.com/questions/51351464/user-configuration-settings-in-net-core
/// </summary>
public class AppSettings
{
// marked as private to prevent outside classes from creating new.
private AppSettings()
{
ReloadSettings = true;
RefreshDirctories = true;
Shuffle = false;
VideoVolume = false;
Rotation = 0;
NumberOfSecondsToShowIP = 10;
OXMOrientnation = "--orientation 0";
SearchDirectories = new List<string>() { };
CurrentPlayList = new List<string>() { };
RemoteClients = new List<string>() { };
CurrentDirectory = SpecialDirectories.MyPictures;
DateTimeFormat = "H:mm tt";
DateTimeFontFamily = "Terminal";
InfoBarFontSize = 50;
SlideshowTransitionTime = 30000; // milliseconds between slides
FadeTransitionTime = 10000; // milliseconds for fades
ImageStretch = Stretch.UniformToFill; // Default image stretch
// Video Settings
VideoStretch = "Fill"; // Used for OMXPlayer
PlaybackFullVideo = false; // This means videos will obey transition time by default
ExpandDirectoriesByDefault = false; // WebUI setting to expand the trees
ListenerPort = 8000; // Default port for the WebUI to listen on
IsSyncEnabled = false; // Sync with other frames off by default
IgnoreFolders = ".lrlibrary,.photoslibrary"; // TODO: Expose this in the Advanced UI
ScreenStatus = true; // Default for Screen On / Off function
ShowInfoDateTime = false; // Show Date Time in Infobar On / Off function
ShowInfoFileName = false; // Show Filename in Infobar On / Off function
ShowEXIFData = false; // Show Exif Data in Infobar On / Off function
ShowInfoIP = "false"; // Show IP in Infobar On / Off function
HideInfoBar = false; // Hide Infobar On / Off function
DynaframeIP = Helpers.GetIP(); // Dynaframe IP Address
SlideShowPaused = false; // Pause Slideshow on / off
EnableLogging = true; // Enables logging...should be set to false by default at some point.
// Tag settings
InclusiveTagFilters = ""; // Semicolon delimited list of images to include. Blank string means 'all'
// Blurbox Settings
BlurBoxSigmaX = 30; // See BlurboxImage.axaml.cs for usage
BlurBoxSigmaY = 30; // Used in line: blurPaint.ImageFilter = SKImageFilter.CreateBlur(50, 50);
BlurBoxMargin = -400; // Set to negative to scale the background image
}
private static string _jsonSource;
private static AppSettings _appSettings = null;
public static AppSettings Default
{
get
{
if (_appSettings == null)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
_jsonSource = $"{AppDomain.CurrentDomain.BaseDirectory}{Path.DirectorySeparatorChar}appsettings.json";
var config = builder.Build();
_appSettings = new AppSettings();
config.Bind(_appSettings);
if (_appSettings.SearchDirectories.Count == 0)
{
// Firstrun...if there are no search directories, add in mypictures and subfolders
_appSettings.SearchDirectories.Add(SpecialDirectories.MyPictures);
_appSettings.CurrentPlayList.Clear();
foreach (string dir in Directory.GetDirectories(SpecialDirectories.MyPictures))
{
_appSettings.CurrentPlayList.Add(dir);
}
string dirPath = AppDomain.CurrentDomain.BaseDirectory + "web/uploads/";
_appSettings.SearchDirectories.Add(dirPath);
foreach (string dir in Directory.GetDirectories(dirPath))
{
_appSettings.CurrentPlayList.Add(dir);
}
}
}
return _appSettings;
}
}
public void Save()
{
// open config file
string json = JsonConvert.SerializeObject(_appSettings);
//write string to file
System.IO.File.WriteAllText(_jsonSource, json);
}
/// <summary>
/// Should the pictures in the folder shuffle?
/// </summary>
public bool Shuffle { get; set; }
/// <summary>
/// Should videos play with volume? Default off.
/// </summary>
public bool VideoVolume { get; set; }
/// <summary>
/// WebUI setting around if the directories should be expanded.
/// </summary>
public bool ExpandDirectoriesByDefault { get; set; }
/// <summary>
/// Rotation of the images and text
/// </summary>
public int Rotation { get; set; }
/// <summary>
/// keeps track of orientation for OMXPlayer
/// </summary>
public string OXMOrientnation { get; set; }
/// <summary>
/// List of directories which should be scanned for pictures
/// </summary>
public List<String> SearchDirectories { get; set; }
public List<string> CurrentPlayList { get; set; }
/// <summary>
/// The size of the font for the info bar
/// </summary>
public int InfoBarFontSize { get; set; }
public enum InfoBar { Clock, FileInfo, DateTime, Error, IP, OFF, InitialIP, ExifData }
public InfoBar InfoBarState { get; set; }
/// <summary>
/// Time to crossfade between images
/// </summary>
public int FadeTransitionTime { get; set; }
/// <summary>
/// Time to show each slide
/// </summary>
public int SlideshowTransitionTime { get; set; }
public string DateTimeFormat { get; set; }
// Font used for the clock/infobar
public string DateTimeFontFamily { get; set; }
// This is the currently selected 'playlist'.
// This will need to be expanded to an array in the future to support
// multiple folders being selected at once
public string CurrentDirectory { get; set; }
public int NumberOfSecondsToShowIP { get; set; }
/// <summary>
/// This alters how images are shown..stretch / aspect ratio settings are part
/// of this. Stretch is an Avalonia property.
/// </summary>
public Stretch ImageStretch { get; set; }
/// <summary>
/// Tracks the video fill setting for omxplayer. This is what states if it should
/// zoom, stretch, show original size, etc. Ignored for Windows currently.
/// </summary>
public string VideoStretch { get; set; }
/// <summary>
/// This controls how video playback is handled. If true the full video is always played, else transition time is obeyed
/// </summary>
public bool PlaybackFullVideo { get; set; }
/// <summary>
/// Control if we should reload settings on the page (for layout/rendering)
/// </summary>
public bool ReloadSettings { get; set; }
/// <summary>
/// Track if we should Refresh the Directories or not (for changes such as added files)
/// </summary>
public bool RefreshDirctories { get; set; }
/// <summary>
/// The public port the webUI should be running on. This setting will require a restart
/// to take effect, and the plan is to only expose it via the appsettings file.
/// </summary>
public int ListenerPort { get; set; }
// Sync Settings
public bool IsSyncEnabled { get; set; }
/// <summary>
/// Default for Screen On / Off function for buttons
/// </summary>
public bool ScreenStatus { get; set; }
/// <summary>
/// Show Date Time On / Off function for buttons
/// </summary>
public bool ShowInfoDateTime { get; set; }
/// <summary>
/// Show Infobar Filename On / Off function for buttons
/// </summary>
public bool ShowInfoFileName { get; set; }
/// <summary>
/// Show Infobar IP Address On / Off function for buttons
/// </summary>
public string ShowInfoIP { get; set; }
/// <summary>
/// Show Exif Data On / Off function for buttons
/// </summary>
public bool ShowEXIFData { get; set; }
/// <summary>
/// Hide Infobar On / Off function for buttons
/// </summary>
public bool HideInfoBar { get; set; }
/// <summary>
/// Dynaframe Current IP
/// </summary>
public string DynaframeIP { get; set; }
/// <summary>
/// On / Off for slideshow paused
/// </summary>
public bool SlideShowPaused { get; set; }
/// <summary>
/// List of ip addresses which are used to send remote commands to control clients
/// </summary>
public List<string> RemoteClients { get; set; }
/// <summary>
/// List of folders, comma seperated, to ignore looking in
/// </summary>
public string IgnoreFolders { get; set; }
public string InclusiveTagFilters { get; set; }
/// <summary>
/// Allows the enabling or disabling of logging. Defaulting to disabled, this can be turned on
/// to help troubleshoot issues.
/// </summary>
public bool EnableLogging { get; set; }
// BLURBOX Settings
/// <summary>
/// SigmaX amount of blur applied for an SKPaint blur effect
/// </summary>
public float BlurBoxSigmaX { get; set; }
/// <summary>
/// SigmaY amount of blur applied for an SKPaint blur effect
/// </summary>
public float BlurBoxSigmaY { get; set; }
/// <summary>
/// The margin the blurbox should use when displayed. Setting this to negative can scale the background to hide text/edges.
/// </summary>
public double BlurBoxMargin { get; set; }
}
}