@@ -328,7 +328,7 @@ public object FillWithWpfControls(
328
328
dp . ContextMenu = new ContextMenu ( ) ;
329
329
dp . ContextMenu . Items . Add ( new MenuItem ( ) { Header = "Jump to selected .." , Tag = "JUMP" } ) ;
330
330
dp . ContextMenu . Items . Add ( new Separator ( ) ) ;
331
- dp . ContextMenu . Items . Add ( new MenuItem ( ) { Header = "Edit Node .." , Tag = "EDIT" } ) ;
331
+ dp . ContextMenu . Items . Add ( new MenuItem ( ) { Header = "Edit Node / Edge .." , Tag = "EDIT" } ) ;
332
332
dp . ContextMenu . Items . Add ( new MenuItem ( ) { Header = "Create Node (to selected) .." , Tag = "CREATE" } ) ;
333
333
dp . ContextMenu . Items . Add ( new MenuItem ( ) { Header = "Delete (selected) Node(s) .." , Tag = "DELETE" } ) ;
334
334
@@ -507,6 +507,33 @@ protected void AdjustNodeInBom(
507
507
} ) ;
508
508
}
509
509
510
+ protected void AdjustEdgeInBom (
511
+ Aas . ISubmodelElement edgeSme ,
512
+ string edgeIdShort ,
513
+ string edgeSemId ,
514
+ string edgeSuppSemId )
515
+ {
516
+ // access
517
+ if ( _submodel == null || edgeSme == null )
518
+ return ;
519
+
520
+ // write back new values
521
+ edgeSme . IdShort = edgeIdShort ;
522
+ if ( edgeSemId ? . HasContent ( ) == true )
523
+ edgeSme . SemanticId = new Aas . Reference ( Aas . ReferenceTypes . ExternalReference ,
524
+ ( new Aas . IKey [ ] { new Aas . Key ( Aas . KeyTypes . GlobalReference , edgeSemId ) } ) . ToList ( ) ) ;
525
+ else
526
+ edgeSme . SemanticId = null ;
527
+
528
+ if ( edgeSuppSemId ? . HasContent ( ) == true )
529
+ edgeSme . SupplementalSemanticIds = ( new Aas . IReference [ ] {
530
+ new Aas . Reference ( Aas . ReferenceTypes . ExternalReference ,
531
+ ( new Aas . IKey [ ] { new Aas . Key ( Aas . KeyTypes . GlobalReference , edgeSuppSemId ) } ) . ToList ( ) )
532
+ } ) . ToList ( ) ;
533
+ else
534
+ edgeSme . SupplementalSemanticIds = null ;
535
+ }
536
+
510
537
#if cdscsd
511
538
///// <summary>
512
539
/////
@@ -609,12 +636,12 @@ protected void ContextMenu_Click(object sender, RoutedEventArgs e)
609
636
if ( action != "OK" || ! ( st . AasElem is Aas . ISubmodelElement nodeSme ) )
610
637
return ;
611
638
612
- // modidfy
639
+ // modify
613
640
AdjustNodeInBom (
614
641
nodeSme ,
615
642
nodeIdShort : st . TextBoxIdShort . Text ,
616
- nodeSuppSemId : st . ComboBoxNodeSupplSemId . Text ,
617
- nodeSemId : st . ComboBoxNodeSemId . Text ) ;
643
+ nodeSemId : st . ComboBoxNodeSemId . Text ,
644
+ nodeSuppSemId : st . ComboBoxNodeSupplSemId . Text ) ;
618
645
619
646
// refresh
620
647
SetNeedsFinalize ( true ) ;
@@ -629,7 +656,9 @@ protected void ContextMenu_Click(object sender, RoutedEventArgs e)
629
656
&& edge . Edge ? . UserData is Aas . ISubmodelElement edgeSme )
630
657
{
631
658
// create job
632
- var stat = new DialogueStatus ( ) { Type = DialogueType . EditEdge , AasElem = edgeSme } ;
659
+ var stat = new DialogueStatus ( ) {
660
+ Type = DialogueType . EditEdge , AasElem = edgeSme
661
+ } ;
633
662
634
663
// set the action
635
664
stat . Action = ( st , action ) =>
@@ -638,8 +667,12 @@ protected void ContextMenu_Click(object sender, RoutedEventArgs e)
638
667
if ( action != "OK" || ! ( st . AasElem is Aas . ISubmodelElement esme ) )
639
668
return ;
640
669
641
- // modidfy
642
- esme . IdShort = st . TextBoxIdShort . Text ;
670
+ // modify
671
+ AdjustEdgeInBom (
672
+ esme ,
673
+ edgeIdShort : st . TextBoxIdShort . Text ,
674
+ edgeSemId : st . ComboBoxRelSemId . Text ,
675
+ edgeSuppSemId : st . ComboBoxRelSupplSemId . Text ) ;
643
676
644
677
// refresh
645
678
SetNeedsFinalize ( true ) ;
@@ -1263,7 +1296,7 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
1263
1296
Content = editEdge ? "Rel.idShort:" : "Node.idShort:"
1264
1297
} ) ;
1265
1298
AddToGrid ( grid , 0 , 1 , colSpan : 1 , fe : stat . TextBoxIdShort = new TextBox ( ) {
1266
- Text = editNode ? stat . AasElem ? . IdShort : "" ,
1299
+ Text = ( editNode || editEdge ) ? stat . AasElem ? . IdShort : "" ,
1267
1300
VerticalContentAlignment = VerticalAlignment . Center ,
1268
1301
Padding = new Thickness ( 0 , - 1 , 0 , - 1 ) ,
1269
1302
Margin = new Thickness ( 0 , 2 , 0 , 2 ) ,
@@ -1294,7 +1327,8 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
1294
1327
}
1295
1328
else
1296
1329
{
1297
- stat . ComboBoxNodeSemId . Text = "" + ( stat . AasElem as Aas . IHasSemantics ) . SemanticId . Keys ? . FirstOrDefault ( ) ? . Value ;
1330
+ stat . ComboBoxNodeSemId . Text = "" + ( stat . AasElem as Aas . IHasSemantics ) .
1331
+ SemanticId . Keys ? . FirstOrDefault ( ) ? . Value ;
1298
1332
}
1299
1333
1300
1334
AddToGrid ( grid , 1 , 1 , colSpan : 3 , fe : stat . ComboBoxNodeSemId ) ;
@@ -1309,6 +1343,13 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
1309
1343
VerticalContentAlignment = VerticalAlignment . Center
1310
1344
} ;
1311
1345
1346
+ if ( _bomRecords != null )
1347
+ foreach ( var br in _bomRecords )
1348
+ if ( br . NodeSupplSemIds != null )
1349
+ foreach ( var nss in br . NodeSupplSemIds )
1350
+ if ( ! stat . ComboBoxNodeSupplSemId . Items . Contains ( nss ) )
1351
+ stat . ComboBoxNodeSupplSemId . Items . Add ( nss ) ;
1352
+
1312
1353
if ( ! editNode )
1313
1354
{
1314
1355
stat . ComboBoxNodeSupplSemId . Text = "" ;
@@ -1338,10 +1379,18 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
1338
1379
1339
1380
stat . ComboBoxRelSemId . Items . Add ( prefHS . CD_HasPart ? . GetSingleKey ( ) ? . Value ) ;
1340
1381
stat . ComboBoxRelSemId . Items . Add ( prefHS . CD_IsPartOf ? . GetSingleKey ( ) ? . Value ) ;
1341
- if ( stat . ReverseDir )
1342
- stat . ComboBoxRelSemId . Text = stat . ComboBoxRelSemId . Items [ 1 ] . ToString ( ) ;
1343
- else
1344
- stat . ComboBoxRelSemId . Text = stat . ComboBoxRelSemId . Items [ 0 ] . ToString ( ) ;
1382
+
1383
+ if ( ! editEdge )
1384
+ {
1385
+ if ( stat . ReverseDir )
1386
+ stat . ComboBoxRelSemId . Text = stat . ComboBoxRelSemId . Items [ 1 ] . ToString ( ) ;
1387
+ else
1388
+ stat . ComboBoxRelSemId . Text = stat . ComboBoxRelSemId . Items [ 0 ] . ToString ( ) ;
1389
+ } else
1390
+ {
1391
+ stat . ComboBoxRelSemId . Text = "" + ( stat . AasElem as Aas . IHasSemantics )
1392
+ . SemanticId . Keys ? . FirstOrDefault ( ) ? . Value ;
1393
+ }
1345
1394
1346
1395
AddToGrid ( grid , 3 , 1 , colSpan : 3 , fe : stat . ComboBoxRelSemId ) ;
1347
1396
@@ -1355,6 +1404,24 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
1355
1404
VerticalContentAlignment = VerticalAlignment . Center
1356
1405
} ;
1357
1406
1407
+ if ( _bomRecords != null )
1408
+ foreach ( var br in _bomRecords )
1409
+ if ( br . EdgeSupplSemIds != null )
1410
+ foreach ( var nss in br . EdgeSupplSemIds )
1411
+ if ( ! stat . ComboBoxRelSupplSemId . Items . Contains ( nss ) )
1412
+ stat . ComboBoxRelSupplSemId . Items . Add ( nss ) ;
1413
+
1414
+ if ( ! editEdge )
1415
+ {
1416
+ stat . ComboBoxRelSupplSemId . Text = "" ;
1417
+ }
1418
+ else
1419
+ {
1420
+ stat . ComboBoxRelSupplSemId . Text =
1421
+ "" + ( stat . AasElem as Aas . IHasSemantics ) ? . SupplementalSemanticIds ?
1422
+ . FirstOrDefault ( ) ? . Keys ? . FirstOrDefault ( ) ? . Value ;
1423
+ }
1424
+
1358
1425
AddToGrid ( grid , 4 , 1 , colSpan : 3 , fe : stat . ComboBoxRelSupplSemId ) ;
1359
1426
}
1360
1427
0 commit comments