public FormInstanceMultiLangProp(
            FormInstanceListOfSame parentInstance, FormDescMultiLangProp parentDesc,
            AdminShell.SubmodelElement source = null, bool deepCopy = false)
        {
            // way back to description
            this.parentInstance = parentInstance;
            this.desc           = parentDesc;

            // initialize Referable
            var mlp = new AdminShell.MultiLanguageProperty();

            this.sme = mlp;
            InitReferable(parentDesc, source);

            // check, if a source is present
            this.sourceSme = source;
            var mlpSource = this.sourceSme as AdminShell.MultiLanguageProperty;

            if (mlpSource != null)
            {
                // take over
                mlp.value = new AdminShell.LangStringSet(mlpSource.value);
            }

            // create user control
            this.subControl             = new FormSubControlMultiLangProp();
            this.subControl.DataContext = this;
        }
 public FormDescMultiLangProp(FormDescMultiLangProp other)
     : base(other)
 {
 }
Beispiel #3
0
        private static void RecurseExportAsTemplate(
            AdminShell.SubmodelElementWrapperCollection smwc, FormDescListOfElement tels,
            AdminShell.AdministrationShellEnv env = null, AdminShell.ListOfConceptDescriptions cds = null)
        {
            // access
            if (smwc == null || tels == null)
            {
                return;
            }

            // over all elems
            foreach (var smw in smwc)
            {
                if (smw != null && smw.submodelElement != null)
                {
                    FormDescSubmodelElement tsme = null;
                    if (smw.submodelElement is AdminShell.Property p)
                    {
                        tsme = new FormDescProperty(
                            "" + p.idShort, FormMultiplicity.One, p.semanticId?.GetAsExactlyOneKey(),
                            "" + p.idShort, valueType: p.valueType);
                    }
                    if (smw.submodelElement is AdminShell.MultiLanguageProperty mlp)
                    {
                        tsme = new FormDescMultiLangProp(
                            "" + mlp.idShort, FormMultiplicity.One, mlp.semanticId?.GetAsExactlyOneKey(),
                            "" + mlp.idShort);
                    }
                    if (smw.submodelElement is AdminShell.File fl)
                    {
                        tsme = new FormDescFile(
                            "" + fl.idShort, FormMultiplicity.One, fl.semanticId?.GetAsExactlyOneKey(),
                            "" + fl.idShort);
                    }
                    if (smw.submodelElement is AdminShell.ReferenceElement rf)
                    {
                        tsme = new FormDescReferenceElement(
                            "" + rf.idShort, FormMultiplicity.One, rf.semanticId?.GetAsExactlyOneKey(),
                            "" + rf.idShort);
                    }
                    if (smw.submodelElement is AdminShell.SubmodelElementCollection smec)
                    {
                        tsme = new FormDescSubmodelElementCollection(
                            "" + smec.idShort, FormMultiplicity.One, smec.semanticId?.GetAsExactlyOneKey(),
                            "" + smec.idShort);
                    }

                    if (tsme != null)
                    {
                        // take over directly
                        tsme.PresetCategory = smw.submodelElement.category;

                        // Qualifers
                        var qs = smw.submodelElement.qualifiers;

                        var q = qs?.FindType("FormTitle");
                        if (q != null)
                        {
                            tsme.FormTitle = "" + q.value;
                        }

                        q = qs?.FindType("FormInfo");
                        if (q != null)
                        {
                            tsme.FormInfo = "" + q.value;
                        }

                        q = qs?.FindType("EditIdShort");
                        if (q != null)
                        {
                            tsme.FormEditIdShort = q.value.Trim().ToLower() == "true";
                        }

                        q = qs?.FindType("EditDescription");
                        if (q != null)
                        {
                            tsme.FormEditDescription = q.value.Trim().ToLower() == "true";
                        }

                        q = qs?.FindType("Multiplicity");
                        if (q != null)
                        {
                            foreach (var m in (FormMultiplicity[])Enum.GetValues(typeof(FormMultiplicity)))
                            {
                                if (("" + q.value) == Enum.GetName(typeof(FormMultiplicity), m))
                                {
                                    tsme.Multiplicity = m;
                                }
                            }
                        }

                        q = qs?.FindType("PresetValue");
                        if (q != null && tsme is FormDescProperty)
                        {
                            (tsme as FormDescProperty).presetValue = "" + q.value;
                        }

                        q = qs?.FindType("PresetMimeType");
                        if (q != null && tsme is FormDescFile)
                        {
                            (tsme as FormDescFile).presetMimeType = "" + q.value;
                        }

                        q = qs?.FindType("FormChoices");
                        if (q != null && q.value.HasContent() && tsme is FormDescProperty fdprop)
                        {
                            var choices = q.value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            if (choices != null && choices.Length > 0)
                            {
                                fdprop.comboBoxChoices = choices;
                            }
                        }

                        // adopt presetIdShort
                        if (tsme.Multiplicity == FormMultiplicity.ZeroToMany ||
                            tsme.Multiplicity == FormMultiplicity.OneToMany)
                        {
                            tsme.PresetIdShort += "{0:00}";
                        }

                        // Ignore this element
                        q = qs?.FindType("FormIgnore");
                        if (q != null)
                        {
                            continue;
                        }
                    }

                    if (tsme != null)
                    {
                        tels.Add(tsme);
                    }

                    // in any case, check for CD
                    if (env != null && cds != null && smw?.submodelElement?.semanticId?.Keys != null)
                    {
                        var masterCd = env.FindConceptDescription(smw?.submodelElement?.semanticId?.Keys);
                        if (masterCd != null && masterCd.identification != null)
                        {
                            // already in cds?
                            var copyCd = cds.Find(masterCd.identification);
                            if (copyCd == null)
                            {
                                // add clone
                                cds.Add(new AdminShell.ConceptDescription(masterCd));
                            }
                        }
                    }

                    // recurse
                    if (smw.submodelElement is AdminShell.SubmodelElementCollection)
                    {
                        RecurseExportAsTemplate(
                            (smw.submodelElement as AdminShell.SubmodelElementCollection).value,
                            (tsme as FormDescSubmodelElementCollection).value, env, cds);
                    }
                }
            }
        }