@@ -36,6 +36,9 @@ public partial class MainWindow
36
36
private readonly Storyboard EnableServerAnim ;
37
37
public readonly List < MenuItem > MenuItems ;
38
38
39
+ private EditorElement EditorToFocus ;
40
+ private readonly DispatcherTimer SelectDocumentTimer ;
41
+
39
42
private bool ClosingBuffer ;
40
43
private readonly bool FullyInitialized ;
41
44
@@ -68,33 +71,53 @@ public MainWindow(SplashScreen sc)
68
71
ThemeManager . GetAppTheme ( Program . OptionsObject . Program_Theme ) ) ;
69
72
}
70
73
71
- ObjectBrowserColumn . Width =
72
- new GridLength ( Program . OptionsObject . Program_ObjectbrowserWidth , GridUnitType . Pixel ) ;
73
- var heightDescriptor =
74
- DependencyPropertyDescriptor . FromProperty ( ColumnDefinition . WidthProperty , typeof ( ItemsControl ) ) ;
75
- heightDescriptor . AddValueChanged ( EditorObjectBrowserGrid . ColumnDefinitions [ 1 ] ,
76
- EditorObjectBrowserGridRow_WidthChanged ) ;
74
+ // Timer to select the newly opened editor 200ms after it has been opened
75
+ SelectDocumentTimer = new DispatcherTimer ( )
76
+ {
77
+ Interval = TimeSpan . FromMilliseconds ( 200 ) ,
78
+ } ;
79
+
80
+ SelectDocumentTimer . Tick += ( s , e ) =>
81
+ {
82
+ SelectDocumentTimer . Stop ( ) ;
83
+ EditorToFocus . editor . Focus ( ) ;
84
+ } ;
85
+
86
+ // Restore sizes of panels and separators
87
+ ObjectBrowserColumn . Width = new GridLength ( Program . OptionsObject . Program_ObjectbrowserWidth , GridUnitType . Pixel ) ;
88
+ var heightDescriptor = DependencyPropertyDescriptor . FromProperty ( ColumnDefinition . WidthProperty , typeof ( ItemsControl ) ) ;
89
+ heightDescriptor . AddValueChanged ( EditorObjectBrowserGrid . ColumnDefinitions [ 1 ] , EditorObjectBrowserGridRow_WidthChanged ) ;
90
+
91
+ // Fill the configs menu and some toolbar combobox items
77
92
FillConfigMenu ( ) ;
78
93
CompileButton . ItemsSource = CompileButtonDict ;
79
94
CompileButton . SelectedIndex = 0 ;
80
95
CActionButton . ItemsSource = ActionButtonDict ;
81
96
CActionButton . SelectedIndex = 0 ;
82
97
98
+ // Enable/disable toolbar on startup
83
99
if ( Program . OptionsObject . UI_ShowToolBar )
84
100
{
85
101
Win_ToolBar . Height = double . NaN ;
86
102
}
87
103
104
+ // Fill OB scripting directories combobox from the bottom
88
105
OBDirList . ItemsSource = Program . Configs [ Program . SelectedConfig ] . SMDirectories ;
89
106
OBDirList . SelectedIndex = 0 ;
90
107
108
+ // Set some visual effects
91
109
MetroDialogOptions . AnimateHide = MetroDialogOptions . AnimateShow = false ;
92
110
BlendOverEffect = ( Storyboard ) Resources [ "BlendOverEffect" ] ;
93
111
EnableServerAnim = ( Storyboard ) Resources [ "EnableServerAnim" ] ;
94
112
DisableServerAnim = ( Storyboard ) Resources [ "DisableServerAnim" ] ;
113
+
114
+ // Start OB
95
115
ChangeObjectBrowserToDirectory ( Program . OptionsObject . Program_ObjectBrowserDirectory ) ;
116
+
117
+ // Translate
96
118
Language_Translate ( true ) ;
97
119
120
+ // Load previously opened files
98
121
if ( Program . OptionsObject . LastOpenFiles != null )
99
122
{
100
123
foreach ( var file in Program . OptionsObject . LastOpenFiles )
@@ -103,6 +126,7 @@ public MainWindow(SplashScreen sc)
103
126
}
104
127
}
105
128
129
+ // Take startup commands in consideration
106
130
var args = Environment . GetCommandLineArgs ( ) ;
107
131
for ( var i = 0 ; i < args . Length ; ++ i )
108
132
{
@@ -112,9 +136,11 @@ public MainWindow(SplashScreen sc)
112
136
}
113
137
}
114
138
139
+ // Close SplashScreen
115
140
sc . Close ( TimeSpan . FromMilliseconds ( 500.0 ) ) ;
116
141
FullyInitialized = true ;
117
142
143
+ // Enclose menuitems in an accesible list to set their InputGestureTexts easier
118
144
MenuItems = new ( )
119
145
{
120
146
MenuI_File ,
@@ -127,16 +153,24 @@ public MainWindow(SplashScreen sc)
127
153
} ;
128
154
129
155
LoadInputGestureTexts ( ) ;
156
+
157
+ // Load the commands dictionary in memory
130
158
LoadCommandsDictionary ( ) ;
159
+
160
+ // Load the recent files list
131
161
LoadRecentsList ( ) ;
132
162
163
+ // Disable the Reopen last closed tab button on startup for obvious reasons
133
164
MenuI_ReopenLastClosedTab . IsEnabled = false ;
134
165
166
+ // Updates the status of the File tab of the OB
135
167
UpdateOBFileButton ( ) ;
136
168
169
+ // Sets up the OB search cooldown timer
137
170
SearchCooldownTimer = new DispatcherTimer { Interval = TimeSpan . FromMilliseconds ( 300 ) } ;
138
171
SearchCooldownTimer . Tick += OnSearchCooldownTimerTick ;
139
172
173
+ // Passes the Logging Box to the LoggingControl class
140
174
LoggingControl . LogBox = LogTextbox ;
141
175
}
142
176
#endregion
@@ -390,6 +424,8 @@ private void AddEditorElement(FileInfo fInfo, string editorTitle, bool SelectMe,
390
424
{
391
425
layoutDocument . IsSelected = true ;
392
426
editor . editor . TextArea . Caret . Show ( ) ;
427
+ EditorToFocus = editor ;
428
+ SelectDocumentTimer . Start ( ) ;
393
429
}
394
430
}
395
431
0 commit comments