Esempio n. 1
0
        public blazorSessionService()
        {
            sessionNumber = ++sessionCounter;
            sessionTotal++;
            AnyUiDisplayContextHtml.addSession(sessionNumber);

            packages        = new PackageCentral();
            _packageCentral = packages;

            env = null;

            helper             = new DispEditHelperEntities();
            helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);
            // some functionality still uses repo != null to detect editMode!!
            repo            = new ModifyRepo();
            helper.editMode = editMode;
            helper.hintMode = hintMode;
            helper.repo     = repo;
            helper.context  = null;
            helper.packages = packages;

            stack17 = new AnyUiStackPanel()
            {
                Orientation = AnyUiOrientation.Vertical
            };

            if (env?.AasEnv?.AdministrationShells != null)
            {
                helper.DisplayOrEditAasEntityAas(packages, env.AasEnv,
                                                 env.AasEnv.AdministrationShells[0], editMode, stack17, hintMode: hintMode);
            }

            htmlDotnetThread = new Thread(AnyUiDisplayContextHtml.htmlDotnetLoop);
            htmlDotnetThread.Start();
        }
Esempio n. 2
0
        //
        // Qualifiable
        //

        public void DisplayOrEditEntityQualifierCollection(AnyUiStackPanel stack,
                                                           AdminShell.QualifierCollection qualifiers,
                                                           Action <AdminShell.QualifierCollection> setOutput,
                                                           AdminShell.Referable relatedReferable = null)
        {
            // access
            if (stack == null)
            {
                return;
            }

            // members
            this.AddGroup(stack, "Qualifiable:", levelColors.SubSection);

            if (this.SafeguardAccess(
                    stack, repo, qualifiers, "Qualifiers:", "Create empty list of Qualifiers!",
                    v =>
            {
                setOutput?.Invoke(new AdminShell.QualifierCollection());
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.QualifierHelper(stack, repo, qualifiers, relatedReferable: relatedReferable);
            }
        }
Esempio n. 3
0
        //
        // List of References
        //

        public void DisplayOrEditEntityListOfReferences(AnyUiStackPanel stack,
                                                        List <AdminShell.Reference> references,
                                                        Action <List <AdminShell.Reference> > setOutput,
                                                        string entityName,
                                                        string[] addPresetNames = null, AdminShell.Key[] addPresetKeys = null,
                                                        AdminShell.Referable relatedReferable = null)
        {
            // access
            if (stack == null)
            {
                return;
            }

            // hasDataSpecification are MULTIPLE references. That is: multiple x multiple keys!
            if (this.SafeguardAccess(
                    stack, this.repo, references, $"{entityName}:", "Create data element!",
                    v =>
            {
                setOutput?.Invoke(new List <AdminShell.Reference>());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddGroup(stack, $"{entityName}:", levelColors.SubSection);

                if (editMode)
                {
                    // let the user control the number of references
                    this.AddAction(
                        stack, $"{entityName}:", new[] { "Add Reference", "Delete last reference" }, repo,
                        (buttonNdx) =>
                    {
                        if (buttonNdx == 0)
                        {
                            references.Add(new AdminShell.Reference());
                        }

                        if (buttonNdx == 1 && references.Count > 0)
                        {
                            references.RemoveAt(references.Count - 1);
                        }

                        return(new AnyUiLambdaActionRedrawEntity());
                    });
                }

                // now use the normal mechanism to deal with editMode or not ..
                if (references != null && references.Count > 0)
                {
                    for (int i = 0; i < references.Count; i++)
                    {
                        this.AddKeyListKeys(
                            stack, String.Format("reference[{0}]", i), references[i].Keys, repo,
                            packages, PackageCentral.PackageCentral.Selector.MainAux,
                            AdminShell.Key.AllElements,
                            addEclassIrdi: true,
                            relatedReferable: relatedReferable);
                    }
                }
            }
        }
Esempio n. 4
0
        //
        // special Submodel References
        //

        public void DisplayOrEditEntitySubmodelRef(AnyUiStackPanel stack,
                                                   AdminShell.SubmodelRef smref,
                                                   Action <AdminShell.SubmodelRef> setOutput,
                                                   string entityName)
        {
            // access
            if (stack == null)
            {
                return;
            }

            // members
            this.AddHintBubble(stack, hintMode, new[] {
                new HintCheck(
                    () => { return(smref == null); },
                    $"No {entityName}. Please consider adding a reference " +
                    "to an adequate Submodel."),
            });
            if (this.SafeguardAccess(
                    stack, repo, smref, $"{entityName}:",
                    "Create data element!",
                    v =>
            {
                setOutput?.Invoke(new AdminShell.SubmodelRef());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddGroup(
                    stack, $"{entityName} - Reference to describing Submodel:",
                    levelColors.SubSection);
                this.AddKeyListKeys(
                    stack, $"{entityName}:", smref.Keys,
                    repo, packages, PackageCentral.PackageCentral.Selector.Main, "Submodel");
            }
        }
Esempio n. 5
0
        //
        // HasSemantic
        //

        public void DisplayOrEditEntitySemanticId(AnyUiStackPanel stack,
                                                  AdminShell.SemanticId semanticId,
                                                  Action <AdminShell.SemanticId> setOutput,
                                                  string statement           = null,
                                                  bool checkForCD            = false,
                                                  string addExistingEntities = null,
                                                  CopyPasteBuffer cpb        = null)
        {
            // access
            if (stack == null)
            {
                return;
            }

            // members
            this.AddGroup(stack, "Semantic ID:", levelColors.SubSection);

            // hint
            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => { return(semanticId == null || semanticId.IsEmpty); },
                    "Check if you want to add a semantic reference. " + statement,
                    severityLevel: HintCheck.Severity.Notice,
                    breakIfTrue: true),
                new HintCheck(
                    () => { return(checkForCD &&
                                   semanticId[0].type != AdminShell.Key.ConceptDescription); },
                    "The semanticId usually refers to a ConceptDescription " +
                    "within the respective repository.",
                    severityLevel: HintCheck.Severity.Notice)
            });

            // add from Copy Buffer
            var bufferKeys = CopyPasteBuffer.PreparePresetsForListKeys(cpb);

            // add the keys
            if (this.SafeguardAccess(
                    stack, repo, semanticId, "semanticId:", "Create data element!",
                    v =>
            {
                setOutput?.Invoke(new AdminShell.SemanticId());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddKeyListKeys(
                    stack, "semanticId", semanticId.Keys, repo,
                    packages, PackageCentral.PackageCentral.Selector.MainAux,
                    addExistingEntities: addExistingEntities, addFromPool: true,
                    addEclassIrdi: true,
                    addPresetNames: bufferKeys.Item1,
                    addPresetKeyLists: bufferKeys.Item2,
                    jumpLambda: (kl) =>
                {
                    return(new AnyUiLambdaActionNavigateTo(AdminShell.Reference.CreateNew(kl)));
                });
            }
        }
Esempio n. 6
0
        //
        //
        // --- Overall calling function
        //
        //

        public AnyUiStackPanel ClearDisplayDefautlStack()
        {
            theMasterPanel.Children.Clear();
            var sp    = new AnyUiStackPanel();
            var spwpf = new Label();

            DockPanel.SetDock(spwpf, Dock.Top);
            theMasterPanel.Children.Add(spwpf);
            _lastRenderedRootElement = null;
            return(sp);
        }
Esempio n. 7
0
        public void DisplayOrEditEntityModelingKind(AnyUiStackPanel stack,
                                                    AdminShell.ModelingKind kind,
                                                    Action <AdminShell.ModelingKind> setOutput,
                                                    string instanceExceptionStatement     = null,
                                                    AdminShell.Referable relatedReferable = null)
        {
            // access
            if (stack == null)
            {
                return;
            }

            // members
            this.AddGroup(stack, "Kind (of model):", levelColors.SubSection);

            this.AddHintBubble(stack, hintMode, new[] {
                new HintCheck(
                    () => { return(kind == null); },
                    "Providing kind information is mandatory. Typically you want to model instances. " +
                    "A manufacturer would define types of assets, as well.",
                    breakIfTrue: true),
                new HintCheck(
                    () => { return(kind.kind.Trim().ToLower() != "instance"); },
                    "Check for kind setting. 'Instance' is the usual choice." + instanceExceptionStatement,
                    severityLevel: HintCheck.Severity.Notice)
            });
            if (this.SafeguardAccess(
                    stack, repo, kind, "kind:", "Create data element!",
                    v =>
            {
                setOutput?.Invoke(new AdminShell.ModelingKind());
                return(new AnyUiLambdaActionRedrawEntity());
            }
                    ))
            {
                this.AddKeyValueRef(
                    stack, "kind", kind, ref kind.kind, null, repo,
                    v =>
                {
                    kind.kind = v as string;
                    this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                    return(new AnyUiLambdaActionNone());
                },
                    new[] { AdminShell.ModelingKind.Template, AdminShell.ModelingKind.Instance });
            }
        }
Esempio n. 8
0
        //
        // DataSpecificationIEC61360
        //

        public void DisplayOrEditEntityDataSpecificationIEC61360(AnyUiStackPanel stack,
                                                                 AdminShell.DataSpecificationIEC61360 dsiec,
                                                                 AdminShell.Referable relatedReferable = null)
        {
            // access
            if (stack == null || dsiec == null)
            {
                return;
            }

            // members
            this.AddGroup(
                stack, "Data Specification Content IEC61360:", levelColors.SubSection);

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => { return(dsiec.preferredName == null || dsiec.preferredName.Count < 1); },
                    "Please add a preferred name, which could be used on user interfaces " +
                    "to identify the concept to a human person.",
                    breakIfTrue: true),
                new HintCheck(
                    () => { return(dsiec.preferredName.Count < 2); },
                    "Please add multiple languanges.")
            });
            if (this.SafeguardAccess(
                    stack, repo, dsiec.preferredName, "preferredName:", "Create data element!",
                    v =>
            {
                dsiec.preferredName = new AdminShell.LangStringSetIEC61360();
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddKeyListLangStr(stack, "preferredName", dsiec.preferredName,
                                       repo, relatedReferable: relatedReferable);
            }

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => { return(dsiec.shortName == null || dsiec.shortName.Count < 1); },
                    "Please check if you can add a short name, which is a reduced, even symbolic version of " +
                    "the preferred name. IEC 61360 defines some symbolic rules " +
                    "(e.g. greek characters) for this name.",
                    severityLevel: HintCheck.Severity.Notice,
                    breakIfTrue: true),
                new HintCheck(
                    () => { return(dsiec.shortName.Count < 2); },
                    "Please add multiple languanges.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            if (this.SafeguardAccess(
                    stack, repo, dsiec.shortName, "shortName:", "Create data element!",
                    v =>
            {
                dsiec.shortName = new AdminShell.LangStringSetIEC61360();
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddKeyListLangStr(stack, "shortName", dsiec.shortName,
                                       repo, relatedReferable: relatedReferable);
            }

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => {
                    return((dsiec.unitId == null || dsiec.unitId.Count < 1) &&
                           (dsiec.unit == null || dsiec.unit.Trim().Length < 1));
                },
                    "Please check, if you can provide a unit or a unitId, " +
                    "in which the concept is being measured. " +
                    "Usage of SI-based units is encouraged.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            this.AddKeyValueRef(
                stack, "unit", dsiec, ref dsiec.unit, null, repo,
                v =>
            {
                dsiec.unit = v as string;
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionNone());
            });

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => {
                    return((dsiec.unit == null || dsiec.unit.Trim().Length < 1) &&
                           (dsiec.unitId == null || dsiec.unitId.Count < 1));
                },
                    "Please check, if you can provide a unit or a unitId, " +
                    "in which the concept is being measured. " +
                    "Usage of SI-based units is encouraged.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            if (this.SafeguardAccess(
                    stack, repo, dsiec.unitId, "unitId:", "Create data element!",
                    v =>
            {
                dsiec.unitId = new AdminShell.UnitId();
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddKeyListKeys(
                    stack, "unitId", dsiec.unitId.Keys, repo,
                    packages, PackageCentral.PackageCentral.Selector.MainAux,
                    AdminShell.Key.GlobalReference, addEclassIrdi: true,
                    relatedReferable: relatedReferable);
            }

            this.AddKeyValueRef(
                stack, "valueFormat", dsiec, ref dsiec.valueFormat, null, repo,
                v =>
            {
                dsiec.valueFormat = v as string;
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionNone());
            });

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () =>
                {
                    return(dsiec.sourceOfDefinition == null || dsiec.sourceOfDefinition.Length < 1);
                },
                    "Please check, if you can provide a source of definition for the concepts. " +
                    "This could be an informal link to a document, glossary item etc.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            this.AddKeyValueRef(
                stack, "sourceOfDef.", dsiec, ref dsiec.sourceOfDefinition, null, repo,
                v =>
            {
                dsiec.sourceOfDefinition = v as string;
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionNone());
            });

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => { return(dsiec.symbol == null || dsiec.symbol.Trim().Length < 1); },
                    "Please check, if you can provide formulaic character for the concept.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            this.AddKeyValueRef(
                stack, "symbol", dsiec, ref dsiec.symbol, null, repo,
                v =>
            {
                dsiec.symbol = v as string;
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionNone());
            });

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => { return(dsiec.dataType == null || dsiec.dataType.Trim().Length < 1); },
                    "Please provide data type for the concept. " +
                    "Data types are provided by the IEC 61360.")
            });
            this.AddKeyValueRef(
                stack, "dataType", dsiec, ref dsiec.dataType, null, repo,
                v =>
            {
                dsiec.dataType = v as string;
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionNone());
            },
                comboBoxIsEditable: true,
                comboBoxItems: AdminShell.DataSpecificationIEC61360.DataTypeNames);

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => { return(dsiec.definition == null || dsiec.definition.Count < 1); },
                    "Please check, if you can add a definition, which could be used to describe exactly, " +
                    "how to establish a value/ measurement for the concept.",
                    severityLevel: HintCheck.Severity.Notice,
                    breakIfTrue: true),
                new HintCheck(
                    () => { return(dsiec.definition.Count < 2); },
                    "Please add multiple languanges.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            if (this.SafeguardAccess(
                    stack, repo, dsiec.definition, "definition:", "Create data element!",
                    v =>
            {
                dsiec.definition = new AdminShell.LangStringSetIEC61360();
                this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddKeyListLangStr(stack, "definition", dsiec.definition,
                                       repo, relatedReferable: relatedReferable);
            }
        }
