예제 #1
0
        private void SetPointStyle(GeometryStyle style, XmlElement PointSymbolizer, XmlNamespaceManager nsm)
        {
            string stroke           = string.Empty;
            string strokeWidth      = string.Empty;
            string strokeOpacity    = string.Empty;
            string strokeLinejoin   = string.Empty;
            string strokeLineCap    = string.Empty;
            string strokeDasharray  = string.Empty;
            string strokeDashOffset = string.Empty;
            string fill             = string.Empty;
            string fillOpacity      = string.Empty;
            string pointSymbolPath  = string.Empty;


            XmlNodeList pointSymbols = PointSymbolizer.SelectNodes(
                "sld:Graphic/sld:ExternalGraphic/sld:OnlineResource", nsm);

            foreach (XmlElement pointSymbol in pointSymbols)
            {
                if (pointSymbol != null)
                {
                    pointSymbolPath = pointSymbol.GetAttribute("xlink:href");
                }
            }
            SetStyle(style, stroke, strokeWidth, strokeOpacity, strokeLinejoin, strokeLineCap, strokeDasharray,
                     strokeDashOffset, fill, fillOpacity, pointSymbolPath);
        }
예제 #2
0
        /// <summary>
        /// returns  a Random VectorStyle with no symbols.
        /// 
        /// </summary>
        /// <returns></returns>
        public static GeometryStyle RandomGeometryStyle()
        {
            GeometryStyle vs = new GeometryStyle();

            vs.EnableOutline = random.Next(0, 2) == 1;

            vs.Fill = RandomBrush();
            vs.Line = RandomPen();
            vs.Outline = RandomPen();
            vs.Symbol = RandomSymbol();
            vs.Outline.Width += vs.Line.Width;

            vs.HighlightFill = RandomBrush();
            vs.HighlightLine = RandomPen();
            vs.HighlightOutline = RandomPen();
            vs.HighlightSymbol = RandomSymbol();


            vs.SelectFill = RandomBrush();
            vs.SelectLine = RandomPen();
            vs.SelectOutline = RandomPen();
            vs.SelectSymbol = RandomSymbol();


            return vs;
        }
예제 #3
0
        private static GeometryStyle generateStyle(String layer)
        {
            GeometryStyle style = new GeometryStyle();

            style.Enabled = true;

            switch (layer)
            {
            case "Marshland":
            case "Robot Tracks":
            case "Roads":
            case "Fires":
            case "Treasures":
            case "Nice Views":
            case "Fault Lines":
            case "Contamination":
            case "Notices":
            case "Radioactive Fuel Rods":
            case "Bases":
            case "Houses":
            case "Measures":
            case "Contacts":
            case "Prospects":
            default:
                style.Fill             = new SolidStyleBrush(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value);
                style.HighlightFill    = new SolidStyleBrush(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value);
                style.SelectFill       = new SolidStyleBrush(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value);
                style.Outline          = new StylePen(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value, _rnd.NextDouble() * 6);
                style.HighlightOutline = new StylePen(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value, _rnd.NextDouble() * 6);
                style.SelectOutline    = new StylePen(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value, _rnd.NextDouble() * 6);
                break;
            }

            return(style);
        }
예제 #4
0
        /// <summary>
        /// returns  a Random VectorStyle with no symbols.
        ///
        /// </summary>
        /// <returns></returns>
        public static GeometryStyle RandomGeometryStyle()
        {
            GeometryStyle vs = new GeometryStyle();

            vs.EnableOutline = random.Next(0, 2) == 1;

            vs.Fill           = RandomBrush();
            vs.Line           = RandomPen();
            vs.Outline        = RandomPen();
            vs.Symbol         = RandomSymbol();
            vs.Outline.Width += vs.Line.Width;

            vs.HighlightFill    = RandomBrush();
            vs.HighlightLine    = RandomPen();
            vs.HighlightOutline = RandomPen();
            vs.HighlightSymbol  = RandomSymbol();


            vs.SelectFill    = RandomBrush();
            vs.SelectLine    = RandomPen();
            vs.SelectOutline = RandomPen();
            vs.SelectSymbol  = RandomSymbol();


            return(vs);
        }
예제 #5
0
        public IDictionary <string, GeometryStyle> ParseFeatureStyle(XmlDocument doc)
        {
            Dictionary <string, GeometryStyle> styles = new Dictionary <string, GeometryStyle>();

            // Load SLD file
            NameTable           nt  = new NameTable();
            XmlNamespaceManager nsm = new XmlNamespaceManager(nt);

            nsm.AddNamespace("sld", "http://www.opengis.net/sld");
            nsm.AddNamespace("ogc", "http://www.opengis.net/ogc");
            nsm.AddNamespace("xlink", "http://www.w3.org/1999/xlink");


            XmlDocument sldConfig = new XmlDocument(nt);

            sldConfig.LoadXml(doc.OuterXml);


            XmlNodeList featureTypeStyleEls = sldConfig.SelectNodes("//sld:FeatureTypeStyle", nsm);


            foreach (XmlElement featTypeStyle in featureTypeStyleEls)
            {
                XmlElement  el       = (XmlElement)featTypeStyle.SelectSingleNode("sld:FeatureTypeName", nsm);
                string      mainName = el != null ? el.InnerText : "";
                XmlNodeList rules    = featTypeStyle.SelectNodes("sld:Rule", nsm);

                foreach (XmlElement rule in rules)
                {
                    el = (XmlElement)rule.SelectSingleNode("sld:Name", nsm);
                    string        name  = el != null ? el.InnerText : "";
                    GeometryStyle style = new GeometryStyle();
                    SetSymbologyForRule(style, rule, nsm);
                    styles.Add(mainName + ":" + name, style);
                }
            }

            return(styles);


            //style.AreFeaturesSelectable
            //style.Enabled
            //style.EnableOutline
            //style.Fill
            //style.HighlightFill
            //style.HighlightLine
            //style.HighlightOutline
            //style.HighlightSymbol
            //style.Line
            //style.MaxVisible
            //style.MinVisible
            //style.Outline
            //style.RenderingMode
            //style.SelectFill
            //style.SelectLine
            //style.SelectOutline
            //style.SelectSymbol
        }
