Exemplo n.º 1
0
        public MapForm1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set table search path to value sampledatasearch registry key
            string s = Environment.CurrentDirectory;
            Microsoft.Win32.RegistryKey keySamp = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\MapInfo\MapXtreme\6.6");
            if ((keySamp != null) && (keySamp.GetValue("SampleDataSearchPath") != null))
            {
                s = (string)keySamp.GetValue("SampleDataSearchPath");
                if (s.EndsWith("\\")==false)
                {
                    s += "\\";
                }
                keySamp.Close();
            }
            Session.Current.TableSearchPath.Path = s;

            // Add the USA table to the map
            mapControl1.Map.Load(new MapTableLoader("usa.tab"));

            // Listen to some map events
            mapControl1.Map.ViewChangedEvent += new ViewChangedEventHandler(Map_ViewChanged);
            mapControl1.Resize += new EventHandler(mapControl1_Resize);

            // Create a ranged theme on the USA layer.
            Map map = mapControl1.Map;
            FeatureLayer lyr = map.Layers["usa"] as MapInfo.Mapping.FeatureLayer;
            RangedTheme thm = new MapInfo.Mapping.Thematics.RangedTheme(
                lyr,
                "Round(MI_Area(Obj, 'sq mi', 'Spherical'), 1)",
                "Area (square miles)",
                5,
                MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);
            lyr.Modifiers.Append(thm);

            // Change the default fill colors from Red->Gray to White->Blue
            AreaStyle ars;
            // Get the style from our first bin
            CompositeStyle cs = thm.Bins[0].Style;
            // Get the region -- Area -- style
            ars = cs.AreaStyle;
            // Change the fill color
            ars.Interior = StockStyles.WhiteFillStyle();
            // Update the CompositeStyle with the new region color
            cs.AreaStyle = ars;
            // Update the bin with the new CompositeStyle settings
            thm.Bins[0].Style = cs;

            // Change the style settings on the last bin
            int nLastBin = thm.Bins.Count - 1;
            cs = thm.Bins[nLastBin].Style;
            ars = cs.AreaStyle;
            ars.Interior = StockStyles.BlueFillStyle();
            thm.Bins[nLastBin].Style = cs;

            // Tell the theme how to fill in the other bins
            thm.SpreadBy = SpreadByPart.Color;
            thm.ColorSpreadBy = ColorSpreadMethod.Rgb;
            thm.RecomputeStyles();

            // Create a legend
            legend = map.Legends.CreateLegend(new Size(5, 5));
            legend.Border = true;
            ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("Area", "Area", thm);
            legend.Frames.Append(frame);
            frame.Title = "Area (sq. mi.)";
            map.Adornments.Append(legend);
            // Set the initial legend location to be the lower right corner of the map control.
            System.Drawing.Point pt = new System.Drawing.Point(0, 0);
            pt.X = mapControl1.Size.Width - legend.Size.Width;
            pt.Y = mapControl1.Size.Height - legend.Size.Height;
            legend.Location = pt;
        }
Exemplo n.º 2
0
        public MapForm1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set table search path to value sampledatasearch registry key
            string s = Environment.CurrentDirectory;
            Microsoft.Win32.RegistryKey keySamp = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\MapInfo\MapXtreme\6.6");
            if ((keySamp != null) && (keySamp.GetValue("SampleDataSearchPath") != null))
            {
                s = (string)keySamp.GetValue("SampleDataSearchPath");
                if (s.EndsWith("\\")==false)
                {
                    s += "\\";
                }
                keySamp.Close();
            }
            Session.Current.TableSearchPath.Path = s;

            // Add the USA table to the map
            mapControl1.Map.Load(new MapTableLoader("usa.tab"));

            // Listen to the appropriate map event to allow the status bar to be updated
            mapControl1.Map.ViewChangedEvent += new ViewChangedEventHandler(Map_ViewChanged);

            // Create a ranged theme on the USA layer.
            Map map = mapControl1.Map;
            FeatureLayer lyr = map.Layers["usa"] as MapInfo.Mapping.FeatureLayer;
            RangedTheme thm = new MapInfo.Mapping.Thematics.RangedTheme(
                lyr,
                "Round(MI_Area(Obj, 'sq mi', 'Spherical'), 1)",
                "Area (square miles)",
                5,
                MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);
            lyr.Modifiers.Append(thm);

            // Create a legend
            Legend legend = map.Legends.CreateLegend(new Size(5, 5));
            // Create a LegendFrame that contains the theme and add that frame to the Legend.
            ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("Area", "Area", thm);
            legend.Frames.Append(frame);
            frame.Title = "Area (sq. mi.)";

            // Create a LegendExport and export the legend to a bitmap file.
            MapInfo.Mapping.LegendExport legendExport = new MapInfo.Mapping.LegendExport(map, legend);
            legendExport.Format = ExportFormat.Bmp;
            legendExport.ExportSize = new ExportSize(300, 200);
            legendExport.Export("legend.bmp");

            // Display the legend in a window.
            System.Windows.Forms.Form legendForm = new LegendForm();
            legendForm.BackgroundImage = System.Drawing.Image.FromFile("legend.bmp");
            legendForm.Size = new Size(300, 200);
            legendForm.Show();

            // Alternatively, you can add the legend as a child window of the map
            //  by appending it to the Adornments collection.  In this case, most likely
            //  a smaller size should be used when the Legend object is created.
            //
            //legend.Border = true;
            //map.Adornments.Append(legend);

            // Set the initial legend location to be the upper left corner of the map control.
            //legend.Location = new System.Drawing.Point(mapControl1.Left, mapControl1.Top);
        }
