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

HicServices / RDMP / 15165437080

21 May 2025 02:51PM UTC coverage: 57.32% (-0.06%) from 57.38%
15165437080

push

github

web-flow
Merge pull request #2196 from HicServices/task/RDMP-93-extraction-complete-notification

Task/rdmp 93 extraction complete notification

11363 of 21368 branches covered (53.18%)

Branch coverage included in aggregate %.

3 of 83 new or added lines in 3 files covered. (3.61%)

32291 of 54790 relevant lines covered (58.94%)

17456.64 hits per line

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

36.6
/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 ??
48,600!
27
                                                          throw new NotImplementedException(
48,600✔
28
                                                              "Isolated Storage does not work in this environment...");
48,600✔
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);
50✔
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
    #region Catalogue flag visibility settings
199

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

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

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

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

224
    public static bool ShowNonExtractableCatalogues
225
    {
226
        get => AppSettings.GetValueOrDefault("ShowNonExtractableCatalogues", true);
40✔
227
        set => AppSettings.AddOrUpdateValue("ShowNonExtractableCatalogues", value);
48✔
228
    }
229

230
    /// <summary>
231
    /// True to apply theme changes to context menus and tool strips.
232
    /// </summary>
233
    public static bool ApplyThemeToMenus
234
    {
235
        get => AppSettings.GetValueOrDefault("ApplyThemeToMenus", true);
×
236
        set => AppSettings.AddOrUpdateValue("ApplyThemeToMenus", value);
×
237
    }
238

239
    /// <summary>
240
    /// Determines line wrapping in multi line editor controls when lines stretch off the control client area
241
    /// </summary>
242
    public static int WrapMode
243
    {
244
        get => AppSettings.GetValueOrDefault("WrapMode", 0);
40✔
245
        set => AppSettings.AddOrUpdateValue("WrapMode", value);
×
246
    }
247

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

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

271
    /// <summary>
272
    /// True to show the cohort creation wizard when creating new cohorts.  False to create
273
    /// a default empty configuration.
274
    /// </summary>
275
    public static bool ShowCohortWizard
276
    {
277
        get => AppSettings.GetValueOrDefault("ShowCohortWizard", false);
×
278
        set => AppSettings.AddOrUpdateValue("ShowCohortWizard", value);
×
279
    }
280

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

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

302
    public static string RecentHistory
303
    {
304
        get => AppSettings.GetValueOrDefault("RecentHistory", "");
60✔
305
        set => AppSettings.AddOrUpdateValue("RecentHistory", value);
18✔
306
    }
307

308
    /// <summary>
309
    /// <para>When enabled RDMP will record certain performance related metrics (how long refresh takes etc).</para>
310
    /// <para>These figures are completely internal to the application and are not transmitted anywhere.You can view the results in the toolbar.</para>
311
    /// </summary>
312
    public static bool DebugPerformance
313
    {
314
        get => AppSettings.GetValueOrDefault("DebugPerformance", false);
41,518✔
315
        set => AppSettings.AddOrUpdateValue("DebugPerformance", value);
×
316
    }
317

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

328

329
    /// <summary>
330
    /// Show a popup confirmation dialog at the end of a pipeline completing execution
331
    /// </summary>
332
    public static bool ShowPipelineCompletedPopup
333
    {
334
        get => AppSettings.GetValueOrDefault("ShowPipelineCompletedPopup", true);
×
335
        set => AppSettings.AddOrUpdateValue("ShowPipelineCompletedPopup", value);
×
336
    }
337

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

348
    public static string ConsoleColorScheme
349
    {
350
        get => AppSettings.GetValueOrDefault("ConsoleColorScheme", "default");
×
351
        set => AppSettings.AddOrUpdateValue("ConsoleColorScheme", value);
×
352
    }
353

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

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

374
    /// <summary>
375
    /// Timeout in seconds to allow for creating archive trigger, index etc
376
    /// </summary>
377
    public static int ArchiveTriggerTimeout
378
    {
379
        get => AppSettings.GetValueOrDefault("ArchiveTriggerTimeout", 30);
1,380✔
380
        set => AppSettings.AddOrUpdateValue("ArchiveTriggerTimeout", value);
×
381
    }
382

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

389
    public static int FindWindowHeight
390
    {
391
        get => AppSettings.GetValueOrDefault("FindWindowHeight", 400);
×
392
        set => AppSettings.AddOrUpdateValue("FindWindowHeight", value);
×
393
    }
394

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

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

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

431
    /// <summary>
432
    /// Enable to automatically expand the tree when opening or creating cohorts in
433
    /// Cohort Builder
434
    /// </summary>
435
    public static bool ExpandAllInCohortBuilder
436
    {
437
        get => AppSettings.GetValueOrDefault("ExpandAllInCohortBuilder", true);
2✔
438
        set => AppSettings.AddOrUpdateValue("ExpandAllInCohortBuilder", value);
×
439
    }
