コード例 #1
0
 public StackedLabelProvider(IProvider provider, LabelStyle labelStyle, Pen rectangleLine = null,
     Brush rectangleFill = null)
 {
     _provider = provider;
     _labelStyle = labelStyle;
     _rectangleLine = rectangleLine ?? new Pen(Color.Gray);
     _rectangleFill = rectangleFill;
 }
コード例 #2
0
 public static Pen Copy(this Pen pen)
 {
     if (pen == null)
     {
         return(null);
     }
     return(new Pen {
         Width = pen.Width,
         Color = pen.Color.Copy(),
         PenStyle = pen.PenStyle,
         DashArray = pen.DashArray,
         PenStrokeCap = pen.PenStrokeCap,
         StrokeJoin = pen.StrokeJoin,
         StrokeMiterLimit = pen.StrokeMiterLimit
     });
 }
コード例 #3
0
ファイル: Pen.cs プロジェクト: HackatonArGP/Guardianes
        public bool Equals(Pen pen)
        {
            if (Width != pen.Width)
            {
                return false;
            }

            if ((Color == null) ^ (pen.Color == null)) //if one or the other is null then they are not equal, but not when they are both null
            {
                return false;
            }

            if (Color != null && !Color.Equals(pen.Color))
            {
                return false;
            }

            return true;
        }
コード例 #4
0
        private VectorStyle GetVectorStyle(LandStatus status, bool isOwnLand, bool demandAuthorities, bool ischecked, bool isGreenpeaceUser, bool islockedOnly, bool denouncedByMe)
        {
            Brush fill = null;
            Pen outline = null;

            switch (status)
            {
                case LandStatus.NotChecked:  //STATUS 2 SIN CHEQUEAR
                    fill = new Brush { Color = Color.FromArgb(255, 255, 255, 255) };
                    outline = new Pen { Color = Color.Black, Width = 1 };
                    break;
                case LandStatus.Ok: //STATUS 3 SIN DESMONTES
                    fill = new Brush { Color = Color.FromArgb(143, 121, 136, 35) };
                    outline = new Pen { Color = Color.FromArgb(255, 169, 183, 41), Width = 4 };
                    break;
                case LandStatus.Alert:  //STATUS 4 CON DESMONTES
                     fill = new Brush { Color = Color.FromArgb(143, 255, 236, 0) };
                outline = new Pen { Color = Color.FromArgb(255, 255, 242, 0), Width = 4 };
                    
                    break;
                default: //DEFAULT, IDEM SIN CHEQUEAR
                    fill = new Brush { Color = Color.FromArgb(255, 255, 255, 255) };
                    outline = new Pen { Color = Color.Black, Width = 1 };
                    break;
            }

            if (ischecked && (status == LandStatus.Alert || status == LandStatus.Ok)) //VERIFICADA POR MI DESMONTADA O SIN DESMONTE
            {
                outline = new Pen { Color = Color.FromArgb(0, 0, 0, 0), Width = 1 };
            }

            if (isOwnLand && (status != LandStatus.Alert && status != LandStatus.Ok))  //MI PROPIA LAND
            {
                outline = new Pen { Color = Color.White, Width = 4 };
            }

            if (demandAuthorities)  //LISTA PARA DEMANDAR
            {
                 fill = new Brush { Color = Color.FromArgb(143, 167, 11, 10) };
                 outline = new Pen { Color = Color.FromArgb(255, 217, 7, 7), Width = 4 };

                if (denouncedByMe)
                {
                    outline = new Pen { Color = Color.FromArgb(0, 0, 0, 0), Width = 1 };

                }
            }

            if (!demandAuthorities && islockedOnly)
            {
                outline = new Pen { Color = Color.FromArgb(0, 0, 0, 0), Width = 1 };
            }

            var vStyle = new VectorStyle
            {
                Fill = fill,
                Outline = outline,
            };

            if (opacity == 0)
            {
                vStyle.SetOpacity(0);
            }
            else
            {
                if (Current.Instance.MapControl.Viewport.Resolution > 2.4 || Current.Instance.MapControl.Viewport.Resolution == 0)
                {
                        vStyle.SetOpacity(opacity);
                }
                else
                {
                    vStyle.SetOpacity(0);
                }
            } 

            return vStyle;
        }
コード例 #5
0
        private VectorStyle GetVectorStyle(LandStatus status, bool isOwnLand)
        {
            Brush fill;
            Pen outline;

            switch (status)
            {
                case LandStatus.NotChecked:
                    fill = new Brush { Color = Color.White };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
                case LandStatus.Ok:
                    fill = new Brush { Color = Color.Green };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
                case LandStatus.Alert:
                    fill = new Brush { Color = Color.Red };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
                default:
                    fill = new Brush { Color = Color.Orange };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
            }

            if (isOwnLand)
            {
                outline = new Pen { Color = Color.Orange, Width = 4 };
            }

            var vStyle = new VectorStyle
            {
                Fill = fill,
                Outline = outline,
            };
            vStyle.SetOpacity(opacity);
            return vStyle;
        }
コード例 #6
0
        private static List<Feature> GetFeaturesInView(double resolution, LabelStyle labelStyle,
            IEnumerable<IFeature> features, Pen line, Brush fill)
        {
            var margin = resolution*50;
            var clusters = new List<Cluster>();
            // todo: repeat until there are no more merges
            ClusterFeatures(clusters, features, margin, labelStyle, resolution);

            const int textHeight = 18;

            var results = new List<Feature>();

            foreach (var cluster in clusters)
            {
                if (cluster.Features.Count > 1) results.Add(CreateBoxFeature(resolution, cluster, line, fill));

                var offsetY = double.NaN;

                var orderedFeatures = cluster.Features.OrderBy(f => f.Geometry.GetBoundingBox().GetCentroid().Y);

                foreach (var pointFeature in orderedFeatures)
                {
                    var position = CalculatePosition(cluster);

                    offsetY = CalculateOffsetY(offsetY, textHeight);

                    var labelText = labelStyle.GetLabelText(pointFeature);
                    var labelFeature = CreateLabelFeature(position, labelStyle, offsetY, labelText);

                    results.Add(labelFeature);
                }
            }
            return results;
        }
コード例 #7
0
 private static Feature CreateBoxFeature(double resolution, Cluster cluster, Pen line, 
     Brush fill)
 {
     return new Feature
     {
         Geometry = ToPolygon(GrowBox(cluster.Box, resolution)),
         Styles = new[]
         {
             new VectorStyle
             {
                 Outline = line,
                 Fill = fill
             }
         }
     };
 }