Skip to content

Commit

Permalink
Refactor: Changed format of settings and added a settings file, right…
Browse files Browse the repository at this point in the history
… now this is write only
  • Loading branch information
crcrewso committed Feb 19, 2024
1 parent b1d6e8b commit 9567f6c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 18 deletions.
49 changes: 31 additions & 18 deletions DicomStrictCompare/DSCcore/Controller/settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,54 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Collections.Specialized;
using System.Runtime.CompilerServices;

namespace DCSCore.Controller
{
/// <summary>
/// Consolidated settings collection to undo feature creep spaghettification.
/// </summary>
public class Settings
public class Settings(
Model.Dta[] dtas
, bool runDoseComparisons
, bool runPDDComparisons
, bool runProfileComparisons
, int coresIn = 4
)
{

/// <summary>
/// Simple dta algorithm for fractional DTA adjustment
/// </summary>


public Model.Dta[] Dtas { get; }
public bool RunDoseComparisons { get; }
public bool RunPDDComparisons { get; }
public bool RunProfileComparisons { get; }
public int CpuParallel { get; private set; } = 1;
public Model.Dta[] Dtas { get; } = dtas;
public bool RunDoseComparisons { get; } = runDoseComparisons;
public bool RunPDDComparisons { get; } = runPDDComparisons;
public bool RunProfileComparisons { get; } = runProfileComparisons;
public int CpuParallel { get; private set; } = Math.Min(coresIn, Environment.ProcessorCount);

public Settings(
DCSCore.Model.Dta[] dtas
, bool runDoseComparisons
, bool runPDDComparisons
, bool runProfileComparisons
, int coresIn
)
public void Save()
{
Dtas = dtas;
RunDoseComparisons = runDoseComparisons;
RunPDDComparisons = runPDDComparisons;
RunProfileComparisons = runProfileComparisons;
CpuParallel = Math.Min(coresIn, Environment.ProcessorCount);
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = config.AppSettings.Settings;

//settings["RunDoseComparisons"].Value = RunDoseComparisons.ToString();
//settings["RunPDDComparisons"].Value = RunPDDComparisons.ToString();
//settings["RunProfileComparisons"].Value = RunProfileComparisons.ToString();
settings["CpuParallel"].Value = CpuParallel.ToString() ;

config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name);

}



}



}
26 changes: 26 additions & 0 deletions DicomStrictCompare/DSCcore/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions DicomStrictCompare/DSCcore/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>

0 comments on commit 9567f6c

Please sign in to comment.