Skip to content

Commit c963de8

Browse files
committed
Added scrolling with keys.
1 parent ec6ce5c commit c963de8

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

UI/MemoryViewControl.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using ReClassNET.DataExchange;
99
using ReClassNET.Debugger;
1010
using ReClassNET.Memory;
11-
using ReClassNET.Native;
1211
using ReClassNET.Nodes;
1312
using ReClassNET.Util;
1413

@@ -572,21 +571,29 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
572571
else if (key == Keys.Down || key == Keys.Up)
573572
{
574573
HotSpot toSelect = null;
574+
bool isAtEnd = false;
575+
576+
var query = hotSpots
577+
.Where(h => h.Type == HotSpotType.Select)
578+
.Where(h => h.Node.ParentNode == selectionCaret.Node.ParentNode);
579+
575580
if (key == Keys.Down)
576581
{
577-
toSelect = hotSpots
582+
var temp = query
578583
.SkipUntil(h => h.Node == selectionCaret.Node)
579-
.Where(h => h.Type == HotSpotType.Select)
580-
.Where(h => h.Node.ParentNode == selectionCaret.Node.ParentNode)
581-
.FirstOrDefault();
584+
.ToList();
585+
586+
toSelect = temp.FirstOrDefault();
587+
isAtEnd = toSelect != null && toSelect == temp.LastOrDefault();
582588
}
583589
else
584590
{
585-
toSelect = hotSpots
591+
var temp = query
586592
.TakeWhile(h => h.Node != selectionCaret.Node)
587-
.Where(h => h.Type == HotSpotType.Select)
588-
.Where(h => h.Node.ParentNode == selectionCaret.Node.ParentNode)
589-
.LastOrDefault();
593+
.ToList();
594+
595+
toSelect = temp.LastOrDefault();
596+
isAtEnd = toSelect != null && toSelect == temp.FirstOrDefault();
590597
}
591598

592599
if (toSelect != null)
@@ -622,6 +629,11 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
622629

623630
OnSelectionChanged();
624631

632+
if (isAtEnd)
633+
{
634+
DoScroll(ScrollOrientation.VerticalScroll, key == Keys.Down ? 1 : - 1);
635+
}
636+
625637
Invalidate();
626638

627639
return true;

UI/ScrollableCustomControl.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ private void DoScroll(ScrollEventType type, ScrollProperties scrollProperties)
142142
SetValue(type, scrollProperties, newValue);
143143
}
144144

145+
public void DoScroll(ScrollOrientation orientation, int amount)
146+
{
147+
if (orientation == ScrollOrientation.VerticalScroll && VerticalScroll.Enabled == false)
148+
{
149+
return;
150+
}
151+
if (orientation == ScrollOrientation.HorizontalScroll && HorizontalScroll.Enabled == false)
152+
{
153+
return;
154+
}
155+
156+
var scrollProperties = orientation == ScrollOrientation.VerticalScroll ? (ScrollProperties)VerticalScroll : (ScrollProperties)HorizontalScroll;
157+
158+
SetValue(ScrollEventType.ThumbPosition, scrollProperties, scrollProperties.Value + amount);
159+
}
160+
145161
private void ProcessMessage(ref Message msg, ScrollProperties scrollProperties)
146162
{
147163
Contract.Requires(scrollProperties != null);

0 commit comments

Comments
 (0)