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

            // initialize Referable
            var re = new AdminShell.ReferenceElement();

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

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

            if (reSource != null)
            {
                // take over
                re.value = new AdminShell.Reference(reSource.value);
            }

            // create user control
            this.subControl             = new FormSubControlReferenceElement();
            this.subControl.DataContext = this;
        }
        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 FormDescInstancesPair FindInstance(FormInstanceListOfSame searchInst)
 {
     if (searchInst == null)
     {
         return(null);
     }
     foreach (var x in this)
     {
         if (x?.instances == searchInst)
         {
             return(x);
         }
     }
     return(null);
 }
        public FormInstanceSubmodel(FormDescSubmodel desc)
            : base(null, desc)
        {
            // require desc!
            if (desc == null || desc.SubmodelElements == null)
            {
                // done
                return;
            }

            foreach (var subDesc in desc.SubmodelElements)
            {
                var los  = new FormInstanceListOfSame(this, subDesc);
                var pair = new FormDescInstancesPair(subDesc, los);
                PairInstances.Add(pair);
            }
        }
        public FormInstanceSubmodelElementCollection(
            FormInstanceListOfSame parentInstance,
            FormDescSubmodelElementCollection parentDesc, AdminShell.SubmodelElement source = null)
        {
            // way back to description
            this.desc           = parentDesc;
            this.parentInstance = parentInstance;
            var smecDesc = this.desc as FormDescSubmodelElementCollection;

            // initialize Referable
            var smec = new AdminShell.SubmodelElementCollection();

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

            // initially create pairs
            if (smecDesc?.value != null)
            {
                foreach (var subDesc in smecDesc.value)
                {
                    var los  = new FormInstanceListOfSame(this, subDesc);
                    var pair = new FormDescInstancesPair(subDesc, los);
                    PairInstances.Add(pair);
                }
            }

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

            if (smecSource != null)
            {
                if (this.PairInstances != null)
                {
                    foreach (var pair in this.PairInstances)
                    {
                        pair?.instances?.PresetInstancesBasedOnSource(smecSource.value);
                    }
                }
            }

            // create user control
            this.subControl             = new FormSubControlSMEC();
            this.subControl.DataContext = this;
        }
        public FormInstanceProperty(
            FormInstanceListOfSame parentInstance, FormDescProperty parentDesc,
            AdminShell.SubmodelElement source = null, bool deepCopy = false)
        {
            // way back to description
            this.parentInstance = parentInstance;
            this.desc           = parentDesc;

            // initialize Referable
            var p = new AdminShell.Property();

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

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

            if (pSource != null)
            {
                // take over
                p.valueType = pSource.valueType;
                p.value     = pSource.value;
            }
            else
            {
                // some more preferences
                if (parentDesc.allowedValueTypes != null && parentDesc.allowedValueTypes.Length >= 1)
                {
                    p.valueType = parentDesc.allowedValueTypes[0];
                }

                if (parentDesc.presetValue != null && parentDesc.presetValue.Length > 0)
                {
                    p.value = parentDesc.presetValue;
                    // immediately set touched in order to have this value saved
                    this.Touch();
                }
            }

            // create user control
            this.subControl             = new FormSubControlProperty();
            this.subControl.DataContext = this;
        }
 /// <summary>
 /// Build a new instance, based on the description data
 /// </summary>
 public override FormInstanceSubmodelElement CreateInstance(
     FormInstanceListOfSame parentInstance, AdminShell.SubmodelElement source = null)
 {
     return(new FormInstanceReferenceElement(parentInstance, this, source));
 }
 /// <summary>
 /// Build a new instance, based on the description data
 /// </summary>
 public virtual FormInstanceSubmodelElement CreateInstance(
     FormInstanceListOfSame parentInstance, AdminShell.SubmodelElement source = null)
 {
     return(null);
 }
 public FormDescInstancesPair(FormDescBase desc, FormInstanceListOfSame instances)
 {
     this.desc      = desc;
     this.instances = instances;
 }
Esempio n. 10
0
 public FormInstanceBase(FormInstanceListOfSame parentInstance, FormDescBase desc)
 {
     this.parentInstance = parentInstance;
     this.desc           = desc;
 }