示例#1
0
        private void ReadXmlText(XmlReader xr)
        {
            // Read thru all the Text elements
            string val          = null;
            PointF location     = new PointF();
            string family       = "Arial";
            float  fontsize     = 8;
            bool   bBold        = false;
            bool   bItalic      = false;
            bool   bUnderline   = false;
            bool   bLineThrough = false;

            string temp;

            while (xr.Read())
            {
                if (!xr.IsStartElement())
                {
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "Text")
                    {
                        break;
                    }
                    continue;
                }

                switch (xr.Name)
                {
                case "Location":
                    PointF[] pfa = ReadXmlPoints(xr);
                    location = pfa[0];
                    break;

                case "Value":
                    val = xr.ReadString();
                    break;

                case "FontFamily":
                    family = xr.ReadString();
                    break;

                case "FontSize":
                    temp = xr.ReadString();
                    try
                    {
                        fontsize = float.Parse(temp, NumberFormatInfo.InvariantInfo);
                    }
                    catch
                    {
                        fontsize = 8;
                    }
                    break;

                case "FontWeight":
                    temp  = xr.ReadString();
                    bBold = temp.ToLower() == "bold";
                    break;

                case "FontStyle":
                    temp    = xr.ReadString();
                    bItalic = temp.ToLower() == "italic";
                    break;

                case "TextDecoration":
                    temp = xr.ReadString();
                    switch (temp.ToLower())
                    {
                    case "underline":
                        bUnderline = true;
                        break;

                    case "linethrough":
                        bUnderline = true;
                        break;
                    }
                    break;
                }
            }
            if (val != null && location != null)
            {
                MapText mt = new MapText(val, location);
                mt.FontFamily   = family;
                mt.FontSize     = fontsize;
                mt.bBold        = bBold;
                mt.bItalic      = bItalic;
                mt.bLineThrough = bLineThrough;
                mt.bUnderline   = bUnderline;
                AddMapObject(mt);
            }
        }
        private void ReadXmlText(XmlReader xr)
        {
            // Read thru all the Text elements
            string val = null;
            PointF location= new PointF();
            string family = "Arial";
            float fontsize = 8;
            bool bBold = false;
            bool bItalic = false;
            bool bUnderline = false;
            bool bLineThrough = false;

            string temp;
            while (xr.Read())
            {
                if (!xr.IsStartElement())
                {
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "Text")
                        break;
                    continue;
                }

                switch (xr.Name)
                {
                    case "Location":
                        PointF[] pfa = ReadXmlPoints(xr);
                        location = pfa[0];
                        break;
                    case "Value":
                        val = xr.ReadString();
                        break;
                    case "FontFamily":
                        family = xr.ReadString();
                        break;
                    case "FontSize":
                        temp = xr.ReadString();
                        try
                        {
                            fontsize = float.Parse(temp, NumberFormatInfo.InvariantInfo);
                        }
                        catch
                        {
                            fontsize = 8;
                        }
                        break;
                    case "FontWeight":
                        temp = xr.ReadString();
                        bBold = temp.ToLower() == "bold";
                        break;
                    case "FontStyle":
                        temp = xr.ReadString();
                        bItalic = temp.ToLower() == "italic";
                        break;
                    case "TextDecoration":
                        temp = xr.ReadString();
                        switch (temp.ToLower())
                        {
                            case "underline":
                                bUnderline = true;
                                break;
                            case "linethrough":
                                bUnderline = true;
                                break;
                        }
                        break;
                }
            }
            if (val != null && location != null)
            {
                MapText mt = new MapText(val, location);
                mt.FontFamily = family;
                mt.FontSize = fontsize;
                mt.bBold = bBold;
                mt.bItalic = bItalic;
                mt.bLineThrough = bLineThrough;
                mt.bUnderline = bUnderline;
                AddMapObject(mt);
            }
        }