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

HicServices / RDMP / 19129827733

06 Nov 2025 08:43AM UTC coverage: 57.107% (-0.3%) from 57.409%
19129827733

push

github

web-flow
Merge branch 'develop' into dependabot/nuget/develop/NUnit.Analyzers-4.7.0

11418 of 21469 branches covered (53.18%)

Branch coverage included in aggregate %.

201 of 873 new or added lines in 49 files covered. (23.02%)

65 existing lines in 14 files now uncovered.

32412 of 55282 relevant lines covered (58.63%)

17586.73 hits per line

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

34.9
/Rdmp.Core/ReusableLibraryCode/Settings/UserSettings.cs
1
// Copyright (c) The University of Dundee 2018-2024
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.IO;
10
using System.Linq;
11
using FAnsi.Discovery;
12
using Rdmp.Core.ReusableLibraryCode.Checks;
13

14
namespace Rdmp.Core.ReusableLibraryCode.Settings;
15

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

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

30

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

37
    public static string LocalFileSystemLocation 
38
    {
39
        get => AppSettings.GetValueOrDefault("LocalFileSystemLocation", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "rdmp")); 
×
40
        set => AppSettings.AddOrUpdateValue("LocalFileSystemLocation", value);
×
41
    }
42

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

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

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

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

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

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

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

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

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

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

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

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

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

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

173

174
    public static bool PromptRenameOnCohortFilterChange
175
    {
176
        get => AppSettings.GetValueOrDefault("PromptRenameOnCohortFilterChange", true);
×
177
        set => AppSettings.AddOrUpdateValue("PromptRenameOnCohortFilterChange", value);
×
178
    }
179

180
    public static bool NewFindAndReplace
181
    {
182
        get => AppSettings.GetValueOrDefault("NewFindAndReplace", false);
×
183
        set => AppSettings.AddOrUpdateValue("NewFindAndReplace", value);
×
184
    }
185

186

187
    public static string ExtractionWebhookUsername
188
    {
NEW
189
        get => AppSettings.GetValueOrDefault("ExtractionWebhookUsername", null);
×
NEW
190
        set => AppSettings.AddOrUpdateValue("ExtractionWebhookUsername", value);
×
191
    }
192
    public static string ExtractionWebhookUrl
193
    {
194
        get => AppSettings.GetValueOrDefault("ExtractionWebhookUrl", null);
28✔
NEW
195
        set => AppSettings.AddOrUpdateValue("ExtractionWebhookUrl", value);
×
196
    }
197

198
    public static bool DefaultLogViewFlat
199
    {
NEW
200
        get => AppSettings.GetValueOrDefault("DefaultLogViewFlat", false);
×
NEW
201
        set => AppSettings.AddOrUpdateValue("DefaultLogViewFlat", value);
×
202
    }
203

204
    #region Catalogue flag visibility settings
205

206
    public static bool ShowInternalCatalogues
207
    {
208
        get => AppSettings.GetValueOrDefault("ShowInternalCatalogues", true);
24✔
209
        set => AppSettings.AddOrUpdateValue("ShowInternalCatalogues", value);
32✔
210
    }
211

212
    public static bool ShowDeprecatedCatalogues
213
    {
214
        get => AppSettings.GetValueOrDefault("ShowDeprecatedCatalogues", true);
24✔
215
        set => AppSettings.AddOrUpdateValue("ShowDeprecatedCatalogues", value);
32✔
216
    }
217

218
    public static bool ShowProjectSpecificCatalogues
219
    {
220
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificCatalogues", true);
24✔
221
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificCatalogues", value);
32✔
222
    }
223

224
    /// <summary>
225
    /// True to apply theme changes to context menus and tool strips.
226
    /// </summary>
227
    public static bool ApplyThemeToMenus
228
    {
229
        get => AppSettings.GetValueOrDefault("ApplyThemeToMenus", true);
×
230
        set => AppSettings.AddOrUpdateValue("ApplyThemeToMenus", value);
×
231
    }
232

233
    /// <summary>
234
    /// Determines line wrapping in multi line editor controls when lines stretch off the control client area
235
    /// </summary>
236
    public static int WrapMode
237
    {
238
        get => AppSettings.GetValueOrDefault("WrapMode", 0);
40✔
239
        set => AppSettings.AddOrUpdateValue("WrapMode", value);
×
240
    }
