예제 #1
0
        private void DisplayMap_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();

            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp");

            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Draw a feature based on a value and hue family colors.
            Collection <GeoColor> colorsInFamily = GeoColor.GetColorsInHueFamily(GeoColor.StandardColors.Red, 5);
            ValueStyle            valueStyle     = new ValueStyle();

            valueStyle.ColumnName = "CNTRY_NAME";
            valueStyle.ValueItems.Add(new ValueItem("United States", new AreaStyle(new GeoSolidBrush(colorsInFamily[0]))));
            valueStyle.ValueItems.Add(new ValueItem("China", new AreaStyle(new GeoSolidBrush(colorsInFamily[1]))));
            valueStyle.ValueItems.Add(new ValueItem("Brazil", new AreaStyle(new GeoSolidBrush(colorsInFamily[2]))));
            valueStyle.ValueItems.Add(new ValueItem("Australia", new AreaStyle(new GeoSolidBrush(colorsInFamily[3]))));
            valueStyle.ValueItems.Add(new ValueItem("South Africa", new AreaStyle(new GeoSolidBrush(colorsInFamily[4]))));
            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);

            LayerOverlay worldOverlay = new LayerOverlay();

            worldOverlay.Layers.Add("WorldLayer", worldLayer);
            winformsMap1.Overlays.Add(worldOverlay);

            winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2);
            winformsMap1.Refresh();
        }
        public ValueStyleViewModel(ValueStyle style, StyleBuilderArguments requiredValues)
            : base(style)
        {
            HelpKey               = "ValueStyleHelp";
            this.valueItems       = new ObservableCollection <ValueItemEntity>();
            this.ActualObject     = style;
            this.actualValueStyle = style;
            this.requiredValues   = requiredValues;
            this.columnNames      = new Dictionary <string, string>();
            foreach (var columnName in requiredValues.ColumnNames)
            {
                string alias = requiredValues.FeatureLayer.FeatureSource.GetColumnAlias(columnName);
                this.columnNames[columnName] = alias;
            }

            if (string.IsNullOrEmpty(actualValueStyle.ColumnName))
            {
                SelectedColumnName = columnNames.FirstOrDefault();
            }

            InitializeValueItems();

            if (requiredValues.FeatureLayer != null)
            {
                AnalyzeCount(requiredValues.FeatureLayer);
            }
        }
예제 #3
0
        private void Refresh()
        {
            ShapefileLayer areaLayer = Map1.FindLayer <ShapefileLayer>("countries-900913");

            if (areaLayer == null)
            {
                return;
            }
            if (values == null)
            {
                values = areaLayer.Source.GetUniqueFieldValues(columnName).Distinct().ToArray();
            }

            areaLayer.Styles.Clear();
            ValueStyle valueStyle = ValueStyle.Create(columnName, values, DimensionType.Area, colorFamily, new GeoColor(255, 108, 144, 150), 0.01f);

            areaLayer.Styles.Add(valueStyle);

            LegendTitleTextBlock.Text = $"Thematic by \"{columnName}\" column";
            LegendView.Update(valueStyle.ValueItems.OrderBy(i => i.Value).SelectMany(i =>
            {
                foreach (var style in i.Styles)
                {
                    style.Name = $"{columnName} = \"{i.Value}\"";
                }
                return(i.Styles);
            }));
            Map1.Refresh(RefreshType.Redraw);
        }
        private void DrawAFeatureBasedOnAValue_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();

            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp");

            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Draw a feature based on a value
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "CNTRY_NAME";
            valueStyle.ValueItems.Add(new ValueItem("United States", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)))));

            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);

            LayerOverlay worldOverlay = new LayerOverlay();

            worldOverlay.Layers.Add("WorldLayer", worldLayer);
            winformsMap1.Overlays.Add("worldOverlay", worldOverlay);

            winformsMap1.CurrentExtent = new RectangleShape(-165.946875, 86.4359375, -35.86875, -6.3765625);
            winformsMap1.Refresh();
        }
예제 #5
0
 public HudBar(string label, float value, float max, ValueStyle valueStyle, TextStyle textStyle, TipSignal?tooltip = null, float[] thresholds = null) : base(label, tooltip, textStyle)
 {
     _thresholds = thresholds;
     _max        = max;
     _value      = value;
     _valueStyle = valueStyle;
 }
예제 #6
0
파일: AppStatis.cs 프로젝트: pxmarc/dp2
            public double Total         = 0;                   // 累加值

            public string GetValueString(ValueStyle style)
            {
                StringBuilder s = new StringBuilder(4096);

                if ((style & ValueStyle.Total) != 0)
                {
                    s.Append(this.Total.ToString());
                }
                if ((style & ValueStyle.List) != 0)
                {
                    foreach (double v in this.Values)
                    {
                        if (s.Length > 0)
                        {
                            s.Append(",");
                        }
                        if (v != 0)
                        {
                            s.Append(v.ToString());
                        }
                    }
                }

                return(s.ToString());
            }
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            mapView.MapUnit = GeographyUnit.DecimalDegree;
            LayerOverlay layerOverlay = new LayerOverlay();

            shapeFileLayer = new ShapeFileFeatureLayer(SampleHelper.Get("Countries02.shp"));
            shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColors.Black, 1), new GeoSolidBrush(GeoColors.LightSkyBlue));
            shapeFileLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            shapeFileLayer.Open();
            layerOverlay.Layers.Add(shapeFileLayer);

            fourColorLayer = new InMemoryFeatureLayer();
            ValueStyle valueStyle = new ValueStyle {
                ColumnName = "Color"
            };

            valueStyle.ValueItems.Add(new ValueItem("1", AreaStyle.CreateSimpleAreaStyle(GeoColors.LightGreen)));
            valueStyle.ValueItems.Add(new ValueItem("2", AreaStyle.CreateSimpleAreaStyle(GeoColors.LightSkyBlue)));
            valueStyle.ValueItems.Add(new ValueItem("3", AreaStyle.CreateSimpleAreaStyle(GeoColors.Yellow)));
            valueStyle.ValueItems.Add(new ValueItem("4", AreaStyle.CreateSimpleAreaStyle(GeoColors.LightPink)));
            fourColorLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            fourColorLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            layerOverlay.Layers.Add(fourColorLayer);

            mapView.Overlays.Add(layerOverlay);

            mapView.CurrentExtent = new RectangleShape(-174, 117, 180, -120);
            mapView.Refresh();
        }
        private void DrawFeaturesBasedOnValues_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();

            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            ShapeFileFeatureLayer worldCapitalsLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\WorldCapitals.shp");

            worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Draw features based on values
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "POP_RANK";
            valueStyle.ValueItems.Add(new ValueItem("1", PointStyles.Capital1));
            valueStyle.ValueItems.Add(new ValueItem("2", PointStyles.Capital3));
            valueStyle.ValueItems.Add(new ValueItem("3", PointStyles.City7));
            worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);

            LayerOverlay worldOverlay = new LayerOverlay();

            worldOverlay.Layers.Add("WorldCaptials", worldCapitalsLayer);
            winformsMap1.Overlays.Add(worldOverlay);

            winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.Default;
            winformsMap1.CurrentExtent     = new RectangleShape(-143.4, 109.3, 116.7, -76.3);
            winformsMap1.Refresh();
        }
