-
Notifications
You must be signed in to change notification settings - Fork 1
/
Settings.ascx.cs
162 lines (135 loc) · 6.58 KB
/
Settings.ascx.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
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
using System;
using System.IO;
using System.Linq;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
namespace TidyModules.DocumentExplorer
{
public partial class Settings : ModuleSettingsBase
{
#region Base Method Implementations
/// <summary>
/// LoadSettings loads the settings from the Database and displays them
/// </summary>
public override void LoadSettings()
{
try
{
DocumentSettings settings = new DocumentSettings(ModuleConfiguration);
FillThemes(settings.Theme);
txtJqueryUICSS.Text = settings.JqueryUICSS;
txtPrimeUIJS.Text = settings.PrimeUIJS;
txtPrimeUICSS.Text = settings.PrimeUICSS;
txtFontAwesomeCSS.Text = settings.FontAwesomeCSS;
chkShowIcon.Checked = settings.ShowIcon;
txtNameHeaderClass.Text = settings.NameHeaderClass;
txtNameBodyClass.Text = settings.NameBodyClass;
chkNameFilter.Checked = settings.NameFilter;
ListItem nameMode = rblNameFilterMatchModes.Items.FindByValue(settings.NameFilterMatchMode);
if (nameMode != null)
nameMode.Selected = true;
chkNameSortable.Checked = settings.NameSortable;
chkShowDate.Checked = settings.ShowDate;
txtDateHeaderClass.Text = settings.DateHeaderClass;
txtDateBodyClass.Text = settings.DateBodyClass;
chkDateFilter.Checked = settings.DateFilter;
ListItem dateMode = rblDateFilterMatchModes.Items.FindByValue(settings.DateFilterMatchMode);
if (dateMode != null)
dateMode.Selected = true;
chkDateSortable.Checked = settings.DateSortable;
chkShowSize.Checked = settings.ShowSize;
txtSizeHeaderClass.Text = settings.SizeHeaderClass;
txtSizeBodyClass.Text = settings.SizeBodyClass;
chkSizeFilter.Checked = settings.SizeFilter;
ListItem sizeMode = rblSizeFilterMatchModes.Items.FindByValue(settings.SizeFilterMatchMode);
if (sizeMode != null)
sizeMode.Selected = true;
chkSizeSortable.Checked = settings.SizeSortable;
txtRows.Text = settings.Rows.ToString();
chkResetFilters.Checked = settings.ResetFilters;
chkUserFolder.Checked = settings.UserFolder;
chkFileManagement.Checked = settings.FileManagement;
chkOpenOnDblclick.Checked = settings.OpenOnDblclick;
chkImagePreview.Checked = settings.ImagePreview;
txtThumbnailWidth.Text = settings.ThumbnailWidth.ToString();
txtThumbnailHeight.Text = settings.ThumbnailHeight.ToString();
}
catch (Exception exc)
{
//Module failed to load
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// <summary>
/// UpdateSettings saves the modified settings to the Database
/// </summary>
public override void UpdateSettings()
{
try
{
DocumentSettings settings = new DocumentSettings(ModuleConfiguration);
settings.JqueryUICSS = txtJqueryUICSS.Text;
settings.PrimeUIJS = txtPrimeUIJS.Text;
settings.PrimeUICSS = txtPrimeUICSS.Text;
settings.FontAwesomeCSS = txtFontAwesomeCSS.Text;
settings.Theme = cboThemes.SelectedValue;
settings.ShowIcon = chkShowIcon.Checked;
settings.NameHeaderClass = txtNameHeaderClass.Text;
settings.NameBodyClass = txtNameBodyClass.Text;
settings.NameFilter = chkNameFilter.Checked;
settings.NameFilterMatchMode = rblNameFilterMatchModes.SelectedValue;
settings.NameSortable = chkNameSortable.Checked;
settings.ShowDate = chkShowDate.Checked;
settings.DateHeaderClass = txtDateHeaderClass.Text;
settings.DateBodyClass = txtDateBodyClass.Text;
settings.DateFilter = chkDateFilter.Checked;
settings.DateFilterMatchMode = rblDateFilterMatchModes.SelectedValue;
settings.DateSortable = chkDateSortable.Checked;
settings.ShowSize = chkShowSize.Checked;
settings.SizeHeaderClass = txtSizeHeaderClass.Text;
settings.SizeBodyClass = txtSizeBodyClass.Text;
settings.SizeFilter = chkSizeFilter.Checked;
settings.SizeFilterMatchMode = rblSizeFilterMatchModes.SelectedValue;
settings.SizeSortable = chkSizeSortable.Checked;
settings.Rows = int.Parse(txtRows.Text);
settings.ResetFilters = chkResetFilters.Checked;
settings.UserFolder = chkUserFolder.Checked;
settings.FileManagement = chkFileManagement.Checked;
settings.OpenOnDblclick = chkOpenOnDblclick.Checked;
settings.ImagePreview = chkImagePreview.Checked;
settings.ThumbnailWidth = int.Parse(txtThumbnailWidth.Text);
settings.ThumbnailHeight = int.Parse(txtThumbnailHeight.Text);
settings.UpdateSettings();
}
catch (Exception exc)
{
//Module failed to load
Exceptions.ProcessModuleLoadException(this, exc);
}
}
#endregion
#region Private Methods
private void FillThemes(string theme)
{
string basePath = MapPath(ControlPath);
string folderPath = Path.Combine(basePath, @"Scripts\themes\");
ListItem[] themes = Directory.GetDirectories(folderPath).Select(d => new ListItem(GetName(d))).ToArray();
cboThemes.Items.Add(new ListItem(Localization.GetString("SelectTheme", LocalResourceFile), "(none)"));
cboThemes.Items.AddRange(themes);
ListItem item = cboThemes.Items.FindByText(theme);
if (item != null)
item.Selected = true;
}
private string GetName(string folderName)
{
string name = string.Empty;
int pos = folderName.LastIndexOf(@"\");
if (pos > -1)
name = folderName.Substring(pos + 1);
return name;
}
#endregion
}
}