public void SetContents( AdminShellPackageEnv package, ConceptModelZveiTechnicalData theDefs, string defaultLang, AdminShell.Submodel sm) { // access if (sm == null) { return; } // section General var smcFurther = sm.submodelElements.FindFirstSemanticIdAs <AdminShell.SubmodelElementCollection>( theDefs.CD_FurtherInformation.GetSingleKey()); if (smcFurther != null) { // single items TextBoxValidDate.Text = "" + smcFurther.value.FindFirstSemanticIdAs <AdminShell.Property>( theDefs.CD_ValidDate.GetSingleKey())?.value; // Lines var tsl = new List <string>(); foreach (var smw in smcFurther.value.FindAllSemanticId( theDefs.CD_TextStatement.GetSingleKey(), allowedTypes: AdminShell.SubmodelElement.PROP_MLP)) { tsl.Add("" + smw?.submodelElement?.ValueAsText(defaultLang)); } ItemsControlStatements.ItemsSource = tsl; } }
public void Start( AdminShellPackageEnv package, AdminShell.Submodel sm, TechnicalDataOptions options, PluginEventStack eventStack) { // set the context this.thePackage = package; this.theSubmodel = sm; this.theOptions = options; this.theEventStack = eventStack; // retrieve the Definitions this.theDefs = new ConceptModelZveiTechnicalData(sm); // ok, directly set contents SetContents(); }
public void TableAddPropertyRows_Recurse( ConceptModelZveiTechnicalData theDefs, string defaultLang, AdminShellPackageEnv package, Table table, AdminShell.SubmodelElementWrapperCollection smwc, int depth = 0) { // access if (table == null || smwc == null) { return; } // make a RowGroup var currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); // go element by element foreach (var smw in smwc) { // access if (smw?.submodelElement == null) { continue; } var sme = smw.submodelElement; // prepare information about displayName, semantics unit var semantics = "-"; var unit = ""; // make up property name (1) var dispName = "" + sme.idShort; var dispNameWithCD = dispName; // make up semantics if (sme.semanticId != null) { if (sme.semanticId.Matches(theDefs.CD_SemanticIdNotAvailable.GetSingleKey())) { semantics = "(not available)"; } else { // the semantics display semantics = "" + sme.semanticId.ToString(2); // find better property name (2) var cd = package?.AasEnv?.FindConceptDescription(sme.semanticId); if (cd != null) { // unit? unit = "" + cd.GetIEC61360()?.unit; // names var dsn = cd.GetDefaultShortName(defaultLang); if (dsn != "") { dispNameWithCD = dsn; } var dpn = cd.GetDefaultPreferredName(defaultLang); if (dpn != "") { dispNameWithCD = dpn; } } } } // make up even better better property name (3) var descDef = "" + sme.description?.langString?.GetDefaultStr(defaultLang); if (descDef.HasContent()) { dispName = descDef; dispNameWithCD = dispName; } // special function? if (sme is AdminShell.SubmodelElementCollection && true == sme.semanticId?.Matches(theDefs.CD_MainSection.GetSingleKey())) { // finalize current row group?? ; // Main Section var cell = NewTableCellPara("" + dispName, null, "ParaStyleSectionMain", columnSpan: 3, padding: new Thickness(5 * depth, 0, 0, 0)); // add cell (to a new row group) currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); var tr = new TableRow(); currentRowGroup.Rows.Add(tr); tr.Cells.Add(cell); // recurse into that (again, new group) TableAddPropertyRows_Recurse( theDefs, defaultLang, package, table, (sme as AdminShell.SubmodelElementCollection).value, depth + 1); // start new group currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); } else if (sme is AdminShell.SubmodelElementCollection && true == sme.semanticId?.Matches(theDefs.CD_SubSection.GetSingleKey())) { // finalize current row group?? ; // Sub Section var cell = NewTableCellPara("" + dispName, null, "ParaStyleSectionSub", columnSpan: 3, padding: new Thickness(5 * depth, 0, 0, 0)); // add cell (to a new row group) currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); var tr = new TableRow(); currentRowGroup.Rows.Add(tr); tr.Cells.Add(cell); // recurse into that TableAddPropertyRows_Recurse( theDefs, defaultLang, package, table, (sme as AdminShell.SubmodelElementCollection).value, depth + 1); // start new group currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); } else if (sme is AdminShell.Property || sme is AdminShell.MultiLanguageProperty || sme is AdminShell.Range) { // make a row (in current group) var tr = new TableRow(); currentRowGroup.Rows.Add(tr); // add cells tr.Cells.Add(NewTableCellPara(dispNameWithCD, "CellStylePropertyLeftmost", "ParaStyleProperty", padding: new Thickness(5 * depth, 0, 0, 0))); tr.Cells.Add(NewTableCellPara(semantics, "CellStylePropertyOther", "ParaStyleProperty")); tr.Cells.Add(NewTableCellPara("" + sme.ValueAsText(defaultLang) + " " + unit, "CellStylePropertyOther", "ParaStyleProperty")); } } // finalize current row group?? ; }
public void SetContents( AdminShellPackageEnv package, ConceptModelZveiTechnicalData theDefs, string defaultLang, AdminShell.Submodel sm) { FlowDocViewer.Document = CreateFlowDocument(package, theDefs, defaultLang, sm); }
public FlowDocument CreateFlowDocument( AdminShellPackageEnv package, ConceptModelZveiTechnicalData theDefs, string defaultLang, AdminShell.Submodel sm) { // access if (package == null || theDefs == null || sm == null) { return(null); } // section Properties var smcProps = sm.submodelElements.FindFirstSemanticIdAs <AdminShell.SubmodelElementCollection>( theDefs.CD_TechnicalProperties.GetSingleKey()); if (smcProps == null) { return(null); } // make document FlowDocument doc = new FlowDocument(); // make a table var table = new Table(); doc.Blocks.Add(table); table.CellSpacing = 0; table.FontFamily = new FontFamily("Arial"); // make a header var tgHeader = new TableRowGroup(); table.RowGroups.Add(tgHeader); var trh = new TableRow(); tgHeader.Rows.Add(trh); trh.Cells.Add(NewTableCellPara("Property", "CellStyleHeaderLeftmost", "ParaStyleHeader")); trh.Cells.Add(NewTableCellPara("Semantics", "CellStyleHeaderOther", "ParaStyleHeader")); trh.Cells.Add(NewTableCellPara("Value", "CellStyleHeaderOther", "ParaStyleHeader")); // print properties TableAddPropertyRows_Recurse(theDefs, defaultLang, package, table, smcProps.value); // dummy cells #if FALSE int dummyCells = 0; if (dummyCells > 0) { // make a row (in current group) var currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); // add cells for (int i = 0; i < 100; i++) { var tr = new TableRow(); currentRowGroup.Rows.Add(tr); tr.Cells.Add( NewTableCellPara( "" + i, "CellStylePropertyLeftmost", "ParaStyleProperty", padding: new Thickness(5 * 0, 0, 0, 0))); tr.Cells.Add(NewTableCellPara("" + i * i, "CellStylePropertyOther", "ParaStyleProperty")); tr.Cells.Add( NewTableCellPara( "" + Math.Sqrt(1.0 * i), "CellStylePropertyOther", "ParaStyleProperty")); } } #endif // ok return(doc); }
public void SetContents( AdminShellPackageEnv package, ConceptModelZveiTechnicalData theDefs, string defaultLang, AdminShell.Submodel sm) { // access if (sm == null) { return; } // section General var smcGeneral = sm.submodelElements.FindFirstSemanticIdAs <AdminShell.SubmodelElementCollection>( theDefs.CD_GeneralInformation.GetSingleKey()); if (smcGeneral != null) { // Product info TextBoxProdDesig.Text = "" + smcGeneral.value.FindFirstSemanticId( theDefs.CD_ManufacturerProductDesignation.GetSingleKey(), allowedTypes: AdminShell.SubmodelElement.PROP_MLP)? .submodelElement?.ValueAsText(defaultLang); TextBoxProdCode.Text = "" + smcGeneral.value.FindFirstSemanticIdAs <AdminShell.Property>( theDefs.CD_ManufacturerOrderCode.GetSingleKey())?.value; TextBoxPartNumber.Text = "" + smcGeneral.value.FindFirstSemanticIdAs <AdminShell.Property>( theDefs.CD_ManufacturerPartNumber.GetSingleKey())?.value; // Manu data TextBoxManuName.Text = "" + smcGeneral.value.FindFirstSemanticIdAs <AdminShell.Property>( theDefs.CD_ManufacturerName.GetSingleKey())?.value; if (package != null) { ImageManuLogo.Source = AasxWpfBaseUtils.LoadBitmapImageFromPackage( package, smcGeneral.value.FindFirstSemanticIdAs <AdminShell.File>( theDefs.CD_ManufacturerLogo.GetSingleKey())?.value ); } // Product Images var pil = new List <ProductImageRecord>(); foreach (var pi in smcGeneral.value.FindAllSemanticIdAs <AdminShell.File>( theDefs.CD_ProductImage.GetSingleKey())) { var data = AasxWpfBaseUtils.LoadBitmapImageFromPackage(package, pi.value); if (data != null) { pil.Add(new ProductImageRecord(data)); } } ItemsControlProductImages.ItemsSource = pil; } // also Section: Product Classifications var smcClassifications = sm.submodelElements.FindFirstSemanticIdAs <AdminShell.SubmodelElementCollection>( theDefs.CD_ProductClassifications.GetSingleKey()); if (smcClassifications != null) { var clr = new List <ClassificationRecord>(); foreach (var smc in smcClassifications.value.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( theDefs.CD_ProductClassificationItem.GetSingleKey())) { var sys = ( "" + smc.value.FindFirstSemanticIdAs <AdminShell.Property>( theDefs.CD_ProductClassificationSystem.GetSingleKey())?.value).Trim(); var ver = ( "" + smc.value.FindFirstSemanticIdAs <AdminShell.Property>( theDefs.CD_ClassificationSystemVersion.GetSingleKey())?.value).Trim(); var cls = ( "" + smc.value.FindFirstSemanticIdAs <AdminShell.Property>( theDefs.CD_ProductClassId.GetSingleKey())?.value).Trim(); if (sys != "" && cls != "") { clr.Add(new ClassificationRecord(sys, ver, cls)); } } ItemsControlClassifications.ItemsSource = clr; } }