Skip to content

Commit 9cc14c4

Browse files
committed
20 files in mru list
Put selected file from mru on top of mru Do not set file dirty on export of CANopennode (save and restore actual dirty value). Lazy workaround File can be closed with right click on open Project (in tabcontrol).
1 parent 2711f0c commit 9cc14c4

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

EDSEditorGUI/Form1.cs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ private void openEDSfile(string path,InfoSection.Filetype ft)
218218

219219
private void exportCanOpenNode(DeviceView dv, string FileName, ExporterFactory.Exporter exporterType)
220220
{
221+
bool saveDirty = dv.eds.Dirty; // dispatch update will set it to dirty. Save and restore axtual dirty status
221222
Warnings.warning_list.Clear();
222223

223224
IExporter exporter = ExporterFactory.getExporter(exporterType);
@@ -241,6 +242,7 @@ private void exportCanOpenNode(DeviceView dv, string FileName, ExporterFactory.E
241242
}
242243

243244
dv.dispatch_updateOD();
245+
dv.eds.Dirty = saveDirty; // dispatch update will set it to dirty. Restore saved dirty status
244246
}
245247

246248
private void exportCanOpenNodeToolStripMenuItem_Click(object sender, EventArgs e)
@@ -762,6 +764,8 @@ void OpenRecentFile(object sender, EventArgs e)
762764
if (ext == ".dcf")
763765
openEDSfile(filepath, InfoSection.Filetype.File_DCF);
764766

767+
addtoMRU(filepath);
768+
765769
}
766770

767771
private void ODEditor_MainForm_FormClosed(object sender, FormClosedEventArgs e)
@@ -816,8 +820,8 @@ private void addtoMRU(string path)
816820

817821
_mru.Insert(0, path);
818822

819-
if (_mru.Count > 10)
820-
_mru.RemoveAt(10);
823+
if (_mru.Count > 20)
824+
_mru.RemoveAt(20);
821825

822826
populateMRU();
823827

@@ -1322,5 +1326,37 @@ private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
13221326
Preferences p = new Preferences();
13231327
p.ShowDialog();
13241328
}
1329+
1330+
private void tabControl1_MouseClick(object sender, MouseEventArgs e)
1331+
{
1332+
TabPage tp;
1333+
if (e.Button == MouseButtons.Right)
1334+
{
1335+
for (int i = 0; i <= tabControl1.TabCount - 1; i++)
1336+
{
1337+
if (tabControl1.GetTabRect(i).Contains(e.Location))
1338+
{
1339+
tp = tabControl1.TabPages[i];
1340+
1341+
DialogResult dialogResult = MessageBox.Show(tabControl1.TabPages[i].Text, "Close file?", MessageBoxButtons.YesNo);
1342+
if (dialogResult == DialogResult.Yes)
1343+
{
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]);
1356+
}
1357+
}
1358+
}
1359+
}
1360+
}
13251361
}
13261362
}

0 commit comments

Comments
 (0)