Skip to content

Commit f1959a1

Browse files
committed
Merge branch 'pr/n60_inserting_target' into bugfix
# Conflicts: # EDSEditorGUI/DeviceODView.cs # EDSEditorGUI/Form1.cs
2 parents 7307e46 + 45e1d41 commit f1959a1

8 files changed

Lines changed: 1093 additions & 945 deletions

EDSEditorGUI/DeviceODView.cs

Lines changed: 636 additions & 626 deletions
Large diffs are not rendered by default.

EDSEditorGUI/DeviceView.Designer.cs

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

EDSEditorGUI/DeviceView.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
1818
*/
1919

2020
using System;
21+
using System.Collections.Generic;
2122
using System.Windows.Forms;
2223
using libEDSsharp;
2324

@@ -27,13 +28,20 @@ public partial class DeviceView : MyTabUserControl
2728
{
2829

2930
readonly public EDSsharp eds;
31+
readonly private List<EDSsharp> network;
3032

31-
public DeviceView(EDSsharp eds_target)
33+
public event EventHandler<UpdateODViewEventArgs> UpdateODViewForEDS;
34+
35+
public DeviceView(EDSsharp eds_target, List<EDSsharp> network)
3236
{
3337
eds = eds_target;
38+
this.network = network;
3439

3540
InitializeComponent();
3641

42+
this.deviceODView1.network = network;
43+
this.deviceODView1.UpdateODViewForEDS += DeviceODView1_UpdateODView;
44+
3745
foreach (TabPage tp in tabControl1.TabPages)
3846
{
3947
foreach(Object o in tp.Controls)
@@ -54,6 +62,15 @@ public DeviceView(EDSsharp eds_target)
5462

5563
}
5664

65+
private void DeviceODView1_UpdateODView(object sender, UpdateODViewEventArgs e)
66+
{
67+
EventHandler<UpdateODViewEventArgs> handler = UpdateODViewForEDS;
68+
if(handler != null)
69+
{
70+
handler(this, e);
71+
}
72+
}
73+
5774
#region UpdateDispatchEvents
5875

5976
// This region handles update requests that are dispatched to the various user controls on the tabs

EDSEditorGUI/EDSEditorGUI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
<Compile Include="TableLayoutDB.cs">
153153
<SubType>Component</SubType>
154154
</Compile>
155+
<Compile Include="UpdateODViewEventArgs.cs" />
155156
<Compile Include="Warnings.cs">
156157
<SubType>Form</SubType>
157158
</Compile>

EDSEditorGUI/Form1.cs

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ You should have received a copy of the GNU General Public License
2626
using System.IO;
2727
using libEDSsharp;
2828
using Xml2CSharp;
29+
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
2930

3031
namespace ODEditor
3132
{
@@ -154,17 +155,37 @@ void ProfileAddClick(object sender, EventArgs e)
154155
return;
155156
}
156157

157-
InsertObjects insObjForm = new InsertObjects(dv.eds, eds.ods, "0");
158+
InsertObjects insObjForm = new InsertObjects(dv.eds, network, eds.ods, "0");
158159

159160
if (insObjForm.ShowDialog() == DialogResult.OK)
160161
{
161-
dv.eds.Dirty = true;
162+
EDSsharp modifiedEds = insObjForm.GetModifiedEDS();
163+
modifiedEds.Dirty = true;
164+
165+
if(modifiedEds == dv.eds)
166+
{
162167
dv.dispatch_updateOD();
163168
dv.dispatch_updatePDOinfo();
164169

165170
dv.eds.UpdatePDOcount();
166171
dv.dispatch_updatedevice();
167172
}
173+
else
174+
{
175+
foreach(TabPage page in tabControl1.TabPages)
176+
{
177+
DeviceView devView = (DeviceView)page.Controls[0];
178+
if(devView.eds == modifiedEds)
179+
{
180+
devView.dispatch_updateOD();
181+
devView.dispatch_updatePDOinfo();
182+
183+
devView.eds.UpdatePDOcount();
184+
devView.dispatch_updatedevice();
185+
}
186+
}
187+
}
188+
}
168189
}
169190
}
170191

