Exemple #1
0
        public static TextSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                TextSymbol textSymbol = new TextSymbol();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "antialiasing": textSymbol.Antialiasing = Convert.ToBoolean(value); break;

                            case "blockout": textSymbol.BlockOut = ColorConverter.ToColor(value); break;

                            case "font": textSymbol.Font = value; break;

                            case "fontcolor": textSymbol.FontColor = ColorConverter.ToColor(value); break;

                            case "fontsize": textSymbol.FontSize = reader.ReadContentAsInt(); break;

                            case "fontstyle": textSymbol.FontStyle = (FontStyle)ArcXmlEnumConverter.ToEnum(typeof(FontStyle), value); break;

                            case "glowing": textSymbol.Glowing = ColorConverter.ToColor(value); break;

                            case "interval": textSymbol.Interval = Convert.ToInt32(value); break;

                            case "outline": textSymbol.Outline = ColorConverter.ToColor(value); break;

                            case "printmode": textSymbol.PrintMode = (PrintMode)ArcXmlEnumConverter.ToEnum(typeof(PrintMode), value); break;

                            case "shadow": textSymbol.Shadow = ColorConverter.ToColor(value); break;

                            case "transparency": textSymbol.Transparency = Convert.ToDouble(value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(textSymbol);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #2
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (Antialiasing)
                {
                    writer.WriteAttributeString("antialiasing", "true");
                }

                if (CapType != CapType.Butt)
                {
                    writer.WriteAttributeString("captype", ArcXmlEnumConverter.ToArcXml(typeof(CapType), CapType));
                }

                if (!Color.IsEmpty && Color != Color.Black)
                {
                    writer.WriteAttributeString("color", ColorConverter.ToArcXml(Color));
                }

                if (JoinType != JoinType.Round)
                {
                    writer.WriteAttributeString("jointype", ArcXmlEnumConverter.ToArcXml(typeof(JoinType), JoinType));
                }

                if (!Overlap)
                {
                    writer.WriteAttributeString("overlap", "false");
                }

                if (0 <= Transparency && Transparency < 1)
                {
                    writer.WriteAttributeString("transparency", Transparency.ToString("0.000"));
                }

                if (Type != LineType.Solid)
                {
                    writer.WriteAttributeString("type", ArcXmlEnumConverter.ToArcXml(typeof(LineType), Type));
                }

                if (Width > 1)
                {
                    writer.WriteAttributeString("width", Width.ToString());
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #3
0
        public static ShieldSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                ShieldSymbol shieldSymbol = new ShieldSymbol();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "antialiasing": shieldSymbol.Antialiasing = Convert.ToBoolean(value); break;

                            case "bottomcolor": shieldSymbol.BottomColor = ColorConverter.ToColor(value); break;

                            case "font": shieldSymbol.Font = value; break;

                            case "fontcolor": shieldSymbol.FontColor = ColorConverter.ToColor(value); break;

                            case "fontsize": shieldSymbol.FontSize = Convert.ToInt32(value); break;

                            case "fontstyle": shieldSymbol.FontStyle = (FontStyle)ArcXmlEnumConverter.ToEnum(typeof(FontStyle), value); break;

                            case "labelmode": shieldSymbol.LabelMode = (ShieldLabelMode)ArcXmlEnumConverter.ToEnum(typeof(ShieldLabelMode), value); break;

                            case "middlecolor": shieldSymbol.MiddleColor = ColorConverter.ToColor(value); break;

                            case "minsize": shieldSymbol.MinSize = Convert.ToInt32(value); break;

                            case "shadow": shieldSymbol.Shadow = ColorConverter.ToColor(value); break;

                            case "topcolor": shieldSymbol.TopColor = ColorConverter.ToColor(value); break;

                            case "transparency": shieldSymbol.Transparency = Convert.ToDouble(value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(shieldSymbol);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #4
0
        public static ChartSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                ChartSymbol chartSymbol = new ChartSymbol();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "antialiasing": chartSymbol.Antialiasing = Convert.ToBoolean(value); break;

                            case "maxsize": chartSymbol.MaxSize = Convert.ToInt32(value); break;

                            case "maxvalue": chartSymbol.MaxValue = Convert.ToInt32(value); break;

                            case "minsize": chartSymbol.MinSize = Convert.ToInt32(value); break;

                            case "minvalue": chartSymbol.MinValue = Convert.ToInt32(value); break;

                            case "mode": chartSymbol.Mode = (ChartSymbolMode)ArcXmlEnumConverter.ToEnum(typeof(ChartSymbolMode), value); break;

                            case "outline": chartSymbol.Outline = ColorConverter.ToColor(value); break;

                            case "shadow": chartSymbol.Shadow = ColorConverter.ToColor(value); break;

                            case "size": chartSymbol.Size = Convert.ToInt32(value); break;

                            case "sizefield": chartSymbol.SizeField = value; break;

                            case "transparency": chartSymbol.Transparency = Convert.ToDouble(value); break;

                            case "width": chartSymbol.Width = Convert.ToInt32(value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(chartSymbol);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #5
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (!String.IsNullOrEmpty(ID))
                {
                    writer.WriteAttributeString("id", ID);
                }

                if (Type != LayerType.None)
                {
                    writer.WriteAttributeString("type", ArcXmlEnumConverter.ToArcXml(typeof(LayerType), Type));
                }

                if (Dataset != null)
                {
                    Dataset.WriteTo(writer);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #6
0
        public static Extension ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Extension extension = new Extension();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "type": extension.Type = (ExtensionType)ArcXmlEnumConverter.ToEnum(typeof(ExtensionType), 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 GcStyle.XmlName: extension.GcStyle = GcStyle.ReadFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(extension);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #7
0
		public static LayoutInfo ReadFrom(ArcXmlReader reader)
		{
			try
			{
				LayoutInfo layoutInfo = new LayoutInfo();

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

						if (value.Length > 0)
						{
							switch (reader.Name)
							{
								case "pageunits": layoutInfo.PageUnits = (PageUnits)ArcXmlEnumConverter.ToEnum(typeof(PageUnits), 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 "ENVELOPE": layoutInfo.Envelope = EnvelopeSerializer.ReadFrom(reader); break;
              }
						}

						reader.Read();
					}
				}

				return layoutInfo;
			}
			catch (Exception ex)
			{
				if (ex is ArcXmlException)
				{
					throw ex;
				}
				else
				{
					throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
				}
			}
		}
Exemple #8
0
        public static SimpleMarkerSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "antialiasing": simpleMarkerSymbol.Antialiasing = Convert.ToBoolean(value); break;

                            case "color": simpleMarkerSymbol.Color = ColorConverter.ToColor(value); break;

                            case "outline": simpleMarkerSymbol.Outline = ColorConverter.ToColor(value); break;

                            case "overlap": simpleMarkerSymbol.Overlap = Convert.ToBoolean(value); break;

                            case "shadow": simpleMarkerSymbol.Shadow = ColorConverter.ToColor(value); break;

                            case "transparency": simpleMarkerSymbol.Transparency = Convert.ToDouble(value); break;

                            case "type": simpleMarkerSymbol.Type = (MarkerType)ArcXmlEnumConverter.ToEnum(typeof(MarkerType), value); break;

                            case "usecentroid": simpleMarkerSymbol.UseCentroid = Convert.ToBoolean(value); break;

                            case "width": simpleMarkerSymbol.Width = Convert.ToInt32(value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(simpleMarkerSymbol);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #9
0
        public static HashLineSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                HashLineSymbol hashLineSymbol = new HashLineSymbol();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "antialiasing": hashLineSymbol.Antialiasing = Convert.ToBoolean(value); break;

                            case "color": hashLineSymbol.Color = ColorConverter.ToColor(value); break;

                            case "interval": hashLineSymbol.Interval = Convert.ToInt32(value); break;

                            case "linethickness": hashLineSymbol.LineThickness = Convert.ToInt32(value); break;

                            case "tickthickness": hashLineSymbol.TickThickness = Convert.ToInt32(value); break;

                            case "overlap": hashLineSymbol.Overlap = Convert.ToBoolean(value); break;

                            case "transparency": hashLineSymbol.Transparency = Convert.ToDouble(value); break;

                            case "type": hashLineSymbol.Type = (HashLineType)ArcXmlEnumConverter.ToEnum(typeof(HashLineType), value); break;

                            case "width": hashLineSymbol.Width = Convert.ToInt32(value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(hashLineSymbol);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #10
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (Antialiasing)
                {
                    writer.WriteAttributeString("antialiasing", "true");
                }

                if (!FinishColor.IsEmpty)
                {
                    writer.WriteAttributeString("finishcolor", ColorConverter.ToArcXml(FinishColor));
                }

                if (!Overlap)
                {
                    writer.WriteAttributeString("overlap", "false");
                }

                if (!StartColor.IsEmpty)
                {
                    writer.WriteAttributeString("startcolor", ColorConverter.ToArcXml(StartColor));
                }

                if (0 <= Transparency && Transparency < 1)
                {
                    writer.WriteAttributeString("transparency", Transparency.ToString("0.000"));
                }

                if (Type != GradientFillType.BDiagonal)
                {
                    writer.WriteAttributeString("type", ArcXmlEnumConverter.ToArcXml(typeof(GradientFillType), Type));
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #11
0
        public static GradientFillSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                GradientFillSymbol gradientFillSymbol = new GradientFillSymbol();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "antialiasing": gradientFillSymbol.Antialiasing = Convert.ToBoolean(value); break;

                            case "finishcolor": gradientFillSymbol.FinishColor = ColorConverter.ToColor(value); break;

                            case "overlap": gradientFillSymbol.Overlap = Convert.ToBoolean(value); break;

                            case "startcolor": gradientFillSymbol.StartColor = ColorConverter.ToColor(value); break;

                            case "transparency": gradientFillSymbol.Transparency = Convert.ToDouble(value); break;

                            case "type": gradientFillSymbol.Type = (GradientFillType)ArcXmlEnumConverter.ToEnum(typeof(GradientFillType), value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(gradientFillSymbol);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #12
0
        public static RasterRange ReadFrom(ArcXmlReader reader)
        {
            try
            {
                RasterRange rasterRange = new RasterRange();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "color": rasterRange.Color = ColorConverter.ToColor(value); break;

                            case "equality": rasterRange.Equality = (RangeEquality)ArcXmlEnumConverter.ToEnum(typeof(RangeEquality), value); break;

                            case "label": rasterRange.Label = value; break;

                            case "lower": rasterRange.Lower = Convert.ToDouble(value); break;

                            case "transparency": rasterRange.Transparency = Convert.ToDouble(value); break;

                            case "upper": rasterRange.Upper = Convert.ToDouble(value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(rasterRange);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #13
0
        public static Output ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Output output = new Output();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "file": output.File = value; break;

                            case "height": output.Height = Convert.ToInt32(value); break;

                            case "url": output.Url = value; break;

                            case "width": output.Width = Convert.ToInt32(value); break;

                            case "type": output.Type = (ImageType)ArcXmlEnumConverter.ToEnum(typeof(ImageType), value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(output);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #14
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (Distance > 0)
                {
                    writer.WriteAttributeString("distance", Distance.ToString());
                }

                if (BufferUnits != BufferUnits.Default)
                {
                    writer.WriteAttributeString("bufferunits", ArcXmlEnumConverter.ToArcXml(typeof(BufferUnits), BufferUnits));
                }

                if (!Project)
                {
                    writer.WriteAttributeString("project", "false");
                }

                if (SpatialQuery != null)
                {
                    SpatialQuery.WriteTo(writer);
                }

                if (TargetLayer != null)
                {
                    TargetLayer.WriteTo(writer);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #15
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (!String.IsNullOrEmpty(BaseUrl))
                {
                    writer.WriteAttributeString("baseurl", BaseUrl);
                }

                if (!String.IsNullOrEmpty(Name))
                {
                    writer.WriteAttributeString("name", Name);
                }

                if (!String.IsNullOrEmpty(Path))
                {
                    writer.WriteAttributeString("path", Path);
                }

                if (Type != ImageType.Default)
                {
                    writer.WriteAttributeString("type", ArcXmlEnumConverter.ToArcXml(typeof(ImageType), Type));
                }

                if (!String.IsNullOrEmpty(Url))
                {
                    writer.WriteAttributeString("url", Url);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #16
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (Equality != RangeEquality.Lower)
                {
                    writer.WriteAttributeString("equality", ArcXmlEnumConverter.ToArcXml(typeof(RangeEquality), Equality));
                }

                if (!String.IsNullOrEmpty(Label))
                {
                    writer.WriteAttributeString("label", Label);
                }

                if (!String.IsNullOrEmpty(Lower))
                {
                    writer.WriteAttributeString("lower", Lower);
                }

                if (!String.IsNullOrEmpty(Upper))
                {
                    writer.WriteAttributeString("upper", Upper);
                }

                if (Symbol != null)
                {
                    Symbol.WriteTo(writer);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #17
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (ForGeocoding)
                {
                    writer.WriteAttributeString("extensions", "true");
                }
                else
                {
                    if (!String.IsNullOrEmpty(DataFrame))
                    {
                        writer.WriteAttributeString("dataframe", DataFrame);
                    }

                    writer.WriteAttributeString("acetateinfo", AcetateInfo ? "true" : "false");
                    writer.WriteAttributeString("dpi", Dpi.ToString());
                    writer.WriteAttributeString("envelope", Envelope ? "true" : "false");
                    writer.WriteAttributeString("extensions", Extensions ? "true" : "false");
                    writer.WriteAttributeString("fields", Fields ? "true" : "false");
                    writer.WriteAttributeString("relativescale", RelativeScale ? "true" : "false");
                    writer.WriteAttributeString("renderer", Renderer ? "true" : "false");
                    writer.WriteAttributeString("toc", Toc ? "true" : "false");
                    writer.WriteAttributeString("toctype", ArcXmlEnumConverter.ToArcXml(typeof(ImageType), TocType));

                    writer.WriteEndElement();
                }
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #18
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (!String.IsNullOrEmpty(FromLayer))
                {
                    writer.WriteAttributeString("fromlayer", FromLayer);
                }

                if (!String.IsNullOrEmpty(Name))
                {
                    writer.WriteAttributeString("name", Name);
                }

                if (Type != DatasetType.None)
                {
                    writer.WriteAttributeString("method", ArcXmlEnumConverter.ToArcXml(typeof(DatasetType), Type));
                }

                if (!String.IsNullOrEmpty(Workspace))
                {
                    writer.WriteAttributeString("workspace", Workspace);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #19
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (!String.IsNullOrEmpty(Label))
                {
                    writer.WriteAttributeString("label", Label);
                }

                if (Method != ExactMethod.IsExact)
                {
                    writer.WriteAttributeString("method", ArcXmlEnumConverter.ToArcXml(typeof(ExactMethod), Method));
                }

                if (!String.IsNullOrEmpty(Value))
                {
                    writer.WriteAttributeString("value", Value);
                }

                if (Symbol != null)
                {
                    Symbol.WriteTo(writer);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #20
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                writer.WriteAttributeString("relation", ArcXmlEnumConverter.ToArcXml(typeof(SpatialRelation), Relation));

                if (Buffer != null)
                {
                    Buffer.WriteTo(writer);
                }

                if (Shape != null)
                {
                    if (Shape.OgcGeometryType == OgcGeometryType.Point)
                    {
                        GeometrySerializer.WriteAsMultiPointTo(writer, (IPoint)Shape);
                    }
                    else
                    {
                        GeometrySerializer.WriteTo(writer, Shape);
                    }
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #21
0
        public static MapUnits ReadFrom(ArcXmlReader reader)
        {
            try
            {
                MapUnits mapUnits = new MapUnits();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "units": mapUnits.Units = (Units)ArcXmlEnumConverter.ToEnum(typeof(Units), value); break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(mapUnits);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #22
0
        public static RasterShieldSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                RasterShieldSymbol rasterShieldSymbol = new RasterShieldSymbol();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "antialiasing": rasterShieldSymbol.Antialiasing = Convert.ToBoolean(value); break;

                            case "boundary": rasterShieldSymbol.Boundary = Convert.ToBoolean(value); break;

                            case "font": rasterShieldSymbol.Font = value; break;

                            case "fontcolor": rasterShieldSymbol.FontColor = ColorConverter.ToColor(value); break;

                            case "fontsize": rasterShieldSymbol.FontSize = Convert.ToInt32(value); break;

                            case "fontstyle": rasterShieldSymbol.FontStyle = (FontStyle)ArcXmlEnumConverter.ToEnum(typeof(FontStyle), value); break;

                            case "image": rasterShieldSymbol.Image = value; break;

                            case "labelmode": rasterShieldSymbol.LabelMode = (ShieldLabelMode)ArcXmlEnumConverter.ToEnum(typeof(ShieldLabelMode), value); break;

                            case "printmode": rasterShieldSymbol.PrintMode = (PrintMode)ArcXmlEnumConverter.ToEnum(typeof(PrintMode), value); break;

                            case "shadow": rasterShieldSymbol.Shadow = ColorConverter.ToColor(value); break;

                            case "transparency": rasterShieldSymbol.Transparency = Convert.ToDouble(value); break;

                            case "url": rasterShieldSymbol.Url = value; break;

                            case "textposition":
                                string[] p = value.Split(new char[] { ',' });
                                rasterShieldSymbol.TextPosition = new NetTopologySuite.Geometries.Point(Convert.ToDouble(p[0]), Convert.ToDouble(p[1]));
                                break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                return(rasterShieldSymbol);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #23
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (Antialiasing)
                {
                    writer.WriteAttributeString("antialiasing", "true");
                }

                if (Boundary)
                {
                    writer.WriteAttributeString("antialiasing", "true");
                }

                if (!String.IsNullOrEmpty(Font) && String.Compare(Font, "Arial", true) != 0)
                {
                    writer.WriteAttributeString("font", Font);
                }

                if (FontColor != Color.Black)
                {
                    writer.WriteAttributeString("fontcolor", ColorConverter.ToArcXml(FontColor));
                }

                if (FontSize != 12)
                {
                    writer.WriteAttributeString("fontsize", FontSize.ToString());
                }

                if (FontStyle != FontStyle.Regular)
                {
                    writer.WriteAttributeString("fontstyle", ArcXmlEnumConverter.ToArcXml(typeof(FontStyle), FontStyle));
                }

                if (!String.IsNullOrEmpty(Image))
                {
                    writer.WriteAttributeString("image", Image);
                }

                if (LabelMode != ShieldLabelMode.NumericOnly)
                {
                    writer.WriteAttributeString("labelmode", ArcXmlEnumConverter.ToArcXml(typeof(ShieldLabelMode), LabelMode));
                }

                if (PrintMode != PrintMode.None)
                {
                    writer.WriteAttributeString("printmode", ArcXmlEnumConverter.ToArcXml(typeof(PrintMode), PrintMode));
                }

                if (!Shadow.IsEmpty)
                {
                    writer.WriteAttributeString("shadow", ColorConverter.ToArcXml(Shadow));
                }

                if (TextPosition != null)
                {
                    writer.WriteAttributeString("textposition", String.Format("{0},{1}", TextPosition.Coordinate.X, TextPosition.Coordinate.Y));
                }

                if (0 <= Transparency && Transparency < 1)
                {
                    writer.WriteAttributeString("transparency", Transparency.ToString("0.000"));
                }

                if (!String.IsNullOrEmpty(Url))
                {
                    writer.WriteAttributeString("url", Url);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #24
0
        public static Field ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Field field = new Field();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "alias": field.Alias = value; break;

                            case "description": field.Description = value; break;

                            case "name": field.Name = value; break;

                            case "precision": field.Precision = Convert.ToInt32(value); break;

                            case "size": field.Size = Convert.ToInt32(value); break;

                            case "type": field.Type = (FieldType)ArcXmlEnumConverter.ToEnum(typeof(FieldType), value); break;

                            case "value": field.Value = 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 FieldValue.XmlName: field.FieldValue = FieldValue.ReadFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(field);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #25
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (!String.IsNullOrEmpty(ID))
                {
                    writer.WriteAttributeString("id", ID);
                }

                if (Type != LayerType.None)
                {
                    writer.WriteAttributeString("type", ArcXmlEnumConverter.ToArcXml(typeof(LayerType), Type));
                }

                if (!String.IsNullOrEmpty(MaxScale))
                {
                    writer.WriteAttributeString("maxscale", MaxScale);
                }

                if (!String.IsNullOrEmpty(MinScale))
                {
                    writer.WriteAttributeString("mincale", MinScale);
                }

                if (!String.IsNullOrEmpty(Name))
                {
                    writer.WriteAttributeString("name", Name);
                }

                if (!Visible)
                {
                    writer.WriteAttributeString("visible", "false");
                }

                if (CoordSys != null)
                {
                    CoordSys.WriteTo(writer);
                }

                if (Dataset != null)
                {
                    Dataset.WriteTo(writer);
                }

                if (ImageProperties != null)
                {
                    ImageProperties.WriteTo(writer);
                }

                if (Objects != null)
                {
                    foreach (Object obj in Objects)
                    {
                        obj.WriteTo(writer);
                    }
                }

                if (Query != null)
                {
                    Query.WriteTo(writer);
                }

                if (Renderer != null)
                {
                    Renderer.WriteTo(writer);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #26
0
        public static SimpleLabelRenderer ReadFrom(ArcXmlReader reader)
        {
            try
            {
                SimpleLabelRenderer simpleLabelRenderer = new SimpleLabelRenderer();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "field": simpleLabelRenderer.Field = value; break;

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

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

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

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

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

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

                            case "rotationalangles": simpleLabelRenderer.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 ShieldSymbol.XmlName: simpleLabelRenderer.Symbol = ShieldSymbol.ReadFrom(reader); break;

                            case TextSymbol.XmlName: simpleLabelRenderer.Symbol = TextSymbol.ReadFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(simpleLabelRenderer);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #27
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (!String.IsNullOrEmpty(Field))
                {
                    writer.WriteAttributeString("field", Field);
                }

                if (FeatureWeight != LabelWeight.NoWeight)
                {
                    writer.WriteAttributeString("featureweight", ArcXmlEnumConverter.ToArcXml(typeof(LabelWeight), FeatureWeight));
                }

                if (HowManyLabels != HowManyLabels.OneLabelPerShape)
                {
                    writer.WriteAttributeString("howmanylabels", ArcXmlEnumConverter.ToArcXml(typeof(HowManyLabels), HowManyLabels));
                }

                if (LabelBufferRatio > 0)
                {
                    writer.WriteAttributeString("labelbufferratio", LabelBufferRatio.ToString("0.000"));
                }

                if (!String.IsNullOrEmpty(LabelPriorities))
                {
                    writer.WriteAttributeString("labelpriorities", LabelPriorities);
                }

                if (LabelWeight != LabelWeight.HighWeight)
                {
                    writer.WriteAttributeString("labelweight", ArcXmlEnumConverter.ToArcXml(typeof(LabelWeight), LabelWeight));
                }

                if (LineLabelPosition != LineLabelPosition.PlaceAbove)
                {
                    writer.WriteAttributeString("linelabelposition", ArcXmlEnumConverter.ToArcXml(typeof(LineLabelPosition), LineLabelPosition));
                }

                if (!String.IsNullOrEmpty(RotationalAngles))
                {
                    writer.WriteAttributeString("rotationalangles", RotationalAngles);
                }

                if (Symbol != null)
                {
                    Symbol.WriteTo(writer);
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #28
0
        public static FClass ReadFrom(ArcXmlReader reader)
        {
            try
            {
                FClass fClass = new FClass();

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

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "type": fClass.Type = (FClassType)ArcXmlEnumConverter.ToEnum(typeof(FClassType), 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 "ENVELOPE": fClass.Envelope = EnvelopeSerializer.ReadFrom(reader); break;

                            case Field.XmlName:
                                if (fClass.Fields == null)
                                {
                                    fClass.Fields = new Fields();
                                }

                                fClass.Fields.Add(Field.ReadFrom(reader));
                                break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(fClass);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Exemple #29
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (!String.IsNullOrEmpty(Lower))
                {
                    writer.WriteAttributeString("lower", Lower);
                }

                if (Alignment != ObjectAlignment.BottomLeft)
                {
                    writer.WriteAttributeString("alignment", ArcXmlEnumConverter.ToArcXml(typeof(ObjectAlignment), Alignment));
                }

                writer.WriteAttributeString("units", ArcXmlEnumConverter.ToArcXml(typeof(ObjectUnits), Units));

                if (!String.IsNullOrEmpty(Upper))
                {
                    writer.WriteAttributeString("upper", Upper);
                }

                if (CoordSys != null)
                {
                    CoordSys.WriteTo(writer);
                }

                if (_shape != null)
                {
                    if (_shape.OgcGeometryType == OgcGeometryType.Point)
                    {
                        GeometrySerializer.WriteAsMultiPointTo(writer, (IPoint)_shape);
                    }
                    else
                    {
                        GeometrySerializer.WriteTo(writer, _shape);
                    }

                    if (Symbol != null)
                    {
                        Symbol.WriteTo(writer);
                    }
                }

                if (_northArrow != null)
                {
                    _northArrow.WriteTo(writer);
                }

                if (_scaleBar != null)
                {
                    _scaleBar.WriteTo(writer);
                }

                if (_text != null)
                {
                    bool symbolAdded = false;

                    if (_text.Symbol == null)
                    {
                        _text.Symbol = (TextMarkerSymbol)Symbol;
                        symbolAdded  = true;
                    }

                    _text.WriteTo(writer);

                    if (symbolAdded)
                    {
                        _text.Symbol = null;
                    }
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }
Exemple #30
0
        public override void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                if (Antialiasing)
                {
                    writer.WriteAttributeString("antialiasing", "true");
                }

                if (MaxSize > 0)
                {
                    writer.WriteAttributeString("maxsize", MaxSize.ToString());
                }

                if (MaxSize > 0 && MaxValue > 0)
                {
                    writer.WriteAttributeString("maxvalue", MaxValue.ToString());
                }

                if (MinSize > 0)
                {
                    writer.WriteAttributeString("minsize", MinSize.ToString());
                }

                if (MinSize > 0 && MinValue > 0)
                {
                    writer.WriteAttributeString("minvalue", MinValue.ToString());
                }

                if (Mode != ChartSymbolMode.Pie)
                {
                    writer.WriteAttributeString("mode", ArcXmlEnumConverter.ToArcXml(typeof(ChartSymbolMode), Mode));
                }

                if (!Outline.IsEmpty)
                {
                    writer.WriteAttributeString("outline", ColorConverter.ToArcXml(Outline));
                }

                if (!Shadow.IsEmpty)
                {
                    writer.WriteAttributeString("shadow", ColorConverter.ToArcXml(Shadow));
                }

                if (Size > 0)
                {
                    writer.WriteAttributeString("size", Size.ToString());
                }

                if (!String.IsNullOrEmpty(SizeField))
                {
                    writer.WriteAttributeString("sizefield", SizeField);
                }

                if (0 <= Transparency && Transparency < 1)
                {
                    writer.WriteAttributeString("transparency", Transparency.ToString("0.000"));
                }

                if (Width > 0)
                {
                    writer.WriteAttributeString("width", Width.ToString());
                }

                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not write {0} object.", GetType().Name), ex);
                }
            }
        }