Skip to content

Commit 2009da2

Browse files
committed
Moved settings into the ViewInfo class again to support multiple settings objects.
1 parent 35cb367 commit 2009da2

30 files changed

+218
-204
lines changed

Nodes/BaseArrayNode.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ protected int Draw(ViewInfo view, int x, int y, string type, HotSpotType exchang
3030
var tx = x;
3131
x = AddAddressOffset(view, x, y);
3232

33-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
34-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name);
35-
x = AddText(view, x, y, Program.Settings.IndexColor, HotSpot.NoneId, "[");
36-
x = AddText(view, x, y, Program.Settings.IndexColor, 0, Count.ToString());
37-
x = AddText(view, x, y, Program.Settings.IndexColor, HotSpot.NoneId, "]");
33+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
34+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name);
35+
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, "[");
36+
x = AddText(view, x, y, view.Settings.IndexColor, 0, Count.ToString());
37+
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, "]");
3838

3939
x = AddIcon(view, x, y, Icons.LeftArrow, 2, HotSpotType.Click);
40-
x = AddText(view, x, y, Program.Settings.IndexColor, HotSpot.NoneId, "(");
41-
x = AddText(view, x, y, Program.Settings.IndexColor, 1, CurrentIndex.ToString());
42-
x = AddText(view, x, y, Program.Settings.IndexColor, HotSpot.NoneId, ")");
40+
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, "(");
41+
x = AddText(view, x, y, view.Settings.IndexColor, 1, CurrentIndex.ToString());
42+
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, ")");
4343
x = AddIcon(view, x, y, Icons.RightArrow, 3, HotSpotType.Click);
4444

45-
x = AddText(view, x, y, Program.Settings.ValueColor, HotSpot.NoneId, $"<{InnerNode.Name} Size={MemorySize}>");
45+
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.NoneId, $"<{InnerNode.Name} Size={MemorySize}>");
4646
x = AddIcon(view, x + 2, y, Icons.Change, 4, exchange);
4747

4848
x += view.Font.Width;

Nodes/BaseFunctionPtrNode.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ protected int Draw(ViewInfo view, int x, int y, string type, string name)
4747

4848
x = AddAddressOffset(view, x, y);
4949

50-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
51-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, name) + view.Font.Width;
50+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
51+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, name) + view.Font.Width;
5252

5353
x = AddOpenClose(view, x, y) + view.Font.Width;
5454

5555
x = AddComment(view, x, y);
5656

57-
if (Program.Settings.ShowCommentSymbol)
57+
if (view.Settings.ShowCommentSymbol)
5858
{
5959
var value = view.Memory.ReadObject<IntPtr>(Offset);
6060

@@ -67,7 +67,7 @@ protected int Draw(ViewInfo view, int x, int y, string type, string name)
6767
var symbol = symbols.GetSymbolString(value, module);
6868
if (!string.IsNullOrEmpty(symbol))
6969
{
70-
x = AddText(view, x, y, Program.Settings.OffsetColor, HotSpot.ReadOnlyId, symbol) + view.Font.Width;
70+
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.ReadOnlyId, symbol) + view.Font.Width;
7171
}
7272
}
7373
}
@@ -83,7 +83,7 @@ protected int Draw(ViewInfo view, int x, int y, string type, string name)
8383
{
8484
y += view.Font.Height;
8585

86-
AddText(view, tx, y, Program.Settings.NameColor, HotSpot.ReadOnlyId, line);
86+
AddText(view, tx, y, view.Settings.NameColor, HotSpot.ReadOnlyId, line);
8787
}
8888
}
8989

Nodes/BaseHexCommentNode.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ protected int AddComment(ViewInfo view, int x, int y, float fvalue, IntPtr ivalu
1313
{
1414
Contract.Requires(view != null);
1515

16-
if (Program.Settings.ShowCommentFloat)
16+
if (view.Settings.ShowCommentFloat)
1717
{
18-
x = AddText(view, x, y, Program.Settings.ValueColor, HotSpot.ReadOnlyId, $"({(fvalue > -99999.0f && fvalue < 99999.0f ? fvalue : 0.0f):0.000})");
18+
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.ReadOnlyId, $"({(fvalue > -99999.0f && fvalue < 99999.0f ? fvalue : 0.0f):0.000})");
1919
}
20-
if (Program.Settings.ShowCommentInteger)
20+
if (view.Settings.ShowCommentInteger)
2121
{
2222
if (ivalue == IntPtr.Zero)
2323
{
24-
x = AddText(view, x, y, Program.Settings.ValueColor, HotSpot.ReadOnlyId, "(0)");
24+
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.ReadOnlyId, "(0)");
2525
}
2626
else
2727
{
28-
x = AddText(view, x, y, Program.Settings.ValueColor, HotSpot.ReadOnlyId, $"({ivalue.ToInt64()}|0x{uvalue.ToUInt64():X})");
28+
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.ReadOnlyId, $"({ivalue.ToInt64()}|0x{uvalue.ToUInt64():X})");
2929
}
3030
}
3131

