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


        #endregion

        #region WPF handling
        //==================

        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            // change title
            this.LabelPanel.Content = "Known Submodel Templates";

            // try populate
            try
            {
                // re-new
                _viewModel.Clear();

                // figure our relative path
                var basePath = "" + System.IO.Path.GetDirectoryName(
                    Assembly.GetExecutingAssembly()?.Location);

#if __old
                if (theOptions?.Records != null && theSubmodel?.semanticId != null)
                {
                    foreach (var rec in theOptions.Records)
                    {
                        var found = false;

                        if (rec.AllowSubmodelSemanticId != null)
                        {
                            foreach (var x in rec.AllowSubmodelSemanticId)
                            {
                                if (true == theSubmodel?.semanticId?.Matches(x))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }

                        if (found)
                        {
                            _viewModel.Add(new KnownSubmodelViewItem(rec, basePath));
                        }
                    }
                }
#else
                foreach (var rec in _options.LookupAllIndexKey <KnownSubmodelsOptionsRecord>(
                             _submodel?.semanticId?.GetAsExactlyOneKey()))
                {
                    _viewModel.Add(new KnownSubmodelViewItem(rec, basePath));
                }
#endif

                ScrollMainContent.ItemsSource = _viewModel;
            }
            catch (Exception ex)
            {
                _log?.Error(ex, "when preparing display items");
            }
        }
Ejemplo n.º 2
0
        public void Run()
        {
            try
            {
                exitCode = ExitCode.ErrorServerNotStarted;
                Log.Info("will start..........");
                ConsoleSampleServer().Wait();
                Console.WriteLine("Server started.");
                exitCode = ExitCode.ErrorServerRunning;
            }
            catch (Exception ex)
            {
                Utils.Trace("ServiceResultException:" + ex.Message);
                Log.Error(ex, "starting server");
                Console.WriteLine("Exception: {0}", ex.Message);
                exitCode = ExitCode.ErrorServerException;
                return;
            }

            exitCode = ExitCode.Ok;
        }
Ejemplo n.º 3
0
 public void Run()
 {
     try
     {
         exitCode = ExitCode.ErrorServerNotStarted;
         Log.Info("will start..........");
         ConsoleSampleServer().Wait();
         Console.WriteLine("Server started.");
         exitCode = ExitCode.Ok;
     }
     catch (Exception ex)
     {
         var st = ex.Message;
         if (!(IgnoreFurtherErrors && (st.Contains("Mindestens ein") || st.Contains("At least"))))
         {
             Utils.Trace("ServiceResultException:" + st);
             Log.Error(ex, "starting server");
             Console.WriteLine("Exception: {0}", ex.Message);
             exitCode = ExitCode.ErrorServerException;
             Stop();
             FinallyStopped = AllowFinallyStopped;
         }
     }
 }
