-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMainWindow.Diagnose.vb
More file actions
155 lines (136 loc) · 6.81 KB
/
MainWindow.Diagnose.vb
File metadata and controls
155 lines (136 loc) · 6.81 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
' 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
Console.WriteLine("========== NOTEBOOK DIAGNOSTICS ==========")
Console.WriteLine($"Timestamp: {DateTime.Now:yyyy-MM-dd HH:mm:ss}")
Console.WriteLine()
' Main notebook (editor tabs)
Console.WriteLine("MAIN NOTEBOOK (Editor):")
If pNotebook IsNot Nothing Then
Console.WriteLine($" Type: {pNotebook.GetType().Name}")
Console.WriteLine($" Pages: {pNotebook.NPages}")
Console.WriteLine($" Current Page: {pNotebook.CurrentPage}")
Console.WriteLine($" Visible: {pNotebook.Visible}")
Console.WriteLine($" Realized: {pNotebook.IsRealized}")
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)
Console.WriteLine($" Tab {i}: '{lLabel}' - Widget Visible: {lWidget?.Visible}")
Next
End If
Else
Console.WriteLine(" Not INITIALIZED")
End If
Console.WriteLine()
' Left notebook (project/object explorers)
Console.WriteLine("LEFT NOTEBOOK (Explorers):")
If pLeftNotebook IsNot Nothing Then
Console.WriteLine($" Type: {pLeftNotebook.GetType().Name}")
Console.WriteLine($" Pages: {pLeftNotebook.NPages}")
Console.WriteLine($" Current Page: {pLeftNotebook.CurrentPage}")
Console.WriteLine($" Visible: {pLeftNotebook.Visible}")
Console.WriteLine($" Realized: {pLeftNotebook.IsRealized}")
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)
Console.WriteLine($" Tab {i}: '{lLabel}' - Widget Visible: {lWidget?.Visible}")
Next
End If
Else
Console.WriteLine(" NOT INITIALIZED")
End If
Console.WriteLine()
' Bottom panel notebook
Console.WriteLine("BOTTOM NOTEBOOK (Panels):")
If pBottomPanelManager IsNot Nothing Then
Dim lBottomNotebook As Widget = pBottomPanelManager.GetNotebook()
If lBottomNotebook IsNot Nothing Then
Console.WriteLine($" Type: {lBottomNotebook.GetType().Name}")
If TypeOf lBottomNotebook Is CustomDrawNotebook Then
Dim lCustom As CustomDrawNotebook = DirectCast(lBottomNotebook, CustomDrawNotebook)
Console.WriteLine($" Pages: {lCustom.NPages}")
Console.WriteLine($" Current Page: {lCustom.CurrentPage}")
Console.WriteLine($" Visible: {lCustom.Visible}")
Console.WriteLine($" Realized: {lCustom.IsRealized}")
for i As Integer = 0 To lCustom.NPages - 1
Dim lLabel As String = lCustom.GetTabLabel(i)
Dim lWidget As Widget = lCustom.GetNthPage(i)
Console.WriteLine($" Tab {i}: '{lLabel}' - Widget Visible: {lWidget?.Visible}")
Next
End If
Else
Console.WriteLine(" Not INITIALIZED")
End If
Else
Console.WriteLine(" MANAGER Not INITIALIZED")
End If
Console.WriteLine()
Console.WriteLine("========== End DIAGNOSTICS ==========")
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
Console.WriteLine("F12 pressed - Running notebook diagnostics")
DiagnoseAllNotebooks()
' Also run EnsureNotebooksReady to attempt a fix
Console.WriteLine("Attempting To fix notebook visibility...")
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
Console.WriteLine("AutoDiagnose: Left notebook is Nothing")
lNeedsFix = True
ElseIf Not pLeftNotebook.Visible Then
Console.WriteLine("AutoDiagnose: Left notebook not visible")
lNeedsFix = True
ElseIf pMainHPaned IsNot Nothing AndAlso pMainHPaned.Position < 50 Then
Console.WriteLine($"AutoDiagnose: HPaned position too small ({pMainHPaned.Position})")
lNeedsFix = True
End If
' If issues detected, attempt automatic fix
If lNeedsFix Then
Console.WriteLine("AutoDiagnose: Issues detected, attempting automatic fix...")
ForceShowLeftPanel()
Else
Console.WriteLine("AutoDiagnose: Left panel appears OK")
End If
Catch ex As Exception
Console.WriteLine($"AutoDiagnoseOnStartup error: {ex.Message}")
End Try
End Sub
End Class