private IEnumerator resetZoom()
    {
        var controlSize  = control.Size;
        var screenSize   = control.GetManager().GetScreenSize();
        var animatedSize = new dfAnimatedVector2(control.Size, controlSize, 0.2f);

        if (controlSize.x >= screenSize.x - 10 || controlSize.y >= screenSize.y - 10)
        {
            animatedSize.EndValue = fitImage(screenSize.x * 0.75f, screenSize.y * 0.75f, control.Width, control.Height);
        }
        else
        {
            animatedSize.EndValue = fitImage(screenSize.x, screenSize.y, control.Width, control.Height);
        }

        var endPosition      = new Vector3(screenSize.x - animatedSize.EndValue.x, screenSize.y - animatedSize.EndValue.y, 0) * 0.5f;
        var animatedPosition = new dfAnimatedVector3(control.RelativePosition, endPosition, animatedSize.Length);
        var animatedRotation = new dfAnimatedQuaternion(control.transform.rotation, Quaternion.identity, animatedSize.Length);

        while (!animatedSize.IsDone)
        {
            control.Size               = animatedSize;
            control.RelativePosition   = animatedPosition;
            control.transform.rotation = animatedRotation;

            yield return(null);
        }
    }
	public IEnumerator OnDoubleTapGesture()
	{

		if( DisplayImage == null )
		{
			Debug.LogWarning( "The DisplayImage property is not configured, cannot select the image" );
			yield break;
		}

		var photo = ( (GameObject)Instantiate( DisplayImage.gameObject ) ).GetComponent<dfTextureSprite>();

		myImage.GetManager().AddControl( photo );

		photo.Texture = myImage.Texture;
		photo.Size = myImage.Size;
		photo.RelativePosition = myImage.GetAbsolutePosition();
		photo.transform.rotation = Quaternion.identity;
		photo.BringToFront();
		photo.Opacity = 1f;
		photo.IsVisible = true;

		var screenSize = myImage.GetManager().GetScreenSize();
		var fullSize = new Vector2( photo.Texture.width, photo.Texture.height );
		var displaySize = fitImage( screenSize.x * 0.75f, screenSize.y * 0.75f, fullSize.x, fullSize.y );
		var displayPosition = new Vector3( ( screenSize.x - displaySize.x ) * 0.5f, ( screenSize.y - displaySize.y ) * 0.5f );

		var animatedPosition = new dfAnimatedVector3( myImage.GetAbsolutePosition(), displayPosition, 0.2f );
		var animatedSize = new dfAnimatedVector2( myImage.Size, displaySize, 0.2f );

		while( !animatedPosition.IsDone || !animatedSize.IsDone )
		{

			photo.Size = animatedSize;
			photo.RelativePosition = animatedPosition;

			yield return null;

		}

	}
Exemple #3
0
    public IEnumerator OnDoubleTapGesture()
    {
        if (DisplayImage == null)
        {
            Debug.LogWarning("The DisplayImage property is not configured, cannot select the image");
            yield break;
        }

        var photo = ((GameObject)Instantiate(DisplayImage.gameObject)).GetComponent <dfTextureSprite>();

        myImage.GetManager().AddControl(photo);

        photo.Texture            = myImage.Texture;
        photo.Size               = myImage.Size;
        photo.RelativePosition   = myImage.GetAbsolutePosition();
        photo.transform.rotation = Quaternion.identity;
        photo.BringToFront();
        photo.Opacity   = 1f;
        photo.IsVisible = true;

        var screenSize      = myImage.GetManager().GetScreenSize();
        var fullSize        = new Vector2(photo.Texture.width, photo.Texture.height);
        var displaySize     = fitImage(screenSize.x * 0.75f, screenSize.y * 0.75f, fullSize.x, fullSize.y);
        var displayPosition = new Vector3((screenSize.x - displaySize.x) * 0.5f, (screenSize.y - displaySize.y) * 0.5f);

        var animatedPosition = new dfAnimatedVector3(myImage.GetAbsolutePosition(), displayPosition, 0.2f);
        var animatedSize     = new dfAnimatedVector2(myImage.Size, displaySize, 0.2f);

        while (!animatedPosition.IsDone || !animatedSize.IsDone)
        {
            photo.Size             = animatedSize;
            photo.RelativePosition = animatedPosition;

            yield return(null);
        }
    }
    private IEnumerator resetZoom()
    {
        var controlSize = control.Size;
        var screenSize = control.GetManager().GetScreenSize();
        var animatedSize = new dfAnimatedVector2( control.Size, controlSize, 0.2f );

        if( controlSize.x >= screenSize.x - 10 || controlSize.y >= screenSize.y - 10 )
        {
            animatedSize.EndValue = fitImage( screenSize.x * 0.75f, screenSize.y * 0.75f, control.Width, control.Height );
        }
        else
        {
            animatedSize.EndValue = fitImage( screenSize.x, screenSize.y, control.Width, control.Height );
        }

        var endPosition = new Vector3( screenSize.x - animatedSize.EndValue.x, screenSize.y - animatedSize.EndValue.y, 0 ) * 0.5f;
        var animatedPosition = new dfAnimatedVector3( control.RelativePosition, endPosition, animatedSize.Length );
        var animatedRotation = new dfAnimatedQuaternion( control.transform.rotation, Quaternion.identity, animatedSize.Length );

        while( !animatedSize.IsDone )
        {

            control.Size = animatedSize;
            control.RelativePosition = animatedPosition;
            control.transform.rotation = animatedRotation;

            yield return null;

        }
    }