private void MtpVisu_MtpObjectDoubleClick(MtpData.MtpBaseObject source)
 {
     if (source == null)
     {
         return;
     }
     SetMessage("DblClick name {0} RefID {1}", source.Name, source.RefID);
 }
        private void MtpVisu_MtpObjectDoubleClick(MtpData.MtpBaseObject source)
        {
            // access
            if (source == null || this.activeMtpFileElem == null || this.theSubmodel?.submodelElements == null)
            {
                return;
            }

            // for the active file, find a Reference for it
            var mtpFileElemReference = this.activeMtpFileElem.GetReference();

            // inside the Submodel .. look out for Relations
            // (ConceptDescription)(no-local)[IRI]http://www.admin-shell.io/mtp/1/0/documentationReference
            var relKey = new AdminShell.Key("ConceptDescription", false,
                                            "IRI", "http://www.admin-shell.io/mtp/1/0/documentationReference");
            var searchRelation = this.theSubmodel?.submodelElements.FindDeep <AdminShell.RelationshipElement>(
                (candidate) =>
            {
                return(true == candidate?.semanticId?.MatchesExactlyOneKey(relKey, AdminShell.Key.MatchMode.Relaxed));
            });

            foreach (var rel in searchRelation)
            {
                // access
                if (rel.first == null || rel.second == null)
                {
                    continue;
                }

                // do some "math"
                var hit = false;
                if (source.Name != null)
                {
                    hit = rel.first.Matches(mtpFileElemReference
                                            + (new AdminShell.Key(
                                                   AdminShell.Key.GlobalReference, true, AdminShell.Key.Custom, source.Name)),
                                            AdminShell.Key.MatchMode.Relaxed);
                }
                if (source.RefID != null)
                {
                    hit = hit || rel.first.Matches(mtpFileElemReference
                                                   + (new AdminShell.Key(
                                                          AdminShell.Key.GlobalReference, true, AdminShell.Key.Custom, source.RefID)),
                                                   AdminShell.Key.MatchMode.Relaxed);
                }

                // yes?
                if (hit)
                {
                    var evt = new AasxPluginResultEventNavigateToReference();
                    evt.targetReference = new AdminShell.Reference(rel.second);
                    this.theEventStack.PushEvent(evt);
                }
            }
        }
Exemplo n.º 3
0
        private void MtpVisu_MtpObjectDoubleClick(MtpData.MtpBaseObject source)
        {
            // access
            var sme   = this.theSubmodel?.submodelElements;
            var first = this.activeMtpFileElem.GetReference();

            if (source == null || this.activeMtpFileElem == null || sme == null || first == null)
            {
                return;
            }

            // for the active file, find a Reference for it

            foreach (var searchId in new[] { source.Name, source.RefID })
            {
                // access
                if (searchId == null)
                {
                    continue;
                }
                //
                // Search for FileToNavigateElement
                //

                var firstFtn = first + (new AdminShell.Key(
                                            AdminShell.Key.GlobalReference, true, AdminShell.Key.Custom, searchId));
                this.theLog?.Info($"DblClick MTP .. search reference: {firstFtn.ToString(1)}");

                foreach (var fileToNav in sme.FindAllSemanticIdAs <AdminShell.RelationshipElement>(
                             this.defsInterop?.CD_FileToNavigateElement?.GetReference(), AdminShell.Key.MatchMode.Relaxed))
                {
                    if (fileToNav.first?.Matches(firstFtn, AdminShell.Key.MatchMode.Relaxed) == true)
                    {
                        // try activate
                        var ev = new AasxIntegrationBase.AasxPluginResultEventNavigateToReference();
                        ev.targetReference = new AdminShell.Reference(fileToNav.second);
                        this.theEventStack?.PushEvent(ev);
                        return;
                    }
                }

                //
                // Search for FileToEntity
                //

                var firstFte = first + (new AdminShell.Key(
                                            AdminShell.Key.GlobalReference, true, AdminShell.Key.Custom, searchId));
                this.theLog?.Info($"DblClick MTP .. search reference: {firstFte.ToString(1)}");

                foreach (var fileToEnt in sme.FindAllSemanticIdAs <AdminShell.RelationshipElement>(
                             this.defsInterop?.CD_FileToEntity?.GetReference(), AdminShell.Key.MatchMode.Relaxed))
                {
                    if (fileToEnt.first?.Matches(firstFte, AdminShell.Key.MatchMode.Relaxed) == true)
                    {
                        // debug
                        this.theLog?.Info($"try find Entity {"" + fileToEnt.second} ..");

                        // find Entity, check if self-contained
                        var foundRef = this.thePackage?.AasEnv?.FindReferableByReference(fileToEnt.second);
                        if (foundRef is AdminShell.Entity foundEnt &&
                            foundEnt.GetEntityType() == AdminShell.Entity.EntityTypeEnum.SelfManagedEntity &&
                            foundEnt.assetRef != null)
                        {
                            // try activate
                            var ev = new AasxIntegrationBase.AasxPluginResultEventNavigateToReference();
                            ev.targetReference = new AdminShell.Reference(foundEnt.assetRef);
                            this.theEventStack?.PushEvent(ev);
                            return;
                        }
                    }
                }
            }
        }