Пример #1
0
        /// <summary>
        /// Create a set of minimal options
        /// </summary>
        public static GenericFormOptions CreateDefault()
        {
            var opt = new GenericFormOptions();

            var rec = new GenericFormsOptionsRecord()
            {
                FormTag   = "SMP",
                FormTitle = "Sample declaration of a GenericTemplate"
            };

            opt.Records.Add(rec);

            rec.FormSubmodel = new FormDescSubmodel(
                "Submodel Root",
                new AdminShell.Key("Submodel", false, "IRI", "www.exmaple.com/sms/1112"),
                "Example",
                "Information string");

            rec.FormSubmodel.Add(new FormDescProperty(
                                     formText: "Sample Property",
                                     multiplicity: FormMultiplicity.OneToMany,
                                     smeSemanticId: new AdminShell.Key("ConceptDescription", false, "IRI", "www.example.com/cds/1113"),
                                     presetIdShort: "SampleProp{0:0001}",
                                     valueType: "string",
                                     presetValue: "123"));

            return(opt);
        }
Пример #2
0
        private void DisplaySubmodel()
        {
            // show the edit panel
            OuterTabControl.SelectedItem = TabPanelEdit;

            // clear first
            ScrollViewerForm.Content = null;

            // test trivial access
            if (theOptions == null || theSubmodel == null)
            {
                return;
            }

            // identify the record
            // check for a record in options, that matches Submodel
            currentFormRecord = theOptions.MatchRecordsForSemanticId(theSubmodel.semanticId);
            if (currentFormRecord == null)
            {
                return;
            }

            // check form
            if (currentFormRecord.FormSubmodel == null || currentFormRecord.FormSubmodel.SubmodelElements == null)
            {
                return;
            }

            // initialize form
            formInUpdateMode     = true;
            updateSourceElements = theSubmodel.submodelElements;

            // take over existing data
            this.currentFormInst = new FormInstanceSubmodel(currentFormRecord.FormSubmodel);
            this.currentFormInst.InitReferable(currentFormRecord.FormSubmodel, theSubmodel);
            this.currentFormInst.PresetInstancesBasedOnSource(updateSourceElements);
            this.currentFormInst.outerEventStack = theEventStack;

            // bring it to the panel
            var elementsCntl = new FormListOfDifferentControl();

            elementsCntl.DataContext = this.currentFormInst;
            ScrollViewerForm.Content = elementsCntl;
        }
Пример #3
0
        public GenericFormsOptionsRecord MatchRecordsForSemanticId(AdminShell.SemanticId sem)
        {
            // check for a record in options, that matches Submodel
            GenericFormsOptionsRecord res = null;

            if (Records != null)
            {
                foreach (var rec in Records)
                {
                    if (rec?.FormSubmodel?.KeySemanticId != null)
                    {
                        if (sem != null && sem.Matches(rec.FormSubmodel.KeySemanticId))
                        {
                            res = rec;
                            break;
                        }
                    }
                }
            }
            return(res);
        }