//====================

        private void FindFileAndDisplay()
        {
            // access
            if (this.theSubmodel?.submodelElements == null || this.thePackage == null)
            {
                return;
            }

            // file?
            var fe = this.theSubmodel.submodelElements.FindFirstSemanticIdAs <AdminShell.File>(
                AasxPredefinedConcepts.ImageMap.Static.CD_ImageFile.GetReference(),
                AdminShellV20.Key.MatchMode.Relaxed);

            if (fe == null)
            {
                return;
            }

            // bitmap data
            var bitmapdata = thePackage.GetByteArrayFromUriOrLocalPackage(fe.value);

            if (bitmapdata == null)
            {
                return;
            }

            // set?
            var bi = (BitmapSource) new ImageSourceConverter().ConvertFrom(bitmapdata);

            this.ImageContent.Source = bi;
        }
Exemple #2
0
        public void TestThatSupplementaryMaterialIsLoaded()
        {
            var packaging = new AasCore.Aas3.Package.Packaging();

            using var tmpDir = new TemporaryDirectory();

            var pth = System.IO.Path.Combine(tmpDir.Path, "dummy.aasx");

            var supplUri = new Uri(
                "/aasx-suppl/some-company/some-manual.pdf",
                UriKind.Relative);

            var supplContent = Encoding.UTF8.GetBytes("some content");

            // Create a package
            {
                using var pkg = packaging.Create(pth);

                var spec = pkg.MakeSpec(
                    pkg.PutPart(
                        new Uri("/aasx/some-company/data.xml", UriKind.Relative),
                        "text/xml",
                        Get01FestoAasxXmlBytes()));

                pkg.RelateSupplementaryToSpec(
                    pkg.PutPart(
                        supplUri,
                        "application/pdf",
                        supplContent),
                    spec);

                pkg.Flush();
            }

            // Load the AASX using AasxCsharpLibrary
            {
                using var package = new AdminShellPackageEnv(pth);

                Assert.IsTrue(package.IsOpen);

                var lst = package.GetListOfSupplementaryFiles();

                Assert.AreEqual(1, lst.Count);
                var suppl = lst.First();
                Assert.AreEqual(supplUri, suppl.Uri);
                Assert.AreEqual(
                    Encoding.UTF8.GetString(supplContent),
                    Encoding.UTF8.GetString(
                        package.GetByteArrayFromUriOrLocalPackage(
                            suppl.Uri.ToString()))
                    );
            }
        }