@@ -34,22 +34,22 @@ protected int AddComment(ViewInfo view, int x, int y, float fvalue, IntPtr ivalu
3434
{
3535
x += view.Font.Width;
3636

37-
if (Program.Settings.ShowCommentPointer)
37+
if (view.Settings.ShowCommentPointer)
3838
{
39-
x = AddText(view, x, y, Program.Settings.OffsetColor, HotSpot.NoneId, "->") + view.Font.Width;
40-
x = AddText(view, x, y, Program.Settings.OffsetColor, HotSpot.ReadOnlyId, namedAddress) + view.Font.Width;
39+
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.NoneId, "->") + view.Font.Width;
40+
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.ReadOnlyId, namedAddress) + view.Font.Width;
4141
}
4242

43-
if (Program.Settings.ShowCommentRtti)
43+
if (view.Settings.ShowCommentRtti)
4444
{
4545
var rtti = view.Memory.Process.ReadRemoteRuntimeTypeInformation(ivalue);
4646
if (!string.IsNullOrEmpty(rtti))
4747
{
48-
x = AddText(view, x, y, Program.Settings.OffsetColor, HotSpot.ReadOnlyId, rtti) + view.Font.Width;
48+
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.ReadOnlyId, rtti) + view.Font.Width;
4949
}
5050
}
5151

52-
if (Program.Settings.ShowCommentSymbol)
52+
if (view.Settings.ShowCommentSymbol)
5353
{
5454
var module = view.Memory.Process.GetModuleToPointer(ivalue);
5555
if (module != null)
@@ -60,37 +60,37 @@ protected int AddComment(ViewInfo view, int x, int y, float fvalue, IntPtr ivalu
6060
var symbol = symbols.GetSymbolString(ivalue, module);
6161
if (!string.IsNullOrEmpty(symbol))
6262
{
63-
x = AddText(view, x, y, Program.Settings.OffsetColor, HotSpot.ReadOnlyId, symbol) + view.Font.Width;
63+
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.ReadOnlyId, symbol) + view.Font.Width;
6464
}
6565
}
6666
}
6767
}
6868

69-
if (Program.Settings.ShowCommentString)
69+
if (view.Settings.ShowCommentString)
7070
{
7171
var data = view.Memory.Process.ReadRemoteMemory(ivalue, 64);
7272

7373
// First check if it could be an UTF8 string and if not try UTF16.
7474
if (data.Take(IntPtr.Size).InterpretAsUTF8().IsPrintableData())
7575
{
7676
var text = new string(Encoding.UTF8.GetChars(data).TakeWhile(c => c != 0).ToArray());
77-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.ReadOnlyId, $"'{text}'") + view.Font.Width;
77+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.ReadOnlyId, $"'{text}'") + view.Font.Width;
7878
}
7979
else if(data.Take(IntPtr.Size * 2).InterpretAsUTF16().IsPrintableData())
8080
{
8181
var text = new string(Encoding.Unicode.GetChars(data).TakeWhile(c => c != 0).ToArray());
82-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.ReadOnlyId, $"L'{text}'") + view.Font.Width;
82+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.ReadOnlyId, $"L'{text}'") + view.Font.Width;
8383
}
8484
}
8585

86-
if (Program.Settings.ShowCommentPluginInfo)
86+
if (view.Settings.ShowCommentPluginInfo)
8787
{
8888
foreach (var reader in NodeInfoReader)
8989
{
9090
var info = reader.ReadNodeInfo(this, ivalue, view.Memory);
9191
if (info != null)
9292
{
93-
x = AddText(view, x, y, Program.Settings.PluginColor, HotSpot.ReadOnlyId, info) + view.Font.Width;
93+
x = AddText(view, x, y, view.Settings.PluginColor, HotSpot.ReadOnlyId, info) + view.Font.Width;
9494
}
9595
}
9696
}

Nodes/BaseHexNode.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ protected int Draw(ViewInfo view, int x, int y, string text, int length)
3737
x += TextPadding + 16;
3838
x = AddAddressOffset(view, x, y);
3939

