Ejemplo n.º 1
0
        protected void ReadFromXMLChildItems(XElement xml, string childColletionTagName, ICollection <UIControlInstanceModel> childCollection)
        {
            ScreenModel screen = null;

            if (!(this is ScreenModel))
            {
                System.Diagnostics.Debug.Assert(this.ParentScreen != null, "Parent Screen can't be null");
                screen = this.ParentScreen;
            }
            else
            {
                screen = this as ScreenModel;
            }

            System.Diagnostics.Debug.Assert(screen.ParentProject != null, "Parent project can't be null");
            System.Diagnostics.Debug.Assert(screen.ParentProject.mobiseConfiguration != null, "Mobise configuration can't be null");
            System.Diagnostics.Debug.Assert(screen.ParentProject.mobiseConfiguration.Controls != null, "Mobise configuration control definitions can't be null");
            System.Diagnostics.Debug.Assert(screen.ParentProject.mobiseConfiguration.ControllerDefinitons != null, "Mobise configuration controller definitions can't be null");

            XElement childColletionTag = xml.Element(childColletionTagName);

            if (childColletionTag != null && childColletionTag.HasElements)
            {
                // Parallel.ForEach(controls.Elements("control"), (element) =>
                foreach (XElement element in childColletionTag.Elements())
                {
                    string childItemID = element.Attribute("mobiseID") != null?element.Attribute("mobiseID").Value : string.Empty;

                    UIControlInstanceModel newControl = childCollection.FirstOrDefault(ctrl => ctrl.MobiseObjectID == childItemID);
                    if (newControl == null)
                    {
                        string controlType = element.Attribute("type") != null?element.Attribute("type").Value : string.Empty;

                        UIControlDefinitionModel definition = null;
                        definition = screen.ParentProject.mobiseConfiguration.Controls.FirstOrDefault(def => def.Name.Equals(controlType, StringComparison.OrdinalIgnoreCase));

                        if (definition != null)
                        {
                            newControl = new UIControlInstanceModel(definition);

                            if (this is ScreenModel)
                            {
                                newControl.ParentScreen = this as ScreenModel;
                            }
                            else
                            {
                                newControl.ParentScreen = this.ParentScreen;
                            }
                            childCollection.Add(newControl);
                        }
                    }
                    newControl.FromXml(element);
                }
                ;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes the specified instance.
 /// </summary>
 /// <param name="instance">The instance.</param>
 public void Remove(UIControlInstanceModel instance)
 {
     if (this.Children != null)
     {
         if (this.Children.Contains(instance))
         {
             this.Children.Remove(instance);
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates the control instance.
 /// </summary>
 /// <param name="definition">The definition.</param>
 /// <returns></returns>
 public UIControlInstanceModel CreateAndAddControlInstance(UIControlDefinitionModel definition)
 {
     if (this.Children != null)
     {
         UIControlInstanceModel newInstance = new UIControlInstanceModel(this, definition);
         this.Children.Add(newInstance);
         return(newInstance);
     }
     return(null);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds the specified instance.
 /// </summary>
 /// <param name="instace">The instance.</param>
 public void Add(UIControlInstanceModel instance)
 {
     if (this.Children != null)
     {
         instance.ParentScreen = this;
         if (!this.Children.Contains(instance))
         {
             this.Children.Add(instance);
         }
     }
 }