• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 7263096385

19 Dec 2023 02:18PM UTC coverage: 56.766% (-0.007%) from 56.773%
7263096385

Pull #1708

github

JFriel
update changelog
Pull Request #1708: Add ability to configure and use local file system within GUI

10723 of 20359 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 6 new or added lines in 2 files covered. (0.0%)

53 existing lines in 1 file now uncovered.

30650 of 52524 relevant lines covered (58.35%)

7296.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

37.63
/Rdmp.Core/ReusableLibraryCode/Settings/UserSettings.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.Collections.Generic;
9
using System.Linq;
10
using FAnsi.Discovery;
11
using Rdmp.Core.ReusableLibraryCode.Checks;
12

13
namespace Rdmp.Core.ReusableLibraryCode.Settings;
14

15
/// <summary>
16
/// This is the Settings static class that can be used in your Core solution or in any
17
/// of your client applications. All settings are laid out the same exact way with getters
18
/// and setters.
19
/// </summary>
20
public static class UserSettings
21
{
22
    private static readonly Lazy<RDMPApplicationSettings> Implementation =
4✔
23
        new(static () => new RDMPApplicationSettings(), System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
8✔
24

25
    private static RDMPApplicationSettings AppSettings => Implementation.Value ??
36,874!
26
                                                          throw new NotImplementedException(
36,874✔
27
                                                              "Isolated Storage does not work in this environment...");
36,874✔
28

29

30
    public static bool UseLocalFileSystem
31
    {
NEW
32
        get => AppSettings.GetValueOrDefault("UseLocalFileSystem", false);
×
NEW
33
        set => AppSettings.AddOrUpdateValue("UseLocalFileSystem", value);
×
34
    }
35

36
    public static string LocalFileSystemLocation 
37
    {
NEW
38
        get => AppSettings.GetValueOrDefault("LocalFileSystemLocation", "\\temp\\rdmp"); 
×
NEW
39
        set => AppSettings.AddOrUpdateValue("LocalFileSystemLocation", value);
×
40
    }
41

42
    /// <summary>
43
    /// Show a Yes/No confirmation dialog box when closing RDMP
44
    /// </summary>
45
    public static bool ConfirmApplicationExiting
46
    {
UNCOV
47
        get => AppSettings.GetValueOrDefault("ConfirmExit", true);
×
48
        set => AppSettings.AddOrUpdateValue("ConfirmExit", value);
×
49
    }
50

51
    /// <summary>
52
    /// True if the user has accepted the open source license agreements for RDMP and
53
    /// dependencies used in the software (i.e. MIT and GNU licenses).
54
    /// </summary>
55
    public static string LicenseAccepted
56
    {
UNCOV
57
        get => AppSettings.GetValueOrDefault("LicenseAccepted", null);
×
58
        set => AppSettings.AddOrUpdateValue("LicenseAccepted", value);
×
59
    }
60

61
    /// <summary>
62
    /// Automatically launch the RDMP Home Screen on launch of the RDMP application, regardless of the last window you viewed.
63
    /// </summary>
64
    public static bool ShowHomeOnStartup
65
    {
UNCOV
66
        get => AppSettings.GetValueOrDefault("ShowHomeOnStartup", false);
×
67
        set => AppSettings.AddOrUpdateValue("ShowHomeOnStartup", value);
×
68
    }
69

70
    /// <summary>
71
    /// If checked series included in graphs that have no values will not be displayed
72
    /// </summary>
73
    public static bool IncludeZeroSeriesInGraphs
74
    {
75
        get => AppSettings.GetValueOrDefault("IncludeZeroSeriesInGraphs", true);
4✔
76
        set => AppSettings.AddOrUpdateValue("IncludeZeroSeriesInGraphs", value);
6✔
77
    }
78

79
    /// <summary>
80
    /// Adds an additional behaviour when changing tabs that highlights the tree view
81
    /// collection that has that object visible in it.
82
    /// </summary>
83
    public static bool EmphasiseOnTabChanged
84
    {
UNCOV
85
        get => AppSettings.GetValueOrDefault("EmphasiseOnTabChanged", false);
×
86
        set => AppSettings.AddOrUpdateValue("EmphasiseOnTabChanged", value);
×
87
    }
88

89
    /// <summary>
90
    /// True to disable any auto starting tutorials
91
    /// </summary>
92
    public static bool DisableTutorials
93
    {
UNCOV
94
        get => AppSettings.GetValueOrDefault("DisableTutorials", false);
×
95
        set => AppSettings.AddOrUpdateValue("DisableTutorials", value);
×
96
    }
97

98
    /// <summary>
99
    /// The connection string to the main RDMP platform database
100
    /// </summary>
101
    public static string CatalogueConnectionString
102
    {
UNCOV
103
        get => AppSettings.GetValueOrDefault("CatalogueConnectionString", "");
×
104
        set => AppSettings.AddOrUpdateValue("CatalogueConnectionString", value);
×
105
    }
106

107
    /// <summary>
108
    /// The connection string to the data export RDMP platform database.  This database will contain
109
    /// refrerences to objects in the <see cref="CatalogueConnectionString"/> database
110
    /// </summary>
111
    public static string DataExportConnectionString
112
    {
UNCOV
113
        get => AppSettings.GetValueOrDefault("DataExportConnectionString", "");
×
114
        set => AppSettings.AddOrUpdateValue("DataExportConnectionString", value);
×
115
    }
116

117
    /// <summary>
118
    /// The colour scheme and format for the RDMP gui client application
119
    /// </summary>
120
    public static string Theme
121
    {
UNCOV
122
        get => AppSettings.GetValueOrDefault("Theme", "ResearchDataManagementPlatform.Theme.MyVS2015BlueTheme");
×
123
        set => AppSettings.AddOrUpdateValue("Theme", value);
×
124
    }
125

126
    /// <summary>
127
    /// When selecting a result from the Find dialog the selected item is pinned in the corresponding view.
128
    /// </summary>
129
    public static bool FindShouldPin
130
    {
UNCOV
131
        get => AppSettings.GetValueOrDefault("FindShouldPin", true);
×
132
        set => AppSettings.AddOrUpdateValue("FindShouldPin", value);
×
133
    }
134

135
    /// <summary>
136
    /// Set the amount of time (in seconds) that the Create Database processes should wait before timing out.
137
    /// </summary>
138
    public static int CreateDatabaseTimeout
139
    {
140
        get => AppSettings.GetValueOrDefault("CreateDatabaseTimeout", 30);
16✔
UNCOV
141
        set => AppSettings.AddOrUpdateValue("CreateDatabaseTimeout",
×
142
            DiscoveredServerHelper.CreateDatabaseTimeoutInSeconds = Math.Max(value, 30));
×
143
    }
144

145
    /// <summary>
146
    /// Set the amount of time (in milliseconds) that tooltips should take to appear in the tree collection views (e.g. list of Catalogues etc)
147
    /// </summary>
148
    public static int TooltipAppearDelay
149
    {
150
        get => AppSettings.GetValueOrDefault("TooltipAppearDelay", 750);
20✔
UNCOV
151
        set => AppSettings.AddOrUpdateValue("TooltipAppearDelay", Math.Max(10, value));
×
152
    }
153

154
    /// <summary>
155
    /// When using the Find feature this option will automatically filter out any cohort set containers (i.e. UNION / INTERSECT / EXCEPT containers)
156
    /// </summary>
157
    public static bool ScoreZeroForCohortAggregateContainers
158
    {
159
        get => AppSettings.GetValueOrDefault("ScoreZeroForCohortAggregateContainers", false);
50✔
160
        set => AppSettings.AddOrUpdateValue("ScoreZeroForCohortAggregateContainers", value);
8✔
161
    }
162

163
    /// <summary>
164
    /// Create audit objects for specific objects/changes (e.g. changes to Catalogue Deprecated status).
165
    /// </summary>
166
    public static bool EnableCommits
167
    {
168
        get => AppSettings.GetValueOrDefault("EnableCommits", true);
22✔
UNCOV
169
        set => AppSettings.AddOrUpdateValue("EnableCommits", value);
×
170
    }
171

172

173
    #region Catalogue flag visibility settings
174

175
    public static bool ShowInternalCatalogues
176
    {
177
        get => AppSettings.GetValueOrDefault("ShowInternalCatalogues", true);
40✔
178
        set => AppSettings.AddOrUpdateValue("ShowInternalCatalogues", value);
48✔
179
    }
180

181
    public static bool ShowDeprecatedCatalogues
182
    {
183
        get => AppSettings.GetValueOrDefault("ShowDeprecatedCatalogues", true);
40✔
184
        set => AppSettings.AddOrUpdateValue("ShowDeprecatedCatalogues", value);
48✔
185
    }
186

187
    public static bool ShowColdStorageCatalogues
188
    {
189
        get => AppSettings.GetValueOrDefault("ShowColdStorageCatalogues", true);
40✔
190
        set => AppSettings.AddOrUpdateValue("ShowColdStorageCatalogues", value);
48✔
191
    }
192

193
    public static bool ShowProjectSpecificCatalogues
194
    {
195
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificCatalogues", true);
40✔
196
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificCatalogues", value);
48✔
197
    }
198

199
    public static bool ShowNonExtractableCatalogues
200
    {
201
        get => AppSettings.GetValueOrDefault("ShowNonExtractableCatalogues", true);
40✔
202
        set => AppSettings.AddOrUpdateValue("ShowNonExtractableCatalogues", value);
48✔
203
    }
204

205
    /// <summary>
206
    /// True to apply theme changes to context menus and tool strips.
207
    /// </summary>
208
    public static bool ApplyThemeToMenus
209
    {
UNCOV
210
        get => AppSettings.GetValueOrDefault("ApplyThemeToMenus", true);
×
211
        set => AppSettings.AddOrUpdateValue("ApplyThemeToMenus", value);
×
212
    }
213

214
    /// <summary>
215
    /// Determines line wrapping in multi line editor controls when lines stretch off the control client area
216
    /// </summary>
217
    public static int WrapMode
218
    {
219
        get => AppSettings.GetValueOrDefault("WrapMode", 0);
40✔
UNCOV
220
        set => AppSettings.AddOrUpdateValue("WrapMode", value);
×
221
    }
222

223
    /// <summary>
224
    /// <para>Base colours used for generating heatmaps in HEX format.  Colour intensity will vary
225
    /// from the first color to the second.</para>
226
    /// 
227
    /// <para>The first colour represents the lowest values and should
228
    /// typically be darker than the second which represents high values.</para>
229
    /// </summary>
230
    public static string HeatMapColours
231
    {
UNCOV
232
        get => AppSettings.GetValueOrDefault("HeatMapColours", null);
×
233
        set => AppSettings.AddOrUpdateValue("HeatMapColours", value);
×
234
    }
235

236
    /// <summary>
237
    /// <para>Adds a 5 second delay after startup</para>
238
    /// <para>Use this option to add a delay that can be helpful for troubleshooting issues on RDMP startup. </para>
239
    /// </summary>
240
    public static bool Wait5SecondsAfterStartupUI
241
    {
242
        get => AppSettings.GetValueOrDefault("Wait5SecondsAfterStartupUI", true);
10✔
243
        set => AppSettings.AddOrUpdateValue("Wait5SecondsAfterStartupUI", value);
12✔
244
    }
245

246
    /// <summary>
247
    /// True to show the cohort creation wizard when creating new cohorts.  False to create
248
    /// a default empty configuration.
249
    /// </summary>
250
    public static bool ShowCohortWizard
251
    {
UNCOV
252
        get => AppSettings.GetValueOrDefault("ShowCohortWizard", false);
×
253
        set => AppSettings.AddOrUpdateValue("ShowCohortWizard", value);
×
254
    }
255

256
    /// <summary>
257
    /// <para>True to enable "stirct validation" for containers in Cohort Builder Queries.</para>
258
    ///
259
    /// <para>Will not allow empty sets, or sets that only have one item.</para>
260
    /// </summary>
261
    public static bool StrictValidationForCohortBuilderContainers
262
    {
263
        get => AppSettings.GetValueOrDefault("StrictValidationForCohortBuilderContainers", true);
38✔
UNCOV
264
        set => AppSettings.AddOrUpdateValue("StrictValidationForCohortBuilderContainers", value);
×
265
    }
266

267
    /// <summary>
268
    /// Changes the behaviour of mouse double clicks in tree views.  When enabled double
269
    /// click expands nodes instead of opening the double clicked object (the default behaviour).
270
    /// </summary>
271
    public static bool DoubleClickToExpand
272
    {
UNCOV
273
        get => AppSettings.GetValueOrDefault("DoubleClickToExpand", false);
×
274
        set => AppSettings.AddOrUpdateValue("DoubleClickToExpand", value);
×
275
    }
276

277
    public static string RecentHistory
278
    {
279
        get => AppSettings.GetValueOrDefault("RecentHistory", "");
60✔
280
        set => AppSettings.AddOrUpdateValue("RecentHistory", value);
18✔
281
    }
282

283
    /// <summary>
284
    /// <para>When enabled RDMP will record certain performance related metrics (how long refresh takes etc).</para>
285
    /// <para>These figures are completely internal to the application and are not transmitted anywhere.You can view the results in the toolbar.</para>
286
    /// </summary>
287
    public static bool DebugPerformance
288
    {
289
        get => AppSettings.GetValueOrDefault("DebugPerformance", false);
30,140✔
UNCOV
290
        set => AppSettings.AddOrUpdateValue("DebugPerformance", value);
×
291
    }
292

293
    /// <summary>
294
    /// <para>Automatically resize columns in the RDMP user interface with fit contents.</para>
295
    /// <para>Can be disabled if problems arrise with column content or header visibility</para>
296
    /// </summary>
297
    public static bool AutoResizeColumns
298
    {
299
        get => AppSettings.GetValueOrDefault("AutoResizeColumns", true);
30✔
UNCOV
300
        set => AppSettings.AddOrUpdateValue("AutoResizeColumns", value);
×
301
    }
302

303

304
    /// <summary>
305
    /// Show a popup confirmation dialog at the end of a pipeline completing execution
306
    /// </summary>
307
    public static bool ShowPipelineCompletedPopup
308
    {
UNCOV
309
        get => AppSettings.GetValueOrDefault("ShowPipelineCompletedPopup", true);
×
310
        set => AppSettings.AddOrUpdateValue("ShowPipelineCompletedPopup", value);
×
311
    }
312

313
    /// <summary>
314
    /// <para>Enable to skip the checking stage of pipeline source component CohortIdentificationConfigurationSource.</para>
315
    /// <para>In slow computer, or contesest databases this can take a while to compile. This option lets you disable it.</para>
316
    /// </summary>
317
    public static bool SkipCohortBuilderValidationOnCommit
318
    {
UNCOV
319
        get => AppSettings.GetValueOrDefault("SkipCohortBuilderValidationOnCommit", false);
×
320
        set => AppSettings.AddOrUpdateValue("SkipCohortBuilderValidationOnCommit", value);
×
321
    }
322

323
    public static string ConsoleColorScheme
324
    {
UNCOV
325
        get => AppSettings.GetValueOrDefault("ConsoleColorScheme", "default");
×
326
        set => AppSettings.AddOrUpdateValue("ConsoleColorScheme", value);
×
327
    }
328

329
    /// <summary>
330
    /// <para>When true RDMP log viewer will hide table load audits where no inserts/updates/deletes were applied.</para>
331
    /// <para>This is helpful if a load targets many tables not all of which will be updated in a given run</para>
332
    /// </summary>
333
    public static bool HideEmptyTableLoadRunAudits
334
    {
UNCOV
335
        get => AppSettings.GetValueOrDefault("HideEmptyTableLoadRunAudits", false);
×
336
        set => AppSettings.AddOrUpdateValue("HideEmptyTableLoadRunAudits", value);
×
337
    }
338

339
    /// <summary>
340
    /// <para>Enables additional Find filters for objects that are in:</para>
341
    /// <para>Cold Storage, Internal, Deprecated, Project Specific and Non Extractable</para>
342
    /// </summary>
343
    public static bool AdvancedFindFilters
344
    {
UNCOV
345
        get => AppSettings.GetValueOrDefault("AdvancedFindFilters", false);
×
346
        set => AppSettings.AddOrUpdateValue("AdvancedFindFilters", value);
×
347
    }
348

349
    /// <summary>
350
    /// Timeout in seconds to allow for creating archive trigger, index etc
351
    /// </summary>
352
    public static int ArchiveTriggerTimeout
353
    {
354
        get => AppSettings.GetValueOrDefault("ArchiveTriggerTimeout", 30);
1,198✔
UNCOV
355
        set => AppSettings.AddOrUpdateValue("ArchiveTriggerTimeout", value);
×
356
    }
357

358
    public static int FindWindowWidth
359
    {
UNCOV
360
        get => AppSettings.GetValueOrDefault("FindWindowWidth", 730);
×
361
        set => AppSettings.AddOrUpdateValue("FindWindowWidth", value);
×
362
    }
363

364
    public static int FindWindowHeight
365
    {
UNCOV
366
        get => AppSettings.GetValueOrDefault("FindWindowHeight", 400);
×
367
        set => AppSettings.AddOrUpdateValue("FindWindowHeight", value);
×
368
    }
369

370
    /// <summary>
371
    /// Enable to refresh only objects which you make changes to instead of
372
    /// fetching all database changes since your last edit.  This improves
373
    /// performance in large RDMP deployments with thousands of Projects configured.
374
    /// </summary>
375
    public static bool SelectiveRefresh
376
    {
377
        get => AppSettings.GetValueOrDefault("SelectiveRefresh", false);
150✔
UNCOV
378
        set => AppSettings.AddOrUpdateValue("SelectiveRefresh", value);
×
379
    }
380

381
    /// <summary>
382
    /// Set to true to always attempt to force joins on all tables under a Catalogue
383
    /// when building queries (in Cohort Builder).  This makes it impossible to untick
384
    /// force joins.
385
    /// </summary>
386
    public static bool AlwaysJoinEverything
387
    {
388
        get => AppSettings.GetValueOrDefault("AlwaysJoinEverything", false);
648✔
UNCOV
389
        set => AppSettings.AddOrUpdateValue("AlwaysJoinEverything", value);
×
390
    }
391

392
    /// <summary>
393
    /// <para>
394
    /// Determines whether queries are automatically sent and results displayed in
395
    /// data tabs in RDMP (e.g. View top 100 etc).  Enable to automatically send the
396
    /// queries.  Disable to show the SQL but require the user to press F5 or click Run
397
    /// to execute.
398
    /// </para>
399
    /// </summary>
400
    public static bool AutoRunSqlQueries
401
    {
UNCOV
402
        get => AppSettings.GetValueOrDefault("AutoRunSqlQueries", false);
×
403
        set => AppSettings.AddOrUpdateValue("AutoRunSqlQueries", value);
×
404
    }
405

406
    /// <summary>
407
    /// Enable to automatically expand the tree when opening or creating cohorts in
408
    /// Cohort Builder
409
    /// </summary>
410
    public static bool ExpandAllInCohortBuilder
411
    {
412
        get => AppSettings.GetValueOrDefault("ExpandAllInCohortBuilder", true);
2✔
UNCOV
413
        set => AppSettings.AddOrUpdateValue("ExpandAllInCohortBuilder", value);
×
414
    }
415

416
    /// <summary>
417
    /// True to show ProjectSpecific Catalogues' columns in extraction configuration user interface
418
    /// </summary>
419
    public static bool ShowProjectSpecificColumns
420
    {
421
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificColumns", true);
18✔
UNCOV
422
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificColumns", value);
×
423
    }
424

425
    /// <summary>
426
    /// <para>When generating an aggregate graph, use the column alias instead of the select sql.  For example
427
    /// when you have the select column 'SELECT YEAR(dt) as myYear' then the GROUP BY will default to
428
    /// 'GROUP BY YEAR(dt)'.  Setting this property to true will instead use 'GROUP BY myYear'.  Typically
429
    /// this only works in MySql but it is not universally supported by all MySql versions and server settings
430
    /// </para>
431
    /// <para>Defaults to false.</para>
432
    /// </summary>
433
    public static bool UseAliasInsteadOfTransformInGroupByAggregateGraphs
434
    {
435
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificColumns", false);
268✔
436
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificColumns", value);
8✔
437
    }
438

439
    #endregion
440

441
    /// <summary>
442
    /// Returns the error level the user wants for <paramref name="errorCode"/> or <see cref="ErrorCode.DefaultTreatment"/> (if no custom
443
    /// reporting level has been set up for this error code).
444
    /// </summary>
445
    /// <param name="errorCode"></param>
446
    /// <returns></returns>
447
    public static CheckResult GetErrorReportingLevelFor(ErrorCode errorCode)
448
    {
449
        var result = AppSettings.GetValueOrDefault($"EC_{errorCode.Code}", errorCode.DefaultTreatment.ToString());
32✔
450

451
        return Enum.Parse<CheckResult>(result);
32✔
452
    }
453

454
    /// <summary>
455
    /// Changes the reporting level of the given error to <paramref name="value"/> instead of its <see cref="ErrorCode.DefaultTreatment"/>
456
    /// </summary>
457
    /// <param name="errorCode"></param>
458
    /// <param name="value"></param>
459
    public static void SetErrorReportingLevelFor(ErrorCode errorCode, CheckResult value)
460
    {
461
        AppSettings.AddOrUpdateValue($"EC_{errorCode.Code}", value.ToString());
16✔
462
    }
16✔
463

464
    public static bool GetTutorialDone(Guid tutorialGuid) =>
UNCOV
465
        tutorialGuid != Guid.Empty && AppSettings.GetValueOrDefault($"T_{tutorialGuid:N}", false);
×
466

467
    public static void SetTutorialDone(Guid tutorialGuid, bool value)
468
    {
UNCOV
469
        if (tutorialGuid == Guid.Empty)
×
470
            return;
×
471

UNCOV
472
        AppSettings.AddOrUpdateValue($"T_{tutorialGuid:N}", value);
×
473
    }
×
474

475
    public static void SetColumnWidth(Guid columnGuid, int width)
476
    {
477
        if (columnGuid == Guid.Empty)
3,132!
UNCOV
478
            return;
×
479
        SetColumnWidth(columnGuid.ToString("N"), width);
3,132✔
480
    }
3,132✔
481

482
    public static void SetColumnWidth(string colIdentifier, int width)
483
    {
484
        AppSettings.AddOrUpdateValue($"ColW_{colIdentifier}", width);
3,132✔
485
    }
3,132✔
486

487
    public static void SetColumnVisible(Guid columnGuid, bool visible)
488
    {
UNCOV
489
        if (columnGuid == Guid.Empty)
×
490
            return;
×
491

UNCOV
492
        SetColumnVisible(columnGuid.ToString("N"), visible);
×
493
    }
×
494

495
    public static void SetColumnVisible(string colIdentifier, bool visible)
496
    {
UNCOV
497
        AppSettings.AddOrUpdateValue($"ColV_{colIdentifier}", visible);
×
498
    }
×
499

500
    public static int GetColumnWidth(Guid columnGuid) =>
501
        columnGuid == Guid.Empty ? 100 : GetColumnWidth(columnGuid.ToString("N"));
128!
502

503
    public static int GetColumnWidth(string colIdentifier) =>
504
        AppSettings.GetValueOrDefault($"ColW_{colIdentifier}", 100);
128✔
505

506
    public static bool GetColumnVisible(Guid columnGuid) =>
507
        columnGuid == Guid.Empty || GetColumnVisible(columnGuid.ToString("N"));
128!
508

509
    public static bool GetColumnVisible(string colIdentifier) =>
510
        AppSettings.GetValueOrDefault($"ColV_{colIdentifier}", true);
128✔
511

512
    public static string[] GetHistoryForControl(Guid controlGuid)
513
    {
514
        return AppSettings.GetValueOrDefault($"A_{controlGuid:N}", "").Split(new[] { "#!#" }, StringSplitOptions.None);
22✔
515
    }
516

517
    public static void SetHistoryForControl(Guid controlGuid, IEnumerable<string> history)
518
    {
519
        AppSettings.AddOrUpdateValue($"A_{controlGuid:N}", string.Join("#!#", history));
204✔
520
    }
204✔
521

522
    public static void AddHistoryForControl(Guid guid, string v)
523
    {
UNCOV
524
        if (string.IsNullOrWhiteSpace(v))
×
525
            return;
×
526

UNCOV
527
        var l = GetHistoryForControl(guid).ToList();
×
528

UNCOV
529
        if (l.Contains(v))
×
530
            return;
×
531

UNCOV
532
        l.Add(v);
×
533

UNCOV
534
        SetHistoryForControl(guid, l.Distinct().ToList());
×
535
    }
×
536

537
    public static Tuple<string, bool> GetLastColumnSortForCollection(Guid controlGuid)
538
    {
539
        lock (_oLockUserSettings)
2✔
540
        {
541
            var value = AppSettings.GetValueOrDefault($"LastColumnSort_{controlGuid:N}", null);
2✔
542

543
            //if we don't have a value
544
            if (string.IsNullOrWhiteSpace(value))
2!
545
                return null;
2✔
546

UNCOV
547
            var args = value.Split(new[] { "#!#" }, StringSplitOptions.RemoveEmptyEntries);
×
548

549
            //or it doesn't split properly
UNCOV
550
            if (args.Length != 2)
×
551
                return null;
×
552

553
            //or either element is null
UNCOV
554
            if (string.IsNullOrWhiteSpace(args[0]) || string.IsNullOrWhiteSpace(args[1]))
×
555
                return null;
×
556

UNCOV
557
            if (bool.TryParse(args[1], out var ascending))
×
558
                return Tuple.Create(args[0], ascending);
×
559
        }
×
560

UNCOV
561
        return null;
×
562
    }
2✔
563

564
    private static object _oLockUserSettings = new();
4✔
565

566
    public static void SetLastColumnSortForCollection(Guid controlGuid, string columnName, bool ascending)
567
    {
568
        lock (_oLockUserSettings)
2✔
569
        {
570
            AppSettings.AddOrUpdateValue($"LastColumnSort_{controlGuid:N}", $"{columnName}#!#{ascending}");
2✔
571
        }
2✔
572
    }
2✔
573

574

575
    /// <summary>
576
    /// Returns the last known manually set splitter distance for the Control who is
577
    /// identified by <paramref name="controlGuid"/> or -1 if none set yet
578
    /// </summary>
579
    /// <param name="controlGuid"></param>
580
    /// <returns></returns>
581
    public static int GetSplitterDistance(Guid controlGuid) =>
UNCOV
582
        AppSettings.GetValueOrDefault($"SplitterDistance_{controlGuid:N}", -1);
×
583

584
    /// <summary>
585
    /// Records that the user has manaully changed the splitter distance of the Control
586
    /// who is identified by <paramref name="controlGuid"/>
587
    /// </summary>
588
    /// <param name="controlGuid"></param>
589
    /// <param name="splitterDistance"></param>
590
    public static void SetSplitterDistance(Guid controlGuid, int splitterDistance)
591
    {
UNCOV
592
        lock (_oLockUserSettings)
×
593
        {
UNCOV
594
            AppSettings.AddOrUpdateValue($"SplitterDistance_{controlGuid:N}", splitterDistance);
×
595
        }
×
596
    }
×
597

598
    public static void ClearUserSettings()
599
    {
600
        AppSettings.Clear();
2✔
601
    }
2✔
602
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc