/// <summary>
    /// Zooms the camera in/out until it reaches the target
    /// </summary>
    void Zoom_()
    {
        switch (_zoomDirection)
        {
        // zoom in
        case ZoomDirection.In:
            TheCamera.orthographicSize -= _zoomSpeed * Time.deltaTime * SpeedAdjustment;
            // stop when target reached
            if (TheCamera.orthographicSize < _targetZoom)
            {
                _zoomDirection             = ZoomDirection.None;
                TheCamera.orthographicSize = _targetZoom;
            }
            break;

        // zoom out
        case ZoomDirection.Out:
            TheCamera.orthographicSize += _zoomSpeed * Time.deltaTime * SpeedAdjustment;
            // stop when target reached
            if (TheCamera.orthographicSize > _targetZoom)
            {
                _zoomDirection             = ZoomDirection.None;
                TheCamera.orthographicSize = _targetZoom;
            }
            break;
        }
    }
    /// <summary>
    /// Start the movement
    /// </summary>
    /// <param name="targetPosition">Where to move to (where the camera should end up)</param>
    public void StartMovement(Vector2 targetPosition, float targetZoom)
    {
        // get the differences in X and Y directions
        var xDifference = Math.Abs(targetPosition.x - transform.localPosition.x);
        var yDifference = Math.Abs(targetPosition.y - transform.localPosition.y);
        var zDifference = Math.Abs(targetZoom - TheCamera.orthographicSize);

        // calculate the speed to move at
        var max = (Math.Max(Math.Max(xDifference, yDifference), zDifference));

        _xSpeed    = xDifference / max;
        _ySpeed    = yDifference / max;
        _zoomSpeed = zDifference / max;

        _targetPosition = targetPosition;
        _targetZoom     = targetZoom;

        // get the original movement
        if (_targetPosition.x != transform.localPosition.x)
        {
            _xMovement = _targetPosition.x > transform.localPosition.x ? MovementDirectionX.Right : MovementDirectionX.Left;
        }
        if (_targetPosition.y != transform.localPosition.y)
        {
            _yMovement = _targetPosition.y > transform.localPosition.y ? MovementDirectionY.Up : MovementDirectionY.Down;
        }
        if (_targetZoom != TheCamera.orthographicSize)
        {
            _zoomDirection = _targetZoom < TheCamera.orthographicSize ? ZoomDirection.In : ZoomDirection.Out;
        }

        // set values
        _callbackCalled = false;
    }
Exemple #3
0
        /// <summary>
        /// Raises zoom gesture event to subscribers.
        /// </summary>
        /// <param name="direction">Zoom direction.</param>
        private void OnZoom(ZoomDirection direction)
        {
            var func = Zoom;

            if (func != null)
            {
                func(this, new ZoomEventArgs(direction));
            }
        }
Exemple #4
0
        private double GetNewValue(double value, double factor, ZoomDirection direction)
        {
            if (direction == ZoomDirection.In)
            {
                return(value / factor);
            }

            return(value * factor);
        }
        public override void ZoomMove(string VideoSource, ZoomDirection Direction, string Timeout)
        {
            ParametersValidation validation = new ParametersValidation();

            validation.Add(ParameterType.String, "VideoSource", VideoSource);
            validation.Add(ParameterType.OptionalString, "Timeout", Timeout);
            validation.Add(ParameterType.String, "Direction", Direction.ToString());
            ExecuteVoidCommand(validation, ProvisioningServiceTest.ZoomMoveTest);
        }
Exemple #6
0
        private void OnSeriesEnd(ZoomDirection direction)
        {
            var ev = direction == ZoomDirection.In ? StEvent.SceneZoomedIn : StEvent.SceneZoomedOut;

            UISharedRTClient.Instance.clienRt.SendStatsEvent(ev,
                                                             SessionInfo.Get().person.Id,
                                                             SessionInfo.Get().discussion.Id,
                                                             topicNavPanel.selectedTopic.Id,
                                                             DeviceType.Wpf);
        }
            //private Duration AnimationDuration
            //{
            //	get { return new Duration(TimeSpan.FromMilliseconds(300)); }
            //}

            public void SwitchViews(ZoomDirection direction)
            {
                _switchOut.IsHitTestVisible = false;
                _switchIn.IsHitTestVisible  = false;

                if (direction == ZoomDirection.In)
                {
                    ZoomIn(_switchOut, _switchIn);
                }
                else
                {
                    ZoomOut(_switchOut, _switchIn);
                }
            }
            //private Duration AnimationDuration
            //{
            //	get { return new Duration(TimeSpan.FromMilliseconds(400)); }
            //}

            public void SwitchViews(ZoomDirection direction)
            {
                centerX = _switchIn.RenderSize.Width / 2;
                centerY = _switchIn.RenderSize.Height / 2;

                if (direction == ZoomDirection.In)
                {
                    ZoomIn();
                }
                else
                {
                    ZoomOut();
                }
            }
    public void InitialiseZoom(ZoomDirection t_direction, float t_zoomSpeed, float t_zoomAmount = 0.0f, float t_timeToZoom = 0.0f, CameraMovementState t_state = CameraMovementState.None)
    {
        SetZoomDirection(t_direction);
        SetInitialZoom(GetPosition().z);
        SetTrackingType(TrackingType.None);
        SetCameraState(CameraMovementState.None);
        SetTimeForZoom(t_timeToZoom);
        SetZoomAmount(t_zoomAmount);
        SetCurrentZoomSpeed(t_zoomSpeed);

        if (t_state != CameraMovementState.None)
        {
            InitialiseMovement(t_state);
        }
    }
Exemple #10
0
        public override void StopZoom(ZoomDirection direction)
        {
            switch (direction)
            {
            case ZoomDirection.In:
                ExecuteMethod("actZoom", "in", "stop");
                break;

            case ZoomDirection.Out:
                ExecuteMethod("actZoom", "out", "stop");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }
        }
        private double CalculateModifiedZoom(double currentLinearZoom, ZoomDirection zoomDirection, double zoomAmount)
        {
            var zoomSign = zoomDirection == ZoomDirection.In ? 1 : -1;

            var newLinearZoom = currentLinearZoom + zoomAmount * zoomSign;

            if (newLinearZoom < MinZoom)
            {
                newLinearZoom = MinZoom;
            }

            if (newLinearZoom > MaxZoom)
            {
                newLinearZoom = MaxZoom;
            }

            return(newLinearZoom);
        }
Exemple #12
0
        public void Zoom(ZoomDirection direction, Point zoomCenter)
        {
            // scale everything
            double scale = ZoomScale;

            switch (direction)
            {
            case ZoomDirection.In:
                scale = 1.0 / scale;
                break;

            case ZoomDirection.Out:
                break;
            }

            // center zoom operation on mouse
            lastPointerPosition = zoomCenter;
            var vp          = _workspace.ActiveViewPort;
            var oldHeight   = vp.ViewHeight;
            var oldWidth    = Width * oldHeight / Height;
            var newHeight   = oldHeight * scale;
            var newWidth    = oldWidth * scale;
            var heightDelta = newHeight - oldHeight;
            var widthDelta  = newWidth - oldWidth;

            var relHoriz     = zoomCenter.X / Width;
            var relVert      = (Height - zoomCenter.Y) / Height;
            var botLeftDelta = new Vector(relHoriz * widthDelta, relVert * heightDelta, 0.0);
            var newVp        = vp.Update(
                bottomLeft: (Point)(vp.BottomLeft - botLeftDelta),
                viewHeight: vp.ViewHeight * scale);

            _workspace.Update(activeViewPort: newVp);

            updateSnapPointsTask.ContinueWith(_ =>
            {
                var snapPoint = GetActiveModelPoint(zoomCenter, updateSnapPointsCancellationTokenSource.Token);
                CursorWorldLocationUpdated?.Invoke(this, snapPoint.WorldPoint);
                if ((_workspace.InputService.AllowedInputTypes & InputType.Point) == InputType.Point)
                {
                    DrawSnapPoint(snapPoint, GetNextDrawSnapPointId());
                }
            }).ConfigureAwait(false);
        }
    public void ChangeZoom(ZoomDirection zoomDirection)
    {
        if (!isNextZoomLevelWithinLimit(zoomDirection))
        {
            return;
        }

        if (zoomDirection == ZoomDirection.In)
        {
            CustomMap.Instance.Zoom += zoomResponsiveness;
        }
        else if (zoomDirection == ZoomDirection.Out)
        {
            CustomMap.Instance.Zoom -= zoomResponsiveness;
        }
        InteractibleMap.Instance.HideTablesAndObjects();
        RemoveAllTiles();
        StartCoroutine(LoadNewTiles());
    }