예제 #9
0
        private Style GetRoadStyle()
        {
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "CFCC";
            LineStyle highwayStyle = new LineStyle(new GeoPen(GeoColor.FromHtml("#b8ac9c"), 7), new GeoPen(GeoColor.FromHtml("#f9de4d"), 5));
            ValueItem highwayItem1 = new ValueItem("A11", highwayStyle);
            ValueItem highwayItem2 = new ValueItem("A21", highwayStyle);
            ValueItem highwayItem3 = new ValueItem("A25", highwayStyle);
            ValueItem highwayItem4 = new ValueItem("A31", highwayStyle);
            ValueItem highwayItem5 = new ValueItem("A35", highwayStyle);

            LineStyle localroadStyle = new LineStyle(new GeoPen(GeoColor.FromHtml("#b8ac9c"), 5), new GeoPen(GeoColor.StandardColors.White, 3));
            ValueItem localroadItem1 = new ValueItem("A41", localroadStyle);
            ValueItem localroadItem2 = new ValueItem("A51", localroadStyle);
            ValueItem localroadItem3 = new ValueItem("A63", localroadStyle);
            ValueItem localroadItem4 = new ValueItem("A64", localroadStyle);
            ValueItem localroadItem5 = new ValueItem("A74", localroadStyle);
            ValueItem unknownItem    = new ValueItem("P41", localroadStyle);

            valueStyle.ValueItems.Add(highwayItem1);
            valueStyle.ValueItems.Add(highwayItem2);
            valueStyle.ValueItems.Add(highwayItem3);
            valueStyle.ValueItems.Add(highwayItem4);
            valueStyle.ValueItems.Add(highwayItem5);
            valueStyle.ValueItems.Add(localroadItem1);
            valueStyle.ValueItems.Add(localroadItem2);
            valueStyle.ValueItems.Add(localroadItem3);
            valueStyle.ValueItems.Add(localroadItem4);
            valueStyle.ValueItems.Add(localroadItem5);
            valueStyle.ValueItems.Add(unknownItem);

            return(valueStyle);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayMapView);

            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "CNTRY_NAME";
            valueStyle.ValueItems.Add(new ValueItem("United States", new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGreen))));

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"SampleData/Countries02.shp"));

            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 233, 232, 214), GeoColor.FromArgb(255, 118, 138, 69)));
            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add("TXlkaA20", worldLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-135.7, 83.6, 113.5, -53);
            androidMap.Overlays.Add(layerOverlay);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
예제 #11
0
        public Brush GetColor(ValueStyle v)
        {
            switch (v)
            {
            case ValueStyle.Default: return(Brushes.White);

            case ValueStyle.Augmented: return(UICollor.purple);

            case ValueStyle.Unmet: return(UICollor.red);

            case ValueStyle.PhysicalDamage: return(Brushes.White);

            case ValueStyle.FireDamage: return(UICollor.darkRed);

            case ValueStyle.ColdDamage: return(UICollor.saturatedBlue);

            case ValueStyle.LightningDamage: return(UICollor.yellow);

            case ValueStyle.ChaosDamage: return(UICollor.pink);

            case ValueStyle.MagicItem: return(UICollor.purple);

            case ValueStyle.RareItem: return(UICollor.lightYellow);

            case ValueStyle.UniqueItem: return(UICollor.darkOrange);
            }
            return(null);
        }
예제 #12
0
파일: item.cs 프로젝트: zhangandding/dp2
        // 供GetBackColor(region)、GetTextColor(region)、GetBorderColor(region)调的私有函数
        // parameters:
        //      region        枚举值,取哪个区域
        //      valueStyle    枚举值,取哪种类型的值
        // return:
        //      Color对象
        Color GetColor(ItemRegion region, ValueStyle valueStyle)
        {
            XmlEditor editor = this.m_document;

            if (editor.VisualCfg == null)
            {
                goto END1;
            }

            VisualStyle style = editor.VisualCfg.GetVisualStyle(this, region);

            if (style == null)
            {
                goto END1;
            }

            if (valueStyle == ValueStyle.BackColor)
            {
                return(style.BackColor);
            }
            else if (valueStyle == ValueStyle.TextColor)
            {
                return(style.TextColor);
            }
            else if (valueStyle == ValueStyle.BorderColor)
            {
                return(style.BorderColor);
            }

END1:
            //缺省值
            if (valueStyle == ValueStyle.BackColor)
            {
                if (region == ItemRegion.Text)
                {
                    return(editor.BackColorDefaultForEditable);
                }
                else if (this is AttrItem)
                {
                    return(editor.AttrBackColorDefault);
                }
                else
                {
                    return(editor.BackColorDefault);
                }
            }
            else if (valueStyle == ValueStyle.TextColor)
            {
                return(editor.TextColorDefault);
            }
            else if (valueStyle == ValueStyle.BorderColor)
            {
                return(editor.BorderColorDefault);
            }
            else
            {
                return(Color.Red);
            }
        }
예제 #13
0
파일: HudBar.cs 프로젝트: Jaxe-Dev/RimHUD
 public HudBar(string label, float value, float max, ValueStyle valueStyle, TextStyle textStyle, Func <string> tooltip = null, float[] thresholds = null, Action onClick = null) : base(label, tooltip, textStyle)
 {
     _thresholds = thresholds;
     _max        = max;
     _value      = value;
     _valueStyle = valueStyle;
     _onClick    = onClick;
 }