40-
if (Program.Settings.ShowNodeText)
40+
if (view.Settings.ShowNodeText)
4141
{
42-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.NoneId, text);
42+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, text);
4343
}
4444

45-
var color = Program.Settings.HighlightChangedValues && highlightUntil > CurrentHighlightTime ? Program.Settings.HighlightColor : Program.Settings.HexColor;
45+
var color = view.Settings.HighlightChangedValues && highlightUntil > CurrentHighlightTime ? view.Settings.HighlightColor : view.Settings.HexColor;
4646
var changed = false;
4747
for (var i = 0; i < length; ++i)
4848
{

Nodes/BaseMatrixNode.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ protected int DrawMatrixType(ViewInfo view, int x, int y, string type, DrawMatri
3535

3636
x = AddAddressOffset(view, x, y);
3737

38-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
39-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name);
38+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
39+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name);
4040
x = AddOpenClose(view, x, y);
4141

4242
x += view.Font.Width;
@@ -72,8 +72,8 @@ protected int DrawVectorType(ViewInfo view, int x, int y, string type, DrawVecto
7272
x = AddIcon(view, x, y, Icons.Vector, HotSpot.NoneId, HotSpotType.None);
7373
x = AddAddressOffset(view, x, y);
7474

75-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
76-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name);
75+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
76+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name);
7777
x = AddOpenClose(view, x, y);
7878

7979
if (levelsOpen[view.Level])

Nodes/BaseNode.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,17 @@ protected int AddAddressOffset(ViewInfo view, int x, int y)
233233
Contract.Requires(view.Context != null);
234234
Contract.Requires(view.Font != null);
235235

236-
if (Program.Settings.ShowNodeOffset)
236+
if (view.Settings.ShowNodeOffset)
237237
{
238-
x = AddText(view, x, y, Program.Settings.OffsetColor, HotSpot.NoneId, $"{Offset.ToInt32():X04}") + view.Font.Width;
238+
x = AddText(view, x, y, view.Settings.OffsetColor, HotSpot.NoneId, $"{Offset.ToInt32():X04}") + view.Font.Width;
239239
}
240240

241-
if (Program.Settings.ShowNodeAddress)
241+
if (view.Settings.ShowNodeAddress)
242242
{
243243
#if WIN32
244-
x = AddText(view, x, y, Program.Settings.AddressColor, HotSpot.AddressId, $"{view.Address.Add(Offset).ToInt32():X08}") + view.Font.Width;
244+
x = AddText(view, x, y, view.Settings.AddressColor, HotSpot.AddressId, $"{view.Address.Add(Offset).ToInt32():X08}") + view.Font.Width;
245245
#else
246-
x = AddText(view, x, y, Program.Settings.AddressColor, HotSpot.AddressId, $"{view.Address.Add(Offset).ToInt64():X016}") + view.Font.Width;
246+
x = AddText(view, x, y, view.Settings.AddressColor, HotSpot.AddressId, $"{view.Address.Add(Offset).ToInt64():X016}") + view.Font.Width;
247247
#endif
248248
}
249249

@@ -267,7 +267,7 @@ protected void AddSelection(ViewInfo view, int x, int y, int height)
267267

268268
if (IsSelected)
269269
{
270-
using (var brush = new SolidBrush(Program.Settings.SelectedColor))
270+
using (var brush = new SolidBrush(view.Settings.SelectedColor))
271271
{
272272
view.Context.FillRectangle(brush, 0, y, view.ClientArea.Right, height);
273273
}
@@ -374,8 +374,8 @@ protected virtual int AddComment(ViewInfo view, int x, int y)
374374
Contract.Requires(view.Context != null);
375375
Contract.Requires(view.Font != null);
376376

377-
x = AddText(view, x, y, Program.Settings.CommentColor, HotSpot.NoneId, "//");
378-
x = AddText(view, x, y, Program.Settings.CommentColor, HotSpot.CommentId, Comment) + view.Font.Width;
377+
x = AddText(view, x, y, view.Settings.CommentColor, HotSpot.NoneId, "//");
378+
x = AddText(view, x, y, view.Settings.CommentColor, HotSpot.CommentId, Comment) + view.Font.Width;
379379

380380
return x;
381381
}
@@ -390,7 +390,7 @@ protected int DrawHidden(ViewInfo view, int x, int y)
390390
Contract.Requires(view != null);
391391
Contract.Requires(view.Context != null);
392392