@@ -181,8 +202,9 @@ private void openEDSfile(string path,InfoSection.Filetype ft)
181202
Bridge bridge = new Bridge(); //tell me again why bridge is not static?
182203
dev = bridge.convert(eds);
183204

184-
DeviceView device = new DeviceView(eds);
205+
DeviceView device = new DeviceView(eds, network);
185206

207+
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
186208
eds.OnDataDirty += Eds_onDataDirty;
187209

188210
tabControl1.TabPages.Add(eds.di.ProductName);
@@ -335,8 +357,9 @@ private void openXDDfile(string path)
335357

336358
tabControl1.TabPages.Add(eds.di.ProductName);
337359

338-
DeviceView device = new DeviceView(eds);
360+
DeviceView device = new DeviceView(eds, network);
339361

362+
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
340363
eds.OnDataDirty += Eds_onDataDirty;
341364

342365
tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
@@ -381,8 +404,8 @@ private void openXMLfile(string path)
381404

382405
tabControl1.TabPages.Add(eds.di.ProductName);
383406

384-
DeviceView device = new DeviceView(eds);
385-
407+
DeviceView device = new DeviceView(eds, network);
408+
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
386409
eds.OnDataDirty += Eds_onDataDirty;
387410

388411
tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
@@ -405,6 +428,26 @@ private void openXMLfile(string path)
405428

406429
}
407430

431+
private void Device_UpdateODViewForEDS(object sender, UpdateODViewEventArgs e)
432+
{
433+
foreach (TabPage page in tabControl1.TabPages)
434+
{
435+
foreach (Control c in page.Controls)
436+
{
437+
if (c.GetType() == typeof(DeviceView))
438+
{
439+
DeviceView d = (DeviceView)c;
440+
if (d.eds == e.EDS)
441+
{
442+
d.dispatch_updateOD();
443+
}
444+
}
445+
446+
}
447+
}
448+
}
449+
450+
408451
private void Eds_onDataDirty(bool dirty, EDSsharp sender)
409452
{
410453
foreach(TabPage page in tabControl1.TabPages)
@@ -534,7 +577,6 @@ private void saveProjectToolStripMenuItem_Click(object sender, EventArgs e)
534577
}
535578
dv.eds.Dirty = false;
536579
}
537-
538580
}
539581

540582
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
@@ -634,7 +676,7 @@ void dosave(DeviceView dv, string FileName, bool xddfileVersion_1_1, bool stripp
634676
}
635677
break;
636678
}
637-
679+
638680
dv.dispatch_updateOD();
639681

640682
}
@@ -649,7 +691,8 @@ private void newToolStripMenuItem_Click(object sender, EventArgs e)
649691

650692
tabControl1.TabPages.Add(eds.di.ProductName);
651693

652-
DeviceView device = new DeviceView(eds);
694+
DeviceView device = new DeviceView(eds, network);
695+
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
653696

654697
eds.OnDataDirty += Eds_onDataDirty;
655698

@@ -892,12 +935,13 @@ private void openXDDNetworkfile(string file)
892935

893936
tabControl1.TabPages.Add(eds.di.ProductName);
894937

895-
DeviceView device = new DeviceView(eds);
938+
DeviceView device = new DeviceView(eds, network);
896939

897940
tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
898941
device.Dock = DockStyle.Fill;
899942

900943
network.Add(eds);
944+
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
901945
eds.OnDataDirty += Eds_onDataDirty;
902946

903947
device.dispatch_updateOD();
@@ -923,12 +967,13 @@ private void openNetworkfile(string file)
923967
tabControl1.TabPages.Add(eds.di.ProductName);
924968

925969

926-
DeviceView device = new DeviceView(eds);
970+
DeviceView device = new DeviceView(eds, network);
927971

928972
tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
929973
device.Dock = DockStyle.Fill;
930974

931975
network.Add(eds);
976+
device.UpdateODViewForEDS += Device_UpdateODViewForEDS;
932977
eds.OnDataDirty += Eds_onDataDirty;
933978

934979
device.dispatch_updateOD();

0 commit comments

Comments
 (0)