예제 #1
0
    public void OnInjectionFinished()
    {
        videoAreaLabel.HideByDisplay();
        if (!songMeta.Video.IsNullOrEmpty())
        {
            ShowVideoImage();
        }
        else if (!songMeta.Cover.IsNullOrEmpty())
        {
            ShowCoverImage();
        }
        else if (!songMeta.Background.IsNullOrEmpty())
        {
            ShowBackgroundImage();
        }

        // Init cover and background image
        if (!songMeta.Background.IsNullOrEmpty())
        {
            ImageManager.LoadSpriteFromUri(SongMetaUtils.GetBackgroundUri(songMeta), sprite => songBackgroundImage.style.backgroundImage = new StyleBackground(sprite));
        }

        // Init cover and background image
        if (!songMeta.Cover.IsNullOrEmpty())
        {
            ImageManager.LoadSpriteFromUri(SongMetaUtils.GetCoverUri(songMeta), sprite => songCoverImage.style.backgroundImage = new StyleBackground(sprite));
        }

        showVideoButton.RegisterCallbackButtonTriggered(() => ShowVideoImage());
        showBackgroundButton.RegisterCallbackButtonTriggered(() => ShowBackgroundImage());
        showCoverButton.RegisterCallbackButtonTriggered(() => ShowCoverImage());

        dragControl = injector
                      .WithRootVisualElement(videoImage)
                      .CreateAndInject <GeneralDragControl>();
        dragControl.AddListener(this);

        videoImage.RegisterCallback <PointerEnterEvent>(evt => cursorManager.SetCursorHorizontal());
        videoImage.RegisterCallback <PointerLeaveEvent>(evt => cursorManager.SetDefaultCursor());
    }