Esempio n. 1
0
    public void SetWarningRegion(Vector3 beginPoint, Vector3 endPoint, float duration)
    {
        WarningRegion region = Instantiate(warningRegion);

        region.BeginPoint = beginPoint;
        region.EndPoint   = endPoint;
        region.Warn(duration);
    }
Esempio n. 2
0
        private void openWarning_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;
            if (!(ofd.ShowDialog() ?? false))
            {
                return;
            }
            FileInfo shapeFile = null;
            FileInfo dbfFile   = null;

            foreach (FileInfo fi in ofd.Files)
            {
                if (fi.Extension.ToLower() == ".shp")
                {
                    shapeFile = fi;
                }
                if (fi.Extension.ToLower() == ".dbf")
                {
                    dbfFile = fi;
                }
            }
            //Read the SHP and DBF files into the ShapeFileReader
            ShapeFile shapeFileReader = new ShapeFile();

            if (shapeFile != null && dbfFile != null)
            {
                shapeFileReader.Read(shapeFile, dbfFile);
            }
            else
            {
                HtmlPage.Window.Alert("Please select a SP and a DBF file to proceed.");
                return;
            }

            Color[] color = new Color[4];
            color[0] = Colors.Blue;
            color[1] = Colors.Yellow;
            color[2] = Colors.Orange;
            color[3] = Colors.Red;

            GraphicsLayer graphicsLayer = Map.Layers["Warning Region"] as GraphicsLayer;

            graphicsLayer.Graphics.Clear();


            WarningRegion region1 = new WarningRegion()
            {
                Name  = "Daya Bay",
                Level = 3,
                Chla  = 15.0
            };
            WarningRegion region2 = new WarningRegion()
            {
                Name  = "Mirs Bay",
                Level = 1,
                Chla  = 15.0
            };
            WarningRegion region3 = new WarningRegion()
            {
                Name  = "Shenzhen Bay",
                Level = 2,
                Chla  = 15.0
            };
            WarningRegion region4 = new WarningRegion()
            {
                Name  = "Maozhou",
                Level = 2,
                Chla  = 15.0
            };
            WarningRegion region5 = new WarningRegion()
            {
                Name  = "Shekou",
                Level = 1,
                Chla  = 15.0
            };
            WarningRegion region6 = new WarningRegion()
            {
                Name  = "Lingding",
                Level = 1,
                Chla  = 15.0
            };
            List <WarningRegion> listregion = new List <WarningRegion>();

            listregion.Add(region1);
            listregion.Add(region2);
            listregion.Add(region3);
            listregion.Add(region4);
            listregion.Add(region5);
            listregion.Add(region6);
            int i = 0;

            foreach (ShapeFileRecord record in shapeFileReader.Records)
            {
                Symbol MySm = new SimpleFillSymbol()
                {
                    BorderBrush     = new System.Windows.Media.SolidColorBrush(Colors.DarkGray),
                    BorderThickness = 2,
                    Fill            = new System.Windows.Media.SolidColorBrush(color[listregion[i].Level - 1])
                    {
                        Opacity = 0.7
                    }
                };
                Graphic graphic = record.ToGraphic();
                graphic.Geometry.SpatialReference = new SpatialReference(4326);
                if (graphic != null)
                {
                    graphic.Symbol = MySm;
                    graphicsLayer.Graphics.Add(graphic);
                }
                graphic.Attributes.Add("Name", listregion[i].Name);
                graphic.Attributes.Add("Region", listregion[i]);
                i++;
            }
        }