Repository navigation
Expand file tree
/
Copy pathMainWindow.Diagnose.vb
More file actions
executable file
·233 lines (214 loc) · 8.96 KB
/
Copy pathMainWindow.Diagnose.vb
File metadata and controls
executable file
·233 lines (214 loc) · 8.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
' MainWindow.Diagnose.vb - Diagnostic methods for MainWindow
Imports Gtk
Imports System
Imports System.IO
Imports SimpleIDE.Dialogs
Imports SimpleIDE.Utilities
Imports SimpleIDE.Widgets
Imports SimpleIDE.Models
Imports SimpleIDE.Interfaces
Partial Public Class MainWindow
''' <summary>
''' Diagnostic method to check the state of all notebooks
''' </summary>
Public Sub DiagnoseAllNotebooks()
Try
#If DEBUG Then
Console.WriteLine("========== NOTEBOOK DIAGNOSTICS ==========")
#End If
#If DEBUG Then
Console.WriteLine($"Timestamp: {DateTime.Now:yyyy-MM-dd HH:mm:ss}")
#End If
#If DEBUG Then
Console.WriteLine()
#End If
' Main notebook (editor tabs)
#If DEBUG Then
Console.WriteLine("MAIN NOTEBOOK (Editor):")
#End If
If pNotebook IsNot Nothing Then
#If DEBUG Then
Console.WriteLine($" Type: {pNotebook.GetType().Name}")
#End If
#If DEBUG Then
Console.WriteLine($" Pages: {pNotebook.NPages}")
#End If
#If DEBUG Then
Console.WriteLine($" Current Page: {pNotebook.CurrentPage}")
#End If
#If DEBUG Then
Console.WriteLine($" Visible: {pNotebook.Visible}")
#End If
#If DEBUG Then
Console.WriteLine($" Realized: {pNotebook.IsRealized}")
#End If
If TypeOf pNotebook Is CustomDrawNotebook Then
Dim lCustom As CustomDrawNotebook = DirectCast(pNotebook, CustomDrawNotebook)
for i As Integer = 0 To lCustom.NPages - 1
Dim lLabel As String = lCustom.GetTabLabel(i)
Dim lWidget As Widget = lCustom.GetNthPage(i)
#If DEBUG Then
Console.WriteLine($" Tab {i}: '{lLabel}' - Widget Visible: {lWidget?.Visible}")
#End If
Next
End If
Else
#If DEBUG Then
Console.WriteLine(" Not INITIALIZED")
#End If
End If
#If DEBUG Then
Console.WriteLine()
#End If
' Left notebook (project/object explorers)
#If DEBUG Then
Console.WriteLine("LEFT NOTEBOOK (Explorers):")
#End If
If pLeftNotebook IsNot Nothing Then
#If DEBUG Then
Console.WriteLine($" Type: {pLeftNotebook.GetType().Name}")
#End If
#If DEBUG Then
Console.WriteLine($" Pages: {pLeftNotebook.NPages}")
#End If
#If DEBUG Then
Console.WriteLine($" Current Page: {pLeftNotebook.CurrentPage}")
#End If
#If DEBUG Then
Console.WriteLine($" Visible: {pLeftNotebook.Visible}")
#End If
#If DEBUG Then
Console.WriteLine($" Realized: {pLeftNotebook.IsRealized}")
#End If
If TypeOf pLeftNotebook Is CustomDrawNotebook Then
Dim lCustom As CustomDrawNotebook = DirectCast(pLeftNotebook, CustomDrawNotebook)
For i As Integer = 0 To lCustom.NPages - 1
Dim lLabel As String = lCustom.GetTabLabel(i)
Dim lWidget As Widget = lCustom.GetNthPage(i)
#If DEBUG Then
Console.WriteLine($" Tab {i}: '{lLabel}' - Widget Visible: {lWidget?.Visible}")
#End If
Next
End If
Else
#If DEBUG Then
Console.WriteLine(" NOT INITIALIZED")
#End If
End If
#If DEBUG Then
Console.WriteLine()
#End If
' Bottom panel notebook
#If DEBUG Then
Console.WriteLine("BOTTOM NOTEBOOK (Panels):")
#End If
If pBottomPanelManager IsNot Nothing Then
Dim lBottomNotebook As Widget = pBottomPanelManager.GetNotebook()
If lBottomNotebook IsNot Nothing Then
#If DEBUG Then
Console.WriteLine($" Type: {lBottomNotebook.GetType().Name}")
#End If
If TypeOf lBottomNotebook Is CustomDrawNotebook Then
Dim lCustom As CustomDrawNotebook = DirectCast(lBottomNotebook, CustomDrawNotebook)
#If DEBUG Then
Console.WriteLine($" Pages: {lCustom.NPages}")
#End If
#If DEBUG Then
Console.WriteLine($" Current Page: {lCustom.CurrentPage}")
#End If
#If DEBUG Then
Console.WriteLine($" Visible: {lCustom.Visible}")
#End If
#If DEBUG Then
Console.WriteLine($" Realized: {lCustom.IsRealized}")
#End If
for i As Integer = 0 To lCustom.NPages - 1
Dim lLabel As String = lCustom.GetTabLabel(i)
Dim lWidget As Widget = lCustom.GetNthPage(i)
#If DEBUG Then
Console.WriteLine($" Tab {i}: '{lLabel}' - Widget Visible: {lWidget?.Visible}")
#End If
Next
End If
Else
#If DEBUG Then
Console.WriteLine(" Not INITIALIZED")
#End If
End If
Else
#If DEBUG Then
Console.WriteLine(" MANAGER Not INITIALIZED")
#End If
End If
#If DEBUG Then
Console.WriteLine()
#End If
#If DEBUG Then
Console.WriteLine("========== End DIAGNOSTICS ==========")
#End If
Catch ex As Exception
Console.WriteLine($"DiagnoseAllNotebooks error: {ex.Message}")
End Try
End Sub
''' <summary>
''' Handles F12 key press for diagnostics
''' </summary>
Private Sub OnKeyPressForDiagnostics(vSender As Object, vArgs As KeyPressEventArgs)
Try
' Check for F12 key
If vArgs.Event.Key = Gdk.Key.F12 Then
#If DEBUG Then
Console.WriteLine("F12 pressed - Running notebook diagnostics")
#End If
DiagnoseAllNotebooks()
' Also run EnsureNotebooksReady to attempt a fix
#If DEBUG Then
Console.WriteLine("Attempting To fix notebook visibility...")
#End If
EnsureNotebooksReady()
vArgs.RetVal = True ' Mark as handled
End If
Catch ex As Exception
Console.WriteLine($"OnKeyPressForDiagnostics error: {ex.Message}")
End Try
End Sub
''' <summary>
''' Automatically diagnose and fix left panel issues on startup if needed
''' </summary>
Private Sub AutoDiagnoseOnStartup()
Try
' Check if left panel is properly visible
Dim lNeedsFix As Boolean = False
' Check various conditions that indicate a problem
If pLeftNotebook Is Nothing Then
#If DEBUG Then
Console.WriteLine("AutoDiagnose: Left notebook is Nothing")
#End If
lNeedsFix = True
ElseIf Not pLeftNotebook.Visible Then
#If DEBUG Then
Console.WriteLine("AutoDiagnose: Left notebook not visible")
#End If
lNeedsFix = True
ElseIf pMainHPaned IsNot Nothing AndAlso pMainHPaned.Position < 50 Then
#If DEBUG Then
Console.WriteLine($"AutoDiagnose: HPaned position too small ({pMainHPaned.Position})")
#End If
lNeedsFix = True
End If
' If issues detected, attempt automatic fix
If lNeedsFix Then
#If DEBUG Then
Console.WriteLine("AutoDiagnose: Issues detected, attempting automatic fix...")
#End If
ForceShowLeftPanel()
Else
#If DEBUG Then
Console.WriteLine("AutoDiagnose: Left panel appears OK")
#End If
End If
Catch ex As Exception
Console.WriteLine($"AutoDiagnoseOnStartup error: {ex.Message}")
End Try
End Sub
End Class