393-
using (var brush = new SolidBrush(IsSelected ? Program.Settings.SelectedColor : Program.Settings.HiddenColor))
393+
using (var brush = new SolidBrush(IsSelected ? view.Settings.SelectedColor : view.Settings.HiddenColor))
394394
{
395395
view.Context.FillRectangle(brush, 0, y, view.ClientArea.Right, 1);
396396
}

Nodes/BaseNumericNode.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ protected int DrawNumeric(ViewInfo view, int x, int y, Image icon, string type,
3535
x = AddIcon(view, x, y, icon, HotSpot.NoneId, HotSpotType.None);
3636
x = AddAddressOffset(view, x, y);
3737

38-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
39-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
40-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NoneId, "=") + view.Font.Width;
41-
x = AddText(view, x, y, Program.Settings.ValueColor, 0, value) + view.Font.Width;
38+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
39+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
40+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NoneId, "=") + view.Font.Width;
41+
x = AddText(view, x, y, view.Settings.ValueColor, 0, value) + view.Font.Width;
4242

4343
AddComment(view, x, y);
4444

Nodes/BaseTextNode.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ protected int DrawText(ViewInfo view, int x, int y, string type, int length, str
4040
x = AddIcon(view, x, y, Icons.Text, HotSpot.NoneId, HotSpotType.None);
4141
x = AddAddressOffset(view, x, y);
4242

43-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
44-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name);
45-
x = AddText(view, x, y, Program.Settings.IndexColor, HotSpot.NoneId, "[");
46-
x = AddText(view, x, y, Program.Settings.IndexColor, 0, length.ToString());
47-
x = AddText(view, x, y, Program.Settings.IndexColor, HotSpot.NoneId, "]") + view.Font.Width;
48-
49-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.NoneId, "= '");
50-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.NoneId, text.LimitLength(150));
51-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.NoneId, "'") + view.Font.Width;
43+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
44+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name);
45+
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, "[");
46+
x = AddText(view, x, y, view.Settings.IndexColor, 0, length.ToString());
47+
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, "]") + view.Font.Width;
48+
49+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "= '");
50+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, text.LimitLength(150));
51+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "'") + view.Font.Width;
5252

5353
AddComment(view, x, y);
5454

Nodes/BaseTextPtrNode.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public int DrawText(ViewInfo view, int x, int y, string type, int length, string
3333
x = AddIcon(view, x, y, Icons.Text, HotSpot.NoneId, HotSpotType.None);
3434
x = AddAddressOffset(view, x, y);
3535

36-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
37-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
36+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
37+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
3838

39-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.NoneId, "= '");
40-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.NoneId, text);
41-
x = AddText(view, x, y, Program.Settings.TextColor, HotSpot.NoneId, "'") + view.Font.Width;
39+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "= '");
40+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, text);
41+
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "'") + view.Font.Width;
4242

4343
AddComment(view, x, y);
4444

Nodes/BitFieldNode.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public override int Draw(ViewInfo view, int x, int y)
109109

110110
x = AddAddressOffset(view, x, y);
111111

112-
x = AddText(view, x, y, Program.Settings.TypeColor, HotSpot.NoneId, "Bits") + view.Font.Width;
113-
x = AddText(view, x, y, Program.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
112+
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, "Bits") + view.Font.Width;
113+
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
114114

115115
x = AddOpenClose(view, x, y) + view.Font.Width;
116116

@@ -121,7 +121,7 @@ public override int Draw(ViewInfo view, int x, int y)
121121
var rect = new Rectangle(x + i * view.Font.Width, y, view.Font.Width, view.Font.Height);
122122
AddHotSpot(view, rect, string.Empty, i, HotSpotType.Edit);
123123
}
124-
x = AddText(view, x, y, Program.Settings.ValueColor, HotSpot.NoneId, ConvertValueToBitString(view.Memory)) + view.Font.Width;
124+
x = AddText(view, x, y, view.Settings.ValueColor, HotSpot.NoneId, ConvertValueToBitString(view.Memory)) + view.Font.Width;
125125

126126
x += view.Font.Width;
127127

@@ -133,7 +133,7 @@ public override int Draw(ViewInfo view, int x, int y)
133133

134134
var format = new StringFormat(StringFormatFlags.DirectionVertical);
135135

136-
using (var brush = new SolidBrush(Program.Settings.ValueColor))
136+
using (var brush = new SolidBrush(view.Settings.ValueColor))
137137
{
138138
view.Context.DrawString("1", view.Font.Font, brush, tx + (bits - 1) * view.Font.Width + 1, y, format);
139139

0 commit comments

Comments
 (0)