@@ -26,6 +26,7 @@ You should have received a copy of the GNU General Public License
2626using System . IO ;
2727using libEDSsharp ;
2828using Xml2CSharp ;
29+ using static System . Windows . Forms . VisualStyles . VisualStyleElement ;
2930
3031namespace 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