示例#1
0
        public App()
        {
            _frame = new Frame("Spotify", true, true, false);

            _spotify = new Spotify();

            _state = new Picture
            {
                Image    = Resources.Stop,
                AutoSize = true,
                Location = new Location(2, Frame.LCDSize.Height - Resources.Stop.Height - 2)
            };

            _track = new Marquee
            {
                Font         = new Font("Arial", 7.5f),
                Location     = new Location(0, 0),
                Size         = new Size(Frame.LCDSize.Width, 11),
                UseCache     = true,
                EndSteps     = 5,
                MarqueeStyle = MarqueeStyle.Visibility
            };

            _artist = new Marquee
            {
                Font         = new Font("Arial", 7.5f),
                Location     = new Location(0, 11),
                Size         = new Size(Frame.LCDSize.Width, 11),
                UseCache     = true,
                EndSteps     = 5,
                MarqueeStyle = MarqueeStyle.Visibility
            };

            _album = new Marquee
            {
                Font           = new Font("Arial", 7.5f, FontStyle.Bold),
                Location       = new Location(0, 22),
                Size           = new Size(Frame.LCDSize.Width, 11),
                Interval       = 500,
                StepSize       = 4,
                EndSteps       = 12,
                UseCache       = true,
                MarqueeStyle   = MarqueeStyle.Visibility,
                Run            = true,
                SyncedMarquees = { _artist, _track }
            };

            _playTime = new ProgressBar
            {
                Horizontal       = true,
                MinimumValue     = 0,
                MaximumValue     = 60,
                Value            = 50,
                Location         = new Location(Resources.Stop.Width + +4, Frame.LCDSize.Height - 8 - 2),
                Size             = new Size(Frame.LCDSize.Width - Resources.Stop.Width - 4 - 2, 8),
                ProgressBarStyle = ProgressBarStyle.Border
            };

            _frame.Components.Add(_state);
            _frame.Components.Add(_track);
            _frame.Components.Add(_artist);
            _frame.Components.Add(_album);
            _frame.Components.Add(_playTime);

            _spotify.AutoUpdate(600);

            _spotify.AvailabilityChanged += _spotify_AvailabilityChanged;
            _spotify.PlayStateChanged    += _spotify_PlayStateChanged;
            _spotify.PlayingTimeChanged  += _spotify_PlayingTimeChanged;
            _spotify.TrackChanged        += _spotify_TrackChanged;

            UpdateVisibility();

            if (!_spotify.IsAvailable)
            {
                return;
            }

            UpdateTrack();
            UpdatePlayTime();
            UpdateStatePicture();
        }