Esempio n. 1
0
        public void LoadFromXML(XmlNode resourceNode)
        {
            XMLResourceTypeFactory.LoadFromXML(resourceNode, this);

            /// if the display color is specified, then load it,
            /// otherwise use a random color
            if (resourceNode.Attributes["display_color"] != null)
            {
                this._displayColor = System.Drawing.Color.FromName(resourceNode.Attributes["display_color"].Value);
            }
            else
            {
                Random random = Controller.Random;
                this._displayColor = System.Drawing.Color.FromArgb(random.Next(256), random.Next(256), random.Next(256), random.Next(256));
            }

            XMLResourceTypeFactory.CreateResourceTypeFields(this.SubTypes, resourceNode);
            foreach (System.Xml.XmlNode node in resourceNode.ChildNodes)
            {
                switch (node.Name)
                {
                case "execute":
                    Scripts.Script executionType = XMLScriptFactory.CreateScript(node);
                    this.Executions.Add(executionType.Name, executionType);
                    break;

                default:
                    continue;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the IResourceType from the specified XmlNode.
        /// </summary>
        /// <param name="node">The node.</param>
        public void LoadFromXML(System.Xml.XmlNode node)
        {
            System.Diagnostics.Debug.Assert(node.Name.Equals(Typename));

            XMLResourceTypeFactory.LoadFromXML(node, this);

            this.MinValue = decimal.MinValue;
            if (node.Attributes["min"] != null)
            {
                this.MinValue = decimal.Parse(node.Attributes["min"].Value);
            }

            this.MaxValue = decimal.MaxValue;
            if (node.Attributes["max"] != null)
            {
                this.MaxValue = decimal.Parse(node.Attributes["max"].Value);
            }

            if (node.Attributes["default"] != null)
            {
                this.DefaultValue = decimal.Parse(node.Attributes["default"].Value);
            }
            else
            {
                if (node.Attributes["min"] != null)
                {
                    if (node.Attributes["max"] != null)
                    {
                        this.DefaultValue = decimal.Divide((MinValue + MaxValue), 2);
                    }
                    else
                    {
                        this.DefaultValue = this.MinValue;
                    }
                }
                else if (node.Attributes["max"] != null)
                {
                    this.DefaultValue = this.MaxValue;
                }
                else
                {
                    this.DefaultValue = 0;
                }
            }

            this.Increment = 1;
            if (node.Attributes["increment"] != null)
            {
                this.Increment = decimal.Parse(node.Attributes["increment"].Value);
            }

            this.DecimalPlaces = 0;
            if (node.Attributes["precision"] != null)
            {
                this.DecimalPlaces = int.Parse(node.Attributes["precision"].Value);
            }

            /// the usual properties (name, help etc) are handled by the caller
        }
Esempio n. 3
0
        public void LoadFromXML(System.Xml.XmlNode node)
        {
            System.Diagnostics.Debug.Assert(node.Name.Equals(Typename));
            XMLResourceTypeFactory.LoadFromXML(node, this);

            /// add all the elements of the enum
            foreach (XmlNode elementNode in node.SelectNodes("enum_element"))
            {
                EnumElementFieldType elementType = new EnumElementFieldType();
                elementType.LoadFromXML(elementNode);
                this._elements.Add(elementType.Name, elementType);
            }
        }
Esempio n. 4
0
        public void LoadFromXML(System.Xml.XmlNode node)
        {
            System.Diagnostics.Debug.Assert(node.Name.Equals(Typename));
            XMLResourceTypeFactory.LoadFromXML(node, this);

            if (node.Attributes["mask"] != null)
            {
                string   maskString = node.Attributes["mask"].Value;
                string[] parts      = maskString.Split('|');
                for (int i = 0; i < parts.Length; ++i)
                {
                    string name          = parts [i];
                    string resourceTypes = parts [++i];
                    Masks.Add(new Mask(name, resourceTypes));
                }
            }
        }
Esempio n. 5
0
 public void LoadFromXML(System.Xml.XmlNode node)
 {
     System.Diagnostics.Debug.Assert(node.Name.Equals(Typename));
     XMLResourceTypeFactory.LoadFromXML(node, this);
     XMLResourceTypeFactory.CreateResourceTypeFields(this.SubTypes, node);
 }