@@ -112,15 +112,18 @@ public void SaveToFile(string configFilePath)
112112 }
113113 }
114114
115+ private bool isPortable = true ;
115116 public bool IsPortable
116117 {
117118 get
118119 {
119- return GetValue ( "portable" , true ) ;
120+ return isPortable ;
120121 }
121122 set
122123 {
123- SetValue ( "portable" , value ) ;
124+ if ( isPortable == value ) return ;
125+ isPortable = value ;
126+ Save ( ) ;
124127 }
125128 }
126129
@@ -131,6 +134,7 @@ public bool Contains(string name)
131134
132135 public void SetValue ( string name , string value )
133136 {
137+ if ( _settings . TryGetValue ( name , out var prevValue ) && prevValue == value ) return ;
134138 _settings [ name ] = value ;
135139 Save ( ) ;
136140 }
@@ -152,6 +156,7 @@ public void Remove(string name)
152156
153157 public void SetValue ( string name , int value )
154158 {
159+ if ( _settings . TryGetValue ( name , out var prevValue ) && int . TryParse ( prevValue , out var oldValue ) && oldValue == value ) return ;
155160 _settings [ name ] = value . ToString ( ) ;
156161 Save ( ) ;
157162 }
@@ -172,6 +177,7 @@ public int GetValue(string name, int value)
172177
173178 public void SetValue ( string name , float value )
174179 {
180+ if ( _settings . TryGetValue ( name , out var prevValue ) && float . TryParse ( prevValue , out var oldValue ) && oldValue == value ) return ;
175181 _settings [ name ] = value . ToString ( CultureInfo . InvariantCulture ) ;
176182 Save ( ) ;
177183 }
@@ -201,6 +207,7 @@ public double GetValue(string name, double value)
201207
202208 public void SetValue ( string name , bool value )
203209 {
210+ if ( _settings . TryGetValue ( name , out var prevValue ) && bool . TryParse ( prevValue , out var oldValue ) && oldValue == value ) return ;
204211 _settings [ name ] = value ? "true" : "false" ;
205212 Save ( ) ;
206213 }
@@ -217,6 +224,7 @@ public bool GetValue(string name, bool value)
217224
218225 public void SetValue ( string name , Color color )
219226 {
227+ if ( _settings . TryGetValue ( name , out var prevValue ) && int . TryParse ( prevValue , NumberStyles . HexNumber , CultureInfo . InvariantCulture , out int parsedValue ) && Color . FromArgb ( parsedValue ) == color ) return ;
220228 _settings [ name ] = color . ToArgb ( ) . ToString ( "X8" ) ;
221229 Save ( ) ;
222230 }
0 commit comments