241

242
    /// <summary>
243
    /// <para>Base colours used for generating heatmaps in HEX format.  Colour intensity will vary
244
    /// from the first color to the second.</para>
245
    /// 
246
    /// <para>The first colour represents the lowest values and should
247
    /// typically be darker than the second which represents high values.</para>
248
    /// </summary>
249
    public static string HeatMapColours
250
    {
251
        get => AppSettings.GetValueOrDefault("HeatMapColours", null);
×
252
        set => AppSettings.AddOrUpdateValue("HeatMapColours", value);
×
253
    }
254

255
    /// <summary>
256
    /// <para>Adds a 5 second delay after startup</para>
257
    /// <para>Use this option to add a delay that can be helpful for troubleshooting issues on RDMP startup. </para>
258
    /// </summary>
259
    public static bool Wait5SecondsAfterStartupUI
260
    {
261
        get => AppSettings.GetValueOrDefault("Wait5SecondsAfterStartupUI", true);
10✔
262
        set => AppSettings.AddOrUpdateValue("Wait5SecondsAfterStartupUI", value);
12✔
263
    }
264

265
    /// <summary>
266
    /// True to show the cohort creation wizard when creating new cohorts.  False to create
267
    /// a default empty configuration.
268
    /// </summary>
269
    public static bool ShowCohortWizard
270
    {
271
        get => AppSettings.GetValueOrDefault("ShowCohortWizard", false);
×
272
        set => AppSettings.AddOrUpdateValue("ShowCohortWizard", value);
×
273
    }
274

275
    /// <summary>
276
    /// <para>True to enable "stirct validation" for containers in Cohort Builder Queries.</para>
277
    ///
278
    /// <para>Will not allow empty sets, or sets that only have one item.</para>
279
    /// </summary>
280
    public static bool StrictValidationForCohortBuilderContainers
281
    {
282
        get => AppSettings.GetValueOrDefault("StrictValidationForCohortBuilderContainers", true);
38✔
283
        set => AppSettings.AddOrUpdateValue("StrictValidationForCohortBuilderContainers", value);
×
284
    }
285

286
    /// <summary>
287
    /// Changes the behaviour of mouse double clicks in tree views.  When enabled double
288
    /// click expands nodes instead of opening the double clicked object (the default behaviour).
289
    /// </summary>
290
    public static bool DoubleClickToExpand
291
    {
292
        get => AppSettings.GetValueOrDefault("DoubleClickToExpand", false);
×
293
        set => AppSettings.AddOrUpdateValue("DoubleClickToExpand", value);
×
294
    }
295

296
    public static string RecentHistory
297
    {
298
        get => AppSettings.GetValueOrDefault("RecentHistory", "");
60✔
299
        set => AppSettings.AddOrUpdateValue("RecentHistory", value);
18✔
300
    }
301

302
    /// <summary>
303
    /// <para>When enabled RDMP will record certain performance related metrics (how long refresh takes etc).</para>
304
    /// <para>These figures are completely internal to the application and are not transmitted anywhere.You can view the results in the toolbar.</para>
305
    /// </summary>
306
    public static bool DebugPerformance
307
    {
308
        get => AppSettings.GetValueOrDefault("DebugPerformance", false);
49,986✔
309
        set => AppSettings.AddOrUpdateValue("DebugPerformance", value);
×
310
    }
311

312
    /// <summary>
313
    /// <para>Automatically resize columns in the RDMP user interface with fit contents.</para>
314
    /// <para>Can be disabled if problems arise with column content or header visibility</para>
315
    /// </summary>
316
    public static bool AutoResizeColumns
317
    {
318
        get => AppSettings.GetValueOrDefault("AutoResizeColumns", true);
30✔
319
        set => AppSettings.AddOrUpdateValue("AutoResizeColumns", value);
×
320
    }
321

322

323
    /// <summary>
324
    /// Show a popup confirmation dialog at the end of a pipeline completing execution
325
    /// </summary>
326
    public static bool ShowPipelineCompletedPopup
327
    {
328
        get => AppSettings.GetValueOrDefault("ShowPipelineCompletedPopup", true);
×
329
        set => AppSettings.AddOrUpdateValue("ShowPipelineCompletedPopup", value);
×
330
    }
331

332
    /// <summary>
