1- using System ;
1+ using System ;
22using System . Collections . Generic ;
33using System . Diagnostics . Contracts ;
44using System . Drawing ;
1111
1212namespace ReClassNET . UI
1313{
14- public partial class MemoryViewControl : ScrollableCustomControl
14+ public partial class MemoryViewControl : UserControl
1515 {
1616 /// <summary>
1717 /// Contains informations about a selected node.
@@ -78,25 +78,15 @@ public MemoryViewControl()
7878 return ;
7979 }
8080
81+ AutoScroll = true ;
82+
8183 font = Program . MonoSpaceFont ;
8284
8385 editBox . Font = font ;
8486
8587 memoryPreviewPopUp = new MemoryPreviewPopUp ( font ) ;
8688 }
8789
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-
10090 protected override void OnPaint ( PaintEventArgs e )
10191 {
10292 base . OnPaint ( e ) ;
@@ -147,8 +137,8 @@ protected override void OnPaint(PaintEventArgs e)
147137
148138 var drawnSize = args . Node . Draw (
149139 view ,
150- - HorizontalScroll . Value ,
151- - VerticalScroll . Value * font . Height
140+ AutoScrollPosition . X ,
141+ AutoScrollPosition . Y
152142 ) ;
153143 drawnSize . Width += 10 ;
154144
@@ -157,33 +147,7 @@ protected override void OnPaint(PaintEventArgs e)
157147 e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(150, 255, 0, 0)), 1), spot.Rect);
158148 }*/
159149
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 ) ) ;
187151 }
188152
189153 private void OnSelectionChanged ( )
@@ -333,9 +297,12 @@ protected override void OnMouseClick(MouseEventArgs e)
333297 }
334298 else if ( hotSpot . Type == HotSpotType . ChangeClassType || hotSpot . Type == HotSpotType . ChangeWrappedType || hotSpot . Type == HotSpotType . ChangeEnumType )
335299 {
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+ } ;
339306
340307 handler ? . Invoke ( this , new NodeClickEventArgs ( hitObject , hotSpot . Address , hotSpot . Memory , e . Button , e . Location ) ) ;
341308
@@ -574,7 +541,10 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
574541
575542 if ( isAtEnd )
576543 {
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 ) ;
578548 }
579549
580550 Invalidate ( ) ;
0 commit comments