コード例 #1
0
        private void menu_Click(object sender, EventArgs e)
        {
            FormContour Frm = new FormContour();

            Frm.layers = App.Map.GetRasterLayers();

            if (Frm.layers.GetLength(0) <= 0)
            {
                MessageBox.Show("No raster layer found!");
                return;
            }

            if (Frm.ShowDialog() == DialogResult.OK)
            {
                IMapFeatureLayer fl = App.Map.Layers.Add(Frm.Contours);
                fl.LegendText = Frm.LayerName + " - Contours";

                int numlevs = Frm.lev.GetLength(0);

                switch (Frm.contourtype)
                {
                case (Contour.ContourType.Line):
                {
                    LineScheme ls = new LineScheme();
                    ls.Categories.Clear();

                    for (int i = 0; i < Frm.color.GetLength(0); i++)
                    {
                        LineCategory lc = new LineCategory(Frm.color[i], 2.0);

                        lc.FilterExpression = "[Value] = " + Frm.lev[i].ToString();
                        lc.LegendText       = Frm.lev[i].ToString();

                        ls.AddCategory(lc);
                    }

                    fl.Symbology = ls;
                }
                break;

                case (Contour.ContourType.Polygon):
                {
                    PolygonScheme ps = new PolygonScheme();
                    ps.Categories.Clear();

                    for (int i = 0; i < Frm.color.GetLength(0); i++)
                    {
                        PolygonCategory pc = new PolygonCategory(Frm.color[i], Color.Transparent, 0);
                        pc.FilterExpression = "[Lev] = " + i.ToString();
                        pc.LegendText       = Frm.lev[i].ToString() + " - " + Frm.lev[i + 1].ToString();

                        ps.AddCategory(pc);
                    }

                    fl.Symbology = ps;
                }
                break;
                }
            }
        }
コード例 #2
0
ファイル: Snapin.cs プロジェクト: DIVEROVIEDO/DotSpatial
        private void menu_Click(object sender, EventArgs e)
        {
            FormContour Frm = new FormContour();

            Frm.layers = App.Map.GetRasterLayers();

            if (Frm.layers.GetLength(0) <= 0)
            {
                MessageBox.Show("No raster layer found!");
                return;
            }

            if (Frm.ShowDialog() == DialogResult.OK)
            {
                IMapFeatureLayer fl = App.Map.Layers.Add(Frm.Contours);
                fl.LegendText = Frm.LayerName + " - Contours";

                int numlevs = Frm.lev.GetLength(0);

                switch (Frm.contourtype)
                {
                    case (Contour.ContourType.Line):
                        {
                            LineScheme ls = new LineScheme();
                            ls.Categories.Clear();

                            for (int i = 0; i < Frm.color.GetLength(0); i++)
                            {
                                LineCategory lc = new LineCategory(Frm.color[i], 2.0);

                                lc.FilterExpression = "[Value] = " + Frm.lev[i].ToString();
                                lc.LegendText = Frm.lev[i].ToString();

                                ls.AddCategory(lc);
                            }

                            fl.Symbology = ls;
                        }
                        break;

                    case (Contour.ContourType.Polygon):
                        {
                            PolygonScheme ps = new PolygonScheme();
                            ps.Categories.Clear();

                            for (int i = 0; i < Frm.color.GetLength(0); i++)
                            {
                                PolygonCategory pc = new PolygonCategory(Frm.color[i], Color.Transparent, 0);
                                pc.FilterExpression = "[Lev] = " + i.ToString();
                                pc.LegendText = Frm.lev[i].ToString() + " - " + Frm.lev[i + 1].ToString();

                                ps.AddCategory(pc);
                            }

                            fl.Symbology = ps;
                        }
                        break;
                }
            }
        }