1
- using System ;
1
+ using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Diagnostics . Contracts ;
4
4
using System . Drawing ;
11
11
12
12
namespace ReClassNET . UI
13
13
{
14
- public partial class MemoryViewControl : ScrollableCustomControl
14
+ public partial class MemoryViewControl : UserControl
15
15
{
16
16
/// <summary>
17
17
/// Contains informations about a selected node.
@@ -78,25 +78,15 @@ public MemoryViewControl()
78
78
return ;
79
79
}
80
80
81
+ AutoScroll = true ;
82
+
81
83
font = Program . MonoSpaceFont ;
82
84
83
85
editBox . Font = font ;
84
86
85
87
memoryPreviewPopUp = new MemoryPreviewPopUp ( font ) ;
86
88
}
87
89
88
- protected override void OnLoad ( EventArgs e )
89
- {
90
- base . OnLoad ( e ) ;
91
-
92
- VerticalScroll . Enabled = true ;
93
- VerticalScroll . Visible = true ;
94
- VerticalScroll . SmallChange = 10 ;
95
- HorizontalScroll . Enabled = true ;
96
- HorizontalScroll . Visible = true ;
97
- HorizontalScroll . SmallChange = 100 ;
98
- }
99
-
100
90
protected override void OnPaint ( PaintEventArgs e )
101
91
{
102
92
base . OnPaint ( e ) ;
@@ -147,8 +137,8 @@ protected override void OnPaint(PaintEventArgs e)
147
137
148
138
var drawnSize = args . Node . Draw (
149
139
view ,
150
- - HorizontalScroll . Value ,
151
- - VerticalScroll . Value * font . Height
140
+ AutoScrollPosition . X ,
141
+ AutoScrollPosition . Y
152
142
) ;
153
143
drawnSize . Width += 10 ;
154
144
@@ -157,33 +147,7 @@ protected override void OnPaint(PaintEventArgs e)
157
147
e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(150, 255, 0, 0)), 1), spot.Rect);
158
148
}*/
159
149
160
- if ( drawnSize . Height > ClientSize . Height )
161
- {
162
- VerticalScroll . Enabled = true ;
163
-
164
- VerticalScroll . LargeChange = ClientSize . Height / font . Height ;
165
- VerticalScroll . Maximum = ( drawnSize . Height - ClientSize . Height ) / font . Height + VerticalScroll . LargeChange ;
166
- }
167
- else
168
- {
169
- VerticalScroll . Enabled = false ;
170
-
171
- VerticalScroll . Value = VerticalScroll . Minimum ;
172
- }
173
-
174
- if ( drawnSize . Width > ClientSize . Width )
175
- {
176
- HorizontalScroll . Enabled = true ;
177
-
178
- HorizontalScroll . LargeChange = ClientSize . Width ;
179
- HorizontalScroll . Maximum = drawnSize . Width - ClientSize . Width + HorizontalScroll . LargeChange ;
180
- }
181
- else
182
- {
183
- HorizontalScroll . Enabled = false ;
184
-
185
- HorizontalScroll . Value = HorizontalScroll . Minimum ;
186
- }
150
+ AutoScrollMinSize = new Size ( Math . Max ( drawnSize . Width , ClientSize . Width ) , Math . Max ( drawnSize . Height , ClientSize . Height ) ) ;
187
151
}
188
152
189
153
private void OnSelectionChanged ( )
@@ -333,9 +297,12 @@ protected override void OnMouseClick(MouseEventArgs e)
333
297
}
334
298
else if ( hotSpot . Type == HotSpotType . ChangeClassType || hotSpot . Type == HotSpotType . ChangeWrappedType || hotSpot . Type == HotSpotType . ChangeEnumType )
335
299
{
336
- var handler = hotSpot . Type == HotSpotType . ChangeClassType
337
- ? ChangeClassTypeClick : hotSpot . Type == HotSpotType . ChangeWrappedType
338
- ? ChangeWrappedTypeClick : ChangeEnumTypeClick ;
300
+ var handler = hotSpot . Type switch
301
+ {
302
+ HotSpotType . ChangeClassType => ChangeClassTypeClick ,
303
+ HotSpotType . ChangeWrappedType => ChangeWrappedTypeClick ,
304
+ HotSpotType . ChangeEnumType => ChangeEnumTypeClick
305
+ } ;
339
306
340
307
handler ? . Invoke ( this , new NodeClickEventArgs ( hitObject , hotSpot . Address , hotSpot . Memory , e . Button , e . Location ) ) ;
341
308
@@ -574,7 +541,10 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
574
541
575
542
if ( isAtEnd )
576
543
{
577
- DoScroll ( ScrollOrientation . VerticalScroll , key == Keys . Down ? 1 : - 1 ) ;
544
+ const int ScrollAmount = 3 ;
545
+
546
+ var position = AutoScrollPosition ;
547
+ AutoScrollPosition = new Point ( - position . X , - position . Y + ( key == Keys . Down ? ScrollAmount : - ScrollAmount ) * font . Height ) ;
578
548
}
579
549
580
550
Invalidate ( ) ;
0 commit comments