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

Commit 3bd6122

Browse files
committed
rollback to block-scoped namespaces
1 parent bce88ec commit 3bd6122

File tree

90 files changed

+13532
-13443
lines changed

Some content is hidden

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

90 files changed

+13532
-13443
lines changed

Interop/ConfigControl.cs

Lines changed: 147 additions & 146 deletions
Large diffs are not rendered by default.

Interop/HotkeyControl.cs

Lines changed: 113 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -4,138 +4,139 @@
44
using System.Xml;
55
using SPCode.Utils;
66

7-
namespace SPCode.Interop;
8-
9-
public class HotkeyControl
7+
namespace SPCode.Interop
108
{
11-
public static Dictionary<string, string> DefaultHotkeys = new()
9+
public class HotkeyControl
1210
{
13-
{ "New", "Ctrl+N" },
14-
{ "NewTemplate", "Ctrl+Shift+N" },
15-
{ "Open", "Ctrl+O" },
16-
{ "ReopenLastClosedTab", "Ctrl+Shift+T" },
17-
{ "Save", "Ctrl+S" },
18-
{ "SaveAll", "Ctrl+Shift+S" },
19-
{ "SaveAs", "Ctrl+Alt+S" },
20-
{ "Close", "Ctrl+W" },
21-
{ "CloseAll", "Ctrl+Shift+W" },
22-
{ "FoldingsExpand", "Ctrl+P" },
23-
{ "FoldingsCollapse", "Ctrl+Shift+P" },
24-
{ "ReformatCurrent", "Ctrl+R" },
25-
{ "ReformatAll", "Ctrl+Shift+R" },
26-
{ "GoToLine", "Ctrl+G" },
27-
{ "CommentLine", "Ctrl+K" },
28-
{ "UncommentLine", "Ctrl+Shift+K" },
29-
{ "TransformUppercase", "Ctrl+U" },
30-
{ "TransformLowercase", "Ctrl+Shift+U" },
31-
{ "DeleteLine", "Ctrl+D" },
32-
{ "MoveLineDown", "Ctrl+Down" },
33-
{ "MoveLineUp", "Ctrl+Up" },
34-
{ "DupeLineDown", "Ctrl+Alt+Down" },
35-
{ "DupeLineUp", "Ctrl+Alt+Up" },
36-
{ "SearchReplace", "Ctrl+F" },
37-
{ "SearchDefinition", "Ctrl+Shift+F" },
38-
{ "CompileCurrent", "F6" },
39-
{ "CompileAll", "F5" },
40-
{ "CopyPlugins", "F7" },
41-
{ "UploadFTP", "F8" },
42-
{ "StartServer", "F9" },
43-
{ "SendRCON", "F10" },
44-
};
11+
public static Dictionary<string, string> DefaultHotkeys = new()
12+
{
13+
{ "New", "Ctrl+N" },
14+
{ "NewTemplate", "Ctrl+Shift+N" },
15+
{ "Open", "Ctrl+O" },
16+
{ "ReopenLastClosedTab", "Ctrl+Shift+T" },
17+
{ "Save", "Ctrl+S" },
18+
{ "SaveAll", "Ctrl+Shift+S" },
19+
{ "SaveAs", "Ctrl+Alt+S" },
20+
{ "Close", "Ctrl+W" },
21+
{ "CloseAll", "Ctrl+Shift+W" },
22+
{ "FoldingsExpand", "Ctrl+P" },
23+
{ "FoldingsCollapse", "Ctrl+Shift+P" },
24+
{ "ReformatCurrent", "Ctrl+R" },
25+
{ "ReformatAll", "Ctrl+Shift+R" },
26+
{ "GoToLine", "Ctrl+G" },
27+
{ "CommentLine", "Ctrl+K" },
28+
{ "UncommentLine", "Ctrl+Shift+K" },
29+
{ "TransformUppercase", "Ctrl+U" },
30+
{ "TransformLowercase", "Ctrl+Shift+U" },
31+
{ "DeleteLine", "Ctrl+D" },
32+
{ "MoveLineDown", "Ctrl+Down" },
33+
{ "MoveLineUp", "Ctrl+Up" },
34+
{ "DupeLineDown", "Ctrl+Alt+Down" },
35+
{ "DupeLineUp", "Ctrl+Alt+Up" },
36+
{ "SearchReplace", "Ctrl+F" },
37+
{ "SearchDefinition", "Ctrl+Shift+F" },
38+
{ "CompileCurrent", "F6" },
39+
{ "CompileAll", "F5" },
40+
{ "CopyPlugins", "F7" },
41+
{ "UploadFTP", "F8" },
42+
{ "StartServer", "F9" },
43+
{ "SendRCON", "F10" },
44+
};
4545

46-
public static Dictionary<string, string> RestrictedHotkeys = new()
47-
{
48-
{ "Paste", "Ctrl+V" },
49-
{ "Copy", "Ctrl+C" },
50-
{ "Cut", "Ctrl+X" },
51-
{ "Undo", "Ctrl+Z" },
52-
{ "Redo", "Ctrl+Y" },
53-
{ "SelectAll", "Ctrl+A" }
54-
};
46+
public static Dictionary<string, string> RestrictedHotkeys = new()
47+
{
48+
{ "Paste", "Ctrl+V" },
49+
{ "Copy", "Ctrl+C" },
50+
{ "Cut", "Ctrl+X" },
51+
{ "Undo", "Ctrl+Z" },
52+
{ "Redo", "Ctrl+Y" },
53+
{ "SelectAll", "Ctrl+A" }
54+
};
5555

56-
/// <summary>
57-
/// Checks if there are new Hotkeys that haven't been added to the Hotkeys file <br>
58-
/// and buffers all Hotkeys to an array in memory.
59-
/// </summary>
60-
public static void CheckAndBufferHotkeys()
61-
{
62-
try
56+
/// <summary>
57+
/// Checks if there are new Hotkeys that haven't been added to the Hotkeys file <br>
58+
/// and buffers all Hotkeys to an array in memory.
59+
/// </summary>
60+
public static void CheckAndBufferHotkeys()
6361
{
64-
// Load the current Hotkeys file
65-
Program.HotkeysList = new();
66-
var document = new XmlDocument();
67-
document.Load(Constants.HotkeysFile);
62+
try
63+
{
64+
// Load the current Hotkeys file
65+
Program.HotkeysList = new();
66+
var document = new XmlDocument();
67+
document.Load(Constants.HotkeysFile);
6868

69-
// Compare with the default hotkeys to check for new commands
70-
var xmlNodes = document.ChildNodes[0].ChildNodes.Cast<XmlNode>().ToList();
71-
var defaultHksCount = DefaultHotkeys.Count;
69+
// Compare with the default hotkeys to check for new commands
70+
var xmlNodes = document.ChildNodes[0].ChildNodes.Cast<XmlNode>().ToList();
71+
var defaultHksCount = DefaultHotkeys.Count;
7272

73-
// If the count is not equal, there's a new hotkey to be added to the file
74-
if (xmlNodes.Count != defaultHksCount)
75-
{
76-
// Regular for to get the index
77-
for (var i = 0; i < defaultHksCount; i++)
73+
// If the count is not equal, there's a new hotkey to be added to the file
74+
if (xmlNodes.Count != defaultHksCount)
7875
{
79-
var currentHk = DefaultHotkeys.ElementAt(i);
80-
if (!xmlNodes.Any(x => x.Name.Equals(DefaultHotkeys.ElementAt(i).Key)))
76+
// Regular for to get the index
77+
for (var i = 0; i < defaultHksCount; i++)
8178
{
82-
var element = document.CreateElement(string.Empty, currentHk.Key, string.Empty);
83-
var text = document.CreateTextNode(currentHk.Value);
84-
element.AppendChild(text);
85-
document.ChildNodes[0].InsertBefore(element, document.ChildNodes[0].ChildNodes[i]);
79+
var currentHk = DefaultHotkeys.ElementAt(i);
80+
if (!xmlNodes.Any(x => x.Name.Equals(DefaultHotkeys.ElementAt(i).Key)))
81+
{
82+
var element = document.CreateElement(string.Empty, currentHk.Key, string.Empty);
83+
var text = document.CreateTextNode(currentHk.Value);
84+
element.AppendChild(text);
85+
document.ChildNodes[0].InsertBefore(element, document.ChildNodes[0].ChildNodes[i]);
86+
}
8687
}
88+
document.Save(Constants.HotkeysFile);
89+
xmlNodes = document.ChildNodes[0].ChildNodes.Cast<XmlNode>().ToList();
8790
}
88-
document.Save(Constants.HotkeysFile);
89-
xmlNodes = document.ChildNodes[0].ChildNodes.Cast<XmlNode>().ToList();
90-
}
9191

92-
xmlNodes.ForEach(x =>
93-
{
94-
var hki = new HotkeyInfo(new Hotkey(x.InnerText), x.Name);
95-
Program.HotkeysList.Add(hki);
96-
});
92+
xmlNodes.ForEach(x =>
93+
{
94+
var hki = new HotkeyInfo(new Hotkey(x.InnerText), x.Name);
95+
Program.HotkeysList.Add(hki);
96+
});
9797

98+
}
99+
catch (Exception ex)
100+
{
101+
throw new Exception("Error while checking and buffering the hotkeys", ex);
102+
}
98103
}
99-
catch (Exception ex)
100-
{
101-
throw new Exception("Error while checking and buffering the hotkeys", ex);
102-
}
103-
}
104104

105-
/// <summary>
106-
/// Creates the default hotkeys, stores them in an XML and buffers them.
107-
/// </summary>
108-
public static void CreateDefaultHotkeys()
109-
{
110-
try
105+
/// <summary>
106+
/// Creates the default hotkeys, stores them in an XML and buffers them.
107+
/// </summary>
108+
public static void CreateDefaultHotkeys()
111109
{
112-
// Create the XML document
113-
var document = new XmlDocument();
110+
try
111+
{
112+
// Create the XML document
113+
var document = new XmlDocument();
114114

115-
var rootElement = document.CreateElement(string.Empty, "Hotkeys", string.Empty);
116-
document.AppendChild(rootElement);
115+
var rootElement = document.CreateElement(string.Empty, "Hotkeys", string.Empty);
116+
document.AppendChild(rootElement);
117117

118-
// Fill it with the default hotkeys from the dictionary
119-
foreach (var item in DefaultHotkeys)
120-
{
121-
var element = document.CreateElement(string.Empty, item.Key, string.Empty);
122-
var text = document.CreateTextNode(item.Value);
123-
element.AppendChild(text);
124-
rootElement.AppendChild(element);
125-
}
118+
// Fill it with the default hotkeys from the dictionary
119+
foreach (var item in DefaultHotkeys)
120+
{
121+
var element = document.CreateElement(string.Empty, item.Key, string.Empty);
122+
var text = document.CreateTextNode(item.Value);
123+
element.AppendChild(text);
124+
rootElement.AppendChild(element);
125+
}
126126

127-
// Buffer hotkeys in global HotkeyInfo list
128-
Program.HotkeysList = new();
129-
foreach (XmlNode node in document.ChildNodes[0].ChildNodes)
127+
// Buffer hotkeys in global HotkeyInfo list
128+
Program.HotkeysList = new();
129+
foreach (XmlNode node in document.ChildNodes[0].ChildNodes)
130+
{
131+
Program.HotkeysList.Add(new HotkeyInfo(new Hotkey(node.InnerText), node.Name));
132+
}
133+
134+
document.Save(Constants.HotkeysFile);
135+
}
136+
catch (Exception ex)
130137
{
131-
Program.HotkeysList.Add(new HotkeyInfo(new Hotkey(node.InnerText), node.Name));
138+
throw new Exception("Error while creating the default hotkeys", ex);
132139
}
133-
134-
document.Save(Constants.HotkeysFile);
135-
}
136-
catch (Exception ex)
137-
{
138-
throw new Exception("Error while creating the default hotkeys", ex);
139140
}
140141
}
141-
}
142+
}

Interop/LoggingControl.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
using System;
22
using System.Windows.Controls;
33

4-
namespace SPCode.Interop;
5-
6-
public static class LoggingControl
4+
namespace SPCode.Interop
75
{
8-
public static TextBox LogBox;
9-
public static void LogAction(string message, int newLines = 1)
6+
public static class LoggingControl
107
{
11-
try
12-
{
13-
LogBox.Text += $"[{DateTime.Now:HH:mm:ss}] {message} {new string('\n', newLines)}";
14-
LogBox.CaretIndex = LogBox.Text.Length;
15-
LogBox.ScrollToEnd();
16-
}
17-
catch (Exception)
8+
public static TextBox LogBox;
9+
public static void LogAction(string message, int newLines = 1)
1810
{
11+
try
12+
{
13+
LogBox.Text += $"[{DateTime.Now:HH:mm:ss}] {message} {new string('\n', newLines)}";
14+
LogBox.CaretIndex = LogBox.Text.Length;
15+
LogBox.ScrollToEnd();
16+
}
17+
catch (Exception)
18+
{
1919

20+
}
2021
}
2122
}
22-
}
23+
}

0 commit comments

Comments
 (0)