333
    /// <para>Enable to skip the checking stage of pipeline source component CohortIdentificationConfigurationSource.</para>
334
    /// <para>In slow computer, or contesest databases this can take a while to compile. This option lets you disable it.</para>
335
    /// </summary>
336
    public static bool SkipCohortBuilderValidationOnCommit
337
    {
338
        get => AppSettings.GetValueOrDefault("SkipCohortBuilderValidationOnCommit", false);
×
339
        set => AppSettings.AddOrUpdateValue("SkipCohortBuilderValidationOnCommit", value);
×
340
    }
341

342
    public static string ConsoleColorScheme
343
    {
344
        get => AppSettings.GetValueOrDefault("ConsoleColorScheme", "default");
×
345
        set => AppSettings.AddOrUpdateValue("ConsoleColorScheme", value);
×
346
    }
347

348
    /// <summary>
349
    /// <para>When true RDMP log viewer will hide table load audits where no inserts/updates/deletes were applied.</para>
350
    /// <para>This is helpful if a load targets many tables not all of which will be updated in a given run</para>
351
    /// </summary>
352
    public static bool HideEmptyTableLoadRunAudits
353
    {
354
        get => AppSettings.GetValueOrDefault("HideEmptyTableLoadRunAudits", false);
×
355
        set => AppSettings.AddOrUpdateValue("HideEmptyTableLoadRunAudits", value);
×
356
    }
357

358
    /// <summary>
359
    /// <para>Enables additional Find filters for objects that are in:</para>
360
    /// <para>Cold Storage, Internal, Deprecated, Project Specific and Non Extractable</para>
361
    /// </summary>
362
    public static bool AdvancedFindFilters
363
    {
364
        get => AppSettings.GetValueOrDefault("AdvancedFindFilters", false);
×
365
        set => AppSettings.AddOrUpdateValue("AdvancedFindFilters", value);
×
366
    }
367

368
    /// <summary>
369
    /// Timeout in seconds to allow for creating archive trigger, index etc
370
    /// </summary>
371
    public static int ArchiveTriggerTimeout
372
    {
373
        get => AppSettings.GetValueOrDefault("ArchiveTriggerTimeout", 30);
1,380✔
374
        set => AppSettings.AddOrUpdateValue("ArchiveTriggerTimeout", value);
×
375
    }
376

377
    public static int FindWindowWidth
378
    {
379
        get => AppSettings.GetValueOrDefault("FindWindowWidth", 730);
×
380
        set => AppSettings.AddOrUpdateValue("FindWindowWidth", value);
×
381
    }
382

383
    public static int FindWindowHeight
384
    {
385
        get => AppSettings.GetValueOrDefault("FindWindowHeight", 400);
×
386
        set => AppSettings.AddOrUpdateValue("FindWindowHeight", value);
×
387
    }
388

389
    /// <summary>
390
    /// Enable to refresh only objects which you make changes to instead of
391
    /// fetching all database changes since your last edit.  This improves
392
    /// performance in large RDMP deployments with thousands of Projects configured.
393
    /// </summary>
394
    public static bool SelectiveRefresh
395
    {
396
        get => AppSettings.GetValueOrDefault("SelectiveRefresh", false);
454✔
397
        set => AppSettings.AddOrUpdateValue("SelectiveRefresh", value);
×
398
    }
399

400
    /// <summary>
401
    /// Set to true to always attempt to force joins on all tables under a Catalogue
402
    /// when building queries (in Cohort Builder).  This makes it impossible to untick
403
    /// force joins.
404
    /// </summary>
405
    public static bool AlwaysJoinEverything
406
    {
407
        get => AppSettings.GetValueOrDefault("AlwaysJoinEverything", false);
676✔
408
        set => AppSettings.AddOrUpdateValue("AlwaysJoinEverything", value);
×
409
    }
410

411
    /// <summary>
412
    /// <para>
413
    /// Determines whether queries are automatically sent and results displayed in
414
    /// data tabs in RDMP (e.g. View top 100 etc).  Enable to automatically send the
415
    /// queries.  Disable to show the SQL but require the user to press F5 or click Run
416
    /// to execute.
417
    /// </para>
418
    /// </summary>
419
    public static bool AutoRunSqlQueries