예제 #6
0
        private void SetStrokeStyle(GeometryStyle style, XmlElement StrokeSymbolizer, XmlNamespaceManager nsm)
        {
            string stroke           = string.Empty;
            string strokeWidth      = string.Empty;
            string strokeOpacity    = string.Empty;
            string strokeLinejoin   = string.Empty;
            string strokeLineCap    = string.Empty;
            string strokeDasharray  = string.Empty;
            string strokeDashOffset = string.Empty;
            string fill             = string.Empty;
            string fillOpacity      = string.Empty;
            string pointSymbolPath  = string.Empty;

            XmlNodeList polygonStrokeSymbols = StrokeSymbolizer.SelectNodes("sld:Stroke/sld:CssParameter", nsm);

            foreach (XmlElement polygonStrokeSymbol in polygonStrokeSymbols)
            {
                if (polygonStrokeSymbol != null)
                {
                    switch (polygonStrokeSymbol.GetAttribute("name"))
                    {
                    // line
                    case "stroke":
                        stroke = polygonStrokeSymbol.InnerXml;
                        break;

                    case "stroke-width":
                        strokeWidth = polygonStrokeSymbol.InnerXml;
                        break;

                    case "stroke-opacity":
                        strokeOpacity = polygonStrokeSymbol.InnerXml;
                        break;

                    case "stroke-linejoin":     //“mitre”, “round”, and “bevel”
                        strokeLinejoin = polygonStrokeSymbol.InnerXml;
                        break;

                    case "stroke-linecap":     //“butt”, “round”, and “square”.
                        strokeLineCap = polygonStrokeSymbol.InnerXml;
                        break;

                    case "stroke-dasharray":
                        strokeDasharray = polygonStrokeSymbol.InnerXml;
                        break;

                    case "stroke-dashoffset":
                        strokeDashOffset = polygonStrokeSymbol.InnerXml;
                        break;
                    }
                }
            }

            SetStyle(style, stroke, strokeWidth, strokeOpacity, strokeLinejoin, strokeLineCap, strokeDasharray,
                     strokeDashOffset, fill, fillOpacity, pointSymbolPath);
        }
예제 #7
0
        private IStyle calculateVectorStyle(IStyle min, IStyle max, Double value)
        {
            if (!(min is GeometryStyle && max is GeometryStyle))
            {
                throw new ArgumentException(
                          "Both min style and max style must be vector styles to compute a gradient vector style");
            }

            GeometryStyle style     = new GeometryStyle();
            GeometryStyle vectorMin = min as GeometryStyle;
            GeometryStyle vectorMax = max as GeometryStyle;

            Double dFrac = fraction(value);
            Single fFrac = Convert.ToSingle(dFrac);

            style.Enabled       = (dFrac > 0.5 ? min.Enabled : max.Enabled);
            style.EnableOutline = (dFrac > 0.5 ? vectorMin.EnableOutline : vectorMax.EnableOutline);

            if (_fillColorBlend != null)
            {
                style.Fill = new SolidStyleBrush(_fillColorBlend.GetColor(fFrac));
            }
            else if (vectorMin.Fill != null && vectorMax.Fill != null)
            {
                style.Fill = interpolateBrush(vectorMin.Fill, vectorMax.Fill, value);
            }

            if (vectorMin.Line != null && vectorMax.Line != null)
            {
                style.Line = interpolatePen(vectorMin.Line, vectorMax.Line, value);
            }

            if (_lineColorBlend != null)
            {
                style.Line.BackgroundBrush = new SolidStyleBrush(_lineColorBlend.GetColor(fFrac));
            }

            if (vectorMin.Outline != null && vectorMax.Outline != null)
            {
                style.Outline = interpolatePen(vectorMin.Outline, vectorMax.Outline, value);
            }

            style.MinVisible      = interpolateDouble(min.MinVisible, max.MinVisible, value);
            style.MaxVisible      = interpolateDouble(min.MaxVisible, max.MaxVisible, value);
            style.Symbol          = (dFrac > 0.5 ? vectorMin.Symbol : vectorMax.Symbol);
            style.HighlightSymbol = (dFrac > 0.5 ? vectorMin.HighlightSymbol : vectorMax.HighlightSymbol);
            //We don't interpolate the offset but let it follow the symbol instead
            style.SelectSymbol = (dFrac > 0.5 ? vectorMin.SelectSymbol : vectorMax.SelectSymbol);
            return(style);
        }
        private IEnumerable <TRenderObject> enumerateGeoCollection(
            IGeometryCollection collection, GeometryStyle style, RenderState renderState)
        {
            foreach (IGeometry geometry in collection)
            {
                IEnumerable <TRenderObject> rendering
                    = renderGeometry(geometry, style, renderState);

                foreach (TRenderObject renderObject in rendering)
                {
                    yield return(renderObject);
                }
            }
        }
예제 #9
0
        private void SetStrokeStyle(GeometryStyle style, XmlElement StrokeSymbolizer, XmlNamespaceManager nsm)
        {
            string stroke = string.Empty;
            string strokeWidth = string.Empty;
            string strokeOpacity = string.Empty;
            string strokeLinejoin = string.Empty;
            string strokeLineCap = string.Empty;
            string strokeDasharray = string.Empty;
            string strokeDashOffset = string.Empty;
            string fill = string.Empty;
            string fillOpacity = string.Empty;
            string pointSymbolPath = string.Empty;

            XmlNodeList polygonStrokeSymbols = StrokeSymbolizer.SelectNodes("sld:Stroke/sld:CssParameter", nsm);

            foreach (XmlElement polygonStrokeSymbol in polygonStrokeSymbols)
            {
                if (polygonStrokeSymbol != null)
                {
                    switch (polygonStrokeSymbol.GetAttribute("name"))
                    {
                            // line 
                        case "stroke":
                            stroke = polygonStrokeSymbol.InnerXml;
                            break;
                        case "stroke-width":
                            strokeWidth = polygonStrokeSymbol.InnerXml;
                            break;
                        case "stroke-opacity":
                            strokeOpacity = polygonStrokeSymbol.InnerXml;
                            break;
                        case "stroke-linejoin": //“mitre”, “round”, and “bevel”
                            strokeLinejoin = polygonStrokeSymbol.InnerXml;
                            break;
                        case "stroke-linecap": //“butt”, “round”, and “square”.
                            strokeLineCap = polygonStrokeSymbol.InnerXml;
                            break;
                        case "stroke-dasharray":
                            strokeDasharray = polygonStrokeSymbol.InnerXml;
                            break;
                        case "stroke-dashoffset":
                            strokeDashOffset = polygonStrokeSymbol.InnerXml;
                            break;
                    }
                }
            }

            SetStyle(style, stroke, strokeWidth, strokeOpacity, strokeLinejoin, strokeLineCap, strokeDasharray,
                     strokeDashOffset, fill, fillOpacity, pointSymbolPath);
        }