예제 #14
0
        // 获取数值
        public int GetDigitalValue(ValueStyle valueStyle)
        {
            Item item = this.GetItem();

            if (item == null)
            {
                return(0);
            }

            ItemRegion region = GetRegionName();

            if (region == ItemRegion.No)
            {
                return(0);
            }

            if (valueStyle == ValueStyle.LeftBlank)
            {
                return(item.GetLeftBlank(region));
            }

            if (valueStyle == ValueStyle.RightBlank)
            {
                return(item.GetRightBlank(region));
            }

            if (valueStyle == ValueStyle.TopBlank)
            {
                return(item.GetTopBlank(region));
            }

            if (valueStyle == ValueStyle.BottomBlank)
            {
                return(item.GetBottomBlank(region));
            }

            if (valueStyle == ValueStyle.TopBorderHeight)
            {
                return(item.GetTopBorderHeight(region));
            }

            if (valueStyle == ValueStyle.BottomBorderHeight)
            {
                return(item.GetBottomBorderHeight(region));
            }

            if (valueStyle == ValueStyle.LeftBorderWidth)
            {
                return(item.GetLeftBorderWidth(region));
            }

            if (valueStyle == ValueStyle.RightBorderWidth)
            {
                return(item.GetRightBorderWidth(region));
            }

            return(0);
        }
예제 #15
0
        private void LoadStreetData()
        {
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214));

            ShapeFileFeatureLayer ParksShapeLayer = new ShapeFileFeatureLayer(@"..\..\Data\parks.shp");

            ShapeFileFeatureLayer.BuildIndexFile(@"..\..\Data\parks.shp", BuildIndexMode.DoNotRebuild);

            ParksShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            ParksShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.Park1;

            ShapeFileFeatureLayer ParksLabelLayer = new ShapeFileFeatureLayer(@"..\..\Data\parks.shp");

            ParksLabelLayer.RequireIndex = false;
            ParksLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle    = TextStyles.CreateSimpleTextStyle("Name", "Arial", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.SeaGreen, GeoColor.StandardColors.White, 2);
            ParksLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer StreetsShapeLayer = new ShapeFileFeatureLayer(@"..\..\Data\streets.shp");

            ShapeFileFeatureLayer.BuildIndexFile(@"..\..\Data\streets.shp", BuildIndexMode.DoNotRebuild);

            StreetsShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "Type";
            valueStyle.ValueItems.Add(new ValueItem("A", LineStyles.LocalRoad2));
            valueStyle.ValueItems.Add(new ValueItem("M", LineStyles.MajorRoad1));
            StreetsShapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);

            ShapeFileFeatureLayer StreetsLabelLayer = new ShapeFileFeatureLayer(@"..\..\Data\streets.shp");

            StreetsLabelLayer.RequireIndex = false;
            TextStyle textStyle = new TextStyle();

            textStyle.TextColumnName       = "St_name";
            textStyle.TextSolidBrush       = new GeoSolidBrush(GeoColor.StandardColors.Black);
            textStyle.Font                 = new GeoFont("Arial", 7);
            textStyle.TextLineSegmentRatio = 10;
            textStyle.GridSize             = 100;
            textStyle.SplineType           = SplineType.StandardSplining;
            textStyle.DuplicateRule        = LabelDuplicateRule.OneDuplicateLabelPerQuadrant;
            StreetsLabelLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle);
            StreetsLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.GridSize = 5;
            StreetsLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel       = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();

            staticOverlay.Layers.Add("Parks", ParksShapeLayer);
            staticOverlay.Layers.Add("Streets", StreetsShapeLayer);
            staticOverlay.Layers.Add("Parks Labels", ParksLabelLayer);
            staticOverlay.Layers.Add("Streets Labels", StreetsLabelLayer);

            winformsMap1.Overlays.Add("Street Overlay", staticOverlay);
        }
예제 #16
0
        //In the MouseDoubleClick event, we allow adding a new draggable icon by left double clicking on the map and
        //removing an icon by right double clicking.
        private void winformsMap1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            winformsMap1.EditOverlay.EditShapesLayer.Open();
            PointShape clickedPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height);

            //For removing the icon clicked on.
            if (e.Button == MouseButtons.Right)
            {
                Collection <Feature> clickedFeatures = winformsMap1.EditOverlay.EditShapesLayer.QueryTools.GetFeaturesNearestTo(clickedPointShape, GeographyUnit.DecimalDegree, 1,
                                                                                                                                ReturningColumnsType.AllColumns);
                winformsMap1.EditOverlay.EditShapesLayer.Close();

                if (clickedFeatures.Count > 0)
                {
                    //Gets the dimension of the icon and checks if the clicked point is inside it.
                    ValueStyle valueStyle = (ValueStyle)winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[0];
                    //we loop thru the different ValueItem to get the appropriate icon according to the "Type".
                    GeoImage geoImage = null;
                    string   text     = clickedFeatures[0].ColumnValues["Type"].Trim();
                    foreach (ValueItem valueItem in valueStyle.ValueItems)
                    {
                        if (text == valueItem.Value)
                        {
                            geoImage = (GeoImage)valueStyle.ValueItems[0].DefaultPointStyle.Image;
                            break;
                        }
                    }
                    //We check to see if we clicked inside the icon itself.
                    ScreenPointF screenPointF = ExtentHelper.ToScreenCoordinate(winformsMap1.CurrentExtent, clickedFeatures[0], winformsMap1.Width, winformsMap1.Height);
                    RectangleF   rectangleF   = new RectangleF(screenPointF.X - (geoImage.GetWidth() / 2), screenPointF.Y - (geoImage.GetHeight() / 2),
                                                               geoImage.GetWidth(), geoImage.GetHeight());
                    bool IsInside = rectangleF.Contains(new PointF(e.X, e.Y));

                    //If inside, removes the feature from the EditShapesLayer of the EditOverlay.
                    if (IsInside == true)
                    {
                        winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Remove(clickedFeatures[0]);
                        winformsMap1.Refresh(winformsMap1.EditOverlay);
                    }
                }
            }
            //Adding a new icon.
            else if (e.Button == MouseButtons.Left)
            {
                Feature carFeature = new Feature(clickedPointShape);
                carFeature.ColumnValues["Type"] = "Unknown";
                //We use DateTime.Now.Ticks to be sure to use a unique key each time we add a new feature.
                winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(DateTime.Now.Ticks.ToString(), carFeature);
                //We call CalculateAllControlPoints to update the control points with the new feature to be able to drag the newly added feature.
                winformsMap1.EditOverlay.CalculateAllControlPoints();
                winformsMap1.Refresh(winformsMap1.EditOverlay);
            }
        }
