@@ -70,30 +70,44 @@ public static Configuration LoadConfig()
7070 config = GetDefaultConfig ( ) ;
7171 }
7272
73- if ( isDirty ) {
73+ if ( isDirty )
74+ {
7475 config . Save ( ) ;
7576 }
7677
7778 return config ;
7879 }
7980
80- public void ColorStrategyChange ( int Strategy ) {
81+ public void ColorStrategyChange ( int Strategy )
82+ {
8183 this . StagedColorStrategy = ( ColorStrategy ) Strategy ;
8284 }
8385
84- public void NamingStrategyChange ( int Strategy ) {
86+ public void NamingStrategyChange ( int Strategy )
87+ {
8588 this . StagedNamingStrategy = ( NamingStrategy ) Strategy ;
8689 }
8790
88- public void MinColorDiffChange ( float MinDiff ) {
91+ public void MinColorDiffChange ( float MinDiff )
92+ {
8993 this . StagedMinColorDiffPercentage = ( int ) MinDiff ;
9094 }
9195
92- public void MaxDiffColorPickChange ( float MaxColorPicks ) {
96+ public void MaxDiffColorPickChange ( float MaxColorPicks )
97+ {
9398 this . StagedMaxDiffColorPickAttempt = ( int ) MaxColorPicks ;
9499 }
95100
96- public void Save ( ) {
101+ public void FlushStagedChanges ( )
102+ {
103+ StagedColorStrategy = null ;
104+ StagedNamingStrategy = null ;
105+ StagedMaxDiffColorPickAttempt = null ;
106+ StagedMinColorDiffPercentage = null ;
107+ }
108+
109+ public void Save ( )
110+ {
97111 var serializer = new XmlSerializer ( typeof ( Configuration ) ) ;
98112
99113 logger . Message ( "Saving changes to config file" ) ;
@@ -115,26 +129,28 @@ public void Save() {
115129 : this . MinColorDiffPercentage ;
116130
117131 //clear changes and log
118- if ( this . StagedColorStrategy . HasValue ) {
132+ if ( this . StagedColorStrategy . HasValue )
133+ {
119134 logger . Message ( "ColorStrategy changed to " + this . StagedColorStrategy . Value . ToString ( ) ) ;
120- this . StagedColorStrategy = null ;
121135 }
122136
123- if ( this . StagedNamingStrategy . HasValue ) {
137+ if ( this . StagedNamingStrategy . HasValue )
138+ {
124139 logger . Message ( "NamingStrategy changed to " + this . StagedNamingStrategy . Value . ToString ( ) ) ;
125- this . StagedNamingStrategy = null ;
126140 }
127141
128- if ( this . StagedMaxDiffColorPickAttempt . HasValue ) {
142+ if ( this . StagedMaxDiffColorPickAttempt . HasValue )
143+ {
129144 logger . Message ( "MaxDiffColorPickAttempt changed to " + this . StagedMaxDiffColorPickAttempt . Value . ToString ( ) ) ;
130- this . StagedMaxDiffColorPickAttempt = null ;
131145 }
132146
133- if ( this . StagedMinColorDiffPercentage . HasValue ) {
147+ if ( this . StagedMinColorDiffPercentage . HasValue )
148+ {
134149 logger . Message ( "MinColorDiffPercentage changed to " + this . StagedMinColorDiffPercentage . Value . ToString ( ) ) ;
135- this . StagedMinColorDiffPercentage = null ;
136150 }
137151
152+ FlushStagedChanges ( ) ;
153+
138154 //How we let the ColorMonitor thread know to update the strategies
139155 logger . Message ( "Marking undigested changes" ) ;
140156 this . UndigestedChanges = true ;
0 commit comments