예제 #10
0
        /// <summary>
        ///  Creates a new instance of the PointSymbolControl.
        /// </summary>
        public SymbolControl()
        {
            InitializeComponent();
            ItemCount  = 17;
            CellWidth  = 24;
            CellHeight = 24;

            for (int i = 0; i < ItemCount; i++)
            {
                var sdo = new GeometryStyle();
                sdo.Marker.SetVectorMarker((VectorMarker)i);
                sdo.Marker.Size = 0.8f * CellWidth;
                sdo.Fill.Color  = Color.Orange;
                _icons.Add(sdo);
            }
            OnDrawItem += PointSymbolControl_OnDrawItem;
        }
예제 #11
0
        private void SetFillStyle(GeometryStyle style, XmlElement fillSymbolizer, XmlNamespaceManager nsm)
        {
            string stroke           = string.Empty;
            string strokeWidth      = string.Empty;
            string strokeOpacity    = string.Empty;
            string strokeLinejoin   = string.Empty;
            string strokeLineCap    = string.Empty;
            string strokeDasharray  = string.Empty;
            string strokeDashOffset = string.Empty;
            string fill             = string.Empty;
            string fillOpacity      = string.Empty;
            string pointSymbolPath  = string.Empty;

            XmlNodeList polygonFillSymbols = fillSymbolizer.SelectNodes("sld:Fill/sld:CssParameter", nsm);

            foreach (XmlElement polygonFillSymbol in polygonFillSymbols)
            {
                if (polygonFillSymbol != null)
                {
                    switch (polygonFillSymbol.GetAttribute("name"))
                    {
                    //polygon
                    case "fill":
                        fill = polygonFillSymbol.InnerXml;
                        break;

                    case "fill-opacity":
                        fillOpacity = polygonFillSymbol.InnerXml;
                        break;
                    }
                }
            }

            SetStyle(style, stroke, strokeWidth, strokeOpacity, strokeLinejoin, strokeLineCap, strokeDasharray,
                     strokeDashOffset, fill, fillOpacity, pointSymbolPath);


            //Call down to stroke style
            SetStrokeStyle(style, fillSymbolizer, nsm);
        }
예제 #12
0
        private void SetSymbologyForRule(GeometryStyle style, XmlElement rule, XmlNamespaceManager nsm)
        {
            XmlNodeList polygonSymbolizers = rule.SelectNodes("sld:PolygonSymbolizer", nsm);
            XmlNodeList lineSymbolizers    = rule.SelectNodes("sld:LineSymbolizer", nsm);
            XmlNodeList pointSymbolizers   = rule.SelectNodes("sld:PointSymbolizer", nsm);

            if (polygonSymbolizers != null)
            {
                if (polygonSymbolizers.Count > 0)
                {
                    foreach (XmlElement polygonSymbolizer in polygonSymbolizers)
                    {
                        SetFillStyle(style, polygonSymbolizer, nsm);
                    }
                }
            }

            if (lineSymbolizers != null)
            {
                if (lineSymbolizers.Count > 0)
                {
                    foreach (XmlElement lineSymbolizer in lineSymbolizers)
                    {
                        SetStrokeStyle(style, lineSymbolizer, nsm);
                    }
                }
            }

            if (pointSymbolizers != null)
            {
                if (pointSymbolizers.Count > 0)
                {
                    foreach (XmlElement pointSymbolizer in pointSymbolizers)
                    {
                        SetPointStyle(style, pointSymbolizer, nsm);
                    }
                }
            }
        }
예제 #13
0
        private void SetFillStyle(GeometryStyle style, XmlElement fillSymbolizer, XmlNamespaceManager nsm)
        {
            string stroke = string.Empty;
            string strokeWidth = string.Empty;
            string strokeOpacity = string.Empty;
            string strokeLinejoin = string.Empty;
            string strokeLineCap = string.Empty;
            string strokeDasharray = string.Empty;
            string strokeDashOffset = string.Empty;
            string fill = string.Empty;
            string fillOpacity = string.Empty;
            string pointSymbolPath = string.Empty;

            XmlNodeList polygonFillSymbols = fillSymbolizer.SelectNodes("sld:Fill/sld:CssParameter", nsm);

            foreach (XmlElement polygonFillSymbol in polygonFillSymbols)
            {
                if (polygonFillSymbol != null)
                {
                    switch (polygonFillSymbol.GetAttribute("name"))
                    {
                            //polygon
                        case "fill":
                            fill = polygonFillSymbol.InnerXml;
                            break;
                        case "fill-opacity":
                            fillOpacity = polygonFillSymbol.InnerXml;
                            break;
                    }
                }
            }

            SetStyle(style, stroke, strokeWidth, strokeOpacity, strokeLinejoin, strokeLineCap, strokeDasharray,
                     strokeDashOffset, fill, fillOpacity, pointSymbolPath);


            //Call down to stroke style
            SetStrokeStyle(style, fillSymbolizer, nsm);
        }
예제 #14
0
        private void styles_ListChanged(object sender, ListChangedEventArgs e)
        {
            if (e.ListChangedType == ListChangedType.ItemAdded)
            {
                string        name  = "";
                GeometryStyle style = null;

                object o = styles[e.NewIndex];
                if (o is KeyValuePair <string, GeometryStyle> )
                {
                    KeyValuePair <string, GeometryStyle> kvp = (KeyValuePair <string, GeometryStyle>)o;
                    name  = kvp.Key;
                    style = kvp.Value;
                }


                stylesTree1.AddStyleNode(e.NewIndex, name, style);
            }
            else if (e.ListChangedType == ListChangedType.ItemDeleted)
            {
                stylesTree1.Nodes.RemoveAt(e.OldIndex);
            }
        }
        private static GeometryStyle generateStyle(String layer)
        {
            GeometryStyle style = new GeometryStyle();
            style.Enabled = true;

            switch (layer)
            {
                case "Marshland":
                case "Robot Tracks":
                case "Roads":
                case "Fires":
                case "Treasures":
                case "Nice Views":
                case "Fault Lines":
                case "Contamination":
                case "Notices":
                case "Radioactive Fuel Rods":
                case "Bases":
                case "Houses":
                case "Measures":
                case "Contacts":
                case "Prospects":
                default:
                    style.Fill = new SolidStyleBrush(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value);
                    style.HighlightFill = new SolidStyleBrush(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value);
                    style.SelectFill = new SolidStyleBrush(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value);
                    style.Outline = new StylePen(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value, _rnd.NextDouble() * 6);
                    style.HighlightOutline = new StylePen(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value, _rnd.NextDouble() * 6);
                    style.SelectOutline = new StylePen(getColorEntry(_rnd.Next(0, _colorTable.Count)).Value, _rnd.NextDouble() * 6);
                    break;
            }

            return style;
        }
        private IEnumerable <TRenderObject> renderGeometry(
            IGeometry geometry, GeometryStyle style, RenderState renderState)
        {
            if (geometry is IPolygon)
            {
                return(DrawPolygon(geometry as IPolygon,
                                   style.Fill, style.HighlightFill, style.SelectFill,
                                   style.Outline, style.HighlightOutline, style.SelectOutline,
                                   renderState));
            }

            if (geometry is IMultiPolygon)
            {
                return(DrawMultiPolygon(geometry as IMultiPolygon,
                                        style.Fill, style.HighlightFill, style.SelectFill,
                                        style.Outline, style.HighlightOutline, style.SelectOutline,
                                        renderState));
            }

            if (geometry is ILineString)
            {
                return(DrawLineString(geometry as ILineString,
                                      style.Line, style.HighlightLine, style.SelectLine,
                                      style.Outline, style.HighlightOutline, style.SelectOutline,
                                      renderState));
            }

            if (geometry is IMultiLineString)
            {
                return(DrawMultiLineString(geometry as IMultiLineString,
                                           style.Line, style.HighlightLine, style.SelectLine,
                                           style.Outline, style.HighlightOutline, style.SelectOutline,
                                           renderState));
            }

            if (geometry is IPoint)
            {
                return(DrawPoint(geometry as IPoint,
                                 style.Symbol, style.HighlightSymbol, style.SelectSymbol,
                                 renderState));
            }

            if (geometry is IMultiPoint)
            {
                return(DrawMultiPoint(geometry as IMultiPoint,
                                      style.Symbol, style.HighlightSymbol, style.SelectSymbol,
                                      renderState));
            }

            if (geometry is IGeometryCollection)
            {
                //List<TRenderObject> renderObjects = new List<TRenderObject>();

                //foreach (IGeometry g in (geometry as IGeometryCollection))
                //{
                //    renderObjects.AddRange(renderGeometry(g, style, renderState));
                //}

                //return renderObjects;

                return(enumerateGeoCollection(geometry as IGeometryCollection, style, renderState));
            }

            throw new NotSupportedException(
                      String.Format("IGeometry type is not supported: {0}", geometry.GetType()));
        }
예제 #17
0
        /// <summary>
        /// Fills the image list with icons according to the selected colors
        /// </summary>
        protected override void RefreshImageList()
        {
            if (_style == ImageComboStyle.Common)
            {
                return;
            }

            _list.Images.Clear();

            int width = _style == ImageComboStyle.PointShape ? 20 : 64;

            Size sz = new Size(width, 16);

            _list.ImageSize = sz;

            int imgHeight = _list.ImageSize.Height;
            int imgWidth  = _list.ImageSize.Width;

            var rect = new Rectangle(PADDING_X, PADDING_Y, imgWidth - 1 - PADDING_X * 2, imgHeight - 1 - PADDING_Y * 2);

            var foreColor = Enabled ? Color.Black : Color.Gray;

            for (int i = 0; i < _itemCount; i++)
            {
                var img = new Bitmap(imgWidth, imgHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                var g   = Graphics.FromImage(img);

                switch (_style)
                {
                // frame type combo
                case ImageComboStyle.FrameType:
                {
                    if (i == 0)
                    {
                        g.FillRectangle(new SolidBrush(_color1), rect);
                        g.DrawRectangle(new Pen(foreColor), rect);
                    }
                    else if (i == 1)
                    {
                        g.FillEllipse(new SolidBrush(_color1), rect);
                        g.DrawEllipse(new Pen(foreColor), rect);
                    }
                    else if (i == 2)
                    {
                        float left   = rect.X;
                        float right  = rect.X + rect.Width;
                        float top    = rect.Y;
                        float bottom = rect.Y + rect.Height;

                        GraphicsPath path = new GraphicsPath();
                        path.StartFigure();
                        path.AddLine(left + (rect.Height / 4), top, right - (rect.Height / 4), top);

                        path.AddLine(right - (rect.Height / 4), top, right, (top + bottom) / 2);
                        path.AddLine(right, (top + bottom) / 2, right - (rect.Height / 4), bottom);

                        path.AddLine(right - (rect.Height / 4), bottom, left + (rect.Height / 4), bottom);

                        path.AddLine(left + (rect.Height / 4), bottom, left, (top + bottom) / 2);
                        path.AddLine(left, (top + bottom) / 2, left + (rect.Height / 4), top);

                        path.CloseFigure();
                        g.FillPath(new SolidBrush(_color1), path);
                        g.DrawPath(new Pen(foreColor), path);
                        path.Dispose();
                    }
                    break;
                }

                // linear gradient combo
                case ImageComboStyle.LinearGradient:
                {
                    if ((LinearGradient)i == LinearGradient.None)
                    {
                        g.FillRectangle(new SolidBrush(_color1), rect);
                        g.DrawRectangle(new Pen(_outlineColor), rect);
                    }
                    else
                    {
                        LinearGradientBrush lgb = new LinearGradientBrush(rect, _color1, _color2, (LinearGradientMode)i);
                        g.FillRectangle(lgb, rect);
                        g.DrawRectangle(new Pen(_outlineColor), rect);
                        lgb.Dispose();
                    }
                    break;
                }

                //  line style combo
                case ImageComboStyle.LineStyle:
                {
                    var pen = new Pen(_outlineColor)
                    {
                        DashStyle = (DashStyle)i, Width = 2
                    };
                    g.DrawLine(pen, new Point(rect.Left, rect.Top + rect.Height / 2),
                               new Point(rect.Right, rect.Top + rect.Height / 2));
                    break;
                }

                //  line width combo
                case ImageComboStyle.LineWidth:
                {
                    var pen = new Pen(_outlineColor)
                    {
                        Width = i + 1
                    };
                    g.DrawLine(pen, new Point(rect.Left, rect.Top + rect.Height / 2),
                               new Point(rect.Right, rect.Top + rect.Height / 2));
                    break;
                }

                case ImageComboStyle.PointShape:
                {
                    IGeometryStyle sdo = new GeometryStyle();
                    sdo.Fill.Color = _color1;
                    sdo.Line.Color = _outlineColor;

                    var marker = sdo.Marker;
                    marker.VectorMarker = (VectorMarkerType)i;
                    marker.Type         = MarkerType.Vector;
                    marker.Size         = 12;
                    if (marker.VectorMarker == VectorMarkerType.Star)
                    {
                        marker.VectorSideCount = 5;
                        marker.Rotation        = 17;
                        marker.Size            = 14;
                    }
                    else if (marker.VectorMarker == VectorMarkerType.Arrow)
                    {
                        marker.Size     = 14;
                        marker.Rotation = 0;
                    }
                    else
                    {
                        marker.VectorSideCount = 4;
                        marker.Rotation        = 0;
                        marker.Size            = 12;
                    }

                    sdo.DrawPoint(g, 0.0f, 0.0f, imgWidth, imgHeight, BackColor);
                    break;
                }

                case ImageComboStyle.HatchStyle:
                {
                    HatchBrush br = new HatchBrush((HatchStyle)i, _color1, Color.Transparent);
                    g.FillRectangle(br, rect);
                    g.DrawRectangle(new Pen(_outlineColor), rect);
                    br.Dispose();
                    break;
                }

                case ImageComboStyle.HatchStyleWithNone:
                {
                    if (i == 0)
                    {
                        g.FillRectangle(new SolidBrush(_color1), rect);
                        g.DrawRectangle(new Pen(_outlineColor), rect);
                    }
                    else
                    {
                        HatchBrush br = new HatchBrush((HatchStyle)(i - 1), _color1, Color.Transparent);
                        g.FillRectangle(br, rect);
                        g.DrawRectangle(new Pen(_outlineColor), rect);
                        br.Dispose();
                    }
                    break;
                }

                default: return;
                }

                _list.Images.Add(img);
            }
        }
예제 #18
0
 public void AddStyleNode(int index, string name, GeometryStyle style)
 {
     Nodes.Insert(index, new GeometryStyleNode(style, name));
 }
		private void AppendPoints(GeometryStyle style, List<PointF> points)
		{
			if (_points.ContainsKey(style) == false)
				_points[style] = new List<PointF>();

			_points[style].AddRange(points);
		}
예제 #20
0
 public void AddStyleNode(int index, string name, GeometryStyle style)
 {
     Nodes.Insert(index, new GeometryStyleNode(style, name));
 }
		private void AppendStrokePath(GeometryStyle style, GraphicsPath stroke)
		{
			if (_strokes.ContainsKey(style) == false)
				_strokes[style] = new List<GraphicsPath>();

			_strokes[style].Add(stroke);
		}
		private void AppendFilledPath(GeometryStyle style, GraphicsPath path)
		{
			if (_fills.ContainsKey(style) == false)
				_fills[style] = new List<GraphicsPath>();

			_fills[style].Add(path);
		}
        /// <summary>
        /// Renders the geometry of the <paramref name="feature"/>.
        /// </summary>
        /// <param name="feature">The feature to render.</param>
        /// <param name="style">The style to use to render the feature.</param>
        /// <returns>An enumeration of positioned render objects suitable for display.</returns>
        protected override IEnumerable <TRenderObject> DoRenderFeature(IFeatureDataRecord feature, GeometryStyle style, RenderState renderState, ILayer layer)
        {
            if (feature == null)
            {
                throw new ArgumentNullException("feature");
            }
            if (style == null)
            {
                throw new ArgumentNullException("style");
            }

            if (feature.Geometry == null)
            {
                throw new InvalidOperationException("Feature must have a geometry to be rendered.");
            }

            return(renderGeometry(feature.Geometry, style, renderState));
        }
예제 #24
0
 /// <summary>
 /// Initializes a new layer with the given name, style and datasource.
 /// </summary>
 /// <param name="layername">Name of the layer.</param>
 /// <param name="style">Style to apply to the layer.</param>
 /// <param name="dataSource">Data source.</param>
 public GeometryLayer(String layername, GeometryStyle style, IFeatureProvider dataSource)
     : base(layername, style, dataSource) { }
예제 #25
0
        private IStyle calculateVectorStyle(IStyle min, IStyle max, Double value)
        {
            if (!(min is GeometryStyle && max is GeometryStyle))
            {
                throw new ArgumentException(
                    "Both min style and max style must be vector styles to compute a gradient vector style");
            }

            GeometryStyle style = new GeometryStyle();
            GeometryStyle vectorMin = min as GeometryStyle;
            GeometryStyle vectorMax = max as GeometryStyle;

            Double dFrac = fraction(value);
            Single fFrac = Convert.ToSingle(dFrac);
            style.Enabled = (dFrac > 0.5 ? min.Enabled : max.Enabled);
            style.EnableOutline = (dFrac > 0.5 ? vectorMin.EnableOutline : vectorMax.EnableOutline);

            if (_fillColorBlend != null)
            {
                style.Fill = new SolidStyleBrush(_fillColorBlend.GetColor(fFrac));
            }
            else if (vectorMin.Fill != null && vectorMax.Fill != null)
            {
                style.Fill = interpolateBrush(vectorMin.Fill, vectorMax.Fill, value);
            }

            if (vectorMin.Line != null && vectorMax.Line != null)
            {
                style.Line = interpolatePen(vectorMin.Line, vectorMax.Line, value);
            }

            if (_lineColorBlend != null)
            {
                style.Line.BackgroundBrush = new SolidStyleBrush(_lineColorBlend.GetColor(fFrac));
            }

            if (vectorMin.Outline != null && vectorMax.Outline != null)
            {
                style.Outline = interpolatePen(vectorMin.Outline, vectorMax.Outline, value);
            }

            style.MinVisible = interpolateDouble(min.MinVisible, max.MinVisible, value);
            style.MaxVisible = interpolateDouble(min.MaxVisible, max.MaxVisible, value);
            style.Symbol = (dFrac > 0.5 ? vectorMin.Symbol : vectorMax.Symbol);
            style.HighlightSymbol = (dFrac > 0.5 ? vectorMin.HighlightSymbol : vectorMax.HighlightSymbol);
            //We don't interpolate the offset but let it follow the symbol instead
            style.SelectSymbol = (dFrac > 0.5 ? vectorMin.SelectSymbol : vectorMax.SelectSymbol);
            return style;
        }
예제 #26
0
        private void SetSymbologyForRule(GeometryStyle style, XmlElement rule, XmlNamespaceManager nsm)
        {
            XmlNodeList polygonSymbolizers = rule.SelectNodes("sld:PolygonSymbolizer", nsm);
            XmlNodeList lineSymbolizers = rule.SelectNodes("sld:LineSymbolizer", nsm);
            XmlNodeList pointSymbolizers = rule.SelectNodes("sld:PointSymbolizer", nsm);

            if (polygonSymbolizers != null)
                if (polygonSymbolizers.Count > 0)
                {
                    foreach (XmlElement polygonSymbolizer in polygonSymbolizers)
                    {
                        SetFillStyle(style, polygonSymbolizer, nsm);
                    }
                }

            if (lineSymbolizers != null)
                if (lineSymbolizers.Count > 0)
                {
                    foreach (XmlElement lineSymbolizer in lineSymbolizers)
                    {
                        SetStrokeStyle(style, lineSymbolizer, nsm);
                    }
                }

            if (pointSymbolizers != null)
                if (pointSymbolizers.Count > 0)
                {
                    foreach (XmlElement pointSymbolizer in pointSymbolizers)
                    {
                        SetPointStyle(style, pointSymbolizer, nsm);
                    }
                }
        }
예제 #27
0
        public static Geometry FromFileSystemEntry(FileSystemEntry entry)
        {
            var geometry = new Geometry();

            using (var stream = entry.Open())
                using (var reader = new StreamReader(stream))
                {
                    string        line;
                    int           image       = 0;
                    float         thickness   = 0;
                    Matrix2x2     rotMat      = new Matrix2x2();
                    Vector2       translation = new Vector2();
                    ColorRgba     color       = new ColorRgba(0, 0, 0, 0);
                    GeometryStyle style       = GeometryStyle.Undefined;
                    var           tris        = new List <Triangle2D>();
                    var           lines       = new List <Line2D>();

                    Action ApplyStyle = () =>
                    {
                        switch (style)
                        {
                        //no data parsed yet
                        case GeometryStyle.Undefined:
                            break;

                        case GeometryStyle.TexturedTri:
                            geometry.Entries.Add(new GeometryTexturedTriangles(new List <Triangle2D>(tris), color, image, rotMat, translation));
                            tris.Clear();
                            break;

                        case GeometryStyle.SolidTri:
                            geometry.Entries.Add(new GeometrySolidTriangles(new List <Triangle2D>(tris), color));
                            tris.Clear();
                            break;

                        case GeometryStyle.Line:
                            geometry.Entries.Add(new GeometryLines(new List <Line2D>(lines), color, thickness));
                            lines.Clear();
                            break;
                        }

                        style = GeometryStyle.Undefined;
                    };

                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.Trim();

                        var lineMode = line.First();
                        line = line.TrimStart('c', 's', 'l', 't');
                        var paramList = line.Split(':');

                        //trim each entry of the param list
                        for (var i = 0; i < paramList.Length; ++i)
                        {
                            paramList[i] = paramList[i].Trim();
                        }

                        switch (lineMode)
                        {
                        //Clear - Finish the last geometry
                        case 'c':
                            ApplyStyle();
                            break;

                        //Style - Header for the following data
                        case 's':
                            //Check that we have atleast 1 param
                            if (paramList.Length < 1)
                            {
                                throw new InvalidDataException();
                            }

                            //Check which style we are using
                            switch (paramList.First())
                            {
                            //this is the solid triangle style
                            case "s":
                                if (paramList.Length != 5)
                                {
                                    throw new InvalidDataException();
                                }

                                style   = GeometryStyle.SolidTri;
                                color.R = Convert.ToByte(paramList[1]);
                                color.G = Convert.ToByte(paramList[2]);
                                color.B = Convert.ToByte(paramList[3]);
                                color.A = Convert.ToByte(paramList[4]);
                                break;

                            //this is the line style
                            case "l":
                                if (paramList.Length != 6)
                                {
                                    throw new InvalidDataException();
                                }

                                style     = GeometryStyle.Line;
                                thickness = ParseUtility.ParseFloat(paramList[1]);
                                color.R   = Convert.ToByte(paramList[2]);
                                color.G   = Convert.ToByte(paramList[3]);
                                color.B   = Convert.ToByte(paramList[4]);
                                color.A   = Convert.ToByte(paramList[5]);
                                break;

                            //this is the textured triangle style
                            case "tc":
                                if (paramList.Length != 12)
                                {
                                    throw new InvalidDataException();
                                }

                                style   = GeometryStyle.TexturedTri;
                                color.R = Convert.ToByte(paramList[1]);
                                color.G = Convert.ToByte(paramList[2]);
                                color.B = Convert.ToByte(paramList[3]);
                                color.A = Convert.ToByte(paramList[4]);
                                //image id used
                                image = Convert.ToInt32(paramList[5]);
                                //transformation parameters, to map the geometry above the texture
                                rotMat.M11    = ParseUtility.ParseFloat(paramList[6]);
                                rotMat.M12    = ParseUtility.ParseFloat(paramList[7]);
                                rotMat.M21    = ParseUtility.ParseFloat(paramList[8]);
                                rotMat.M22    = ParseUtility.ParseFloat(paramList[9]);
                                translation.X = ParseUtility.ParseFloat(paramList[10]);
                                translation.Y = ParseUtility.ParseFloat(paramList[11]);
                                break;
                            }
                            break;

                        //A line
                        case 'l':
                            Line2D lin;
                            lin.V0 = new Vector2(ParseUtility.ParseFloat(paramList[0]), ParseUtility.ParseFloat(paramList[1]));
                            lin.V1 = new Vector2(ParseUtility.ParseFloat(paramList[2]), ParseUtility.ParseFloat(paramList[3]));
                            lines.Add(lin);
                            break;

                        //A triangle
                        case 't':
                            Triangle2D tri;
                            tri.V0 = new Vector2(ParseUtility.ParseFloat(paramList[0]), ParseUtility.ParseFloat(paramList[1]));
                            tri.V1 = new Vector2(ParseUtility.ParseFloat(paramList[2]), ParseUtility.ParseFloat(paramList[3]));
                            tri.V2 = new Vector2(ParseUtility.ParseFloat(paramList[4]), ParseUtility.ParseFloat(paramList[5]));
                            tris.Add(tri);
                            break;
                        }
                    }

                    ApplyStyle();
                }

            geometry.CalculateBoundings();
            return(geometry);
        }
예제 #28
0
        private void SetStyle(
            GeometryStyle style,
            string stroke,
            string strokeWidth,
            string strokeOpacity,
            string strokeLinejoin,
            string strokeLineCap,
            string strokeDasharray,
            string strokeDashOffset,
            string fill,
            string fillOpacity,
            string pointSymbolPath
            )
        {
            if (!String.IsNullOrEmpty(stroke))
            {
                Color  color   = ColorTranslator.FromHtml(stroke);
                int    opacity = 255;
                double width   = 1;

                if (!String.IsNullOrEmpty(strokeOpacity))
                {
                    opacity = Convert.ToInt32(Math.Round(Convert.ToDouble(strokeOpacity) / 0.0039215, 0));
                    if (opacity > 255)
                    {
                        opacity = 255;
                    }
                }

                if (!String.IsNullOrEmpty(strokeWidth))
                {
                    width = Convert.ToDouble(strokeWidth);
                }

                StyleBrush brush =
                    new SolidStyleBrush(new StyleColor(Convert.ToInt32(color.B), Convert.ToInt32(color.G),
                                                       Convert.ToInt32(color.R), opacity));
                StylePen pen = new StylePen(brush, width);

                if (!String.IsNullOrEmpty(strokeLinejoin))
                {
                    switch (strokeLinejoin.ToLower())
                    {
                    case "mitre":
                        pen.LineJoin = StyleLineJoin.Miter;
                        break;

                    case "round":
                        pen.LineJoin = StyleLineJoin.Round;
                        break;

                    case "bevel":
                        pen.LineJoin = StyleLineJoin.Bevel;
                        break;

                        //case "miterclipped": // Not in SLD
                        //    pen.LineJoin = StyleLineJoin.MiterClipped;
                        //    break;
                    }
                }

                if (!String.IsNullOrEmpty(strokeLineCap))
                {
                    switch (strokeLineCap.ToLower())
                    {
                    case "butt":
                        pen.StartCap = StyleLineCap.Flat;
                        pen.EndCap   = StyleLineCap.Flat;
                        break;

                    case "round":
                        pen.StartCap = StyleLineCap.Round;
                        pen.EndCap   = StyleLineCap.Round;
                        break;

                    case "square":
                        pen.StartCap = StyleLineCap.Square;
                        pen.EndCap   = StyleLineCap.Square;
                        break;

                        // N.B. Loads of others not used in SLD
                    }
                }

                if (!String.IsNullOrEmpty(strokeDasharray))
                {
                    string[] Numbers = strokeDasharray.Split(Char.Parse(" "));

                    IEnumerable <float> dbls = Processor.Select(Numbers, delegate(string o) { return(float.Parse(o)); });
                    pen.DashPattern = Enumerable.ToArray(dbls);
                }

                if (!String.IsNullOrEmpty(strokeDashOffset))
                {
                    float dashOffset;
                    bool  success;
                    success = float.TryParse(strokeDashOffset, out dashOffset);
                    if (success)
                    {
                        pen.DashOffset = dashOffset;
                    }
                }

                // Set pen
                style.Line = pen;
            }

            if (!String.IsNullOrEmpty(fill))
            {
                Color color   = ColorTranslator.FromHtml(fill);
                int   opacity = 255;

                if (!String.IsNullOrEmpty(fillOpacity))
                {
                    opacity = Convert.ToInt32(Math.Round(Convert.ToDouble(fillOpacity) / 0.0039215, 0));
                    if (opacity > 255)
                    {
                        opacity = 255;
                    }
                }

                StyleBrush brush =
                    new SolidStyleBrush(new StyleColor(Convert.ToInt32(color.B), Convert.ToInt32(color.G),
                                                       Convert.ToInt32(color.R), opacity));

                style.Fill = brush;
            }


            if (!String.IsNullOrEmpty(pointSymbolPath))
            {
                Uri source = new Uri(pointSymbolPath);

                if (source.IsFile && File.Exists(source.AbsolutePath))
                {
                    Bitmap b = new Bitmap(source.AbsolutePath);

                    MemoryStream ms = new MemoryStream();
                    b.Save(ms, ImageFormat.Png);
                    ms.Seek(0, SeekOrigin.Begin);

                    style.Symbol = new Symbol2D(ms, new Size2D(12, 10));
                }
                else if (source.IsAbsoluteUri)
                {
                    ///TODO
                }
            }

            style.Enabled       = true;
            style.EnableOutline = true;
        }
 /// <summary>
 /// Creates a new BasicGeometryRenderer2D with the given VectorRenderer2D instance.
 /// </summary>
 /// <param name="vectorRenderer">
 /// A vector renderer.
 /// </param>
 /// <param name="defaultStyle">
 /// The default style to apply to a feature's geometry.
 /// </param>
 public BasicGeometryRenderer2D(VectorRenderer2D <TRenderObject> vectorRenderer, GeometryStyle defaultStyle)
     : base(vectorRenderer)
 {
     DefaultStyle = defaultStyle;
 }