Exemple #14
0
        public void Zoom(ZoomDirection direction, ZoomAmount amount)
        {
            int boxSize = 200;

            if (amount == ZoomAmount.Short)
            {
                boxSize = 750;
            }
            else if (amount == ZoomAmount.Medium)
            {
                boxSize = 250;
            }
            else if (amount == ZoomAmount.Long)
            {
                boxSize = 50;
            }

            HttpPost(url, GetPTZJSONString("34323638666239302D396463362D3131", 500, 500, boxSize, boxSize, direction == ZoomDirection.In));
        }
Exemple #15
0
        public void SubmitStep(ZoomDirection direction)
        {
            _timer.Stop();
            _timer.Start();

            if (SeriesNonEmpty() && direction != _currentDirection)
            {
                _numSteps = 0;
                _end(_currentDirection);
            }
            else
            {
                _numSteps++;
            }

            if (direction != _currentDirection)
            {
                _currentDirection = direction;
            }
        }
Exemple #16
0
        public void SubmitStep(ZoomDirection direction)
        {
            _timer.Stop();
            _timer.Start();

            if (SeriesNonEmpty() && direction != _currentDirection)
            {
                _numSteps = 0;
                _end(_currentDirection);
            }
            else
            {
                _numSteps++;
            }

            if (direction != _currentDirection)
            {
                _currentDirection = direction;
            }
        }
Exemple #17
0
        private ZoomDirection AdjustScale(ZoomDirection direction, ScaleTransform scale, bool mouseOver, Storyboard timer)
        {
            if (direction == ZoomDirection.In)
            {
                if (scale.ScaleX < 1.3)
                {
                    scale.ScaleX += 0.05;
                    scale.ScaleY += 0.05;
                }
                else if (mouseOver == false)
                {
                    direction = ZoomDirection.Out;
                }
            }
            else if (scale.ScaleX > 1.0)
            {
                scale.ScaleX -= 0.05;
                scale.ScaleY -= 0.05;
            }

            timer.Begin();
            return(direction);
        }
Exemple #18
0
        public void Zoom(ZoomDirection dir, bool animate = false)
        {
            if (animate)
            {
                var factor = (dir == ZoomDirection.In) ? _zoomInFactor : _zoomOutFactor;

                ValueAnimation zoomAnimation = new ValueAnimation();
                zoomAnimation.InterpolationMethod = InterpMethod.Linear;
                zoomAnimation.SetKeyFrame(0.0f, App.Camera.Zoom);
                zoomAnimation.SetKeyFrame(0.3f, App.Camera.Zoom * factor);

                ObjectAnimation cameraAnimation = new ObjectAnimation();
                cameraAnimation.AddAttributeAnimation("Zoom", zoomAnimation, WrapMode.Once, 1f);

                App.Camera.ObjectAnimation = cameraAnimation;
            }
            else
            {
                var factor = (dir == ZoomDirection.In) ? _zoomInFactorSmall : _zoomOutFactorSmall;

                App.Camera.Zoom *= factor;
            }
        }
    private bool isNextZoomLevelWithinLimit(ZoomDirection zoom)
    {
        int levelAfterZoom = 0;

        switch (zoom)
        {
        case ZoomDirection.Out:
            levelAfterZoom = CustomMap.Instance.Zoom - zoomResponsiveness;
            break;

        case ZoomDirection.In:
            levelAfterZoom = CustomMap.Instance.Zoom + zoomResponsiveness;
            break;
        }
        if (levelAfterZoom > maxZoomLevel || levelAfterZoom < minZoomLevel)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Exemple #20
0
        public void Zoom(ZoomDirection direction)
        {
            Logger.LogInfo(nameof(SurfaceHolderCallback), nameof(Zoom), "called.");
            Logger.LogInfo(nameof(SurfaceHolderCallback), nameof(Zoom), " direction is: " + direction.ToString());

            if (_Camera != null)
            {
                if (SupportsZoom())
                {
                    Logger.LogInfo(nameof(SurfaceHolderCallback), nameof(Zoom), "zoom is supported.");

                    switch (direction)
                    {
                    case ZoomDirection.In:
                        if (_Parameters.Zoom < _Parameters.MaxZoom)
                        {
                            _Parameters.Zoom++;
                            _Camera.SetParameters(_Parameters);
                        }
                        break;

                    case ZoomDirection.Out:
                        if (_Parameters.Zoom != 0)
                        {
                            _Parameters.Zoom--;
                            _Camera.SetParameters(_Parameters);
                        }
                        break;

                    default:
                        return;
                    }

                    Logger.LogInfo(nameof(SurfaceHolderCallback), nameof(Zoom), "Zoom set to: " + _Parameters.Zoom.ToString());
                }
            }
        }
Exemple #21
0
 public abstract void ZoomMove(string VideoSource, ZoomDirection Direction, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string Timeout);
Exemple #22
0
 protected bool IsZoomLimitReached(ZoomDirection zoomDirection)
 {
     return((zoomDirection == ZoomDirection.In && ZoomValue >= MaxZoom) ||
            (zoomDirection == ZoomDirection.Out && ZoomValue <= MinZoom));
 }
Exemple #23
0
 protected void Zoom(ZoomDirection direction, double amount, Point center)
 {
     ZoomCommand?.Execute(direction, amount, center);
 }
        private void ZoomTo(ZoomDirection direction, double amount, Point center, TransitionSpeed transitionSpeed)
        {
            var newLinearZoom = CalculateModifiedZoom(ViewportZoom, direction, amount);

            ZoomWithCenterTo(newLinearZoom, center, transitionSpeed);
        }
 private void OnMouseZoom(ZoomDirection direction, double amount, Point center)
 => ZoomTo(direction, amount, center, TransitionSpeed.Fast);
Exemple #26
0
 /// <inheritdoc cref="IMapFactory{TDrawingContext}.Zoom(LvcPoint, ZoomDirection)"/>
 public void Zoom(LvcPoint pivot, ZoomDirection direction)
 {
     // not implemented yet.
 }
Exemple #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomOnPointerView"/> command.
 /// </summary>
 /// <param name="pivot">The pivot.</param>
 /// <param name="direction">The direction.</param>
 public ZoomOnPointerView(LvcPoint pivot, ZoomDirection direction)
 {
     Pivot     = pivot;
     Direction = direction;
 }
 public EffectsBuilder Zoom(ZoomDirection direction)
 {
     return Add(EffectsList.Zoom, direction.ToString().ToLower());
 }
Exemple #29
0
 private void OnSeriesEnd(ZoomDirection direction)
 {
     var ev = direction == ZoomDirection.In ? StEvent.SceneZoomedIn : StEvent.SceneZoomedOut;
     UISharedRTClient.Instance.clienRt.SendStatsEvent(ev,
                                                      SessionInfo.Get().person.Id,
                                                      SessionInfo.Get().discussion.Id,
                                                      topicNavPanel.selectedTopic.Id,
                                                      DeviceType.Wpf);
 }
 public void SetZoomDirection(ZoomDirection t_zoomDirection)
 {
     m_zoomDirection = t_zoomDirection;
 }
Exemple #31
0
 public EffectsBuilder Zoom(ZoomDirection direction)
 {
     return(Add(EffectsList.Zoom, direction.ToString().ToLower()));
 }
 public ZoomedEventArgs(Geometries.Point screenPosition, ZoomDirection direction)
 {
     ScreenPosition = screenPosition;
     Direction      = direction;
 }
Exemple #33
0
        private ZoomDirection AdjustScale(ZoomDirection direction, ScaleTransform scale, bool mouseOver, Storyboard timer)
        {
            if (direction == ZoomDirection.In)
            {
                if (scale.ScaleX < 1.3)
                {
                    scale.ScaleX += 0.05;
                    scale.ScaleY += 0.05;
                }
                else if (mouseOver == false)
                {
                    direction = ZoomDirection.Out;
                }
            }
            else if (scale.ScaleX > 1.0)
            {
                scale.ScaleX -= 0.05;
                scale.ScaleY -= 0.05;
            }

            timer.Begin();
            return direction;
        }
Exemple #34
0
 private void Timer_Completed(object sender, EventArgs e)
 {
     Direction = AdjustScale(Direction, ScaleTransform, IsMouseOver, Timer);
 }
        public void Zoom(ZoomDirection direction, ZoomAmount amount)
        {
            PTZProfile profile = GetProfile();

            if (profile == null)
            {
                return;
            }
            if (typeof(PTZSpecV1) == profile.spec.GetType())
            {
                PTZSpecV1 spec     = (PTZSpecV1)profile.spec;
                string    url      = null;
                int       waitTime = 0;
                if (direction == ZoomDirection.In)
                {
                    if (amount == ZoomAmount.Short && !string.IsNullOrWhiteSpace(spec.zoomInShort))
                    {
                        waitTime = spec.ZoomRunTimeShortMs;
                        url      = spec.zoomInShort;
                    }
                    else if (amount == ZoomAmount.Medium && !string.IsNullOrWhiteSpace(spec.zoomInMedium))
                    {
                        waitTime = spec.ZoomRunTimeMediumMs;
                        url      = spec.zoomInMedium;
                    }
                    else if (amount == ZoomAmount.Long && !string.IsNullOrWhiteSpace(spec.zoomInLong))
                    {
                        waitTime = spec.ZoomRunTimeLongMs;
                        url      = spec.zoomInLong;
                    }
                }
                else if (direction == ZoomDirection.Out)
                {
                    if (amount == ZoomAmount.Short && !string.IsNullOrWhiteSpace(spec.zoomOutShort))
                    {
                        waitTime = spec.ZoomRunTimeShortMs;
                        url      = spec.zoomOutShort;
                    }
                    else if (amount == ZoomAmount.Medium && !string.IsNullOrWhiteSpace(spec.zoomOutMedium))
                    {
                        waitTime = spec.ZoomRunTimeMediumMs;
                        url      = spec.zoomOutMedium;
                    }
                    else if (amount == ZoomAmount.Long && !string.IsNullOrWhiteSpace(spec.zoomOutLong))
                    {
                        waitTime = spec.ZoomRunTimeLongMs;
                        url      = spec.zoomOutLong;
                    }
                }
                if (string.IsNullOrWhiteSpace(url))
                {
                    return;
                }

                SimpleProxy.GetData(urlBase + url, camSpec.ptz_username, camSpec.ptz_password);

                if (spec.SendStopCommandAfterZoom && !string.IsNullOrWhiteSpace(spec.stopZoom))
                {
                    Thread.Sleep(waitTime);
                    SimpleProxy.GetData(urlBase + spec.stopZoom, camSpec.ptz_username, camSpec.ptz_password);
                }
            }
        }