Exemplo n.º 3
0
        public MapForm1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set table search path to value sampledatasearch registry key
            string s = Environment.CurrentDirectory;

            Microsoft.Win32.RegistryKey keySamp = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\MapInfo\MapXtreme\6.6");
            if ((keySamp != null) && (keySamp.GetValue("SampleDataSearchPath") != null))
            {
                s = (string)keySamp.GetValue("SampleDataSearchPath");
                if (s.EndsWith("\\") == false)
                {
                    s += "\\";
                }
                keySamp.Close();
            }
            Session.Current.TableSearchPath.Path = s;

            // Add the USA table to the map
            mapControl1.Map.Load(new MapTableLoader("usa.tab"));

            // Listen to some map events
            mapControl1.Map.ViewChangedEvent += new ViewChangedEventHandler(Map_ViewChanged);
            mapControl1.Resize += new EventHandler(mapControl1_Resize);

            // Create a ranged theme on the USA layer.
            Map          map = mapControl1.Map;
            FeatureLayer lyr = map.Layers["usa"] as MapInfo.Mapping.FeatureLayer;
            RangedTheme  thm = new MapInfo.Mapping.Thematics.RangedTheme(
                lyr,
                "Round(MI_Area(Obj, 'sq mi', 'Spherical'), 1)",
                "Area (square miles)",
                5,
                MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);

            lyr.Modifiers.Append(thm);

            // Change the default fill colors from Red->Gray to White->Blue
            AreaStyle ars;
            // Get the style from our first bin
            CompositeStyle cs = thm.Bins[0].Style;

            // Get the region -- Area -- style
            ars = cs.AreaStyle;
            // Change the fill color
            ars.Interior = StockStyles.WhiteFillStyle();
            // Update the CompositeStyle with the new region color
            cs.AreaStyle = ars;
            // Update the bin with the new CompositeStyle settings
            thm.Bins[0].Style = cs;

            // Change the style settings on the last bin
            int nLastBin = thm.Bins.Count - 1;

            cs                       = thm.Bins[nLastBin].Style;
            ars                      = cs.AreaStyle;
            ars.Interior             = StockStyles.BlueFillStyle();
            thm.Bins[nLastBin].Style = cs;

            // Tell the theme how to fill in the other bins
            thm.SpreadBy      = SpreadByPart.Color;
            thm.ColorSpreadBy = ColorSpreadMethod.Rgb;
            thm.RecomputeStyles();

            // Create a legend
            legend        = map.Legends.CreateLegend(new Size(5, 5));
            legend.Border = true;
            ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("Area", "Area", thm);

            legend.Frames.Append(frame);
            frame.Title = "Area (sq. mi.)";
            map.Adornments.Append(legend);
            // Set the initial legend location to be the lower right corner of the map control.
            System.Drawing.Point pt = new System.Drawing.Point(0, 0);
            pt.X            = mapControl1.Size.Width - legend.Size.Width;
            pt.Y            = mapControl1.Size.Height - legend.Size.Height;
            legend.Location = pt;
        }
Exemplo n.º 4
0
        public MapForm1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set table search path to value sampledatasearch registry key
            string s = Environment.CurrentDirectory;

            Microsoft.Win32.RegistryKey keySamp = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\MapInfo\MapXtreme\6.6");
            if ((keySamp != null) && (keySamp.GetValue("SampleDataSearchPath") != null))
            {
                s = (string)keySamp.GetValue("SampleDataSearchPath");
                if (s.EndsWith("\\") == false)
                {
                    s += "\\";
                }
                keySamp.Close();
            }
            Session.Current.TableSearchPath.Path = s;

            // Add the USA table to the map
            mapControl1.Map.Load(new MapTableLoader("usa.tab"));

            // Listen to the appropriate map event to allow the status bar to be updated
            mapControl1.Map.ViewChangedEvent += new ViewChangedEventHandler(Map_ViewChanged);

            // Create a ranged theme on the USA layer.
            Map          map = mapControl1.Map;
            FeatureLayer lyr = map.Layers["usa"] as MapInfo.Mapping.FeatureLayer;
            RangedTheme  thm = new MapInfo.Mapping.Thematics.RangedTheme(
                lyr,
                "Round(MI_Area(Obj, 'sq mi', 'Spherical'), 1)",
                "Area (square miles)",
                5,
                MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);

            lyr.Modifiers.Append(thm);

            // Create a legend
            Legend legend = map.Legends.CreateLegend(new Size(5, 5));
            // Create a LegendFrame that contains the theme and add that frame to the Legend.
            ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("Area", "Area", thm);

            legend.Frames.Append(frame);
            frame.Title = "Area (sq. mi.)";

            // Create a LegendExport and export the legend to a bitmap file.
            MapInfo.Mapping.LegendExport legendExport = new MapInfo.Mapping.LegendExport(map, legend);
            legendExport.Format     = ExportFormat.Bmp;
            legendExport.ExportSize = new ExportSize(300, 200);
            legendExport.Export("legend.bmp");

            // Display the legend in a window.
            System.Windows.Forms.Form legendForm = new LegendForm();
            legendForm.BackgroundImage = System.Drawing.Image.FromFile("legend.bmp");
            legendForm.Size            = new Size(300, 200);
            legendForm.Show();

            // Alternatively, you can add the legend as a child window of the map
            //  by appending it to the Adornments collection.  In this case, most likely
            //  a smaller size should be used when the Legend object is created.
            //
            //legend.Border = true;
            //map.Adornments.Append(legend);

            // Set the initial legend location to be the upper left corner of the map control.
            //legend.Location = new System.Drawing.Point(mapControl1.Left, mapControl1.Top);
        }