示例#1
0
        public static ValueMapRenderer ReadFrom(ArcXmlReader reader)
        {
            try
            {
                ValueMapRenderer valueMapRenderer = new ValueMapRenderer();

                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        string value = reader.ReadContentAsString();

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "lookupfield": valueMapRenderer.LookupField = value; break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case Exact.XmlName: valueMapRenderer.Classifications.Add(Exact.ReadFrom(reader)); break;

                            case Other.XmlName: valueMapRenderer.Classifications.Add(Other.ReadFrom(reader)); break;

                            case Range.XmlName: valueMapRenderer.Classifications.Add(Range.ReadFrom(reader)); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(valueMapRenderer);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
示例#2
0
        public static ValueMapLabelRenderer ReadFrom(ArcXmlReader reader)
        {
            try
            {
                ValueMapLabelRenderer valueMapLabelRenderer = new ValueMapLabelRenderer();

                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        string value = reader.ReadContentAsString();

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "lookupfield": valueMapLabelRenderer.LookupField = value; break;

                            case "labelfield": valueMapLabelRenderer.LabelField = value; break;

                            case "featureweight": valueMapLabelRenderer.FeatureWeight = (LabelWeight)ArcXmlEnumConverter.ToEnum(typeof(LabelWeight), value); break;

                            case "howmanylabels": valueMapLabelRenderer.HowManyLabels = (HowManyLabels)ArcXmlEnumConverter.ToEnum(typeof(HowManyLabels), value); break;

                            case "labelbufferratio": valueMapLabelRenderer.LabelBufferRatio = Convert.ToDouble(value); break;

                            case "labelpriorities": valueMapLabelRenderer.LabelPriorities = value; break;

                            case "labelweight": valueMapLabelRenderer.LabelWeight = (LabelWeight)ArcXmlEnumConverter.ToEnum(typeof(LabelWeight), value); break;

                            case "linelabelposition": valueMapLabelRenderer.LineLabelPosition = (LineLabelPosition)ArcXmlEnumConverter.ToEnum(typeof(LineLabelPosition), value); break;

                            case "rotationalangles": valueMapLabelRenderer.RotationalAngles = value; break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case Exact.XmlName: valueMapLabelRenderer.Classifications.Add(Exact.ReadFrom(reader)); break;

                            case Other.XmlName: valueMapLabelRenderer.Classifications.Add(Other.ReadFrom(reader)); break;

                            case Range.XmlName: valueMapLabelRenderer.Classifications.Add(Range.ReadFrom(reader)); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(valueMapLabelRenderer);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }