Exemple #1
0
        private void Draw()
        {
            var point       = _controller.Value;
            var mapSettings = _mapSettingsController.Value;
            var mapPoint    = CalculatePointHelper.ToMapPoint(mapSettings, point);

            Text = $"{point.X}, {point.Y} ({mapPoint.X}, {mapPoint.Y})\n[{mapSettings.Scale}] {mapSettings.PointLeftTop.X} {mapSettings.PointLeftTop.Y}";
        }
        private bool CanMove(SKPoint controlPosition)
        {
            var mapPoint = CalculatePointHelper.ToMapPoint(MapSettings, controlPosition);
            var radius   = CalculatePointHelper.ToMapDistance(_mapSettingsController.Value, SelectRadius);
            var elements = _selectableObjects.GetElements(mapPoint, radius);

            return(!elements.Any());
        }
Exemple #3
0
        public override bool OnMouseDown(MouseButtonEventArgs mouseButtonEventArgs, SKPoint controlPosition)
        {
            if (mouseButtonEventArgs.ChangedButton != MouseButton.Middle ||
                mouseButtonEventArgs.ButtonState != MouseButtonState.Pressed)
            {
                return(false);
            }

            IsRun = _mapMoveOperation.Start(
                controlPosition,
                CalculatePointHelper.ToMapPoint(_mapSettingsController.Value, controlPosition)
                );
            _logger.LogInformation("MouseOperationMapMove OnMouseDown IsRun: {IsRun}", IsRun);
            return(IsRun);
        }
Exemple #4
0
        private void Draw(SKCanvas canvas, int width, int height)
        {
            var pointMapLT = CalculatePointHelper.ToMapPoint(MapSettings, new SKPoint(0, 0));
            var pointMapRB = CalculatePointHelper.ToMapPoint(MapSettings, new SKPoint(width, height));

            var drawRect = new SKRect(
                pointMapLT.X,
                pointMapLT.Y,
                pointMapRB.X,
                pointMapRB.Y
                );

            _layerManager.Layers
            .ToList()
            .ForEach(v => v.Draw(canvas, drawRect));
        }
Exemple #5
0
        public override bool OnMouseMove(MouseEventArgs mouseEventArgs, SKPoint controlPosition)
        {
            IsRun = IsRun && (mouseEventArgs.MiddleButton == MouseButtonState.Pressed);
            _logger.LogInformation("MouseOperationMapMove OnMouseMove IsRun: {IsRun}", IsRun);
            _logger.LogInformation("_mapMoveOperation IsRun: {IsRun}", _mapMoveOperation.IsRun);
            if (!_mapMoveOperation.IsRun)
            {
                return(false);
            }

            if (mouseEventArgs.MiddleButton != MouseButtonState.Pressed || !IsRun)
            {
                return(_mapMoveOperation.Stop(
                           controlPosition,
                           CalculatePointHelper.ToMapPoint(_mapSettingsController.Value, controlPosition)
                           ));
            }

            return(_mapMoveOperation.Change(
                       controlPosition,
                       CalculatePointHelper.ToMapPoint(_mapSettingsController.Value, controlPosition)
                       ));
        }
        public override bool OnMouseUp(MouseButtonEventArgs mouseButtonEventArgs, SKPoint controlPosition)
        {
            if (!IsRun ||
                mouseButtonEventArgs.ChangedButton != MouseButton.Left ||
                mouseButtonEventArgs.ButtonState != MouseButtonState.Released)
            {
                return(false);
            }

            var mapPoint = CalculatePointHelper.ToMapPoint(MapSettings, controlPosition);
            var radius   = CalculatePointHelper.ToMapDistance(MapSettings, SelectRadius);

            var selectedObject   = _selectableController.Value.FirstOrDefault();
            var intersectObjects = _selectableObjects.GetElements(mapPoint, radius);

            if (!intersectObjects.Any() || intersectObjects.Count == 1 && intersectObjects.First() == selectedObject)
            {
                _selectableController.ClearSelect();
            }
            else
            {
                var index = intersectObjects.IndexOf(selectedObject);
                if (index == -1 || intersectObjects.Count == index + 1)
                {
                    _selectableController.Select(intersectObjects.First());
                }
                else
                {
                    _selectableController.Select(intersectObjects.ElementAt(index + 1));
                }
            }

            _subOperation?.Stop();
            End(controlPosition);
            return(true);
        }
 public SKPoint ToMapPoint(SKPoint controlPoint)
 {
     return(CalculatePointHelper.ToMapPoint(MapSettings, controlPoint));
 }