예제 #17
0
        private void AddMapLayer()
        {
            // Create the MapPrinterLayer and set the position
            MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();

            //Map Printer Layer is in feet (State Plane Texas North Central Feet NAD83)
            mapPrinterLayer.MapUnit = GeographyUnit.Feet;
            //Set the extent of the MapPrinterLayer with world coordinates.
            RectangleShape currentExtent = new RectangleShape(2276456, 6897886, 2280391, 6895437);

            mapPrinterLayer.MapExtent      = currentExtent;
            mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1));
            mapPrinterLayer.Open();

            // Set the maps position slightly above the page center and 8 inches wide and 7 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);

            //Setup the styles for the parcels layer.
            ShapeFileFeatureLayer parcelsLayer = new ShapeFileFeatureLayer(@"..\..\..\Data\Shapefile\parcels.shp", FileAccess.Read);
            //Creates a value style for the parcel type (residential 1, commercial 2, industrial 3).
            ValueStyle typeValueStyle = new ValueStyle();

            typeValueStyle.ColumnName = "PARCELTYPE";
            typeValueStyle.ValueItems.Add(new ValueItem("1", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelGreen))));
            typeValueStyle.ValueItems.Add(new ValueItem("2", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelOrange))));
            typeValueStyle.ValueItems.Add(new ValueItem("3", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelBlue))));
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(typeValueStyle);

            //Creates a value style for affected parcels by new proposal
            ValueStyle affectedValueStyle = new ValueStyle();

            affectedValueStyle.ColumnName = "AFFECTED";
            affectedValueStyle.ValueItems.Add(new ValueItem("YES", new AreaStyle(new GeoPen(GeoColors.DarkGreen, 4), new GeoSolidBrush(GeoColors.Transparent))));
            affectedValueStyle.ValueItems.Add(new ValueItem("D", new AreaStyle(new GeoPen(GeoColors.DarkRed, 4), new GeoSolidBrush(GeoColors.Transparent))));
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(affectedValueStyle);

            //Creates a text style to display tax id of parcels
            TextStyle textStyle = new TextStyle("TAXPIN", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Black));

            textStyle.HaloPen = new GeoPen(GeoColors.White, 2);
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle);
            parcelsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Add the new parcels layer to the MapPrinterLayer
            mapPrinterLayer.Layers.Add(parcelsLayer);

            // Add the MapPrinterLayer to the PrinterInteractiveOverlay
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"];

            printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer);
        }
예제 #18
0
 public ValueStyleItem(ValueStyle style)
     : base(style)
 {
     valueStyle = style;
     if (valueStyle != null)
     {
         foreach (var valueItem in valueStyle.ValueItems)
         {
             ValueSubItem valueStyleItem = new ValueSubItem(valueItem, valueStyle.ColumnName);
             Children.Add(valueStyleItem);
         }
     }
 }
예제 #19
0
        private static void SetDrawingLevelForStyle(Style style)
        {
            AreaStyle       areaStyle       = style as AreaStyle;
            LineStyle       lineStyle       = style as LineStyle;
            PointStyle      pointStyle      = style as PointStyle;
            CompositeStyle  compositeStyle  = style as CompositeStyle;
            FilterStyle     filterStyle     = style as FilterStyle;
            ValueStyle      valueStyle      = style as ValueStyle;
            ClassBreakStyle classBreakStyle = style as ClassBreakStyle;

            if (areaStyle != null)
            {
                areaStyle.SetDrawingLevel();
            }
            else if (lineStyle != null)
            {
                lineStyle.SetDrawingLevel();
            }
            else if (pointStyle != null)
            {
                pointStyle.SetDrawingLevel();
            }
            else if (filterStyle != null)
            {
                foreach (var item in filterStyle.Styles)
                {
                    SetDrawingLevelForStyle(item);
                }
            }
            else if (classBreakStyle != null)
            {
                foreach (var item in classBreakStyle.ClassBreaks.SelectMany(v => v.CustomStyles))
                {
                    SetDrawingLevelForStyle(item);
                }
            }
            else if (valueStyle != null)
            {
                foreach (var item in valueStyle.ValueItems.SelectMany(v => v.CustomStyles))
                {
                    SetDrawingLevelForStyle(item);
                }
            }
            else if (compositeStyle != null)
            {
                foreach (var subStyle in compositeStyle.Styles)
                {
                    SetDrawingLevelForStyle(subStyle);
                }
            }
        }
    /// <summary>
    ///
    /// </summary>
    static Rect ValueField(Rect pos, ref int value, string name, System.Action action, float extraSize = 0, System.Action deleteAction = null)
    {
        if (name == null)
        {
            name = "";
        }
        pos.x     -= extraSize;
        pos.width  = ValueStyle.CalcSize(new GUIContent(name)).x + 19 + ((deleteAction == null) ? 0 : (21 - 3)) + extraSize;
        pos.height = 21;

        GUI.color = new Color(0.85f, 0.85f, 0.85f, 1);
        if (value != -1)
        {
            GUI.Label(pos, name, ValueStyle);
        }
        GUI.color = Color.white;

        if (value != -1)
        {
            // draw editbox
            Rect n1 = pos;
            n1.x     += ValueStyle.CalcSize(new GUIContent(name)).x - 30;
            n1.y     += 3;
            n1.width  = 45 + extraSize;
            n1.height = 21;
            int oldValue = value;
            value = Mathf.Max(0, EditorGUI.IntField(n1, value, TextFieldStyle));
            if ((value != oldValue) && (action != null))
            {
                action.Invoke();
            }
        }

        if (deleteAction != null)
        {
            Rect d = pos;
            d.x     = pos.x + pos.width - 21;
            d.width = 21;
            //GUI.Label(d, "", ValueStyle);
            d.y += 3;
            d.x += 3;
            if (GUI.Button(d, "X", SmallButtonStyle) && (deleteAction != null))
            {
                deleteAction.Invoke();
            }
            d.x -= 3;
            d.y -= 3;
        }

        return(pos);
    }
    /// <summary>
    ///
    /// </summary>
    static float CalcValueFieldSize(string name, bool hasDeleteButton = false)
    {
        float f = 0.0f;

        if (!string.IsNullOrEmpty(name))
        {
            f = ValueStyle.CalcSize(new GUIContent(name)).x + 18;
        }
        if (hasDeleteButton)
        {
            f += 21;
        }
        return(f);
    }
        public ValueStyleUserControl(ValueStyle style, StyleBuilderArguments requiredValues)
        {
            InitializeComponent();
            StyleBuilderArguments = requiredValues;
            valueStyle            = style;
            viewModel             = new ValueStyleViewModel(style, requiredValues);
            DataContext           = viewModel;

            string helpUri = GisEditor.LanguageManager.GetStringResource("ValueStyleHelp");

            if (!string.IsNullOrEmpty(helpUri))
            {
                HelpUri = new Uri(helpUri);
            }
        }
