Skip to content
This repository has been archived by the owner on Apr 7, 2019. It is now read-only.

Commit

Permalink
Fix Issue #46 crash due to invalid DataGridView scroll window size
Browse files Browse the repository at this point in the history
  • Loading branch information
gerritv committed Feb 7, 2016
1 parent 65cb036 commit d29ee07
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
This file documents changes made:
V1.0.9.0 = 2016 Feb 7
V1.0.9.0a = 2016 Feb 7
- Change Set All Axis to Zero from Keypad.0 to key.A Issue #45
- Fix load time on large/huge file, Issue #44
- Replaced ListView with DataGridView for gcode display. Sets up for editing and MDI history in future
- Moved GcodeView class to its own file, refactored code to improve separation
- Removed out of date TODO's
- Fixed error in displaying in gcode view Issue #46
V1.0.8.0 - 2016 Feb 3
- Replace Readline style serial io with Async Read for responsiveness, reliability
- Disable MDI if not connected
Expand Down
3 changes: 2 additions & 1 deletion Grbl-Panel/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
This file documents changes made:
V1.0.9.0 = 2016 Feb 7
V1.0.9.0a = 2016 Feb 7
- Change Set All Axis to Zero from Keypad.0 to key.A Issue #45
- Fix load time on large/huge file, Issue #44
- Replaced ListView with DataGridView for gcode display. Sets up for editing and MDI history in future
- Moved GcodeView class to its own file, refactored code to improve separation
- Removed out of date TODO's
- Fixed error in displaying in gcode view Issue #46
V1.0.8.0 - 2016 Feb 3
- Replace Readline style serial io with Async Read for responsiveness, reliability
- Disable MDI if not connected
Expand Down
39 changes: 29 additions & 10 deletions Grbl-Panel/GrblGcodeView.vb
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,43 @@

Public Sub UpdateGCodeStatus(ByVal stat As String, ByVal index As Integer)
' Set the Status column of the line item
' Keep current active line visible in the view

Dim a As Integer = 0

Dim b As Integer = 0
With _dgview
a = .FirstDisplayedScrollingRowIndex
b = .DisplayedRowCount(True)
End With
Console.WriteLine("a,b, index{0} {1} {2})", a, b, index)


If _filemode Then
_gcodeTable(index).status = stat
If index < _dgview.FirstDisplayedScrollingRowIndex Then
' Make top of queue visible again
_dgview.FirstDisplayedScrollingRowIndex = 0
Else
If (_dgview.FirstDisplayedScrollingRowIndex + _dgview.DisplayedRowCount(True) <= index) Then
_dgview.FirstDisplayedScrollingRowIndex = index - _dgview.DisplayedRowCount(True) + 5
End If
End If
Else ' we always pick the last entry
_gcodeTable(_gcodeTable.Count - 1).status = stat
End If
If index = -1 Then
' we are in MDI mode so use bottom
index = _dgview.RowCount
End If
' Keep current active line visible
If index < _dgview.FirstDisplayedScrollingRowIndex Then
' Make top of queue visible again
_dgview.FirstDisplayedScrollingRowIndex = 0
Else
If (_dgview.FirstDisplayedScrollingRowIndex + _dgview.DisplayedRowCount(True) <= index) Then
_dgview.FirstDisplayedScrollingRowIndex = index - _dgview.DisplayedRowCount(False) + 5
If index < _dgview.FirstDisplayedScrollingRowIndex Then
' Make top of queue visible again
_dgview.FirstDisplayedScrollingRowIndex = 0
Else
If (_dgview.FirstDisplayedScrollingRowIndex + _dgview.DisplayedRowCount(True) <= index) Then
_dgview.FirstDisplayedScrollingRowIndex = index - _dgview.DisplayedRowCount(True) + 1
End If
End If
End If


_dgview.Refresh()
End Sub

Expand Down

0 comments on commit d29ee07

Please sign in to comment.