-
-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathThemeError.cs
More file actions
128 lines (111 loc) · 3.95 KB
/
ThemeError.cs
File metadata and controls
128 lines (111 loc) · 3.95 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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
using System;
using System.Linq;
namespace WinDynamicDesktop
{
public abstract class ThemeError
{
public string errorMsg;
public string themeId;
internal static readonly Func<string, string> _ = Localization.GetTranslation;
public ThemeError(string themeId_)
{
themeId = themeId_;
}
}
class FailedToCopyImage : ThemeError
{
public FailedToCopyImage(string themeId, string imagePath) : base(themeId)
{
errorMsg = string.Format(_("Could not copy image file {0}"), imagePath);
}
}
class FailedToCreateThumbnail : ThemeError
{
public FailedToCreateThumbnail(string themeId) : base(themeId)
{
errorMsg = _("Failed to generate thumbnail: The image could not be loaded");
}
}
class FailedToDownloadImages : ThemeError
{
public FailedToDownloadImages(string themeId) : base(themeId)
{
errorMsg = string.Format(_("Could not download images for '{0}' theme"), themeId);
}
}
class FailedToFindLocation : ThemeError
{
public FailedToFindLocation(string themeId, string path) : base(themeId)
{
errorMsg = string.Format(_("Could not find location {0}"), path);
}
}
class InvalidImageInThemeJSON : ThemeError
{
public InvalidImageInThemeJSON(string themeId, int imageId, string filename) : base(themeId)
{
errorMsg = string.Format(_("Could not find image {0} at {1}"), imageId, filename);
}
}
class InvalidThemeJSON : ThemeError
{
public InvalidThemeJSON(string themeId, string message) : base(themeId)
{
errorMsg = string.Format(_("Could not read theme JSON file: {0}"), message);
}
}
class InvalidZIP : ThemeError
{
public InvalidZIP(string themeId, string zipPath) : base(themeId)
{
errorMsg = string.Format(_("Could not read ZIP file at {0} because its format is invalid"), zipPath);
}
}
class MissingFieldsInThemeJSON : ThemeError
{
private string[] requiredFields = new string[] { "dayImageList", "imageFilename", "nightImageList" };
public MissingFieldsInThemeJSON(string themeId) : base(themeId)
{
errorMsg = string.Format(_("Theme JSON file is missing one or more of these required fields: {0}"),
string.Join(", ", requiredFields.Select((field) => "'" + field + "'")));
}
}
class NoImagesInFolder : ThemeError
{
public NoImagesInFolder(string themeId, string path) : base(themeId)
{
errorMsg = string.Format(_("No images found in folder {0}"), path);
}
}
class NoImagesInZIP : ThemeError
{
public NoImagesInZIP(string themeId, string zipPath) : base(themeId)
{
errorMsg = string.Format(_("No images found in ZIP file {0}"), zipPath);
}
}
class NoImagesMatchingPattern : ThemeError
{
public NoImagesMatchingPattern(string themeId, string pattern) : base(themeId)
{
errorMsg = string.Format(_("No images found that match the pattern {0}"), pattern);
}
}
class NoThemeJSON : ThemeError
{
public NoThemeJSON(string themeId) : base(themeId)
{
errorMsg = _("Theme JSON file not found");
}
}
class NoThemeJSONInZIP : ThemeError
{
public NoThemeJSONInZIP(string themeId, string zipPath) : base(themeId)
{
errorMsg = string.Format(_("Theme JSON not found in ZIP file {0}"), zipPath);
}
}
}