예제 #23
0
        // 获取颜色
        public Color GetColor(ValueStyle valueStyle)
        {
            Item       item   = this.GetItem();
            ItemRegion region = GetRegionName();

            if (valueStyle == ValueStyle.BackColor)
            {
                return(item.GetBackColor(region));
            }
            if (valueStyle == ValueStyle.BorderColor)
            {
                return(item.GetBorderColor(region));
            }

            return(Color.Red);             // 代表错误
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            ValueStyle pointStyle = new ValueStyle();

            pointStyle.ColumnName = "IsWayPoint";
            pointStyle.ValueItems.Add(new ValueItem("0", PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.SimpleColors.Red, 4)));
            pointStyle.ValueItems.Add(new ValueItem("1", PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.SimpleColors.Green, 8)));

            LineStyle roadstyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 1, true);

            TextStyle labelStyle = TextStyles.CreateSimpleTextStyle("name", "Arial", 8, DrawingFontStyles.Bold, GeoColor.SimpleColors.Black);

            labelStyle.PointPlacement  = PointPlacement.UpperCenter;
            labelStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;
            labelStyle.YOffsetInPixel  = 8;

            GpxFeatureLayer gpxFeatureLayer = new GpxFeatureLayer(SampleHelper.GetDataPath(@"Gpx/afoxboro.gpx"));

            gpxFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(pointStyle);
            gpxFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(roadstyle);
            gpxFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            gpxFeatureLayer.Open();

            GpxFeatureLayer gpxTextLayer = new GpxFeatureLayer(SampleHelper.GetDataPath(@"Gpx/afoxboro.gpx"));

            gpxTextLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(labelStyle);
            gpxTextLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(gpxFeatureLayer);
            layerOverlay.Layers.Add(gpxTextLayer);

            WorldMapKitOverlay worldMapKitOverlay = new WorldMapKitOverlay();

            androidMap = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.Overlays.Add(worldMapKitOverlay);
            androidMap.Overlays.Add(layerOverlay);
            androidMap.CurrentExtent = gpxFeatureLayer.GetBoundingBox();
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
        private void SetDefaultStyle()
        {
            var defaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(102, 0, 0, 255), 10, GeoColor.FromArgb(100, 0, 0, 255), 2);
            var defaultLineStyle  = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(100, 0, 0, 255), 2, true);
            var defaultAreaStyle  = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(102, GeoColor.FromHtml("#EFFBD6")), GeoColor.FromArgb(255, 0, 0, 255), 2);

            editShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = defaultPointStyle;
            editShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = defaultLineStyle;
            editShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = defaultAreaStyle;
            editShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = existingFeatureColumnName;
            valueStyle.ValueItems.Add(new ValueItem(string.Empty, PointStyles.CreateSimpleSquareStyle(GeoColor.StandardColors.White, 8, GeoColor.StandardColors.Black)));
            valueStyle.ValueItems.Add(new ValueItem(existingFeatureColumnValue, PointStyles.CreateSimpleSquareStyle(GeoColor.StandardColors.Orange, 8, GeoColor.StandardColors.Black)));

            reshapeControlPointsLayer.Open();
            reshapeControlPointsLayer.Columns.Add(new FeatureSourceColumn(existingFeatureColumnName));
            reshapeControlPointsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            reshapeControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            associateControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = new PointStyle(GetGeoImageFromResource("/ThinkGeo.MapSuite.WpfDesktop.Extension;component/Resources/resize.png"));
            associateControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            snappingPointsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new PeakStyle());
            snappingPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            snappingToleranceLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            snappingToleranceLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Black, 1));

            var unselectedPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.LightGray, 10, GeoColor.StandardColors.LightGray, 2);
            var unselectedLineStyle  = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.LightGray, 3, true);
            var unselectedAreaStyle  = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(0, GeoColor.FromHtml("#EFFBD6")), GeoColor.StandardColors.LightGray, 3);

            editCandidatesLayer.Open();
            editCandidatesLayer.Columns.Add(new FeatureSourceColumn(existingFeatureColumnName));
            editCandidatesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(unselectedAreaStyle);
            editCandidatesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(unselectedLineStyle);
            editCandidatesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(unselectedPointStyle);
            editCandidatesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            editCandidatesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        }
