Ejemplo n.º 1
0
 public UIControlInstanceModel(UIControlDefinitionModel definition)
     : base()
 {
     this.mControlDefinition = definition;
     this.mAttributes        = new Dictionary <AttributeModel, object>();
     this.mAttributesIndex   = new Dictionary <string, AttributeModel>();
     this.LoadControlFromDefinition();
 }
Ejemplo n.º 2
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.º 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>
        /// Initializes a new instance of the <see cref="ScreenModel"/> class.
        /// </summary>
        /// <param name="definition">The definition.</param>
        /// <exception cref="System.ArgumentException">Required container property is not present in the screen definition</exception>
        public ScreenModel(UIControlDefinitionModel definition, ProjectModel projectOwner)
            : base(projectOwner, null, definition)
        {
            System.Diagnostics.Debug.Assert(definition != null, "Screen definition can't be null");
            //System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(definition.Name) && (definition.Name.Equals("screen", StringComparison.OrdinalIgnoreCase) || definition.Name.Equals("view", StringComparison.OrdinalIgnoreCase)), "definition must be for screen or view");
            System.Diagnostics.Debug.Assert(projectOwner != null, "Project owner can't be null");

            this.ParentProject = projectOwner;
            string containerPropertyName = "items";

            if (!string.IsNullOrEmpty(definition.ContainerProperty))
            {
                containerPropertyName = definition.ContainerProperty;
            }
            containerAttribute = this.ControlDefinition.AllAttributes.FirstOrDefault(a => a.Name == containerPropertyName);
            //if (containerAttribute == null)
            //{
            //    throw new ArgumentException("Required container property is not present in the screen definition");
            //}
        }
Ejemplo n.º 5
0
 public UIControlInstanceModel(MobiseModel parent, ScreenModel parentScreen, UIControlDefinitionModel definition)
     : this(definition)
 {
     this.Parent       = parent;
     this.ParentScreen = parentScreen;
 }
 public static UIControlInstanceModel CreateInstance(UIControlDefinitionModel definition)
 {
     return(new UIControlInstanceModel(definition));
 }