Example #1
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);
                }
            }
        }
Example #2
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);
                }
            }
        }
Example #3
0
        public void WriteTo(ArcXmlWriter writer)
        {
            try
            {
                writer.WriteStartElement(XmlName);

                writer.WriteAttributeString("coords", X.ToString() + writer.CoordinateSeparator[0] + Y.ToString());

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

                if (BarColor != Color.FromArgb(255, 162, 115))
                {
                    writer.WriteAttributeString("barcolor", ColorConverter.ToArcXml(BarColor));
                }

                if (BarColor.A > 0)
                {
                    writer.WriteAttributeString("bartransparency", (BarColor.A / 255.0).ToString("0.000"));
                }

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

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

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

                if (FontColor.A > 255)
                {
                    writer.WriteAttributeString("texttransparency", (FontColor.A / 255.0).ToString("0.000"));
                }

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

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

                if (MapUnits != Units.Degrees)
                {
                    writer.WriteAttributeString("mapunits", ArcXmlEnumConverter.ToArcXml(typeof(Units), MapUnits));
                }

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

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

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

                if (Precision > 0)
                {
                    writer.WriteAttributeString("precision", Precision.ToString());
                }

                if (Round > 0)
                {
                    writer.WriteAttributeString("round", Round.ToString());
                }

                if (ScaleUnits != ScaleUnits.Miles)
                {
                    writer.WriteAttributeString("scaleunits", ArcXmlEnumConverter.ToArcXml(typeof(ScaleUnits), ScaleUnits));
                }

                if (ScreenLength > 0)
                {
                    writer.WriteAttributeString("screenlength", ScreenLength.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);
                }
            }
        }
Example #4
0
        public static SimplePolygonSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                SimplePolygonSymbol simplePolygonSymbol = new SimplePolygonSymbol();

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

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

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

                            case "boundarycaptype": simplePolygonSymbol.BoundaryCapType = (CapType)ArcXmlEnumConverter.ToEnum(typeof(CapType), value); break;

                            case "boundarycolor": simplePolygonSymbol.BoundaryColor = Color.FromArgb(simplePolygonSymbol.BoundaryColor.A, ColorConverter.ToColor(value)); break;

                            case "boundaryjointype": simplePolygonSymbol.BoundaryJoinType = (JoinType)ArcXmlEnumConverter.ToEnum(typeof(JoinType), value); break;

                            case "boundarytype": simplePolygonSymbol.BoundaryType = (LineType)ArcXmlEnumConverter.ToEnum(typeof(LineType), value); break;

                            case "boundarywidth": simplePolygonSymbol.BoundaryWidth = Convert.ToInt32(value); break;

                            case "fillcolor": simplePolygonSymbol.FillColor = Color.FromArgb(simplePolygonSymbol.FillColor.A, ColorConverter.ToColor(value)); break;

                            case "fillinterval": simplePolygonSymbol.FillInterval = Convert.ToInt32(value); break;

                            case "filltype": simplePolygonSymbol.FillType = (FillType)ArcXmlEnumConverter.ToEnum(typeof(FillType), value); break;

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

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

                    reader.MoveToElement();
                }

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

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

                if (!Boundary)
                {
                    writer.WriteAttributeString("boundary", "false");
                }
                else
                {
                    if (BoundaryCapType != CapType.Butt)
                    {
                        writer.WriteAttributeString("boundarycaptype", ArcXmlEnumConverter.ToArcXml(typeof(CapType), BoundaryCapType));
                    }

                    if (Color.FromArgb(0, BoundaryColor) != Color.Black)
                    {
                        writer.WriteAttributeString("boundarycolor", ColorConverter.ToArcXml(BoundaryColor));
                    }

                    if (BoundaryColor.A > 0)
                    {
                        writer.WriteAttributeString("boundarytransparency", (BoundaryColor.A / 255.0).ToString("0.000"));
                    }

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

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

                    if (BoundaryWidth > 1)
                    {
                        writer.WriteAttributeString("boundarywidth", BoundaryWidth.ToString());
                    }
                }

                if (Color.FromArgb(0, FillColor) != Color.FromArgb(0, 200, 0))
                {
                    writer.WriteAttributeString("fillcolor", ColorConverter.ToArcXml(FillColor));
                }

                if (FillColor.A > 0)
                {
                    writer.WriteAttributeString("filltransparency", (FillColor.A / 255.0).ToString("0.000"));
                }

                if (FillType != FillType.Solid)
                {
                    writer.WriteAttributeString("filltype", ArcXmlEnumConverter.ToArcXml(typeof(FillType), FillType));
                }

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

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

                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);
                }
            }
        }
Example #6
0
        public static RasterMarkerSymbol ReadFrom(ArcXmlReader reader)
        {
            try
            {
                RasterMarkerSymbol rasterMarkerSymbol = new RasterMarkerSymbol();

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

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

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

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

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

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

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

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

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

                            case "size":
                                string[] d = value.Split(new char[] { ',' });
                                rasterMarkerSymbol.Width  = Convert.ToInt32(d[0]);
                                rasterMarkerSymbol.Height = Convert.ToInt32(d[1]);
                                break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

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

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

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

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

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

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

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

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

                if (UseCentroid)
                {
                    writer.WriteAttributeString("usecentroid", "true");
                }

                if (Width > 0 && Height > 0)
                {
                    writer.WriteAttributeString("size", String.Format("{0},{1}", Width, Height));
                }

                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);
                }
            }
        }