Esempio n. 1
0
        private void DrawLasso()
        {
            if (_coordinates == null)
            {
                return;
            }

            if (_coordinates.LassoPoints.Count > 1)
            {
                var           points = MM_Coordinates.ConvertPoints(_coordinates.LassoPoints, 4).Select(p => p * _scale).ToList();
                RawRectangleF bounds;
                var           geometry = Surface.CreateRegionPathGeometry(points, out bounds, filled: true, closed: true, simplify: true);

                _target.FillGeometry(geometry, Surface.Brushes.GetBrush(_coordinates.LassoColor, 0.5f));
                _target.DrawGeometry(geometry, Surface.Brushes.GetBrush(Color4.White), 2f);
                geometry.Dispose();
            }
            else if (!_coordinates.LassoEnd.IsEmpty)
            {
                var start = ConvertPoint(_coordinates.LassoStart);
                var end   = ConvertPoint(_coordinates.LassoEnd);

                var rawRectangleF = new RawRectangleF(start.X, start.Y, end.X, end.Y);
                _target.FillRectangle(rawRectangleF, Surface.Brushes.GetBrush(_coordinates.LassoColor, 0.5f));
                _target.DrawRectangle(rawRectangleF, Surface.Brushes.GetBrush(Color4.White), 2f);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Perform calculations and update data.
        /// </summary>
        /// <param name="updateTime">Time since last update.</param>
        /// <remarks>include base.Update(renderTime); in overloads to preserve updating UpdateTime field.</remarks>
        public override void Update(RenderTime updateTime)
        {
            base.Update(updateTime);

            if (!Surface.IsDirty && _lastZoom == Surface.Coordinates.ZoomLevel)
            {
                return;
            }

            _lastZoom = Surface.Coordinates.ZoomLevel;

            foreach (var value in regions.Values)
            {
                value.Geometry.Dispose();
            }
            regions.Clear();

            foreach (var boundary in MM_Repository.Counties.Values.ToList())
            {
                RawRectangleF bounds;
                var           geometry = Surface.CreateRegionPathGeometry(MM_Coordinates.ConvertPoints(boundary.Coordinates, Surface.Coordinates.ZoomLevel).ToList(), out bounds, filled: true, simplify: true);

                var region = new RegionProxy(geometry, boundary.DisplayParameter.ForeColor, boundary.DisplayParameter.Width, bounds);
                region.Boundary = boundary;
                if (boundary.Name == "STATE")
                {
                    state = region;
                }
                else
                {
                    regions.Add(boundary, region);
                }
            }

            foreach (MM_Boundary boundary in MM_Repository.Districts.Values.ToList())
            {
                RawRectangleF bounds;
                var           geometry = Surface.CreateRegionPathGeometry(MM_Coordinates.ConvertPoints(boundary.Coordinates, Surface.Coordinates.ZoomLevel).ToList(), out bounds, simplify: true);
                var           region   = new RegionProxy(geometry, boundary.DisplayParameter.ForeColor, boundary.DisplayParameter.Width, bounds);
                regions.Add(boundary, region);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Load Content and initialize unmanaged resources.
        /// </summary>
        public override void LoadContent()
        {
            int width  = 256;
            int height = 256;

            var size  = Surface.RenderTarget2D.PixelSize;
            var sizeV = new Vector2(size.Width, size.Height);

            _start        = sizeV - new Vector2(width, height) - new Vector2(10, 10);
            _end          = sizeV - new Vector2(10, 10);
            _viewLocation = new SharpDX.RectangleF(_start.X, _start.Y, _end.X - _start.X, _end.Y - _start.Y);

            base.LoadContent();

            if (_font == null || _font.IsDisposed)
            {
                _font = Surface.Fonts.GetTextFormat(MM_Repository.OverallDisplay.NetworkMapFont, 5);
            }

            if (_target == null || _target.IsDisposed)
            {
                _target = Surface.CreateRenderTarget(width, height);
            }

            MM_Boundary State;

            if (MM_Repository.Counties.TryGetValue("STATE", out State))
            {
                RawRectangleF bounds;
                var           geometry = Surface.CreateRegionPathGeometry(MM_Coordinates.ConvertPoints(State.Coordinates, 4).ToList(), out bounds, filled: true, simplify: true);
                geometry.Dispose();

                _scale = new Vector2(width / (bounds.Right - bounds.Left), height / (bounds.Bottom - bounds.Top));

                var geometryScaled = Surface.CreateRegionPathGeometry(MM_Coordinates.ConvertPoints(State.Coordinates, 4).ToList(), out bounds, filled: true, compression: 0.001f, simplify: true, scaleX: _scale.X, scaleY: _scale.Y);
                _location = new Vector2(bounds.Left, bounds.Top);

                _state = new RegionProxy(geometryScaled, State.DisplayParameter.ForeColor, State.DisplayParameter.Width, bounds);
            }
        }