public MapUserControl(SourceMaps.ITileSource source)
        {
            InitializeComponent();
            InitMap(source);

            // Init images
            zoomInToolStripMenuItem.Image     = MapExplorer.Properties.Resources.Zoom_In;
            zoomOutToolStripMenuItem.Image    = MapExplorer.Properties.Resources.Zoom_Out;
            centerHereToolStripMenuItem.Image = MapExplorer.Properties.Resources.Center;
        }
Example #2
0
        public MapUserControl(SourceMaps.ITileSource source)
        {
            InitializeComponent();
            InitMap(source);

            // Init images.
            ComponentResourceManager resources = new ComponentResourceManager(typeof(MapUserControl));

            zoomInToolStripMenuItem.Image     = (Image)resources.GetObject("Zoom_In");
            zoomOutToolStripMenuItem.Image    = (Image)resources.GetObject("Zoom_Out");
            centerHereToolStripMenuItem.Image = (Image)resources.GetObject("Center");
        }
        protected virtual void InitMap(SourceMaps.ITileSource source = null)
        {
            if (Map is null)
            {
                // Start init
                _map = new C1Map();
                ((System.ComponentModel.ISupportInitialize)_map).BeginInit();
                SuspendLayout();

                // Basic properties
                _map.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                     | System.Windows.Forms.AnchorStyles.Left)
                                                                    | System.Windows.Forms.AnchorStyles.Right)));
                _map.DistanceScale.Alignment          = System.Drawing.ContentAlignment.BottomLeft;
                _map.DistanceScale.BarStyle.BackColor = _titleColor;
                _map.DistanceScale.BarStyle.ForeColor = _titleColor;

                _map.Location = new System.Drawing.Point(_padding, _padding);
                _map.Size     = new Size(Size.Width - _padding * 2, Size.Height - _padding * 2);

                // Muve options
                _map.PanTool.MarkerStyle.BackColor     = _toolbarLigthColor;
                _map.PanTool.MarkerStyle.BackColor2    = _toolbarDarkColor;
                _map.PanTool.MarkerStyle.GradientStyle = C1.Win.Map.GradientStyle.Vertical;

                _map.PanTool.PanStyle.BackColor     = _toolbarLigthColor;
                _map.PanTool.PanStyle.BackColor2    = _toolbarDarkColor;
                _map.PanTool.PanStyle.GradientStyle = C1.Win.Map.GradientStyle.Vertical;

                _map.PanTool.PanStyle.Stroke.Color = _toolbarDarkColor;

                // Zoom options
                _map.ZoomTool.Margin = new System.Windows.Forms.Padding(20, 70, 0, 0);
                _map.ZoomTool.ButtonStyle.BackColor  = _toolbarLigthColor;
                _map.ZoomTool.ButtonStyle.BackColor2 = _toolbarDarkColor;

                _map.ZoomTool.ButtonStyle.Border.Bottom.Color            = Color.DarkGray;
                _map.ZoomTool.ButtonStyle.Border.Left.Color              = Color.DarkGray;
                _map.ZoomTool.ButtonStyle.Border.Right.Color             = Color.DarkGray;
                _map.ZoomTool.ButtonStyle.Border.RoundRadius.BottomLeft  = 3;
                _map.ZoomTool.ButtonStyle.Border.RoundRadius.BottomRight = 3;
                _map.ZoomTool.ButtonStyle.Border.RoundRadius.TopLeft     = 3;
                _map.ZoomTool.ButtonStyle.Border.RoundRadius.TopRight    = 3;
                _map.ZoomTool.ButtonStyle.Border.Top.Color = Color.DarkGray;
                _map.ZoomTool.ButtonStyle.GradientStyle    = C1.Win.Map.GradientStyle.Vertical;

                _map.ZoomTool.ThumbStyle.BackColor           = _toolbarLigthColor;
                _map.ZoomTool.ThumbStyle.BackColor2          = _toolbarDarkColor;
                _map.ZoomTool.ThumbStyle.Border.Bottom.Color = Color.DarkGray;
                _map.ZoomTool.ThumbStyle.Border.Left.Color   = Color.DarkGray;
                _map.ZoomTool.ThumbStyle.Border.Right.Color  = Color.DarkGray;

                _map.ZoomTool.ThumbStyle.Border.RoundRadius.BottomLeft  = 3;
                _map.ZoomTool.ThumbStyle.Border.RoundRadius.BottomRight = 3;
                _map.ZoomTool.ThumbStyle.Border.RoundRadius.TopLeft     = 3;
                _map.ZoomTool.ThumbStyle.Border.RoundRadius.TopRight    = 3;
                _map.ZoomTool.ThumbStyle.Border.Top.Color = Color.DarkGray;
                _map.ZoomTool.ThumbStyle.GradientStyle    = C1.Win.Map.GradientStyle.Vertical;

                _map.ZoomTool.TrackStyle.BackColor                      = _toolbarLigthColor;
                _map.ZoomTool.TrackStyle.Border.Bottom.Color            = Color.DarkGray;
                _map.ZoomTool.TrackStyle.Border.Left.Color              = Color.DarkGray;
                _map.ZoomTool.TrackStyle.Border.Left.Width              = 1F;
                _map.ZoomTool.TrackStyle.Border.Right.Color             = Color.DarkGray;
                _map.ZoomTool.TrackStyle.Border.RoundRadius.BottomLeft  = 3;
                _map.ZoomTool.TrackStyle.Border.RoundRadius.BottomRight = 3;
                _map.ZoomTool.TrackStyle.Border.RoundRadius.TopLeft     = 3;
                _map.ZoomTool.TrackStyle.Border.RoundRadius.TopRight    = 3;
                _map.ZoomTool.TrackStyle.Border.Top.Color               = Color.DarkGray;

                // Set source map
                if (source is not null)
                {
                    _map.TileLayer.TileSource = source;
                }

                // End init
                ((System.ComponentModel.ISupportInitialize)_map).EndInit();
                ResumeLayout(false);

                // Add events
                _map.MouseMove       += OnMapMouseMove;
                _map.ContextMenuStrip = contextMenuStrip1;
            }

            if (_map is not null)
            {
                Controls.Add(_map);
            }
        }