Ejemplo n.º 4
0
        private void ParseSubmodelToListItems(
            AdminShell.Submodel subModel, AasxPluginDocumentShelf.DocumentShelfOptions options,
            int selectedDocClass, AasxLanguageHelper.LangEnum selectedLanguage, ViewModel.ListType selectedListType)
        {
            try
            {
                // influence list view rendering, as well
                if (selectedListType == ViewModel.ListType.Bars)
                {
                    ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForBar"];
                    ScrollMainContent.ItemsPanel   = (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForBar"];
                }

                if (selectedListType == ViewModel.ListType.Grid)
                {
                    ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForGrid"];
                    ScrollMainContent.ItemsPanel   =
                        (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForGrid"];
                }

                // clean table
                ScrollMainContent.ItemsSource = null;

                // access
                if (subModel == null || options == null)
                {
                    return;
                }

                // make sure for the right Submodel
                var found = false;
                if (options.AllowSubmodelSemanticIds != null)
                {
                    foreach (var x in options.AllowSubmodelSemanticIds)
                    {
                        if (subModel.semanticId != null && subModel.semanticId.Matches(x))
                        {
                            found = true;
                            break;
                        }
                    }
                }
                if (!found)
                {
                    return;
                }

                // right now: hardcoded check for mdoel version
                var modelVersion = DocumentEntity.SubmodelVersion.Default;
                var defs11       = AasxPredefinedConcepts.VDI2770v11.Static;
                if (subModel.semanticId.Matches(defs11?.SM_ManufacturerDocumentation?.GetSemanticKey()))
                {
                    modelVersion = DocumentEntity.SubmodelVersion.V11;
                }

                // what defaultLanguage
                string defaultLang = null;
                if (theViewModel != null && theViewModel.TheSelectedLanguage > AasxLanguageHelper.LangEnum.Any)
                {
                    defaultLang = AasxLanguageHelper.LangEnumToISO639String[(int)theViewModel.TheSelectedLanguage];
                }

                // make new list box items
                var its = new List <DocumentEntity>();
                if (modelVersion != DocumentEntity.SubmodelVersion.V11)
                {
                    its = ListOfDocumentEntity.ParseSubmodelForV10(
                        thePackage, subModel, options, defaultLang, selectedDocClass, selectedLanguage);
                }
                else
                {
                    its = ListOfDocumentEntity.ParseSubmodelForV11(
                        thePackage, subModel, defs11, defaultLang, selectedDocClass, selectedLanguage);
                }

                // post process
                foreach (var ent in its)
                {
                    // make viewbox to host __later__ created image!
                    var vb = new Viewbox();
                    vb.Stretch       = Stretch.Uniform;
                    ent.ImgContainer = vb;

                    // can already put a generated image into the viewbox?
                    if (referableHashToCachedBitmap != null &&
                        referableHashToCachedBitmap.ContainsKey(ent.ReferableHash))
                    {
                        var img = new Image();
                        img.Source             = referableHashToCachedBitmap[ent.ReferableHash];
                        ent.ImgContainer.Child = img;
                    }
                    else
                    {
                        // trigger generation of image

                        // check if already in list
                        DocumentEntity foundDe = null;
                        foreach (var de in theDocEntitiesToPreview)
                        {
                            if (ent.ReferableHash == de.ReferableHash)
                            {
                                foundDe = de;
                            }
                        }

                        lock (theDocEntitiesToPreview)
                        {
                            if (foundDe != null)
                            {
                                theDocEntitiesToPreview.Remove(foundDe);
                            }
                            theDocEntitiesToPreview.Add(ent);
                        }
                    }

                    // attach events and add
                    ent.DoubleClick += DocumentEntity_DoubleClick;
                    ent.MenuClick   += DocumentEntity_MenuClick;
                }

                // finally set
                ScrollMainContent.ItemsSource = its;
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Exception when parse/ display Submodel");
            }
        }
        private void ParseSubmodelToListItems(
            AdminShell.Submodel subModel, AasxPluginDocumentShelf.DocumentShelfOptions options,
            int selectedDocClass, ViewModel.LanguageSelection selectedLanguage, ViewModel.ListType selectedListType)
        {
            try
            {
                // influence list view rendering, as well
                if (selectedListType == ViewModel.ListType.Bars)
                {
                    ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForBar"];
                    ScrollMainContent.ItemsPanel   = (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForBar"];
                }

                if (selectedListType == ViewModel.ListType.Grid)
                {
                    ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForGrid"];
                    ScrollMainContent.ItemsPanel   =
                        (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForGrid"];
                }

                // clean table
                ScrollMainContent.ItemsSource = null;

                // access
                if (subModel == null || options == null)
                {
                    return;
                }

                // make sure for the right Submodel
                var found = false;
                if (options.AllowSubmodelSemanticIds != null)
                {
                    foreach (var x in options.AllowSubmodelSemanticIds)
                    {
                        if (subModel.semanticId != null && subModel.semanticId.Matches(x))
                        {
                            found = true;
                            break;
                        }
                    }
                }
                if (!found)
                {
                    return;
                }

                // what defaultLanguage
                string defaultLang = null;
                if (theViewModel != null && theViewModel.TheSelectedLanguage > ViewModel.LanguageSelection.All)
                {
                    defaultLang = ViewModel.LanguageSelectionToISO639String[(int)theViewModel.TheSelectedLanguage];
                }

                // set a new list
                var its = new List <DocumentEntity>();

                // look for Documents
                if (subModel?.submodelElements != null)
                {
                    foreach (var smcDoc in
                             subModel.submodelElements.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>(
                                 options?.SemIdDocument))
                    {
                        // access
                        if (smcDoc == null || smcDoc.value == null)
                        {
                            continue;
                        }

                        // look immediately for DocumentVersion, as only with this there is a valid List item
                        foreach (var smcVer in
                                 smcDoc.value.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>(
                                     options?.SemIdDocumentVersion))
                        {
                            // access
                            if (smcVer == null || smcVer.value == null)
                            {
                                continue;
                            }

                            //
                            // try to lookup info in smcDoc and smcVer
                            //

                            // take the 1st title
                            var title =
                                "" +
                                smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>(options?.SemIdTitle)?.value;

                            // could be also a multi-language title
                            foreach (var mlp in
                                     smcVer.value.FindAllSemanticIdAs <AdminShell.MultiLanguageProperty>(
                                         options?.SemIdTitle))
                            {
                                if (mlp.value != null)
                                {
                                    title = mlp.value.GetDefaultStr(defaultLang);
                                }
                            }

                            // have multiple opportunities for orga
                            var orga =
                                "" +
                                smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>(
                                    options?.SemIdOrganizationOfficialName)?.value;
                            if (orga.Trim().Length < 1)
                            {
                                orga =
                                    "" +
                                    smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>(
                                        options?.SemIdOrganizationName)?.value;
                            }

                            // class infos
                            var classId =
                                "" +
                                smcDoc.value.FindFirstSemanticIdAs <AdminShell.Property>(
                                    options?.SemIdDocumentClassId)?.value;

                            // collect country codes
                            var countryCodesStr  = new List <string>();
                            var countryCodesEnum = new List <ViewModel.LanguageSelection>();
                            foreach (var cclp in
                                     smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(options?.SemIdLanguage))
                            {
                                // language code
                                var candidate = ("" + cclp.value).Trim().ToUpper();
                                if (candidate.Length < 1)
                                {
                                    continue;
                                }

                                // convert to country codes
                                foreach (var ev in
                                         (ViewModel.LanguageSelection[])Enum.GetValues(typeof(ViewModel.LanguageSelection)))
                                {
                                    if (candidate == ViewModel.LanguageSelectionToISO639String[(int)ev]?.ToUpper())
                                    {
                                        candidate = ViewModel.LanguageSelectionToISO3166String[(int)ev]?.ToUpper();
                                        countryCodesEnum.Add(ev);
                                    }
                                }

                                // add
                                countryCodesStr.Add(candidate);
                            }

                            // evaluate, if in selection
                            var okDocClass =
                                (selectedDocClass < 1 || classId == null || classId.Trim().Length < 1 ||
                                 classId.Trim()
                                 .StartsWith(
                                     DefinitionsVDI2770.GetDocClass(
                                         (DefinitionsVDI2770.Vdi2770DocClass)selectedDocClass)));

                            var okLanguage =
                                (selectedLanguage == ViewModel.LanguageSelection.All ||
                                 countryCodesEnum == null ||
                                 // make only exception, if no language not all (not only the preferred
                                 // of LanguageSelectionToISO639String) are in the property
                                 countryCodesStr.Count < 1 ||
                                 countryCodesEnum.Contains(selectedLanguage));

                            if (!okDocClass || !okLanguage)
                            {
                                continue;
                            }

                            // further info
                            var further = "";
                            foreach (var fi in
                                     smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(
                                         options?.SemIdDocumentVersionIdValue))
                            {
                                further += "\u00b7 version: " + fi.value;
                            }
                            foreach (var fi in
                                     smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(options?.SemIdDate))
                            {
                                further += "\u00b7 date: " + fi.value;
                            }
                            if (further.Length > 0)
                            {
                                further = further.Substring(2);
                            }

                            // construct entity
                            var ent = new DocumentEntity(title, orga, further, countryCodesStr.ToArray());
                            ent.ReferableHash = String.Format(
                                "{0:X14} {1:X14}", thePackage.GetHashCode(), smcDoc.GetHashCode());

                            // for updating data, set the source elements of this document entity
                            ent.SourceElementsDocument        = smcDoc.value;
                            ent.SourceElementsDocumentVersion = smcVer.value;

                            // filename
                            var fn = smcVer.value.FindFirstSemanticIdAs <AdminShell.File>(
                                options?.SemIdDigitalFile)?.value;
                            ent.DigitalFile = fn;

                            // make viewbox to host __later__ created image!
                            var vb = new Viewbox();
                            vb.Stretch       = Stretch.Uniform;
                            ent.ImgContainer = vb;

                            // can already put a generated image into the viewbox?
                            if (referableHashToCachedBitmap != null &&
                                referableHashToCachedBitmap.ContainsKey(ent.ReferableHash))
                            {
                                var img = new Image();
                                img.Source             = referableHashToCachedBitmap[ent.ReferableHash];
                                ent.ImgContainer.Child = img;
                            }
                            else
                            {
                                // trigger generation of image

                                // check if already in list
                                DocumentEntity foundDe = null;
                                foreach (var de in theDocEntitiesToPreview)
                                {
                                    if (ent.ReferableHash == de.ReferableHash)
                                    {
                                        foundDe = de;
                                    }
                                }

                                lock (theDocEntitiesToPreview)
                                {
                                    if (foundDe != null)
                                    {
                                        theDocEntitiesToPreview.Remove(foundDe);
                                    }
                                    theDocEntitiesToPreview.Add(ent);
                                }
                            }

                            // attach events and add
                            ent.DoubleClick += DocumentEntity_DoubleClick;
                            ent.MenuClick   += DocumentEntity_MenuClick;
                            its.Add(ent);
                        }
                    }
                }

                // make new list box items
                ScrollMainContent.ItemsSource = its;
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Exception when parse/ display Submodel");
            }
        }
Ejemplo n.º 6
0
        private void ButtonTabPanels_Click(object sender, RoutedEventArgs e)
        {
            if (sender == ButtonUpdate)
            {
                // add
                if (this.currentFormInst != null &&
                    thePackage != null &&
                    theOptions != null &&
                    theSubmodel != null)
                {
                    // on this level of the hierarchy, shall a new SMEC be created or shall
                    // the existing source of elements be used?
                    AdminShell.SubmodelElementWrapperCollection currentElements = null;
                    if (formInUpdateMode && updateSourceElements != null)
                    {
                        currentElements = updateSourceElements;
                    }
                    else
                    {
                    }

                    // create a sequence of SMEs
                    try
                    {
                        this.currentFormInst.AddOrUpdateDifferentElementsToCollection(
                            currentElements, thePackage, addFilesToPackage: true, editSource: true);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "when adding Document");
                    }

#if __may_be_not__
                    // save directly to ensure consistency
                    try
                    {
                        if (thePackage.Filename != null)
                        {
                            thePackage.SaveAs(thePackage.Filename);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (theLogger != null)
                        {
                            theLogger.Log(
                                $"Saving package {thePackage.Filename} failed for adding Document " +
                                $"and gave: {ex.Message}");
                        }
                    }
#endif
                }
                else
                {
                    Log.Error("Preconditions for adding entities from GenericForm not met.");
                }

                // re-display
                DisplaySubmodel();

                // re-display also in Explorer
                var evt = new AasxPluginResultEventRedrawAllElements();
                if (theEventStack != null)
                {
                    theEventStack.PushEvent(evt);
                }
            }

            if (sender == ButtonFixCDs)
            {
                // check if CDs are present
                if (currentFormRecord == null || currentFormRecord.ConceptDescriptions == null ||
                    currentFormRecord.ConceptDescriptions.Count < 1)
                {
                    Log.Error(
                        "Not able to find appropriate ConceptDescriptions in the GeneralForm option records. " +
                        "Aborting.");
                    return;
                }

                // check for Environment
                var env = this.thePackage?.AasEnv;
                if (env == null)
                {
                    Log.Error(
                        "Not able to access AAS environment for set of Submodel's ConceptDescriptions. Aborting.");
                    return;
                }

                // be safe?
                if (MessageBoxResult.Yes != MessageBox.Show(
                        "Add missing ConceptDescriptions to the AAS?", "Question",
                        MessageBoxButton.YesNo, MessageBoxImage.Warning))
                {
                    return;
                }

                // ok, check
                int nr = 0;
                foreach (var cd in currentFormRecord.ConceptDescriptions)
                {
                    if (cd == null || cd.identification == null)
                    {
                        continue;
                    }
                    var cdFound = env.FindConceptDescription(cd.identification);
                    if (cdFound != null)
                    {
                        continue;
                    }
                    // ok, add
                    var newCd = new AdminShell.ConceptDescription(cd);
                    env.ConceptDescriptions.Add(newCd);
                    nr++;
                }

                // ok
                Log.Info("In total, {0} ConceptDescriptions were added to the AAS environment.", nr);
            }
        }
        //
        // Start page
        //

        private async void ProceedOnPageStart()
        {
            // make runtime options to link to this dialogue
            var ro = new PackCntRuntimeOptions()
            {
                Log             = _logger,
                ProgressChanged = (state, tfs, tbd) =>
                {
                    if (state == PackCntRuntimeOptions.Progress.Ongoing)
                    {
                        // determine
                        if (tfs == null)
                        {
                            tfs = 5 * 1024 * 1024;
                        }
                        var frac = Math.Min(100.0, 100.0 * tbd / tfs.Value);
                        var bshr = AdminShellUtil.ByteSizeHumanReadable(tbd);

                        SetProgressBar(frac, $"{bshr} transferred");
                    }

                    if (state == PackCntRuntimeOptions.Progress.Final)
                    {
                        SetProgressBar(0.0, "");
                    }
                },
                AskForSelectFromList = (caption, items, propRes) =>
                {
                    TabItemSelectFromList.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Background,
                        new Action(() =>
                    {
                        StartPageSelectFromList(caption, items, (li) =>
                        {
                            // never again
                            _selectFromListAction = null;
                            // call
                            propRes?.TrySetResult(li);
                        });
                    }));
                },
                AskForCredentials = (caption, propRes) =>
                {
                    TabItemCredentials.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Background,
                        new Action(() =>
                    {
                        StartPageAskCredentials(caption, (pcc) =>
                        {
                            // never again
                            _askedUserCredentials = null;
                            // call
                            propRes?.TrySetResult(pcc);
                        });
                    }));
                }
            };

            // Log
            var location = TextBoxStartLocation.Text;

            _logger?.Info($"Connect (integrated): Trying to connect to {location} ..");

            // try do the magic
            try
            {
                // quickly parse out container options
                var copts = PackageContainerOptionsBase.CreateDefault(Options.Curr, loadResident: true);
                copts.StayConnected = true == CheckBoxStayConnected.IsChecked;
                if (Int32.TryParse("" + TextBoxUpdatePeriod.Text, out int i))
                {
                    copts.UpdatePeriod = Math.Max(OptionsInformation.MinimumUpdatePeriod, i);
                }

                // create container
                var x = await PackageContainerFactory.GuessAndCreateForAsync(
                    _packageCentral,
                    location,
                    location,
                    overrideLoadResident : true,
                    containerOptions : copts,
                    runtimeOptions : ro);

                // returning "x" is the only way to end the dialogue successfuly
                if (x != null)
                {
                    // prepare result
                    _logger?.Info($"Connect (integrated): guessing and creating container package " +
                                  $"succeeded with {x.ToString()} !");
                    this.Result          = true;
                    this.ResultContainer = x;

                    // close now?
                    if (true == CheckBoxStayAutoClose.IsChecked)
                    {
                        // trigger close
                        ControlClosed?.Invoke();
                    }
                    else
                    {
                        // proceed to summary page
                        StartPageSummary();
                    }
                }
            }
            catch (Exception ex)
            {
                _logger?.Error(ex, "when guessing for packager container!");
            }
        }
Ejemplo n.º 8
0
        private void ParseSubmodelToListItems(
            AdminShell.Submodel subModel, AasxPluginDocumentShelf.DocumentShelfOptions options,
            int selectedDocClass, AasxLanguageHelper.LangEnum selectedLanguage, ViewModel.ListType selectedListType)
        {
            try
            {
                // influence list view rendering, as well
                if (selectedListType == ViewModel.ListType.Bars)
                {
                    ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForBar"];
                    ScrollMainContent.ItemsPanel   = (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForBar"];
                }

                if (selectedListType == ViewModel.ListType.Grid)
                {
                    ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForGrid"];
                    ScrollMainContent.ItemsPanel   =
                        (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForGrid"];
                }

                // clean table
                ScrollMainContent.ItemsSource = null;

                // access
                if (subModel?.semanticId == null || options == null)
                {
                    return;
                }

                // make sure for the right Submodel
                DocumentShelfOptionsRecord foundRec = null;
                foreach (var rec in options.LookupAllIndexKey <DocumentShelfOptionsRecord>(
                             subModel?.semanticId?.GetAsExactlyOneKey()))
                {
                    foundRec = rec;
                }

                if (foundRec == null)
                {
                    return;
                }

                // right now: hardcoded check for mdoel version
                var modelVersion = DocumentEntity.SubmodelVersion.Default;
                var defs11       = AasxPredefinedConcepts.VDI2770v11.Static;
                if (subModel.semanticId.Matches(defs11?.SM_ManufacturerDocumentation?.GetSemanticKey()))
                {
                    modelVersion = DocumentEntity.SubmodelVersion.V11;
                }
                if (foundRec.ForceVersion == DocumentEntity.SubmodelVersion.V10)
                {
                    modelVersion = DocumentEntity.SubmodelVersion.V10;
                }
                if (foundRec.ForceVersion == DocumentEntity.SubmodelVersion.V11)
                {
                    modelVersion = DocumentEntity.SubmodelVersion.V11;
                }

                // set checkbox
                this.CheckBoxLatestVersion.IsChecked = modelVersion == DocumentEntity.SubmodelVersion.V11;

                // set usage info
                var useinf = foundRec.UsageInfo;
                TextBlockUsageInfo.Text   = useinf;
                PanelUsageInfo.Visibility = useinf.HasContent() ? Visibility.Visible : Visibility.Collapsed;

                // what defaultLanguage
                string defaultLang = null;
                if (theViewModel != null && theViewModel.TheSelectedLanguage > AasxLanguageHelper.LangEnum.Any)
                {
                    defaultLang = AasxLanguageHelper.LangEnumToISO639String[(int)theViewModel.TheSelectedLanguage];
                }

                // make new list box items
                var its = new List <DocumentEntity>();
                if (modelVersion != DocumentEntity.SubmodelVersion.V11)
                {
                    its = ListOfDocumentEntity.ParseSubmodelForV10(
                        thePackage, subModel, options, defaultLang, selectedDocClass, selectedLanguage);
                }
                else
                {
                    its = ListOfDocumentEntity.ParseSubmodelForV11(
                        thePackage, subModel, defs11, defaultLang, selectedDocClass, selectedLanguage);
                }

                // post process
                foreach (var ent in its)
                {
                    // make viewbox to host __later__ created image!
                    var vb = new Viewbox();
                    vb.Stretch       = Stretch.Uniform;
                    ent.ImgContainer = vb;

                    // if a preview file exists, try load directly, but not interfere
                    // we delayed load logic, as these images might get more detailed
                    if (ent.PreviewFile?.Path?.HasContent() == true)
                    {
                        var inputFn = ent.PreviewFile.Path;

                        // from package?
                        if (CheckIfPackageFile(inputFn))
                        {
                            inputFn = thePackage.MakePackageFileAvailableAsTempFile(ent.PreviewFile.Path);
                        }

                        ent.LoadImageFromPath(inputFn);
                    }

                    // delayed load logic
                    // can already put a generated image into the viewbox?
                    if (referableHashToCachedBitmap != null &&
                        referableHashToCachedBitmap.ContainsKey(ent.ReferableHash))
                    {
                        var img = new Image();
                        img.Source             = referableHashToCachedBitmap[ent.ReferableHash];
                        ent.ImgContainer.Child = img;
                    }
                    else
                    {
                        // trigger generation of image

                        // check if already in list
                        DocumentEntity foundDe = null;
                        foreach (var de in theDocEntitiesToPreview)
                        {
                            if (ent.ReferableHash == de.ReferableHash)
                            {
                                foundDe = de;
                            }
                        }

                        lock (theDocEntitiesToPreview)
                        {
                            if (foundDe != null)
                            {
                                theDocEntitiesToPreview.Remove(foundDe);
                            }
                            theDocEntitiesToPreview.Add(ent);
                        }
                    }

                    // attach events and add
                    ent.DoubleClick += DocumentEntity_DoubleClick;
                    ent.MenuClick   += DocumentEntity_MenuClick;
                    ent.DragStart   += DocumentEntity_DragStart;
                }

                // finally set
                ScrollMainContent.ItemsSource = its;
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Exception when parse/ display Submodel");
            }
        }