440

441
    /// <summary>
442
    /// True to show ProjectSpecific Catalogues' columns in extraction configuration user interface
443
    /// </summary>
444
    public static bool ShowProjectSpecificColumns
445
    {
446
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificColumns", true);
18✔
447
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificColumns", value);
×
448
    }
449

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

464
    #endregion
465

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

476
        return Enum.Parse<CheckResult>(result);
32✔
477
    }
478

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

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

492
    public static void SetTutorialDone(Guid tutorialGuid, bool value)
493
    {
494
        if (tutorialGuid == Guid.Empty)
×
495
            return;
×
496

497
        AppSettings.AddOrUpdateValue($"T_{tutorialGuid:N}", value);
×
498
    }
×
499

500
    public static void SetColumnWidth(Guid columnGuid, int width)
501
    {
502
        if (columnGuid == Guid.Empty)
3,132!
503
            return;
×
504
        SetColumnWidth(columnGuid.ToString("N"), width);
3,132✔
505
    }
3,132✔
506

507
    public static void SetColumnWidth(string colIdentifier, int width)
508
    {
509
        AppSettings.AddOrUpdateValue($"ColW_{colIdentifier}", width);
3,132✔
510
    }
3,132✔
511

512
    public static void SetColumnVisible(Guid columnGuid, bool visible)
513
    {
514
        if (columnGuid == Guid.Empty)
×
515
            return;
×
516

517
        SetColumnVisible(columnGuid.ToString("N"), visible);
×
518
    }
×
519

520
    public static void SetColumnVisible(string colIdentifier, bool visible)
521
    {
522
        AppSettings.AddOrUpdateValue($"ColV_{colIdentifier}", visible);
×
523
    }
×
524

525
    public static int GetColumnWidth(Guid columnGuid) =>
526
        columnGuid == Guid.Empty ? 100 : GetColumnWidth(columnGuid.ToString("N"));
128!
527

528
    public static int GetColumnWidth(string colIdentifier) =>
529
        AppSettings.GetValueOrDefault($"ColW_{colIdentifier}", 100);
128✔
530

531
    public static bool GetColumnVisible(Guid columnGuid) =>
532
        columnGuid == Guid.Empty || GetColumnVisible(columnGuid.ToString("N"));
128!
533

534
    public static bool GetColumnVisible(string colIdentifier) =>
535
        AppSettings.GetValueOrDefault($"ColV_{colIdentifier}", true);
128✔
536

537
    public static string[] GetHistoryForControl(Guid controlGuid)
538
    {
539
        return AppSettings.GetValueOrDefault($"A_{controlGuid:N}", "").Split(new[] { "#!#" }, StringSplitOptions.None);
22✔
540
    }
541

542
    public static void SetHistoryForControl(Guid controlGuid, IEnumerable<string> history)
543
    {
544
        AppSettings.AddOrUpdateValue($"A_{controlGuid:N}", string.Join("#!#", history));
204✔
545
    }
204✔
546

547
    public static void AddHistoryForControl(Guid guid, string v)
548
    {
549
        if (string.IsNullOrWhiteSpace(v))
×
550
            return;
×
551

552
        var l = GetHistoryForControl(guid).ToList();
×
553

554
        if (l.Contains(v))
×
555
            return;
×
556

557
        l.Add(v);
×
558

559
        SetHistoryForControl(guid, l.Distinct().ToList());
×
560
    }
×
561

562
    public static Tuple<string, bool> GetLastColumnSortForCollection(Guid controlGuid)
563
    {
564
        lock (_oLockUserSettings)
2✔
565
        {
566
            var value = AppSettings.GetValueOrDefault($"LastColumnSort_{controlGuid:N}", null);
2✔
567

568
            //if we don't have a value
569
            if (string.IsNullOrWhiteSpace(value))
2!
570
                return null;
2✔
571

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

574
            //or it doesn't split properly
575
            if (args.Length != 2)
×
576
                return null;
×
577

578
            //or either element is null
579
            if (string.IsNullOrWhiteSpace(args[0]) || string.IsNullOrWhiteSpace(args[1]))
×
580
                return null;
×
581

582
            if (bool.TryParse(args[1], out var ascending))
×
583
                return Tuple.Create(args[0], ascending);
×
584
        }
×
585

586
        return null;
×
587
    }
2✔
588

589
    private static object _oLockUserSettings = new();
4✔
590

591
    public static void SetLastColumnSortForCollection(Guid controlGuid, string columnName, bool ascending)
592
    {
593
        lock (_oLockUserSettings)
2✔
594
        {
595
            AppSettings.AddOrUpdateValue($"LastColumnSort_{controlGuid:N}", $"{columnName}#!#{ascending}");
2✔
596
        }
2✔
597
    }
2✔
598

599

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

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

623
    public static void ClearUserSettings()
624
    {
625
        AppSettings.Clear();
2✔
626
    }
2✔
627
}
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