예제 #30
0
        private void SetPointStyle(GeometryStyle style, XmlElement PointSymbolizer, XmlNamespaceManager nsm)
        {
            string stroke = string.Empty;
            string strokeWidth = string.Empty;
            string strokeOpacity = string.Empty;
            string strokeLinejoin = string.Empty;
            string strokeLineCap = string.Empty;
            string strokeDasharray = string.Empty;
            string strokeDashOffset = string.Empty;
            string fill = string.Empty;
            string fillOpacity = string.Empty;
            string pointSymbolPath = string.Empty;


            XmlNodeList pointSymbols = PointSymbolizer.SelectNodes(
                "sld:Graphic/sld:ExternalGraphic/sld:OnlineResource", nsm);

            foreach (XmlElement pointSymbol in pointSymbols)
            {
                if (pointSymbol != null)
                {
                    pointSymbolPath = pointSymbol.GetAttribute("xlink:href");
                }
            }
            SetStyle(style, stroke, strokeWidth, strokeOpacity, strokeLinejoin, strokeLineCap, strokeDasharray,
                     strokeDashOffset, fill, fillOpacity, pointSymbolPath);
        }
		private Pen FromGeomStyleToPen(GeometryStyle geometryStyle)
		{
			System.Windows.Media.Color c = geometryStyle.StrokeColor;
			Pen v_pen = new Pen(Color.FromArgb(c.A, c.R, c.G, c.B), geometryStyle.StrokeWidth);
			v_pen.LineJoin = LineJoin.Round;
			return v_pen;
		}
