コード例 #1
0
ファイル: ViewSerializer.cs プロジェクト: Ogiss/AbakTools
        private void parseProperties(XmlNode node)
        {
            var properties = new Dictionary <string, object>();

            CoreTools.Xml.ParseChildNodes(node, (child) => {
                string name     = null;
                string valueStr = null;
                string typeStr  = null;

                CoreTools.Xml.ParseNodeAttributes(child, (attrName, attrValue) => {
                    switch (attrName.ToLower())
                    {
                    case "name":
                        name = attrValue;
                        break;

                    case "value":
                        valueStr = attrValue;
                        break;

                    case "type":
                        typeStr = attrValue;
                        break;
                    }
                });
                if (!string.IsNullOrEmpty(name))
                {
                    object value = valueStr;
                    if (!string.IsNullOrEmpty(typeStr) && !string.IsNullOrEmpty(valueStr))
                    {
                        try
                        {
                            switch (typeStr)
                            {
                            case "System.Int32":
                                value = int.Parse(valueStr);
                                break;

                            case "System.Boolean":
                                value = CoreTools.ParseBool(valueStr);
                                break;
                            }
                        }
                        catch { }
                    }
                    properties.Add(name, value);
                }
            }, "add");
            this.context.SetStoredProperties(properties);
        }
コード例 #2
0
ファイル: ViewSerializer.cs プロジェクト: Ogiss/AbakTools
        private Column createColumn(XmlNode node)
        {
            string header          = null;
            string headerTextAlign = null;
            string headerheight    = null;
            string widthStr        = null;
            string textAling       = null;
            string format          = null;
            string path            = null;
            string readOnly        = null;

            CoreTools.Xml.ParseNodeAttributes(node, (attrName, attrValue) => {
                switch (attrName.ToLower())
                {
                case "headertext":
                    header = attrValue;
                    break;

                case "headertextalign":
                    headerTextAlign = attrValue;
                    break;

                case "headerheight":
                    headerheight = attrValue;
                    break;

                case "width":
                    widthStr = attrValue;
                    break;

                case "textalign":
                    textAling = attrValue;
                    break;

                case "format":
                    format = attrValue;
                    break;

                case "propertypath":
                    path = attrValue;
                    break;

                case "readonly":
                    readOnly = attrValue;
                    break;
                }
            });

            if (!string.IsNullOrEmpty(path))
            {
                Column column = new Column();
                //column.PropertyPath = new PropertyPath(this.context.GetDataType(), path);
                //column.HeaderText = string.IsNullOrEmpty(header) ? column.PropertyPath.Last.Name : header;
                column.PropertyDescriptorPath = new PropertyDescriptorPath(this.context.GetDataType(), path);
                column.HeaderText             = string.IsNullOrEmpty(header) ? column.PropertyDescriptorPath.Last.Name : header;
                int i;

                if (int.TryParse(headerTextAlign, out i))
                {
                    column.HeaderTextAlign = (TextAlign)i;
                }

                if (int.TryParse(widthStr, out i))
                {
                    column.Width = i;
                }
                else
                {
                    column.Width = 100;
                }

                if (int.TryParse(textAling, out i))
                {
                    column.TextAlign = (TextAlign)i;
                }
                else
                {
                    column.TextAlign = TextAlign.None;
                }
                column.Format = format;

                if (!string.IsNullOrEmpty(readOnly))
                {
                    column.ReadOnly = CoreTools.ParseBool(readOnly);
                }

                return(column);
            }
            return(null);
        }