420
    {
421
        get => AppSettings.GetValueOrDefault("AutoRunSqlQueries", false);
×
422
        set => AppSettings.AddOrUpdateValue("AutoRunSqlQueries", value);
×
423
    }
424

425
    /// <summary>
426
    /// Enable to automatically expand the tree when opening or creating cohorts in
427
    /// Cohort Builder
428
    /// </summary>
429
    public static bool ExpandAllInCohortBuilder
430
    {
431
        get => AppSettings.GetValueOrDefault("ExpandAllInCohortBuilder", true);
2✔
432
        set => AppSettings.AddOrUpdateValue("ExpandAllInCohortBuilder", value);
×
433
    }
434

435
    /// <summary>
436
    /// True to show ProjectSpecific Catalogues' columns in extraction configuration user interface
437
    /// </summary>
438
    public static bool ShowProjectSpecificColumns
439
    {
440
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificColumns", true);
18✔
441
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificColumns", value);
×
442
    }
443

444
    /// <summary>
445
    /// <para>When generating an aggregate graph, use the column alias instead of the select sql.  For example
446
    /// when you have the select column 'SELECT YEAR(dt) as myYear' then the GROUP BY will default to
447
    /// 'GROUP BY YEAR(dt)'.  Setting this property to true will instead use 'GROUP BY myYear'.  Typically
448
    /// this only works in MySql but it is not universally supported by all MySql versions and server settings
449
    /// </para>
450
    /// <para>Defaults to false.</para>
451
    /// </summary>
452
    public static bool UseAliasInsteadOfTransformInGroupByAggregateGraphs
453
    {
454
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificColumns", false);
292✔
455
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificColumns", value);
8✔
456
    }
457

458
    #endregion
459

460
    /// <summary>
461
    /// Returns the error level the user wants for <paramref name="errorCode"/> or <see cref="ErrorCode.DefaultTreatment"/> (if no custom
462
    /// reporting level has been set up for this error code).
463
    /// </summary>
464
    /// <param name="errorCode"></param>
465
    /// <returns></returns>
466
    public static CheckResult GetErrorReportingLevelFor(ErrorCode errorCode)
467
    {
468
        var result = AppSettings.GetValueOrDefault($"EC_{errorCode.Code}", errorCode.DefaultTreatment.ToString());
32✔
469

470
        return Enum.Parse<CheckResult>(result);
32✔
471
    }
472

473
    /// <summary>
474
    /// Changes the reporting level of the given error to <paramref name="value"/> instead of its <see cref="ErrorCode.DefaultTreatment"/>
475
    /// </summary>
476
    /// <param name="errorCode"></param>
477
    /// <param name="value"></param>
478
    public static void SetErrorReportingLevelFor(ErrorCode errorCode, CheckResult value)
479
    {
480
        AppSettings.AddOrUpdateValue($"EC_{errorCode.Code}", value.ToString());
16✔
481
    }
16✔
482

483
    public static bool GetTutorialDone(Guid tutorialGuid) =>
484
        tutorialGuid != Guid.Empty && AppSettings.GetValueOrDefault($"T_{tutorialGuid:N}", false);
×
485

486
    public static void SetTutorialDone(Guid tutorialGuid, bool value)
487
    {
488
        if (tutorialGuid == Guid.Empty)
×
489
            return;
×
490

491
        AppSettings.AddOrUpdateValue($"T_{tutorialGuid:N}", value);
×
492
    }
×
493

494
    public static void SetColumnWidth(Guid columnGuid, int width)
495
    {
496
        if (columnGuid == Guid.Empty)
3,132!
497
            return;
×
498
        SetColumnWidth(columnGuid.ToString("N"), width);
3,132✔
499
    }
3,132✔
500

501
    public static void SetColumnWidth(string colIdentifier, int width)
502
    {
503
        AppSettings.AddOrUpdateValue($"ColW_{colIdentifier}", width);
3,132✔
504
    }
3,132✔
505

506
    public static void SetColumnVisible(Guid columnGuid, bool visible)
507
    {
508
        if (columnGuid == Guid.Empty)
×
509
            return;
×
510

511
        SetColumnVisible(columnGuid.ToString("N"), visible);
×
512
    }
×
513

514
    public static void SetColumnVisible(string colIdentifier, bool visible)
515
    {
516
        AppSettings.AddOrUpdateValue($"ColV_{colIdentifier}", visible);
×
517
    }
