@@ -11,7 +11,7 @@ namespace SPCode
1111 [ Serializable ]
1212 public class OptionsControl
1313 {
14- public static int SVersion = 13 ;
14+ public static int SVersion = 14 ;
1515 public bool Editor_AgressiveIndentation = true ;
1616 public bool Editor_AutoCloseBrackets = true ;
1717 public bool Editor_AutoCloseStringChars = true ;
@@ -84,6 +84,9 @@ public class OptionsControl
8484 // Version 13
8585 public SearchOptions SearchOptions ;
8686
87+ // Version 14
88+ public ActionOnClose ActionOnClose ;
89+
8790 public int Version = 11 ;
8891
8992 public void FillNullToDefaults ( )
@@ -195,7 +198,7 @@ public void NormalizeSHColors()
195198 SH_CommentsMarker = new SerializableColor ( 0xFF , 0xFF , 0x20 , 0x20 ) ;
196199 SH_Strings = new SerializableColor ( 0xFF , 0xF4 , 0x6B , 0x6C ) ;
197200 SH_PreProcessor = new SerializableColor ( 0xFF , 0x7E , 0x7E , 0x7E ) ;
198- SH_Types = new SerializableColor ( 0xFF , 0x28 , 0x90 , 0xB0 ) ; //56 9C D5
201+ SH_Types = new SerializableColor ( 0xFF , 0x28 , 0x90 , 0xB0 ) ;
199202 SH_TypesValues = new SerializableColor ( 0xFF , 0x56 , 0x9C , 0xD5 ) ;
200203 SH_Keywords = new SerializableColor ( 0xFF , 0x56 , 0x9C , 0xD5 ) ;
201204 SH_ContextKeywords = new SerializableColor ( 0xFF , 0x56 , 0x9C , 0xD5 ) ;
@@ -208,49 +211,7 @@ public void NormalizeSHColors()
208211 SH_Functions = new SerializableColor ( 0xFF , 0x56 , 0x9C , 0xD5 ) ;
209212 SH_Methods = new SerializableColor ( 0xFF , 0x3B , 0xC6 , 0x7E ) ;
210213 }
211- }
212-
213- [ Serializable ]
214- public class SerializableColor
215- {
216- public byte A ;
217- public byte B ;
218- public byte G ;
219- public byte R ;
220-
221- public SerializableColor ( byte _A , byte _R , byte _G , byte _B )
222- {
223- A = _A ;
224- R = _R ;
225- G = _G ;
226- B = _B ;
227- }
228214
229- public static implicit operator SerializableColor ( Color c )
230- {
231- return new SerializableColor ( c . A , c . R , c . G , c . B ) ;
232- }
233-
234- public static implicit operator Color ( SerializableColor c )
235- {
236- return Color . FromArgb ( c . A , c . R , c . G , c . B ) ;
237- }
238- }
239-
240- [ Serializable ]
241- public struct SearchOptions
242- {
243- public string FindText ;
244- public string ReplaceText ;
245- public int SearchType ;
246- public int Document ;
247- public bool CaseSensitive ;
248- public bool MultilineRegex ;
249- public int ReplaceType ;
250- }
251-
252- public static class OptionsControlIOObject
253- {
254215 public static void Save ( )
255216 {
256217 try
@@ -271,32 +232,79 @@ public static OptionsControl Load(out bool ProgramIsNew)
271232 {
272233 if ( File . Exists ( Paths . GetOptionsFilePath ( ) ) )
273234 {
274- object deserializedOptionsObj ;
235+ OptionsControl optionsObject ;
275236 var formatter = new BinaryFormatter ( ) ;
276237 using ( var fileStream = new FileStream ( Paths . GetOptionsFilePath ( ) , FileMode . Open , FileAccess . Read ,
277238 FileShare . ReadWrite ) )
278239 {
279- deserializedOptionsObj = formatter . Deserialize ( fileStream ) ;
240+ optionsObject = ( OptionsControl ) formatter . Deserialize ( fileStream ) ;
280241 }
281242
282- var oc = ( OptionsControl ) deserializedOptionsObj ;
283- oc . FillNullToDefaults ( ) ;
243+ optionsObject . FillNullToDefaults ( ) ;
284244 ProgramIsNew = false ;
285- return oc ;
245+ return optionsObject ;
286246 }
287247 }
288248 catch ( Exception )
289249 {
250+
290251 }
291252
292253 var oco = new OptionsControl ( ) ;
293254 oco . ReCreateCryptoKey ( ) ;
294255#if DEBUG
295- ProgramIsNew = false ;
256+ ProgramIsNew = false ;
296257#else
297258 ProgramIsNew = true ;
298259#endif
299260 return oco ;
300261 }
301262 }
263+
264+ [ Serializable ]
265+ public class SerializableColor
266+ {
267+ public byte A ;
268+ public byte B ;
269+ public byte G ;
270+ public byte R ;
271+
272+ public SerializableColor ( byte _A , byte _R , byte _G , byte _B )
273+ {
274+ A = _A ;
275+ R = _R ;
276+ G = _G ;
277+ B = _B ;
278+ }
279+
280+ public static implicit operator SerializableColor ( Color c )
281+ {
282+ return new SerializableColor ( c . A , c . R , c . G , c . B ) ;
283+ }
284+
285+ public static implicit operator Color ( SerializableColor c )
286+ {
287+ return Color . FromArgb ( c . A , c . R , c . G , c . B ) ;
288+ }
289+ }
290+
291+ [ Serializable ]
292+ public struct SearchOptions
293+ {
294+ public string FindText ;
295+ public string ReplaceText ;
296+ public int SearchType ;
297+ public int Document ;
298+ public bool CaseSensitive ;
299+ public bool MultilineRegex ;
300+ public int ReplaceType ;
301+ }
302+
303+ [ Serializable ]
304+ public enum ActionOnClose
305+ {
306+ Prompt ,
307+ Save ,
308+ DontSave
309+ }
302310}
0 commit comments