예제 #26
0
        private void AddPolygonOverlay(RectangleShape boundingRectangle)
        {
            //We are going to store all of the polygons in an in memory layer
            InMemoryFeatureLayer polygonLayer = new InMemoryFeatureLayer();

            //Here we generate all of our make believe polygons
            Collection <Feature> features = GetGeneratedPolygons(boundingRectangle.GetBoundingBox());

            //Add all of the polygons to the layer
            foreach (var feature in features)
            {
                polygonLayer.InternalFeatures.Add(feature);
            }

            //We are going to style them based on their values we randomly added using the column DataPoint1
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "DataPoint1";

            //Here we add all of the different sub styles so for example "1" is going to be a red semitransparent fill with a black border etc.
            valueStyle.ValueItems.Add(new ValueItem("1", new AreaStyle(new GeoPen(GeoColors.Black, 1f), new GeoSolidBrush(new GeoColor(50, GeoColors.Red)))));
            valueStyle.ValueItems.Add(new ValueItem("2", new AreaStyle(new GeoPen(GeoColors.Black, 1f), new GeoSolidBrush(new GeoColor(50, GeoColors.Blue)))));
            valueStyle.ValueItems.Add(new ValueItem("3", new AreaStyle(new GeoPen(GeoColors.Black, 1f), new GeoSolidBrush(new GeoColor(50, GeoColors.Green)))));
            valueStyle.ValueItems.Add(new ValueItem("4", new AreaStyle(new GeoPen(GeoColors.Black, 1f), new GeoSolidBrush(new GeoColor(50, GeoColors.White)))));

            //We add the style we just created to the custom styles of the first zoom level.  Zoom level on is the highest
            // on as such you can see the whole globe.  Zoom level 20 is the lowest street level.
            polygonLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);

            // He we say that whatever is one zoom level 1 is applied all the way to zoom level 20.  If you only wanted to see this style at lower levels
            // you would make the above line start at ZoomLevel15 say and them apply it to 20.  That way once you zoomed out further than 15 the style would no longer apply.
            polygonLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Create the overlay to house the layer and add it to the map.
            LayerOverlay polygonOverlay = new LayerOverlay();

            // Here we set the overlay to draw as a single tile.  Alternatively we could draw it as multiples tiles all threaded but single tile is a bit faster
            //We like to use multi tile for slow data sources or very complex ones that may take sime to render as you can start to see data as it comes in.
            polygonOverlay.TileType = TileType.SingleTile;

            polygonOverlay.Layers.Add("PolygonLayer", polygonLayer);
            mapView.Overlays.Add("PolygonOverlay", polygonOverlay);
        }
        private static ValueStyle GetIconStyle(string imagePath)
        {
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "TYPE";

            GeoFont       font  = new GeoFont("Arial", 9);
            GeoSolidBrush brush = new GeoSolidBrush(GeoColor.StandardColors.Black);

            valueStyle.ValueItems.Add(new ValueItem("1", new IconStyle(imagePath + "vehicle1.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("2", new IconStyle(imagePath + "vehicle2.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("3", new IconStyle(imagePath + "vehicle3.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("4", new IconStyle(imagePath + "vehicle4.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("5", new IconStyle(imagePath + "vehicle5.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("6", new IconStyle(imagePath + "vehicle6.png", "Type", font, brush)));
            valueStyle.ValueItems.Add(new ValueItem("7", new IconStyle(imagePath + "vehicle7.png", "Type", font, brush)));

            return(valueStyle);
        }
예제 #28
0
파일: item.cs 프로젝트: renyh1013/dp2
		// 供GetBackColor(region)、GetTextColor(region)、GetBorderColor(region)调的私有函数
        // parameters:
		//      region        枚举值,取哪个区域
		//      valueStyle    枚举值,取哪种类型的值
        // return:
        //      Color对象
		Color GetColor(ItemRegion region,ValueStyle valueStyle)
		{
			XmlEditor editor = this.m_document;
			if (editor.VisualCfg == null)
				goto END1;

			VisualStyle style = editor.VisualCfg.GetVisualStyle(this,region);
			if (style == null)
				goto END1;

			if (valueStyle == ValueStyle.BackColor )
				return style.BackColor ;
			else if (valueStyle == ValueStyle.TextColor )
				return style.TextColor ;
			else if (valueStyle == ValueStyle.BorderColor )
				return style.BorderColor  ;
			
			END1:
				//缺省值
				if (valueStyle == ValueStyle.BackColor)
				{
                    if (region == ItemRegion.Text)
                        return editor.BackColorDefaultForEditable;
                    else if (this is AttrItem)
                        return editor.AttrBackColorDefault;
                    else
                        return editor.BackColorDefault;
				}
				else if (valueStyle == ValueStyle.TextColor )
				{
					return editor.TextColorDefault;
				}
				else if (valueStyle == ValueStyle.BorderColor )
				{
					return editor.BorderColorDefault;
				}
				else 
				{
					return Color.Red;
				}
		}
        private void sampleFileListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            GpxFeatureLayer shapeLayer = new GpxFeatureLayer(SampleHelper.Get(sampleFileListBox.SelectedItem.ToString()));

            shapeLayer.FeatureSource.ProjectionConverter = projectionConverter;

            ValueStyle pointStyle = new ValueStyle();

            pointStyle.ColumnName = "IsWayPoint";
            pointStyle.ValueItems.Add(new ValueItem("0", PointStyle.CreateSimplePointStyle(PointSymbolType.Circle, GeoColors.Red, 4)));
            pointStyle.ValueItems.Add(new ValueItem("1", PointStyle.CreateSimplePointStyle(PointSymbolType.Circle, GeoColors.Green, 8)));
            LineStyle roadstyle = LineStyle.CreateSimpleLineStyle(GeoColors.Black, 1, true);

            shapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(pointStyle);
            shapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(roadstyle);
            shapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            GpxFeatureLayer textLayer = new GpxFeatureLayer(SampleHelper.Get(sampleFileListBox.SelectedItem.ToString()));

            textLayer.FeatureSource.ProjectionConverter = projectionConverter;
            TextStyle labelStyle = TextStyle.CreateSimpleTextStyle("name", "Arial", 8, DrawingFontStyles.Bold, GeoColors.Black);

            labelStyle.TextPlacement   = TextPlacement.Upper;
            labelStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;
            labelStyle.YOffsetInPixel  = 8;

            textLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(labelStyle);
            textLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            shapeLayer.Open();
            mapView.CurrentExtent = (shapeLayer.GetBoundingBox());

            var gpsOverlay = (LayerOverlay)mapView.Overlays["GPSOverlay"];

            gpsOverlay.Layers.Clear();
            gpsOverlay.Layers.Add(shapeLayer);
            gpsOverlay.Layers.Add(textLayer);

            mapView.Refresh();
        }
예제 #30
0
        private static ValueStyle GetIconStyle()
        {
            // Get the file path name from its relative path.
            string imagePath = GetFullPath(@"Images/vehicle");

            ValueStyle valueStyle = new ValueStyle()
            {
                ColumnName = "TYPE"
            };

            // Create the icon style for different type of vehicles.
            for (int i = 1; i <= 7; i++)
            {
                IconStyle iconStyle = new IconStyle(string.Format("{0}{1}.png", imagePath, i.ToString(CultureInfo.InvariantCulture), ".png"), "Type", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.StandardColors.Black));
                iconStyle.HaloPen = new GeoPen(GeoColor.SimpleColors.White);
                ValueItem valueItem = new ValueItem(i.ToString(CultureInfo.InvariantCulture), iconStyle);

                valueStyle.ValueItems.Add(valueItem);
            }

            return(valueStyle);
        }
예제 #31
0
        /// <summary>
        /// Adds a ValueStyle to the friscoCrime layer that represents each OffenseGroup as a different color
        /// </summary>
        private void AddValueStyle(ShapeFileFeatureLayer friscoCrime, LegendAdornmentLayer legend)
        {
            // Get all the distinct OffenseGroups in the friscoCrime data
            friscoCrime.Open();
            var offenseGroups = friscoCrime.FeatureSource.GetDistinctColumnValues("OffenseGro");

            friscoCrime.Close();

            // Create a set of colors to represent each OffenseGroup using a spectrum starting from red
            var colors = GeoColor.GetColorsInQualityFamily(GeoColors.Red, offenseGroups.Count);

            // Create a ValueItem styled with a PointStyle to represent each instance of an OffenseGroup
            var valueItems = new Collection <ValueItem>();

            foreach (var offenseGroup in offenseGroups)
            {
                // Create a PointStyle to represent the OffenseGroup by selecting a color using the index of the OffenseGroup
                var style = PointStyle.CreateSimpleCircleStyle(colors[offenseGroups.IndexOf(offenseGroup)], 10,
                                                               GeoColors.Black, 2);

                // Create a ValueItem that will house the pointStyle for the OffenseGroup
                valueItems.Add(new ValueItem(offenseGroup.ColumnValue, style));

                // Add a LegendItem to the legend adornment
                var legendItem = new LegendItem()
                {
                    ImageStyle = style,
                    TextStyle  = new TextStyle(offenseGroup.ColumnValue, new GeoFont("Verdana", 10), GeoBrushes.Black)
                };
                legend.LegendItems.Add(legendItem);
            }

            // Create the ValueStyle that will use the previously created valueItems to style the data using the OffenseGroup column values
            var valueStyle = new ValueStyle("OffenseGro", valueItems);

            // Add the valueStyle to the friscoCrime layer's CustomStyles and apply the style to all ZoomLevels
            friscoCrime.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            friscoCrime.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        }
예제 #32
0
파일: AppStatis.cs 프로젝트: renyh1013/dp2
            public double Total = 0;    // 累加值

            public string GetValueString(ValueStyle style)
            {
                StringBuilder s = new StringBuilder(4096);
                if ((style & ValueStyle.Total) != 0)
                    s.Append(this.Total.ToString());
                if ((style & ValueStyle.List) != 0)
                {
                    foreach (double v in this.Values)
                    {
                        if (s.Length > 0)
                            s.Append(",");
                        if (v != 0)
                            s.Append(v.ToString());
                    }
                }

                return s.ToString();
            }
예제 #33
0
파일: item.cs 프로젝트: renyh1013/dp2
		// 供尺寸值得调的私有函数.
        // parameters:
		//      region      枚举值,取哪个区域
		//      valueStyle  枚举值,取哪种类型的值
		int GetPixelValue(ItemRegion region,ValueStyle valueStyle)
		{
			XmlEditor editor = this.m_document;

			if (editor == null)
				goto END1;

			if (editor.VisualCfg == null)
				goto END1;

			VisualStyle style = editor.VisualCfg.GetVisualStyle(this,region);
			if (style == null)
				goto END1;

			if (valueStyle == ValueStyle.LeftBlank)
				return style.LeftBlank ;
			else if (valueStyle == ValueStyle.RightBlank)
				return style.RightBlank ;
			else if (valueStyle == ValueStyle.TopBlank)
				return style.TopBlank ;
			else if (valueStyle == ValueStyle.BottomBlank)
				return style.BottomBlank ;
			else if (valueStyle == ValueStyle.TopBorderHeight)
				return style.TopBorderHeight;
			else if (valueStyle == ValueStyle.BottomBorderHeight)
				return style.BottomBorderHeight;
			else if (valueStyle == ValueStyle.LeftBorderWidth)
				return style.LeftBorderWidth;
			else if (valueStyle == ValueStyle.RightBorderWidth)
				return style.RightBorderWidth;			
			END1:
				//缺省值
				if (valueStyle == ValueStyle.LeftBlank )
				{
					if (region == ItemRegion.ExpandAttributes 
						|| region == ItemRegion.ExpandContent )
						return 2;  //?
					else
						return 0;
				}
				else if (valueStyle == ValueStyle.RightBlank)
				{
					if (region == ItemRegion.ExpandAttributes 
						|| region == ItemRegion.ExpandContent )
						return 2;  // ?
					else
						return 0;
				}
				else if (valueStyle == ValueStyle.TopBlank)
					return 0;
				else if (valueStyle == ValueStyle.BottomBlank )
					return 0;
				else if (valueStyle == ValueStyle.TopBorderHeight)
				{
					return -1;
				}
				else if (valueStyle == ValueStyle.BottomBorderHeight)
				{
					return -1;
				}
				else if (valueStyle == ValueStyle.LeftBorderWidth)
				{
					return -1;
				}
				else if (valueStyle == ValueStyle.RightBorderWidth)
				{
					return -1;
				}

			return 0;
		}
예제 #34
0
파일: visual.cs 프로젝트: renyh1013/dp2
        // 获取数值
		public int GetDigitalValue(ValueStyle valueStyle)
		{
			Item item = this.GetItem ();
			if (item == null)
				return 0;

			ItemRegion region = GetRegionName();
			if (region == ItemRegion.No )
				return 0;
			
			if (valueStyle == ValueStyle.LeftBlank )
				return item.GetLeftBlank(region);

			if (valueStyle == ValueStyle.RightBlank )
				return item.GetRightBlank (region);

			if (valueStyle == ValueStyle.TopBlank )
				return item.GetTopBlank  (region);

			if (valueStyle == ValueStyle.BottomBlank  )
				return item.GetBottomBlank(region);

			if (valueStyle == ValueStyle.TopBorderHeight)
				return item.GetTopBorderHeight(region);

			if (valueStyle == ValueStyle.BottomBorderHeight)
				return item.GetBottomBorderHeight(region);

			if (valueStyle == ValueStyle.LeftBorderWidth)
				return item.GetLeftBorderWidth(region);

			if (valueStyle == ValueStyle.RightBorderWidth)
				return item.GetRightBorderWidth(region);

			return 0;
		}
예제 #35
0
파일: visual.cs 프로젝트: renyh1013/dp2
        // 获取颜色
		public Color GetColor(ValueStyle valueStyle)
		{
			Item item = this.GetItem ();
			ItemRegion region = GetRegionName();
			
			if (valueStyle == ValueStyle.BackColor  )
				return item.GetBackColor(region);
			if (valueStyle == ValueStyle.BorderColor )
				return item.GetBorderColor (region);

			return Color.Red;  // 代表错误
		}
예제 #36
0
파일: AppStatis.cs 프로젝트: renyh1013/dp2
        // 将一个DOM中的全部值合并到hashtable中
        // parameters:
        //      nDays   本次合并前,已经累加了多少天的数据
        static int MergeValues(
            string strLibraryCodeList,
            Hashtable table,
            XmlDocument dom,
            long nDays,
            ValueStyle valuestyle,
            out string strError)
        {
            strError = "";

            if (dom == null)
            {
                if ((valuestyle & ValueStyle.List) == 0)
                    return 0;

                // 为每个列表增加一个0
                foreach (string path in table.Keys)
                {
                    OneItem info = (OneItem)table[path];
                    info.Values.Add(0);
                }

                return 0;
            }

            List<string> touched_keys = new List<string>();


            // 根下的全部<category>
            int nRet = MergeValues(
                table,
                dom.DocumentElement,
                nDays,
                valuestyle,
                ref touched_keys,
                out strError);
            if (nRet == -1)
                return -1;

            // <library>元素下的<category>
            XmlNodeList nodes = dom.DocumentElement.SelectNodes("library");
            foreach (XmlNode node in nodes)
            {
                string strCode = DomUtil.GetAttr(node, "code");
                if (SessionInfo.IsGlobalUser(strLibraryCodeList) == false
                    && StringUtil.IsInList(strCode, strLibraryCodeList) == false)
                    continue;

                nRet = MergeValues(
                    table,
                    node,
                    nDays,
                    valuestyle,
                    ref touched_keys,
                    out strError);
                if (nRet == -1)
                    return -1;
            }

            if ((valuestyle & ValueStyle.List) != 0)
            {
                // 2012/11/5
                // 为没有处理到的列表增加一个0
                foreach (string path in table.Keys)
                {
                    int index = touched_keys.IndexOf(path);
                    if (index != -1)
                    {
                        touched_keys.RemoveAt(index);   // 逐渐缩小数组,有利于加快速度
                        continue;
                    }
                    OneItem info = (OneItem)table[path];
                    info.Values.Add(0);
                }
            }

            return 0;
        }
예제 #37
0
파일: AppStatis.cs 프로젝트: renyh1013/dp2
        // 把Hashtable中的值写入XML文件中
        static int WriteToXmlFile(
            Hashtable table,
            string strOutputFilename,
            ValueStyle style,
            out string strError)
        {
            strError = "";

            XmlDocument dom = new XmlDocument();
            dom.LoadXml("<root />");

            foreach (string path in table.Keys)
            {
                string[] parts = path.Split(new char[] {'/'});
                if (parts.Length != 3)
                {
                    strError = "hashtable中路径 '"+parts+"' 格式错误。应为三段形态";
                    return -1;
                }
                /*
                // 2015/4/3
                if (parts.Length < 3)
                {
                    strError = "hashtable中路径 '" + path + "' 格式错误。应为至少三段形态";
                    return -1;
                }
                 * */

                string strCode = parts[0];
                string strCategoryName = parts[1];
                string strItemName = parts[2];

                XmlNode nodeLibrary = null;
                if (string.IsNullOrEmpty(strCode) == true)
                    nodeLibrary = dom.DocumentElement;
                else
                {
                    nodeLibrary = dom.DocumentElement.SelectSingleNode("library[@code='" + strCode + "']");
                    if (nodeLibrary == null)
                    {
                        nodeLibrary = dom.CreateElement("library");
                        dom.DocumentElement.AppendChild(nodeLibrary);
                        DomUtil.SetAttr(nodeLibrary, "code", strCode);
                    }
                }

                XmlNode nodeCategory = nodeLibrary.SelectSingleNode("category[@name='" + strCategoryName + "']");
                if (nodeCategory == null)
                {
                    nodeCategory = dom.CreateElement("category");
                    nodeLibrary.AppendChild(nodeCategory);
                    DomUtil.SetAttr(nodeCategory, "name", strCategoryName);
                }

                XmlNode nodeItem = nodeCategory.SelectSingleNode("item[@name='" + strItemName + "']");
                if (nodeItem == null)
                {
                    nodeItem = dom.CreateElement("item");
                    nodeCategory.AppendChild(nodeItem);
                    DomUtil.SetAttr(nodeItem, "name", strItemName);
                }

                OneItem info = (OneItem)table[path];

                DomUtil.SetAttr(nodeItem, "value", info.GetValueString(style));
            }

            dom.Save(strOutputFilename);
            return 0;
        }
예제 #38
0
파일: AppStatis.cs 프로젝트: renyh1013/dp2
        static int MergeValues(
            Hashtable table,
            XmlNode root,
            long nDays,
            ValueStyle valuestyle,
            ref List<string> touched_keys,
            out string strError)
        {
            strError = "";

            string strCode = DomUtil.GetAttr(root, "code");

            XmlNodeList nodes = root.SelectNodes("category");
            foreach (XmlNode node in nodes)
            {
                string strCategoryName = DomUtil.GetAttr(node, "name");
                XmlNodeList items = node.SelectNodes("item");
                foreach (XmlNode item in items)
                {
                    string strItemName = DomUtil.GetAttr(item, "name");

                    string strPath = strCode.Replace("/", "\\") + "/" + strCategoryName.Replace("/", "\\") + "/" + strItemName.Replace("/", "\\");  // 2015/4/3 替换了字符
                    touched_keys.Add(strPath);

                    OneItem info = (OneItem)table[strPath];
                    if (info == null)
                    {
                        info = new OneItem();
                        info.Path = strPath;
                        table[strPath] = info;

                        // 补齐以前欠缺的list值
                        if ((valuestyle & ValueStyle.List) != 0)
                        {
                            for (long i = 0; i < nDays; i++)
                            {
                                info.Values.Add(0);
                            }
                        }
                    }

                    string strItemValue = DomUtil.GetAttr(item, "value");
                    double v = 0;

                    if (double.TryParse(strItemValue, out v) == false)
                    {
                        strError = "XML片断 '"+item.OuterXml+"' 中value属性值 '"+strItemValue+"' 格式错误";
                        return -1;
                    }

                    info.Total += v;

                    if ((valuestyle & ValueStyle.List) != 0)
                        info.Values.Add(v);
                }
            }
            return 0;
        }