示例#1
0
        private async Task LoadFavSprite(bool heart)
        {
            await Task.Run(() =>
            {
                Bitmap spritesheet = heart ? Properties.Resources.heart_sprite : Properties.Resources.fav_sprite;
                int frameSize      = heart ? 400 : 256;
                lightFavSprite     = SpriteLoader.LoadFavSprite(spritesheet, frameSize);
                fadedFavSprite     = SpriteLoader.LoadFadedFavSprite(spritesheet, frameSize);
                darkFavSprite      = SpriteLoader.LoadDarkFavSprite(spritesheet, frameSize);
                favSprite          = lightFavSprite;
            });

            picFavourite.ResetScale();
            if (heart)
            {
                picFavourite.Size = new Size(48, 48);
            }
            else
            {
                picFavourite.Size = new Size(32, 32);
            }

            bool favourite = songInfoStream?.currentInfo?.song.favorite ?? false;

            picFavourite.Image = favourite ? favSprite.Frames[favSprite.Frames.Length - 1] : favSprite.Frames[0];

            ReloadScale();
        }
示例#2
0
        private async void LoadFavSprite()
        {
            heartFavSprite = Settings.Get <bool>(Setting.HeartFavSprite);
            await Task.Run(() =>
            {
                Bitmap spritesheet = heartFavSprite ? Properties.Resources.heart_sprite : Properties.Resources.fav_sprite;
                int frameSize      = heartFavSprite ? 400 : 256;
                lightFavSprite     = SpriteLoader.LoadFavSprite(spritesheet, frameSize);
                fadedFavSprite     = SpriteLoader.LoadFadedFavSprite(spritesheet, frameSize);
                darkFavSprite      = SpriteLoader.LoadDarkFavSprite(spritesheet, frameSize);
                favSprite          = lightFavSprite;
            });

            picFavourite.ResetScale();
            if (heartFavSprite)
            {
                picFavourite.Size     = new Size(48, 48);
                picFavourite.Location = new Point(-8, (panelRight.Height / 2) - 24);
            }
            else
            {
                picFavourite.Size     = new Size(32, 32);
                picFavourite.Location = new Point(0, (panelRight.Height / 2) - 16);
            }

            bool favourite = songInfoStream?.currentInfo?.song.favorite ?? false;

            picFavourite.Image = favourite ? favSprite.Frames[favSprite.Frames.Length - 1] : favSprite.Frames[0];

            ReloadScale();
        }
示例#3
0
        public MainForm()
        {
            InitializeComponent();
            contextMenu1.MenuItems.Add(new MenuItem("LISTEN.moe Desktop Client v" + Globals.VERSION.ToString())
            {
                Enabled = false
            });
            Settings.LoadSettings();
            //Write immediately after loading to flush any new default settings
            Settings.WriteSettings();

            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
            RawInput.RegisterDevice(HIDUsagePage.Generic, HIDUsage.Keyboard, RawInputDeviceFlags.InputSink, this.Handle);

            cts = new CancellationTokenSource();
            ct  = cts.Token;
#pragma warning disable CS4014
            CheckForUpdates(new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext()));
#pragma warning restore CS4014
            StartUpdateAutochecker();

            this.MouseWheel += Form1_MouseWheel;
            this.Icon        = Properties.Resources.icon;

            lblAlbum.Bounds = new Rectangle(58, 26, 321, 22);
            lblTitle.Bounds = new Rectangle(56, 5, 321, 43);
            lblTitle.Text   = "Connecting...";

            notifyIcon1.ContextMenu = contextMenu2;
            notifyIcon1.Icon        = Properties.Resources.icon;

            favSprite          = SpriteLoader.LoadFavSprite();
            fadedFavSprite     = SpriteLoader.LoadFadedFavSprite();
            picFavourite.Image = favSprite.Frames[0];

            RawInput.RegisterCallback(VirtualKeys.MediaPlayPause, async() =>
            {
                await TogglePlayback();
            });

            Connect();

            player = new WebStreamPlayer("https://listen.moe/stream");
            player.SetVisualiser(visualiser);
            player.Play();

            renderLoop = Task.Run(() =>
            {
                while (!ct.IsCancellationRequested)
                {
                    this.Invalidate();
                    Thread.Sleep(33);
                }
            });

            ReloadScale();
            ReloadSettings();
        }
示例#4
0
        public MainForm()
        {
            InitializeComponent();
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);

            centerPanel.MouseDown += Form1_MouseDown;
            centerPanel.MouseMove += Form1_MouseMove;
            centerPanel.MouseUp   += Form1_MouseUp;
            panelRight.MouseDown  += Form1_MouseDown;
            panelRight.MouseMove  += Form1_MouseMove;
            panelRight.MouseUp    += Form1_MouseUp;

            contextMenu1.MenuItems.Add(new MenuItem("LISTEN.moe Desktop Client v" + Globals.VERSION.ToString())
            {
                Enabled = false
            });
            Settings.LoadSettings();
            //Write immediately after loading to flush any new default settings
            Settings.WriteSettings();

            cts = new CancellationTokenSource();
            ct  = cts.Token;
#pragma warning disable CS4014
            CheckForUpdates(new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext()));
#pragma warning restore CS4014
            StartUpdateAutochecker();

            this.MouseWheel += Form1_MouseWheel;
            this.Icon        = Properties.Resources.icon;

            notifyIcon1.ContextMenu = contextMenu2;
            notifyIcon1.Icon        = Properties.Resources.icon;

            lightFavSprite     = SpriteLoader.LoadFavSprite();
            fadedFavSprite     = SpriteLoader.LoadFadedFavSprite();
            darkFavSprite      = SpriteLoader.LoadDarkFavSprite();
            favSprite          = lightFavSprite;
            picFavourite.Image = favSprite.Frames[0];

            if (Settings.Get <bool>("ThumbnailButton"))
            {
                button        = new ThumbnailToolBarButton(Properties.Resources.pause_ico, "Pause");
                button.Click += async(_, __) => await TogglePlayback();

                TaskbarManager.Instance.ThumbnailToolBars.AddButtons(this.Handle, button);
            }

            Connect();

            player = new WebStreamPlayer("https://listen.moe/stream");
            player.SetVisualiser(centerPanel.Visualiser);
            player.Play();

            renderLoop = Task.Run(() =>
            {
                while (!ct.IsCancellationRequested)
                {
                    centerPanel.Invalidate();
                    Thread.Sleep(33);
                }
            });

            ReloadScale();
            ReloadSettings();

            this.SizeChanged += MainForm_SizeChanged;
            UpdatePanelExcludedRegions();
        }