@@ -26,7 +26,9 @@ You should have received a copy of the GNU General Public License
2626using System . Windows . Forms ;
2727using System . IO ;
2828using libEDSsharp ;
29- using static System . Windows . Forms . VisualStyles . VisualStyleElement ;
29+ //using static System.Windows.Forms.VisualStyles.VisualStyleElement;
30+ //using SourceGrid.Cells.Controllers;
31+ //using ToolTip = System.Windows.Forms.ToolTip;
3032
3133namespace ODEditor
3234{
@@ -189,6 +191,12 @@ private void openEDSfile(string path,InfoSection.Filetype ft)
189191 {
190192 EDSsharp eds = new EDSsharp ( ) ;
191193
194+ if ( ! File . Exists ( path ) )
195+ {
196+ MessageBox . Show ( "File " + path + "\n does not exist." ) ;
197+ return ;
198+ }
199+
192200 eds . Loadfile ( path ) ;
193201
194202 DeviceView device = new DeviceView ( eds , network ) ;
@@ -327,6 +335,11 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
327335
328336 private void openXDDfile ( string path )
329337 {
338+ if ( ! File . Exists ( path ) )
339+ {
340+ MessageBox . Show ( "File " + path + "\n does not exist." ) ;
341+ return ;
342+ }
330343 try
331344 {
332345 EDSsharp eds ;
@@ -449,13 +462,13 @@ private void Eds_onDataDirty(bool dirty, EDSsharp sender)
449462 {
450463 foreach ( Control c in page . Controls )
451464 {
452- if ( c . GetType ( ) == typeof ( DeviceView ) )
465+ if ( c . GetType ( ) == typeof ( DeviceView ) )
453466 {
454467 DeviceView d = ( DeviceView ) c ;
455468 if ( d . eds . Dirty == true )
456469 {
457470 page . BackColor = Color . Tomato ;
458- }
471+ }
459472 else
460473 {
461474 page . BackColor = default ( Color ) ;
@@ -1329,34 +1342,52 @@ private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
13291342
13301343 private void tabControl1_MouseClick ( object sender , MouseEventArgs e )
13311344 {
1332- TabPage tp ;
13331345 if ( e . Button == MouseButtons . Right )
13341346 {
13351347 for ( int i = 0 ; i <= tabControl1 . TabCount - 1 ; i ++ )
13361348 {
13371349 if ( tabControl1 . GetTabRect ( i ) . Contains ( e . Location ) )
13381350 {
1339- tp = tabControl1 . TabPages [ i ] ;
1340-
13411351 DialogResult dialogResult = MessageBox . Show ( tabControl1 . TabPages [ i ] . Text , "Close file?" , MessageBoxButtons . YesNo ) ;
13421352 if ( dialogResult == DialogResult . Yes )
13431353 {
1344-
1345- DeviceView device = ( DeviceView ) tabControl1 . TabPages [ i ] . Controls [ 0 ] ;
1346-
1347- if ( device . eds . Dirty == true )
1348- {
1349- if ( MessageBox . Show ( "All unsaved changes will be lost\n continue?" , "Unsaved changes" , MessageBoxButtons . YesNo ) == DialogResult . No )
1350- return ;
1351- }
1352-
1353- network . Remove ( device . eds ) ;
1354-
1355- tabControl1 . TabPages . Remove ( tabControl1 . TabPages [ i ] ) ;
1354+ DeviceView device = ( DeviceView ) tabControl1 . TabPages [ i ] . Controls [ 0 ] ;
1355+ if ( device . eds . Dirty == true )
1356+ {
1357+ if ( MessageBox . Show ( "All unsaved changes will be lost\n continue?" , "Unsaved changes" , MessageBoxButtons . YesNo ) == DialogResult . No )
1358+ return ;
1359+ }
1360+ network . Remove ( device . eds ) ;
1361+ tabControl1 . TabPages . Remove ( tabControl1 . TabPages [ i ] ) ;
13561362 }
13571363 }
13581364 }
13591365 }
13601366 }
1367+ private void tabControl1_MouseHover ( object sender , EventArgs e )
1368+ {
1369+
1370+ TabControl tabControl = sender as TabControl ;
1371+ Point mousePosition = tabControl . PointToClient ( Cursor . Position ) ;
1372+ for ( int i = 0 ; i < tabControl . TabCount ; i ++ )
1373+ {
1374+ Rectangle tabRect = tabControl . GetTabRect ( i ) ;
1375+ if ( tabRect . Contains ( mousePosition ) )
1376+ {
1377+ ToolTip toolTip = new ToolTip ( ) ;
1378+ // Set up the delays for the ToolTip.
1379+
1380+ toolTip . AutoPopDelay = 5000 ;
1381+ toolTip . InitialDelay = 1000 ;
1382+ toolTip . ReshowDelay = 500 ;
1383+ // Force the ToolTip text to be displayed whether or not the form is active.
1384+ toolTip . ShowAlways = true ;
1385+ DeviceView device = ( DeviceView ) tabControl1 . TabPages [ i ] . Controls [ 0 ] ;
1386+ toolTip . SetToolTip ( tabControl , device . eds . projectFilename ) ;
1387+ break ;
1388+ }
1389+ }
1390+ }
1391+
13611392 }
13621393}
0 commit comments