示例#1
0
        /// <summary>
        /// Загрузить настройки
        /// </summary>
        public void Load(XmlNode root)
        {
            try
            {
                if (root != null)
                {
                    XmlNode root_node = root;
                    if (root_node != null)
                    {
                        XmlNodeList childs = root_node.ChildNodes;
                        if (childs != null)
                        {
                            foreach (XmlNode child in childs)
                            {
                                switch (child.Name)
                                {
                                case "parameter":

                                    Parameter parameter = new Parameter(-1);
                                    parameter.DeserializeFromXmlNode(child);

                                    if (parameter.SelfIndex > -1 && parameter.SelfIndex < parameters.Length)
                                    {
                                        parameters[parameter.SelfIndex] = parameter;
                                    }
                                    break;

                                case Tech.TechRoot:

                                    tech.Load(child);
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch { }
        }
示例#2
0
        /// <summary>
        /// Загрузить параметр панели из узела XML
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public void DeSerializeToXmlNode(XmlNode root)
        {
            try
            {
                if (root != null)
                {
                    if (root.HasChildNodes)
                    {
                        foreach (XmlNode child in root.ChildNodes)
                        {
                            switch (child.Name)
                            {
                            case minName:

                                try
                                {
                                    min = float.Parse(child.InnerText);
                                }
                                catch { }
                                break;

                            case maxName:

                                try
                                {
                                    max = float.Parse(child.InnerText);
                                }
                                catch { }
                                break;

                            case colorName:

                                try
                                {
                                    int argb = int.Parse(child.InnerText);
                                    color = System.Drawing.Color.FromArgb(argb);
                                }
                                catch { }
                                break;

                            case "parameter":

                                try
                                {
                                    if (parameter == null)
                                    {
                                        parameter = new Parameter();
                                    }
                                    parameter.DeserializeFromXmlNode(child);
                                }
                                catch
                                {
                                    parameter = null;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            catch { }
        }
示例#3
0
文件: Commutator.cs 项目: slawer/skc
        /// <summary>
        /// Загрузить настройки
        /// </summary>
        public void Load(XmlNode root)
        {
            try
            {
                if (root != null)
                {
                    XmlNode root_node = root;
                    if (root_node != null)
                    {
                        XmlNodeList childs = root_node.ChildNodes;
                        if (childs != null)
                        {
                            foreach (XmlNode child in childs)
                            {
                                switch (child.Name)
                                {
                                    case "parameter":

                                        Parameter parameter = new Parameter(-1);
                                        parameter.DeserializeFromXmlNode(child);

                                        if (parameter.SelfIndex > -1 && parameter.SelfIndex < parameters.Length)
                                        {
                                            parameters[parameter.SelfIndex] = parameter;
                                        }
                                        break;

                                    case Tech.TechRoot:

                                        tech.Load(child);
                                        break;

                                    default:
                                        break;
                                }
                            }
                        }
                    }
                }
            }
            catch { }
        }