Skip to content

Commit 0c97545

Browse files
committed
Merge remote-tracking branch 'Github_origin/ExeptionCatch' into feature
2 parents e6472ec + ba45e03 commit 0c97545

File tree

5 files changed

+70
-23
lines changed

5 files changed

+70
-23
lines changed

EDSEditorGUI/Form1.Designer.cs

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EDSEditorGUI/Form1.cs

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ You should have received a copy of the GNU General Public License
2626
using System.Windows.Forms;
2727
using System.IO;
2828
using 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

3133
namespace 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 + "\ndoes 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 + "\ndoes 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
}

EDSEditorGUI/Form1.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
gqUTTxJHNd2gfCHts8Z5i7NeLLN6n/yF4ayxvMR1qkHEsYBFyBChoowNFOEgRrtBio0knUst/AOeXyaX
131131
Sq4NMHLMowQdiucH/4Pfs7VzE+N+UlgC2l9c92MYCO0CtYrrfh+7bu0ECD4DV0bDX6oC05+kVxpa9Ajo
132132
2QYurhuaugdc7gD9T6ZiKZ4UpBJyOeD9jL4pA/TeAp2r/tzq5zh9AFI0q8QNcHAIjOQpe63Fuzua5/bn
133-
HW9+kH4AMgFyjcd8GS4AAAAJcEhZcwAACw4AAAsOAUC+4UEAAAAHdElNRQfkCwILIglO4xvLAAAAD3RF
133+
HW9+kH4AMgFyjcd8GS4AAAAJcEhZcwAACwwAAAsMAT9AIsgAAAAHdElNRQfkCwILIglO4xvLAAAAD3RF
134134
WHRDb21tZW50AENBTm9wZW7cllV1AAAC8UlEQVRYR9WWz2sTQRTHkx6SQy5RxFv1JDGHogiVIkqFEqLE
135135
QigetKY3iSUpPYh/gD8uoQiJIEKJ0UNNRZKjTaQiHozePAk21eagCC20NdW1plTa8X3f7mw3cZNuzSr6
136136
hQ+8zn6/M29nZts6/hWdIu4T4xZJE2cJ23QvGAyKRCJhCXgp80CN2qNxTAyVP5QZZVXhn6H5mRlGCl5k

libEDSsharp/CanOpenEDS.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,13 @@ public void Loadfile(string filename)
825825
int lineno = 1;
826826
foreach (string linex in System.IO.File.ReadLines(filename))
827827
{
828-
Parseline(linex, lineno);
829-
lineno++;
828+
try
829+
{
830+
Parseline(linex, lineno);
831+
lineno++;
832+
}
833+
catch (Exception) { Warnings.warning_list.Add("Failed to open file \n" + filename);}
834+
830835
}
831836

832837
di = new DeviceInfo(eds["DeviceInfo"]);

libEDSsharp/CanOpenXDD_1_1.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,16 @@ public EDSsharp ReadXML(string file)
100100
dev = (ISO15745ProfileContainer)serializer.Deserialize(reader);
101101
reader.Close();
102102
}
103-
catch (Exception)
103+
catch (Exception e)
104104
{
105+
if (e is System.InvalidOperationException)
106+
{
107+
Warnings.warning_list.Add(String.Format("{0} {1} Action aborted!", e.Message, e.InnerException.Message));
108+
}
109+
else
110+
{
111+
Warnings.warning_list.Add(String.Format("{0} Action aborted!", e.ToString()));
112+
}
105113
return null;
106114
}
107115

0 commit comments

Comments
 (0)