×
518

519
    public static int GetColumnWidth(Guid columnGuid) =>
520
        columnGuid == Guid.Empty ? 100 : GetColumnWidth(columnGuid.ToString("N"));
128!
521

522
    public static int GetColumnWidth(string colIdentifier) =>
523
        AppSettings.GetValueOrDefault($"ColW_{colIdentifier}", 100);
128✔
524

525
    public static bool GetColumnVisible(Guid columnGuid) =>
526
        columnGuid == Guid.Empty || GetColumnVisible(columnGuid.ToString("N"));
128!
527

528
    public static bool GetColumnVisible(string colIdentifier) =>
529
        AppSettings.GetValueOrDefault($"ColV_{colIdentifier}", true);
128✔
530

531
    public static string[] GetHistoryForControl(Guid controlGuid)
532
    {
533
        return AppSettings.GetValueOrDefault($"A_{controlGuid:N}", "").Split(new[] { "#!#" }, StringSplitOptions.None);
22✔
534
    }
535

536
    public static void SetHistoryForControl(Guid controlGuid, IEnumerable<string> history)
537
    {
538
        AppSettings.AddOrUpdateValue($"A_{controlGuid:N}", string.Join("#!#", history));
204✔
539
    }
204✔
540

541
    public static void AddHistoryForControl(Guid guid, string v)
542
    {
543
        if (string.IsNullOrWhiteSpace(v))
×
544
            return;
×
545

546
        var l = GetHistoryForControl(guid).ToList();
×
547

548
        if (l.Contains(v))
×
549
            return;
×
550

551
        l.Add(v);
×
552

553
        SetHistoryForControl(guid, l.Distinct().ToList());
×
554
    }
×
555

556
    public static Tuple<string, bool> GetLastColumnSortForCollection(Guid controlGuid)
557
    {
558
        lock (_oLockUserSettings)
2✔
559
        {
560
            var value = AppSettings.GetValueOrDefault($"LastColumnSort_{controlGuid:N}", null);
2✔
561

562
            //if we don't have a value
563
            if (string.IsNullOrWhiteSpace(value))
2!
564
                return null;
2✔
565

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

568
            //or it doesn't split properly
569
            if (args.Length != 2)
×
570
                return null;
×
571

572
            //or either element is null
573
            if (string.IsNullOrWhiteSpace(args[0]) || string.IsNullOrWhiteSpace(args[1]))
×
574
                return null;
×
575

576
            if (bool.TryParse(args[1], out var ascending))
×
577
                return Tuple.Create(args[0], ascending);
×
578
        }
×
579

580
        return null;
×
581
    }
2✔
582

583
    private static object _oLockUserSettings = new();
4✔
584

585
    public static void SetLastColumnSortForCollection(Guid controlGuid, string columnName, bool ascending)
586
    {
587
        lock (_oLockUserSettings)
2✔
588
        {
589
            AppSettings.AddOrUpdateValue($"LastColumnSort_{controlGuid:N}", $"{columnName}#!#{ascending}");
2✔
590
        }
2✔
591
    }
2✔
592

593

594
    /// <summary>
595
    /// Returns the last known manually set splitter distance for the Control who is
596
    /// identified by <paramref name="controlGuid"/> or -1 if none set yet
597
    /// </summary>
598
    /// <param name="controlGuid"></param>
599
    /// <returns></returns>
600
    public static int GetSplitterDistance(Guid controlGuid) =>
601
        AppSettings.GetValueOrDefault($"SplitterDistance_{controlGuid:N}", -1);
×
602

603
    /// <summary>
604
    /// Records that the user has manually changed the splitter distance of the Control
605
    /// who is identified by <paramref name="controlGuid"/>
606
    /// </summary>
607
    /// <param name="controlGuid"></param>
608
    /// <param name="splitterDistance"></param>
609
    public static void SetSplitterDistance(Guid controlGuid, int splitterDistance)
610
    {
611
        lock (_oLockUserSettings)
×
612
        {
613
            AppSettings.AddOrUpdateValue($"SplitterDistance_{controlGuid:N}", splitterDistance);
×
614
        }
×
615
    }
×
616

617
    public static void ClearUserSettings()
618
    {
619
        AppSettings.Clear();
2✔
620
    }
2✔
621
}
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