Esempio n. 9
0
        //
        // Data Specification
        //

        public void DisplayOrEditEntityHasDataSpecificationReferences(AnyUiStackPanel stack,
                                                                      AdminShell.HasDataSpecification hasDataSpecification,
                                                                      Action <AdminShell.HasDataSpecification> setOutput,
                                                                      string[] addPresetNames               = null, AdminShell.KeyList[] addPresetKeyLists = null,
                                                                      bool dataSpecRefsAreUsual             = false,
                                                                      AdminShell.Referable relatedReferable = null)
        {
            // access
            if (stack == null)
            {
                return;
            }

            // members
            this.AddGroup(stack, "HasDataSpecification (Reference):", levelColors.SubSection);

            // hasDataSpecification are MULTIPLE references. That is: multiple x multiple keys!
            this.AddHintBubble(stack, hintMode, new[] {
                new HintCheck(
                    () => { return(!dataSpecRefsAreUsual && hasDataSpecification != null &&
                                   hasDataSpecification.Count > 0); },
                    "Check if a data specification is appropriate here.",
                    breakIfTrue: true,
                    severityLevel: HintCheck.Severity.Notice)
            });
            if (this.SafeguardAccess(
                    stack, this.repo, hasDataSpecification, "DataSpecification:", "Create data element!",
                    v =>
            {
                setOutput?.Invoke(new AdminShell.HasDataSpecification());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                if (editMode)
                {
                    // let the user control the number of references
                    this.AddAction(
                        stack, "Specifications:",
                        new[] { "Add Reference", "Delete last reference" }, repo,
                        (buttonNdx) =>
                    {
                        if (buttonNdx == 0)
                        {
                            hasDataSpecification.Add(
                                new AdminShell.EmbeddedDataSpecification(
                                    new AdminShell.DataSpecificationRef()));
                        }

                        if (buttonNdx == 1 && hasDataSpecification.Count > 0)
                        {
                            hasDataSpecification.RemoveAt(
                                hasDataSpecification.Count - 1);
                        }

                        this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
                        return(new AnyUiLambdaActionRedrawEntity());
                    });
                }

                // now use the normal mechanism to deal with editMode or not ..
                if (hasDataSpecification != null && hasDataSpecification.Count > 0)
                {
                    for (int i = 0; i < hasDataSpecification.Count; i++)
                    {
                        if (hasDataSpecification[i].dataSpecification != null)
                        {
                            this.AddKeyListKeys(
                                stack, String.Format("reference[{0}]", i),
                                hasDataSpecification[i].dataSpecification.Keys,
                                repo, packages, PackageCentral.PackageCentral.Selector.MainAux,
                                addExistingEntities: null /* "All" */,
                                addPresetNames: addPresetNames, addPresetKeyLists: addPresetKeyLists,
                                relatedReferable: relatedReferable);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        //
        // Identifiable
        //

        public void DisplayOrEditEntityIdentifiable(AnyUiStackPanel stack,
                                                    AdminShell.Identifiable identifiable,
                                                    string templateForIdString,
                                                    DispEditInjectAction injectToId = null,
                                                    bool checkForIri = true)
        {
            // access
            if (stack == null || identifiable == null)
            {
                return;
            }

            // members
            this.AddGroup(stack, "Identifiable:", levelColors.SubSection);

            this.AddHintBubble(stack, hintMode, new[] {
                new HintCheck(
                    () => { return(identifiable.identification == null); },
                    "Providing a worldwide unique identification is mandatory.",
                    breakIfTrue: true),
                new HintCheck(
                    () => { return(checkForIri &&
                                   identifiable.identification.idType != AdminShell.Identification.IRI); },
                    "Check if identification type is correct. Use of IRIs is usual here.",
                    severityLevel: HintCheck.Severity.Notice),
                new HintCheck(
                    () => { return(identifiable.identification.id.Trim() == ""); },
                    "Identification id shall not be empty. You could use the 'Generate' button in order to " +
                    "generate a worldwide unique id. " +
                    "The template of this id could be set by commandline arguments.")
            });
            if (this.SafeguardAccess(
                    stack, repo, identifiable.identification, "identification:", "Create data element!",
                    v =>
            {
                identifiable.identification = new AdminShell.Identification();
                this.AddDiaryEntry(identifiable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddKeyValueRef(
                    stack, "idType", identifiable, ref identifiable.identification.idType, null, repo,
                    v =>
                {
                    var dr = new DiaryReference(identifiable);
                    identifiable.identification.idType = v as string;
                    this.AddDiaryEntry(identifiable, new DiaryEntryStructChange(), diaryReference: dr);
                    return(new AnyUiLambdaActionNone());
                },
                    comboBoxItems: AdminShell.Key.IdentifierTypeNames);

                this.AddKeyValueRef(
                    stack, "id", identifiable, ref identifiable.identification.id, null, repo,
                    v =>
                {
                    var dr = new DiaryReference(identifiable);
                    identifiable.identification.id = v as string;
                    this.AddDiaryEntry(identifiable, new DiaryEntryStructChange(), diaryReference: dr);
                    return(new AnyUiLambdaActionNone());
                },
                    auxButtonTitles: DispEditInjectAction.GetTitles(new[] { "Generate" }, injectToId),
                    auxButtonLambda: (i) =>
                {
                    if (i == 0)
                    {
                        var dr = new DiaryReference(identifiable);
                        identifiable.identification.idType = AdminShell.Identification.IRI;
                        identifiable.identification.id     = AdminShellUtil.GenerateIdAccordingTemplate(
                            templateForIdString);
                        this.AddDiaryEntry(identifiable, new DiaryEntryStructChange(), diaryReference: dr);
                        return(new AnyUiLambdaActionRedrawAllElements(nextFocus: identifiable));
                    }
                    if (i >= 1)
                    {
                        var la = injectToId?.auxLambda?.Invoke(i - 1);
                        return(la);
                    }
                    return(new AnyUiLambdaActionNone());
                });
            }

            this.AddHintBubble(stack, hintMode, new[] {
                new HintCheck(
                    () => { return(identifiable.administration == null); },
                    "Check if providing admistrative information on version/ revision would be useful. " +
                    "This allows for better version management.",
                    breakIfTrue: true,
                    severityLevel: HintCheck.Severity.Notice),
                new HintCheck(
                    () =>
                {
                    return(identifiable.administration.version.Trim() == "" ||
                           identifiable.administration.revision.Trim() == "");
                },
                    "Admistrative information fields should not be empty.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            if (this.SafeguardAccess(
                    stack, repo, identifiable.administration, "administration:", "Create data element!",
                    v =>
            {
                identifiable.administration = new AdminShell.Administration();
                this.AddDiaryEntry(identifiable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddKeyValueRef(
                    stack, "version", identifiable.administration, ref identifiable.administration.version,
                    null, repo,
                    v =>
                {
                    identifiable.administration.version = v as string;
                    this.AddDiaryEntry(identifiable, new DiaryEntryStructChange());
                    return(new AnyUiLambdaActionNone());
                });

                this.AddKeyValueRef(
                    stack, "revision", identifiable.administration, ref identifiable.administration.revision,
                    null, repo,
                    v =>
                {
                    identifiable.administration.revision = v as string;
                    this.AddDiaryEntry(identifiable, new DiaryEntryStructChange());
                    return(new AnyUiLambdaActionNone());
                });
            }
        }
Esempio n. 11
0
        //
        // Referable
        //

        public void DisplayOrEditEntityReferable(AnyUiStackPanel stack,
                                                 AdminShell.Referable referable,
                                                 DispEditInjectAction injectToIdShort = null,
                                                 HintCheck[] addHintsCategory         = null,
                                                 bool categoryUsual = false)
        {
            // access
            if (stack == null || referable == null)
            {
                return;
            }

            // members
            this.AddGroup(stack, "Referable:", levelColors.SubSection);

            // members
            this.AddHintBubble(stack, hintMode, new[] {
                new HintCheck(() => { return(referable.idShort == null || referable.idShort.Length < 1); },
                              "The idShort is meanwhile mandatory for all Referables. It is a short, " +
                              "unique identifier that is unique just in its context, its name space. ", breakIfTrue: true),
                new HintCheck(
                    () => {
                    if (referable.idShort == null)
                    {
                        return(false);
                    }
                    return(!AdminShellUtil.ComplyIdShort(referable.idShort));
                },
                    "The idShort shall only feature letters, digits, underscore ('_'); " +
                    "starting mandatory with a letter."),
                new HintCheck(
                    () => {
                    return(true == referable.idShort?.Contains("---"));
                },
                    "The idShort contains 3 dashes. Probably, the entitiy was auto-named " +
                    "to keep it unqiue because of an operation such a copy/ paste.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            this.AddKeyValueRef(
                stack, "idShort", referable, ref referable.idShort, null, repo,
                v =>
            {
                var dr            = new DiaryReference(referable);
                referable.idShort = v as string;
                this.AddDiaryEntry(referable, new DiaryEntryStructChange(), diaryReference: dr);
                return(new AnyUiLambdaActionNone());
            },
                auxButtonTitles: DispEditInjectAction.GetTitles(null, injectToIdShort),
                auxButtonToolTips: DispEditInjectAction.GetToolTips(null, injectToIdShort),
                auxButtonLambda: injectToIdShort?.auxLambda
                );

            if (!categoryUsual)
            {
                this.AddHintBubble(
                    stack, hintMode,
                    new HintCheck(() => { return(referable.category != null && referable.category.Trim().Length >= 1); },
                                  "The use of category is unusual here.", severityLevel: HintCheck.Severity.Notice));
            }

            this.AddHintBubble(stack, hintMode, this.ConcatHintChecks(null, addHintsCategory));
            this.AddKeyValueRef(
                stack, "category", referable, ref referable.category, null, repo,
                v =>
            {
                referable.category = v as string;
                this.AddDiaryEntry(referable, new DiaryEntryStructChange());
                return(new AnyUiLambdaActionNone());
            },
                comboBoxItems: AdminShell.Referable.ReferableCategoryNames, comboBoxIsEditable: true);

            this.AddHintBubble(
                stack, hintMode,
                new[] {
                new HintCheck(
                    () => {
                    return(referable.description == null || referable.description.langString == null ||
                           referable.description.langString.Count < 1);
                },
                    "The use of an description is recommended to allow the consumer of an Referable " +
                    "to understand the nature of it.",
                    breakIfTrue: true,
                    severityLevel: HintCheck.Severity.Notice),
                new HintCheck(
                    () => { return(referable.description.langString.Count < 2); },
                    "Consider having description in multiple langauges.",
                    severityLevel: HintCheck.Severity.Notice)
            });
            if (this.SafeguardAccess(stack, repo, referable.description, "description:", "Create data element!", v =>
            {
                referable.description = new AdminShell.Description();
                return(new AnyUiLambdaActionRedrawEntity());
            }))
            {
                this.AddHintBubble(
                    stack, hintMode,
                    new HintCheck(
                        () =>
                {
                    return(referable.description.langString == null ||
                           referable.description.langString.Count < 1);
                },
                        "Please add some descriptions in your main languages here to help consumers " +
                        "of your Administration shell to understand your intentions."));
                this.AddKeyListLangStr(stack, "description", referable.description.langString,
                                       repo, relatedReferable: referable);
            }
        }
Esempio n. 12
0
        public DisplayRenderHints DisplayOrEditVisualAasxElement(
            PackageCentral packages,
            ListOfVisualElementBasic entities,
            bool editMode, bool hintMode = false, bool showIriMode = false,
            VisualElementEnvironmentItem.ConceptDescSortOrder?cdSortOrder = null,
            IFlyoutProvider flyoutProvider         = null,
            IPushApplicationEvent appEventProvider = null,
            DispEditHighlight.HighlightFieldInfo hightlightField = null)
        {
            //
            // Start
            //

            // hint mode disable, when not edit
            hintMode = hintMode && editMode;

            // remember objects for UI thread / redrawing
            this._packages            = packages;
            this._theEntities         = entities;
            _helper.packages          = packages;
            _helper.highlightField    = hightlightField;
            _helper.appEventsProvider = appEventProvider;

            // primary access
            var renderHints = new DisplayRenderHints();

            if (theMasterPanel == null || entities == null || entities.Count < 1)
            {
                renderHints.showDataPanel = false;
                return(renderHints);
            }

#if MONOUI
            var stack = ClearDisplayDefautlStack();
#else
            var stack = new AnyUiStackPanel();
#endif

            // create display context for WPF
            _displayContext     = new AnyUiDisplayContextWpf(flyoutProvider, packages);
            _helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);

            // modify repository
            ModifyRepo repo = null;
            if (editMode)
            {
                // some functionality still uses repo != null to detect editMode!!
                repo = new ModifyRepo();
            }
            _helper.editMode    = editMode;
            _helper.hintMode    = hintMode;
            _helper.repo        = repo;
            _helper.showIriMode = showIriMode;
            _helper.context     = _displayContext;

            // inform plug that their potential panel might not shown anymore
            Plugins.AllPluginsInvoke("clear-panel-visual-extension");

            //
            // Test for Blazor
            //
#if __test_blazor
            if (false)
            {
                var lab = new AnyUiLabel();
                lab.Content    = "Hallo";
                lab.Foreground = AnyUiBrushes.DarkBlue;
                stack.Children.Add(lab);

                if (editMode)
                {
                    var tb = new AnyUiTextBox();
                    tb.Foreground = AnyUiBrushes.Black;
                    tb.Text       = "Initial";
                    stack.Children.Add(tb);
                    repo.RegisterControl(tb, (o) =>
                    {
                        Log.Singleton.Info($"Text changed to .. {""+o}");
                        return(new AnyUiLambdaActionNone());
                    });

                    var btn = new AnyUiButton();
                    btn.Content = "Click me!";
                    stack.Children.Add(btn);
                    repo.RegisterControl(btn, (o) =>
                    {
                        Log.Singleton.Error("Button clicked!");
                        return(new AnyUiLambdaActionRedrawAllElements(null));
                    });
                }
            }
#endif

            var inhibitRenderStackToPanel = false;

            if (entities.ExactlyOne)
            {
                //
                // Dispatch: ONE item
                //
                var entity = entities.First();

                // maintain parent. If in doubt, set null
                ListOfVisualElement.SetParentsBasedOnChildHierarchy(entity);

                //
                // Dispatch
                //

                if (entity is VisualElementEnvironmentItem veei)
                {
                    _helper.DisplayOrEditAasEntityAasEnv(
                        packages, veei.theEnv, veei, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAdminShell veaas)
                {
                    _helper.DisplayOrEditAasEntityAas(
                        packages, veaas.theEnv, veaas.theAas, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAsset veas)
                {
                    _helper.DisplayOrEditAasEntityAsset(
                        packages, veas.theEnv, veas.theAsset, editMode, repo, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelRef vesmref)
                {
                    // data
                    AdminShell.AdministrationShell aas = null;
                    if (vesmref.Parent is VisualElementAdminShell xpaas)
                    {
                        aas = xpaas.theAas;
                    }

                    // edit
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesmref.theEnv, aas, vesmref.theSubmodelRef, vesmref.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodel vesm && vesm.theSubmodel != null)
                {
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesm.theEnv, null, null, vesm.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelElement vesme)
                {
                    _helper.DisplayOrEditAasEntitySubmodelElement(
                        packages, vesme.theEnv, vesme.theContainer, vesme.theWrapper, vesme.theWrapper.submodelElement,
                        editMode,
                        repo, stack, hintMode: hintMode,
                        nestedCds: cdSortOrder.HasValue &&
                        cdSortOrder.Value == VisualElementEnvironmentItem.ConceptDescSortOrder.BySme);
                }
                else if (entity is VisualElementOperationVariable vepv)
                {
                    _helper.DisplayOrEditAasEntityOperationVariable(
                        packages, vepv.theEnv, vepv.theContainer, vepv.theOpVar, editMode,
                        stack, hintMode: hintMode);
                }
                else if (entity is VisualElementConceptDescription vecd)
                {
                    _helper.DisplayOrEditAasEntityConceptDescription(
                        packages, vecd.theEnv, null, vecd.theCD, editMode, repo, stack, hintMode: hintMode,
                        preventMove: cdSortOrder.HasValue &&
                        cdSortOrder.Value != VisualElementEnvironmentItem.ConceptDescSortOrder.None);
                }
                else if (entity is VisualElementView vevw)
                {
                    if (vevw.Parent != null && vevw.Parent is VisualElementAdminShell xpaas)
                    {
                        _helper.DisplayOrEditAasEntityView(
                            packages, vevw.theEnv, xpaas.theAas, vevw.theView, editMode, stack,
                            hintMode: hintMode);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "View is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else if (entity is VisualElementReference verf)
                {
                    if (verf.Parent != null && verf.Parent is VisualElementView xpev)
                    {
                        _helper.DisplayOrEditAasEntityViewReference(
                            packages, verf.theEnv, xpev.theView, (AdminShell.ContainedElementRef)verf.theReference,
                            editMode, stack);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "Reference is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else
                if (entity is VisualElementSupplementalFile vesf)
                {
                    _helper.DisplayOrEditAasEntitySupplementaryFile(packages, vesf.theFile, editMode, stack);
                }
                else if (entity is VisualElementPluginExtension vepe)
                {
                    // create controls
                    object result = null;

                    try
                    {
                        // replace at top level
                        theMasterPanel.Children.Clear();
                        if (vepe.thePlugin != null)
                        {
                            result = vepe.thePlugin.InvokeAction(
                                "fill-panel-visual-extension", vepe.thePackage, vepe.theReferable, theMasterPanel);
                        }
                    }
                    catch (Exception ex)
                    {
                        AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                    }

                    // add?
                    if (result == null)
                    {
                        // re-init display!
#if MONOUI
                        stack = ClearDisplayDefautlStack();
#else
                        stack = new AnyUiStackPanel();
#endif

                        // helping message
                        _helper.AddGroup(
                            stack, "Entity from Plugin cannot be rendered!", _helper.levelColors.MainSection);
                    }
                    else
                    {
                        // this is natively done; do NOT render Any UI to WPF
                        inhibitRenderStackToPanel = true;
                    }

                    // show no panel nor scroll
                    renderHints.scrollingPanel = false;
                    renderHints.showDataPanel  = false;
                }
                else
                {
                    _helper.AddGroup(stack, "Entity is unknown!", _helper.levelColors.MainSection);
                }
            }
Esempio n. 13
0
        public DisplayRenderHints DisplayOrEditVisualAasxElement(
            PackageCentral packages,
            ListOfVisualElementBasic entities,
            bool editMode, bool hintMode = false, bool showIriMode = false,
            VisualElementEnvironmentItem.ConceptDescSortOrder?cdSortOrder = null,
            IFlyoutProvider flyoutProvider         = null,
            IPushApplicationEvent appEventProvider = null,
            DispEditHighlight.HighlightFieldInfo hightlightField = null)
        {
            //
            // Start
            //

            // hint mode disable, when not edit
            hintMode = hintMode && editMode;

            // remember objects for UI thread / redrawing
            this._packages            = packages;
            this._theEntities         = entities;
            _helper.packages          = packages;
            _helper.highlightField    = hightlightField;
            _helper.appEventsProvider = appEventProvider;

            // primary access
            var renderHints = new DisplayRenderHints();

            if (theMasterPanel == null || entities == null || entities.Count < 1)
            {
                renderHints.showDataPanel = false;
                return(renderHints);
            }

#if MONOUI
            var stack = ClearDisplayDefautlStack();
#else
            var stack = new AnyUiStackPanel();
#endif

            // create display context for WPF
            _displayContext     = new AnyUiDisplayContextWpf(flyoutProvider, packages);
            _helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);

            // modify repository
            ModifyRepo repo = null;
            if (editMode)
            {
                // some functionality still uses repo != null to detect editMode!!
                repo = new ModifyRepo();
            }
            _helper.editMode    = editMode;
            _helper.hintMode    = hintMode;
            _helper.repo        = repo;
            _helper.showIriMode = showIriMode;
            _helper.context     = _displayContext;

            //
            // Test for Blazor
            //
#if __test_blazor
            if (false)
            {
                var lab = new AnyUiLabel();
                lab.Content    = "Hallo";
                lab.Foreground = AnyUiBrushes.DarkBlue;
                stack.Children.Add(lab);

                if (editMode)
                {
                    var tb = new AnyUiTextBox();
                    tb.Foreground = AnyUiBrushes.Black;
                    tb.Text       = "Initial";
                    stack.Children.Add(tb);
                    repo.RegisterControl(tb, (o) =>
                    {
                        Log.Singleton.Info($"Text changed to .. {""+o}");
                        return(new AnyUiLambdaActionNone());
                    });

                    var btn = new AnyUiButton();
                    btn.Content = "Click me!";
                    stack.Children.Add(btn);
                    repo.RegisterControl(btn, (o) =>
                    {
                        Log.Singleton.Error("Button clicked!");
                        return(new AnyUiLambdaActionRedrawAllElements(null));
                    });
                }
            }
#endif

            var inhibitRenderStackToPanel = false;

            if (entities.ExactlyOne)
            {
                //
                // Dispatch: ONE item
                //
                var entity = entities.First();

                if (entity is VisualElementEnvironmentItem veei)
                {
                    _helper.DisplayOrEditAasEntityAasEnv(
                        packages, veei.theEnv, veei, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAdminShell veaas)
                {
                    _helper.DisplayOrEditAasEntityAas(
                        packages, veaas.theEnv, veaas.theAas, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAsset veas)
                {
                    _helper.DisplayOrEditAasEntityAsset(
                        packages, veas.theEnv, veas.theAsset, editMode, repo, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelRef vesmref)
                {
                    AdminShell.AdministrationShell aas = null;
                    if (vesmref.Parent is VisualElementAdminShell xpaas)
                    {
                        aas = xpaas.theAas;
                    }
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesmref.theEnv, aas, vesmref.theSubmodelRef, vesmref.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodel vesm)
                {
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesm.theEnv, null, null, vesm.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelElement vesme)
                {
                    _helper.DisplayOrEditAasEntitySubmodelElement(
                        packages, vesme.theEnv, vesme.theContainer, vesme.theWrapper, vesme.theWrapper.submodelElement,
                        editMode,
                        repo, stack, hintMode: hintMode,
                        nestedCds: cdSortOrder.HasValue &&
                        cdSortOrder.Value == VisualElementEnvironmentItem.ConceptDescSortOrder.BySme);
                }
                else if (entity is VisualElementOperationVariable vepv)
                {
                    _helper.DisplayOrEditAasEntityOperationVariable(
                        packages, vepv.theEnv, vepv.theContainer, vepv.theOpVar, editMode,
                        stack, hintMode: hintMode);
                }
                else if (entity is VisualElementConceptDescription vecd)
                {
                    _helper.DisplayOrEditAasEntityConceptDescription(
                        packages, vecd.theEnv, null, vecd.theCD, editMode, repo, stack, hintMode: hintMode,
                        preventMove: cdSortOrder.HasValue &&
                        cdSortOrder.Value != VisualElementEnvironmentItem.ConceptDescSortOrder.None);
                }
                else if (entity is VisualElementView vevw)
                {
                    if (vevw.Parent != null && vevw.Parent is VisualElementAdminShell xpaas)
                    {
                        _helper.DisplayOrEditAasEntityView(
                            packages, vevw.theEnv, xpaas.theAas, vevw.theView, editMode, stack,
                            hintMode: hintMode);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "View is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else if (entity is VisualElementReference verf)
                {
                    if (verf.Parent != null && verf.Parent is VisualElementView xpev)
                    {
                        _helper.DisplayOrEditAasEntityViewReference(
                            packages, verf.theEnv, xpev.theView, (AdminShell.ContainedElementRef)verf.theReference,
                            editMode, stack);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "Reference is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else
                if (entity is VisualElementSupplementalFile vesf)
                {
                    _helper.DisplayOrEditAasEntitySupplementaryFile(packages, vesf.theFile, editMode, stack);
                }
                else if (entity is VisualElementPluginExtension vepe)
                {
                    // create controls
                    object result = null;

                    try
                    {
                        // replace at top level
                        theMasterPanel.Children.Clear();
                        if (vepe.thePlugin != null)
                        {
                            result = vepe.thePlugin.InvokeAction(
                                "fill-panel-visual-extension", vepe.thePackage, vepe.theReferable, theMasterPanel);
                        }
                    }
                    catch (Exception ex)
                    {
                        AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                    }

                    // add?
                    if (result == null)
                    {
                        // re-init display!
#if MONOUI
                        stack = ClearDisplayDefautlStack();
#else
                        stack = new AnyUiStackPanel();
#endif

                        // helping message
                        _helper.AddGroup(
                            stack, "Entity from Plugin cannot be rendered!", _helper.levelColors.MainSection);
                    }
                    else
                    {
                        // this is natively done; do NOT render Any UI to WPF
                        inhibitRenderStackToPanel = true;
                    }

                    // show no panel nor scroll
                    renderHints.scrollingPanel = false;
                    renderHints.showDataPanel  = false;
                }
                else
                {
                    _helper.AddGroup(stack, "Entity is unknown!", _helper.levelColors.MainSection);
                }
            }
            else
            {
                //
                // Dispatch: MULTIPLE items
                //
                _helper.DisplayOrEditAasEntityMultipleElements(packages, entities, editMode, stack, cdSortOrder);
            }

            // now render master stack
#if __export_BLAZOR
            var fn = @"fileEdit.json";
            if (!editMode)
            {
                count = 0;
                var jsonSerializerSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.All,
                    Formatting       = Formatting.Indented
                };
                var json = JsonConvert.SerializeObject(stack, jsonSerializerSettings);
                System.IO.File.WriteAllText(fn, json);
            }
            if (editMode)
            {
                if (true && count == 2)
                {
                    count = 0;
                    JsonSerializerSettings settings = new JsonSerializerSettings
                    {
                        // SerializationBinder = new DisplayNameSerializationBinder(
                        //    new[] { typeof(AasxIntegrationBase.AasForms.FormDescListOfElement),
                        //      typeof(AasxIntegrationBase.AasForms.FormDescProperty) }),
                        // SerializationBinder = new DisplayNameSerializationBinder(
                        //     new[] { typeof(AnyUiStackPanel), typeof(AnyUiUIElement) }),
                        // NullValueHandling = NullValueHandling.Ignore,
                        ReferenceLoopHandling = ReferenceLoopHandling.Error,
                        TypeNameHandling      = TypeNameHandling.All,
                        Formatting            = Formatting.Indented
                    };

                    //if (stack is AnyUiPanel pan)
                    //{
                    //    for (int i = 0; i < pan.Children.Count; i++)
                    //    {
                    //        var json = JsonConvert.SerializeObject(pan.Children[i], settings);
                    //        System.IO.File.WriteAllText(fn+"."+i, json);
                    //    }
                    //}
                    var json = JsonConvert.SerializeObject(stack, settings);
                    System.IO.File.WriteAllText(fn, json);
                }
                count++;

                /*
                 * var writer = new System.Xml.Serialization.XmlSerializer(typeof(AnyUiUIElement));
                 * var wfile = new System.IO.StreamWriter(@"c:\development\fileEdit.xml");
                 * writer.Serialize(wfile, stack);
                 * wfile.Close();
                 */
            }
#endif
#if MONOUI
#else
            // render Any UI to WPF?
            if (!inhibitRenderStackToPanel)
            {
                // rendering
                theMasterPanel.Children.Clear();
                var spwpf = _displayContext.GetOrCreateWpfElement(stack);
                _helper.ShowLastHighlights();
                DockPanel.SetDock(spwpf, Dock.Top);
                theMasterPanel.Children.Add(spwpf);

                // register key shortcuts
                var num = _displayContext.PrepareNameList(stack);
                if (num > 0)
                {
                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-up", ModifierKeys.Shift | ModifierKeys.Control, Key.Up,
                        "Move current AAS element up by one position.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-down", ModifierKeys.Shift | ModifierKeys.Control, Key.Down,
                        "Move current AAS element down by one position.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-top", ModifierKeys.Shift | ModifierKeys.Control, Key.Home,
                        "Move current AAS element to the first position of the respective list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-end", ModifierKeys.Shift | ModifierKeys.Control, Key.End,
                        "Move current AAS element to the last position of the respective list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-delete", ModifierKeys.Shift | ModifierKeys.Control, Key.Delete,
                        "Delete current AAS element in the respective list. Shift key skips dialogue.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-cut", ModifierKeys.Shift | ModifierKeys.Control, Key.X,
                        "Transfers current AAS element into paste buffer and deletes in respective list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-copy", ModifierKeys.Shift | ModifierKeys.Control, Key.C,
                        "Copies current AAS element into paste buffer for later pasting.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-paste-into", ModifierKeys.Shift | ModifierKeys.Control, Key.V,
                        "Copy existing paste buffer into the child list of the current AAS element.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-paste-above", ModifierKeys.Shift | ModifierKeys.Control, Key.W,
                        "Copy existing paste buffer above the current AAS element in the same list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-paste-below", ModifierKeys.Shift | ModifierKeys.Control, Key.Y,
                        "Copy existing paste buffer below the current AAS element in the same list.");
                }
            }

            // keep the stack
            _lastRenderedRootElement = stack;
#endif

            // return render hints
            return(renderHints);
        }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            //// env = new AdminShellPackageEnv("Example_AAS_ServoDCMotor_21.aasx");

            loadAasxFiles();
#if __test__PackageLogic
#else
            packages = new PackageCentral();
            // TODO (MIHO, 2021-06-07): how to initialize?
            packages.MainItem.TakeOver(env);

            helper             = new DispEditHelperEntities();
            helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);
            // some functionality still uses repo != null to detect editMode!!
            repo            = new ModifyRepo();
            helper.editMode = editMode;
            helper.hintMode = hintMode;
            helper.repo     = repo;
            helper.context  = null;
            helper.packages = packages;

            stack17             = new AnyUiStackPanel();
            stack17.Orientation = AnyUiOrientation.Vertical;

            helper.DisplayOrEditAasEntityAas(
                packages, env.AasEnv, env.AasEnv.AdministrationShells[0], editMode, stack17, hintMode: hintMode);

            AnyUi.AnyUiDisplayContextHtml.htmlDotnetThread.Start();
#endif

            //
            // Test for Blazor
            //

#if _not_enabled
            stack2 = JsonConvert.DeserializeObject <AnyUiStackPanel>(File.ReadAllText(@"c:\development\file.json"));
            var d = new JavaScriptSerializer();
            stack2 = d.Deserialize <AnyUiStackPanel>(File.ReadAllText(@"c:\development\file.json"));
            var parent = (Dictionary <string, object>)results["Parent"];
#endif

#if _not_enabled
            {
                string s = File.ReadAllText(@"c:\development\file.json");
                var    jsonSerializerSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.All
                };
                stack2 = JsonConvert.DeserializeObject <AnyUiStackPanel>(s, jsonSerializerSettings);
            }
#endif

            if (true)
            {
                stack.Orientation = AnyUiOrientation.Vertical;

                var lab1 = new AnyUiLabel();
                lab1.Content    = "Hallo1";
                lab1.Foreground = AnyUiBrushes.DarkBlue;
                stack.Children.Add(lab1);

                var stck2 = new AnyUiStackPanel();
                stck2.Orientation = AnyUiOrientation.Horizontal;
                stack.Children.Add(stck2);

                var lab2 = new AnyUiLabel();
                lab2.Content    = "Hallo2";
                lab2.Foreground = AnyUiBrushes.DarkBlue;
                stck2.Children.Add(lab2);

                var stck3 = new AnyUiStackPanel();
                stck3.Orientation = AnyUiOrientation.Horizontal;
                stck2.Children.Add(stck3);

                var lab3 = new AnyUiLabel();
                lab3.Content    = "Hallo3";
                lab3.Foreground = AnyUiBrushes.DarkBlue;
                stck3.Children.Add(lab3);

                if (editMode)
                {
                    var tb = new AnyUiTextBox();
                    tb.Foreground = AnyUiBrushes.Black;
                    tb.Text       = "Initial";
                    stck2.Children.Add(tb);

                    var btn = new AnyUiButton();
                    btn.Content     = "Click me!";
                    btn.DisplayData = new BlazorDisplayData(lambda: (o) =>
                    {
                        if (o == btn)
                        {
                            Program.LogLine = "Hallo, Match zwischen Button und callback!";
                        }
                    });
                    stck3.Children.Add(btn);
                }
            }

            CreateHostBuilder(args).Build().Run();
        }