Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 3dfc787

Browse files
committed
Cleanup Spedit
1 parent 71acf2f commit 3dfc787

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6085
-5516
lines changed

Interop/ConfigControl.cs

Lines changed: 109 additions & 134 deletions
Large diffs are not rendered by default.

Interop/OptionsControl.cs

Lines changed: 119 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.IO;
3-
using System.Runtime.Serialization.Formatters.Binary;
42
using System.Security.Cryptography;
53
using System.Windows.Media;
64

@@ -10,157 +8,144 @@ namespace Spedit //leave this here instead of .Interop because of reasons...
108
public class OptionsControl
119
{
1210
public static int SVersion = 10;
13-
public int Version = 10;
14-
15-
public byte[] Program_CryptoKey = null;
16-
public bool Program_UseHardwareSalts = true;
17-
18-
public bool Program_UseHardwareAcceleration = true;
19-
20-
public bool Program_CheckForUpdates = true;
21-
22-
public string Program_SelectedConfig = string.Empty;
2311

24-
public bool Program_OpenCustomIncludes = false;
25-
public bool Program_OpenIncludesRecursively = false;
26-
27-
public bool Program_DynamicISAC = true;
28-
29-
public string Program_AccentColor = "Red";
30-
public string Program_Theme = "BaseDark";
12+
public int Version = 10;
13+
public byte[] ProgramCryptoKey;
14+
public bool ProgramUseHardwareSalts = true;
15+
public bool ProgramUseHardwareAcceleration = true;
16+
public bool ProgramCheckForUpdates = true;
17+
public string ProgramSelectedConfig = string.Empty;
18+
public bool ProgramOpenCustomIncludes = false;
19+
public bool ProgramOpenIncludesRecursively = false;
20+
public bool ProgramDynamicIsac = true;
21+
public string ProgramAccentColor = "Red";
22+
public string ProgramTheme = "BaseDark";
23+
public string ProgramObjectBrowserDirectory = string.Empty;
24+
public double ProgramObjectbrowserWidth = 300.0;
25+
public bool UIAnimations = true;
26+
public bool UIShowToolBar;
27+
public bool EditorWordWrap = false;
28+
public double EditorFontSize = 16.0;
29+
public string EditorFontFamily = "Consolas";
30+
public double EditorScrollLines = 4.0;
31+
public bool EditorAgressiveIndentation = true;
32+
public bool EditorReformatLineAfterSemicolon = true;
33+
public bool EditorReplaceTabsToWhitespace;
34+
public bool EditorAutoCloseBrackets = true;
35+
public bool EditorAutoCloseStringChars = true;
36+
public bool EditorShowSpaces;
37+
public bool EditorShowTabs;
38+
public int EditorIndentationSize = 4;
39+
public bool EditorAutoSave;
40+
public int EditorAutoSaveInterval = 5 * 60;
41+
public string[] LastOpenFiles = new string[0];
42+
public bool SHHighlightDeprecateds = true;
43+
public string Language = string.Empty;
44+
public SerializeableColor SHComments = new SerializeableColor(0xFF, 0x57, 0xA6, 0x49);
45+
public SerializeableColor SHCommentsMarker = new SerializeableColor(0xFF, 0xFF, 0x20, 0x20);
46+
public SerializeableColor SHStrings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
47+
public SerializeableColor SHPreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
48+
public SerializeableColor SHTypes = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
49+
public SerializeableColor SHTypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
50+
public SerializeableColor SHKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
51+
public SerializeableColor SHContextKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
52+
public SerializeableColor SHChars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
53+
public SerializeableColor SHUnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
54+
public SerializeableColor SHNumbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
55+
public SerializeableColor SHSpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
56+
public SerializeableColor SHDeprecated = new SerializeableColor(0xFF, 0xFF, 0x00, 0x00);
57+
public SerializeableColor SHConstants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
58+
public SerializeableColor SHFunctions = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
59+
public SerializeableColor SHMethods = new SerializeableColor(0xFF, 0x3B, 0xC6, 0x7E);
3160

32-
public string Program_ObjectBrowserDirectory = string.Empty;
33-
public double Program_ObjectbrowserWidth = 300.0;
61+
public void FillNullToDefaults()
62+
{
63+
if (ProgramCryptoKey == null)
64+
ReCreateCryptoKey();
3465

35-
public bool UI_Animations = true;
36-
public bool UI_ShowToolBar = false;
66+
if (SVersion <= Version)
67+
return;
3768

38-
public bool Editor_WordWrap = false;
39-
public double Editor_FontSize = 16.0;
40-
public string Editor_FontFamily = "Consolas";
41-
public double Editor_ScrollLines = 4.0;
42-
public bool Editor_AgressiveIndentation = true;
43-
public bool Editor_ReformatLineAfterSemicolon = true;
44-
public bool Editor_ReplaceTabsToWhitespace = false;
45-
public bool Editor_AutoCloseBrackets = true;
46-
public bool Editor_AutoCloseStringChars = true;
47-
public bool Editor_ShowSpaces = false;
48-
public bool Editor_ShowTabs = false;
49-
public int Editor_IndentationSize = 4;
50-
public bool Editor_AutoSave = false;
51-
public int Editor_AutoSaveInterval = 5 * 60;
69+
Program.ClearUpdateFiles();
5270

53-
public string[] LastOpenFiles = new string[0];
71+
if (Version < 2)
72+
UIShowToolBar = false;
5473

55-
public bool SH_HighlightDeprecateds = true;
74+
if (Version < 3)
75+
{
76+
EditorReformatLineAfterSemicolon = true;
77+
EditorScrollLines = 4.0;
78+
ProgramCheckForUpdates = true;
79+
}
5680

57-
public string Language = string.Empty;
81+
if (Version < 4)
82+
EditorReplaceTabsToWhitespace = false;
5883

59-
public SerializeableColor SH_Comments = new SerializeableColor(0xFF, 0x57, 0xA6, 0x49);
60-
public SerializeableColor SH_CommentsMarker = new SerializeableColor(0xFF, 0xFF, 0x20, 0x20);
61-
public SerializeableColor SH_Strings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
62-
public SerializeableColor SH_PreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
63-
public SerializeableColor SH_Types = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
64-
public SerializeableColor SH_TypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
65-
public SerializeableColor SH_Keywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
66-
public SerializeableColor SH_ContextKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
67-
public SerializeableColor SH_Chars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
68-
public SerializeableColor SH_UnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
69-
public SerializeableColor SH_Numbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
70-
public SerializeableColor SH_SpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
71-
public SerializeableColor SH_Deprecated = new SerializeableColor(0xFF, 0xFF, 0x00, 0x00);
72-
public SerializeableColor SH_Constants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
73-
public SerializeableColor SH_Functions = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
74-
public SerializeableColor SH_Methods = new SerializeableColor(0xFF, 0x3B, 0xC6, 0x7E);
84+
if (Version < 5)
85+
ProgramDynamicIsac = true;
7586

76-
public void FillNullToDefaults()
77-
{
78-
if (this.Program_CryptoKey == null)
87+
if (Version < 7)
7988
{
80-
this.ReCreateCryptoKey();
89+
ProgramAccentColor = "Red";
90+
ProgramTheme = "BaseDark";
91+
NormalizeSHColors();
8192
}
82-
if (OptionsControl.SVersion > this.Version)
93+
94+
if (Version < 8)
95+
EditorAutoCloseBrackets = true;
96+
97+
if (Version < 9)
8398
{
84-
Program.ClearUpdateFiles();
85-
if (Version < 2)
86-
{
87-
this.UI_ShowToolBar = false;
88-
}
89-
if (Version < 3)
90-
{
91-
this.Editor_ReformatLineAfterSemicolon = true;
92-
this.Editor_ScrollLines = 4.0;
93-
this.Program_CheckForUpdates = true;
94-
}
95-
if (Version < 4)
96-
{
97-
this.Editor_ReplaceTabsToWhitespace = false;
98-
}
99-
if (Version < 5)
100-
{
101-
this.Program_DynamicISAC = true;
102-
}
103-
if (Version < 7)
104-
{
105-
this.Program_AccentColor = "Red";
106-
this.Program_Theme = "BaseDark";
107-
NormalizeSHColors();
108-
}
109-
if (Version < 8)
110-
{
111-
Editor_AutoCloseBrackets = true;
112-
}
113-
if (Version < 9)
114-
{
115-
Editor_AutoCloseStringChars = true;
116-
Editor_ShowSpaces = false;
117-
Editor_ShowTabs = false;
118-
Editor_IndentationSize = 4;
119-
Language = "";
120-
Program_ObjectBrowserDirectory = string.Empty;
121-
Program_ObjectbrowserWidth = 300.0;
122-
Editor_AutoSave = false;
123-
Editor_AutoSaveInterval = 5 * 60;
124-
this.ReCreateCryptoKey();
125-
Program.MakeRCCKAlert();
126-
}
127-
if (Version < 10)
128-
{
129-
Program_UseHardwareSalts = true;
130-
}
131-
//new Optionsversion - reset new fields to default
132-
this.Version = OptionsControl.SVersion; //then Update Version afterwars
99+
EditorAutoCloseStringChars = true;
100+
EditorShowSpaces = false;
101+
EditorShowTabs = false;
102+
EditorIndentationSize = 4;
103+
Language = "";
104+
ProgramObjectBrowserDirectory = string.Empty;
105+
ProgramObjectbrowserWidth = 300.0;
106+
EditorAutoSave = false;
107+
EditorAutoSaveInterval = 5 * 60;
108+
ReCreateCryptoKey();
109+
Program.MakeRcckAlert();
133110
}
111+
112+
if (Version < 10)
113+
ProgramUseHardwareSalts = true;
114+
115+
//new Optionsversion - reset new fields to default
116+
Version = SVersion; //then Update Version afterwars
134117
}
135118

136119
public void ReCreateCryptoKey()
137120
{
138-
byte[] buffer = new byte[16];
139-
using (RNGCryptoServiceProvider cryptoRandomProvider = new RNGCryptoServiceProvider()) //generate global unique cryptokey
121+
var buffer = new byte[16];
122+
123+
using (var cryptoRandomProvider = new RNGCryptoServiceProvider()) //generate global unique cryptokey
140124
{
141125
cryptoRandomProvider.GetBytes(buffer);
142126
}
143-
this.Program_CryptoKey = buffer;
127+
128+
ProgramCryptoKey = buffer;
144129
}
145130

146131
private void NormalizeSHColors()
147132
{
148-
SH_Comments = new SerializeableColor(0xFF, 0x57, 0xA6, 0x49);
149-
SH_CommentsMarker = new SerializeableColor(0xFF, 0xFF, 0x20, 0x20);
150-
SH_Strings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
151-
SH_PreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
152-
SH_Types = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
153-
SH_TypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
154-
SH_Keywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
155-
SH_ContextKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
156-
SH_Chars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
157-
SH_UnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
158-
SH_Numbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
159-
SH_SpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
160-
SH_Deprecated = new SerializeableColor(0xFF, 0xFF, 0x00, 0x00);
161-
SH_Constants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
162-
SH_Functions = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
163-
SH_Methods = new SerializeableColor(0xFF, 0x3B, 0xC6, 0x7E);
133+
SHComments = new SerializeableColor(0xFF, 0x57, 0xA6, 0x49);
134+
SHCommentsMarker = new SerializeableColor(0xFF, 0xFF, 0x20, 0x20);
135+
SHStrings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
136+
SHPreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
137+
SHTypes = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
138+
SHTypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
139+
SHKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
140+
SHContextKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
141+
SHChars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
142+
SHUnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
143+
SHNumbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
144+
SHSpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
145+
SHDeprecated = new SerializeableColor(0xFF, 0xFF, 0x00, 0x00);
146+
SHConstants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
147+
SHFunctions = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
148+
SHMethods = new SerializeableColor(0xFF, 0x3B, 0xC6, 0x7E);
164149
}
165150
}
166151

@@ -171,59 +156,14 @@ public SerializeableColor(byte _A, byte _R, byte _G, byte _B)
171156
{
172157
A = _A; R = _R; G = _G; B = _B;
173158
}
174-
public byte A = 0x00;
175-
public byte R = 0x00;
176-
public byte G = 0x00;
177-
public byte B = 0x00;
159+
160+
public byte A;
161+
public byte R;
162+
public byte G;
163+
public byte B;
178164
public static implicit operator SerializeableColor(Color c)
179165
{ return new SerializeableColor(c.A, c.R, c.G, c.B ); }
180166
public static implicit operator Color(SerializeableColor c)
181167
{ return Color.FromArgb(c.A, c.R, c.G, c.B); }
182168
}
183-
184-
public static class OptionsControlIOObject
185-
{
186-
public static void Save()
187-
{
188-
try
189-
{
190-
var formatter = new BinaryFormatter();
191-
using (FileStream fileStream = new FileStream("options_0.dat", FileMode.Create, FileAccess.ReadWrite, FileShare.None))
192-
{
193-
formatter.Serialize(fileStream, Program.OptionsObject);
194-
var test = Program.OptionsObject;
195-
}
196-
}
197-
catch (Exception) { }
198-
}
199-
200-
public static OptionsControl Load(out bool ProgramIsNew)
201-
{
202-
try
203-
{
204-
if (File.Exists("options_0.dat"))
205-
{
206-
object deserializedOptionsObj;
207-
var formatter = new BinaryFormatter();
208-
using (FileStream fileStream = new FileStream("options_0.dat", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
209-
{
210-
deserializedOptionsObj = formatter.Deserialize(fileStream);
211-
}
212-
OptionsControl oc = (OptionsControl)deserializedOptionsObj;
213-
oc.FillNullToDefaults();
214-
ProgramIsNew = false;
215-
return oc;
216-
}
217-
}
218-
catch (Exception) { }
219-
OptionsControl oco = new OptionsControl();
220-
oco.ReCreateCryptoKey();
221-
#if DEBUG
222-
ProgramIsNew = true;
223-
#else
224-
ProgramIsNew = true;
225-
#endif
226-
return oco;
227-
}
228-
}
229169
}

0 commit comments

Comments
 (0)