예제 #32
0
        public IDictionary<string, GeometryStyle> ParseFeatureStyle(XmlDocument doc)
        {
            Dictionary<string, GeometryStyle> styles = new Dictionary<string, GeometryStyle>();

            // Load SLD file
            NameTable nt = new NameTable();
            XmlNamespaceManager nsm = new XmlNamespaceManager(nt);
            nsm.AddNamespace("sld", "http://www.opengis.net/sld");
            nsm.AddNamespace("ogc", "http://www.opengis.net/ogc");
            nsm.AddNamespace("xlink", "http://www.w3.org/1999/xlink");


            XmlDocument sldConfig = new XmlDocument(nt);
            sldConfig.LoadXml(doc.OuterXml);


            XmlNodeList featureTypeStyleEls = sldConfig.SelectNodes("//sld:FeatureTypeStyle", nsm);


            foreach (XmlElement featTypeStyle in featureTypeStyleEls)
            {
                XmlElement el = (XmlElement) featTypeStyle.SelectSingleNode("sld:FeatureTypeName", nsm);
                string mainName = el != null ? el.InnerText : "";
                XmlNodeList rules = featTypeStyle.SelectNodes("sld:Rule", nsm);

                foreach (XmlElement rule in rules)
                {
                    el = (XmlElement) rule.SelectSingleNode("sld:Name", nsm);
                    string name = el != null ? el.InnerText : "";
                    GeometryStyle style = new GeometryStyle();
                    SetSymbologyForRule(style, rule, nsm);
                    styles.Add(mainName + ":" + name, style);
                }
            }

            return styles;


            //style.AreFeaturesSelectable
            //style.Enabled
            //style.EnableOutline
            //style.Fill
            //style.HighlightFill
            //style.HighlightLine
            //style.HighlightOutline
            //style.HighlightSymbol
            //style.Line
            //style.MaxVisible
            //style.MinVisible
            //style.Outline
            //style.RenderingMode
            //style.SelectFill
            //style.SelectLine
            //style.SelectOutline
            //style.SelectSymbol
        }
		private Brush FromGeomStyleToBrush(GeometryStyle geometryStyle)
		{
			System.Windows.Media.Color c = geometryStyle.FillColor;
			return new SolidBrush(Color.FromArgb(c.A, c.R, c.G, c.B));
		}
예제 #34
0
        private void SetStyle(
            GeometryStyle style,
            string stroke,
            string strokeWidth,
            string strokeOpacity,
            string strokeLinejoin,
            string strokeLineCap,
            string strokeDasharray,
            string strokeDashOffset,
            string fill,
            string fillOpacity,
            string pointSymbolPath
            )
        {
            if (!String.IsNullOrEmpty(stroke))
            {
                Color color = ColorTranslator.FromHtml(stroke);
                int opacity = 255;
                double width = 1;

                if (!String.IsNullOrEmpty(strokeOpacity))
                {
                    opacity = Convert.ToInt32(Math.Round(Convert.ToDouble(strokeOpacity)/0.0039215, 0));
                    if (opacity > 255)
                        opacity = 255;
                }

                if (!String.IsNullOrEmpty(strokeWidth))
                {
                    width = Convert.ToDouble(strokeWidth);
                }

                StyleBrush brush =
                    new SolidStyleBrush(new StyleColor(Convert.ToInt32(color.B), Convert.ToInt32(color.G),
                                                       Convert.ToInt32(color.R), opacity));
                StylePen pen = new StylePen(brush, width);

                if (!String.IsNullOrEmpty(strokeLinejoin))
                {
                    switch (strokeLinejoin.ToLower())
                    {
                        case "mitre":
                            pen.LineJoin = StyleLineJoin.Miter;
                            break;
                        case "round":
                            pen.LineJoin = StyleLineJoin.Round;
                            break;
                        case "bevel":
                            pen.LineJoin = StyleLineJoin.Bevel;
                            break;

                            //case "miterclipped": // Not in SLD
                            //    pen.LineJoin = StyleLineJoin.MiterClipped;
                            //    break;
                    }
                }

                if (!String.IsNullOrEmpty(strokeLineCap))
                {
                    switch (strokeLineCap.ToLower())
                    {
                        case "butt":
                            pen.StartCap = StyleLineCap.Flat;
                            pen.EndCap = StyleLineCap.Flat;
                            break;
                        case "round":
                            pen.StartCap = StyleLineCap.Round;
                            pen.EndCap = StyleLineCap.Round;
                            break;
                        case "square":
                            pen.StartCap = StyleLineCap.Square;
                            pen.EndCap = StyleLineCap.Square;
                            break;

                            // N.B. Loads of others not used in SLD
                    }
                }

                if (!String.IsNullOrEmpty(strokeDasharray))
                {
                    string[] Numbers = strokeDasharray.Split(Char.Parse(" "));

                    IEnumerable<float> dbls = Processor.Select(Numbers, delegate(string o) { return float.Parse(o); });
                    pen.DashPattern = Enumerable.ToArray(dbls);
                }

                if (!String.IsNullOrEmpty(strokeDashOffset))
                {
                    float dashOffset;
                    bool success;
                    success = float.TryParse(strokeDashOffset, out dashOffset);
                    if (success)
                        pen.DashOffset = dashOffset;
                }

                // Set pen
                style.Line = pen;
            }

            if (!String.IsNullOrEmpty(fill))
            {
                Color color = ColorTranslator.FromHtml(fill);
                int opacity = 255;

                if (!String.IsNullOrEmpty(fillOpacity))
                {
                    opacity = Convert.ToInt32(Math.Round(Convert.ToDouble(fillOpacity)/0.0039215, 0));
                    if (opacity > 255)
                        opacity = 255;
                }

                StyleBrush brush =
                    new SolidStyleBrush(new StyleColor(Convert.ToInt32(color.B), Convert.ToInt32(color.G),
                                                       Convert.ToInt32(color.R), opacity));

                style.Fill = brush;
            }


            if (!String.IsNullOrEmpty(pointSymbolPath))
            {
                Uri source = new Uri(pointSymbolPath);

                if (source.IsFile && File.Exists(source.AbsolutePath))
                {
                    Bitmap b = new Bitmap(source.AbsolutePath);

                    MemoryStream ms = new MemoryStream();
                    b.Save(ms, ImageFormat.Png);
                    ms.Seek(0, SeekOrigin.Begin);

                    style.Symbol = new Symbol2D(ms, new Size2D(12, 10));
                }
                else if (source.IsAbsoluteUri)
                {
                    ///TODO
                }
            }

            style.Enabled = true;
            style.EnableOutline = true;
        }
		private Bitmap FromGeomStyleToPoint(Bitmap sourceBitmap, GeometryStyle geometryStyle)
		{
			return TintBitmap(sourceBitmap, geometryStyle.FillColor.ToGDI(), 1f);
		}
예제 #36
0
 public GeometryRowStyle(GeometryStyle style, GeometryType type)
 {
     Style = style;
     Type  = type;
 }
예제 #37
0
 /// <summary>
 /// Initializes a new layer with the given name, style and datasource.
 /// </summary>
 /// <param name="layername">Name of the layer.</param>
 /// <param name="style">Style to apply to the layer.</param>
 /// <param name="dataSource">Data source.</param>
 public GeometryLayer(String layername, GeometryStyle style, IFeatureProvider dataSource)
     : base(layername, style, dataSource)
 {
 }