예제 #1
0
            public ScrollView(List <libAppStart.App> appList, bool configEnabled)
            {
                // Get Data
                _appList      = appList;
                _configButton = configEnabled;

                // Init Labels
                _item1 = new LcdGdiText();
                _item2 = new LcdGdiText();
                _item3 = new LcdGdiText();

                _item1.Font = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Regular);
                _item2.Font = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Regular);
                _item3.Font = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Regular);

                _item1.Margin = new MarginF(10, 0, 0, 0);
                _item2.Margin = new MarginF(10, 11, 0, 0);
                _item3.Margin = new MarginF(10, 22, 0, 0);

                // Fill In Data
                FillData(0);

                // Init Images
                _imgSelector        = new LcdGdiImage(Properties.Resources.ArrowRight_Inverted);
                _imgSelector.Margin = new MarginF(0, 0, 0, 0);

                _imgControls0        = new LcdGdiImage(Properties.Resources.BottomScreenCommand_Up);
                _imgControls0.Margin = new MarginF(0, 33, 0, 0);
                _imgControls1        = new LcdGdiImage(Properties.Resources.BottomScreenCommand_Down);
                _imgControls1.Margin = new MarginF(40, 33, 0, 0);
                _imgControls2        = new LcdGdiImage(Properties.Resources.BottomScreenCommand_OK);
                _imgControls2.Margin = new MarginF(80, 33, 0, 0);

                _imgControls3 = _4thButton(_configButton);
            }
예제 #2
0
        private void createColor()
        {
            controlsGdi_[0] = new LcdGdiText("Start/Pauze", font3_);
            // controlsGdi[0].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[0].Margin = new MarginF(5, 5, 5, 0);

            controlsGdi_[0].HorizontalAlignment = LcdGdiHorizontalAlignment.Center;

            controlsGdi_[1] = new LcdGdiText("Play next song", font3_);
            controlsGdi_[1].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[1].Margin = new MarginF(5, 30, 5, 0);

            controlsGdi_[2] = new LcdGdiText("Play previous song", font3_);
            controlsGdi_[2].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[2].Margin = new MarginF(5, 55, 5, 0);

            controlsGdi_[3] = new LcdGdiText("Stop playing", font3_);
            controlsGdi_[3].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[3].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            controlsGdi_[3].Margin = new MarginF(5, 80, 0, 0);

            controlsGdi_[4] = new LcdGdiText("Restart song", font3_);
            controlsGdi_[4].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[4].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            controlsGdi_[4].Margin = new MarginF(5, 105, 0, 0);

            this.Children.Add(backgroundGdi_);
            this.Children.Add(controlsGdi_[0]);
            this.Children.Add(controlsGdi_[1]);
            this.Children.Add(controlsGdi_[2]);
            this.Children.Add(controlsGdi_[3]);
            this.Children.Add(controlsGdi_[4]);
        }
예제 #3
0
        private void createMono()
        {
            controlsGdi_[0] = new LcdGdiText("Start/Pauze", font2_);
            controlsGdi_[0].HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            controlsGdi_[0].Margin = new MarginF(-2, -0, 0, 0);

            controlsGdi_[1] = new LcdGdiText("Play next song", font2_);
            controlsGdi_[1].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[1].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            controlsGdi_[1].Margin = new MarginF(-2, 8, 0, 0);

            controlsGdi_[2] = new LcdGdiText("Play previous song", font2_);
            controlsGdi_[2].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[2].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            controlsGdi_[2].Margin = new MarginF(-2, 16, 0, 0);

            controlsGdi_[3] = new LcdGdiText("Stop playing", font2_);
            controlsGdi_[3].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[3].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            controlsGdi_[3].Margin = new MarginF(-2, 24, 0, 0);

            controlsGdi_[4] = new LcdGdiText("Restart song", font2_);
            controlsGdi_[4].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            controlsGdi_[4].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            controlsGdi_[4].Margin = new MarginF(-2, 32, 0, 0);

            this.Children.Add(controlsGdi_[0]);
            this.Children.Add(controlsGdi_[1]);
            this.Children.Add(controlsGdi_[2]);
            this.Children.Add(controlsGdi_[3]);
            this.Children.Add(controlsGdi_[4]);
        }
        private void createMono()
        {
            settingsGdi_[0] = new LcdGdiText("shuffle: " + shuffle_, font2_);
            settingsGdi_[0].HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            settingsGdi_[0].Margin = new MarginF(-2, 0, 0, 0);

            settingsGdi_[1] = new LcdGdiText("Auto DJ: " + autoDJ_, font2_);
            settingsGdi_[1].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            settingsGdi_[1].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            settingsGdi_[1].Margin = new MarginF(-2, 10, 0, 0);

            settingsGdi_[2] = new LcdGdiText("Equalizer: " + equaliser_, font2_);
            settingsGdi_[2].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            settingsGdi_[2].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            settingsGdi_[2].Margin = new MarginF(-2, 20, 0, 0);

            settingsGdi_[3] = new LcdGdiText("Repeat: " + repeat_, font2_);
            settingsGdi_[3].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            settingsGdi_[3].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            settingsGdi_[3].Margin = new MarginF(-2, 30, 0, 0);

            this.Children.Add(settingsGdi_[0]);
            this.Children.Add(settingsGdi_[1]);
            this.Children.Add(settingsGdi_[2]);
            this.Children.Add(settingsGdi_[3]);
        }
        private void createMono()
        {
            mainTextGdi_ = new LcdGdiText("", font2_);
            mainTextGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            mainTextGdi_.Margin = new MarginF(-2, -1, 0, 0);

            this.Children.Add(mainTextGdi_);
        }
        private void createColor()
        {
            mainTextGdi_ = new LcdGdiText("", mainTextFont_);
            mainTextGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            mainTextGdi_.Margin = new MarginF(5, 10, 5, 0);

            secondTextGdi_ = new LcdGdiText("", font4_);
            secondTextGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            secondTextGdi_.Margin = new MarginF(5, 70, 5, 0);

            thirdTextGdi_ = new LcdGdiText("", font4_);
            thirdTextGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            thirdTextGdi_.Margin = new MarginF(5, 125, 5, 0);

            this.Children.Add(mainTextGdi_);
            this.Children.Add(secondTextGdi_);
            this.Children.Add(thirdTextGdi_);
        }
예제 #7
0
            public MessageBox_YesNo(string title, string message)
            {
                _title        = new LcdGdiText();
                _title.Font   = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Bold);
                _title.Margin = new MarginF(0, 0, 0, 0);
                _title.Text   = title;

                _message        = new LcdGdiText();
                _message.Font   = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Regular);
                _message.Margin = new MarginF(0, 10, 0, 0);
                _message.Text   = message;

                _controlYes        = new LcdGdiImage(Properties.Resources.BottomScreenCommand_OK);
                _controlYes.Margin = new MarginF(0, 33, 0, 0);

                _controlNo        = new LcdGdiImage(Properties.Resources.BottomScreenCommand_Cancel);
                _controlNo.Margin = new MarginF(120, 33, 0, 0);
            }
예제 #8
0
        // Update the Now Playing pagetext fields
        public void updateTextFields(LcdDevice device, LcdGdiPage page, LcdGdiScrollViewer scrollViewer,
                                     LcdGdiScrollViewer scrollViewer2, LcdGdiScrollViewer scrollViewer3, LcdGdiText playTime)
        {
            LcdGdiText track = (LcdGdiText)scrollViewer.Child;

            track.Text = m_playerDetails.currentTrack;


            LcdGdiText album = (LcdGdiText)scrollViewer2.Child;

            album.Text = m_playerDetails.currentAlbum;

            LcdGdiText artist = (LcdGdiText)scrollViewer3.Child;

            artist.Text = m_playerDetails.currentArtist;

            playTime.Text = m_playerDetails.playTime;
        }
예제 #9
0
            public static LcdGdiPage GetPage(LcdDevice device)
            {
                LcdGdiPage page = new LcdGdiPage(device);

                /*LcdGdiText title = new LcdGdiText();
                 * title.Text = "Config Mode";
                 * title.Font = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Bold);
                 * title.Margin = new MarginF(0, 0, 0, 0);*/

                LcdGdiText message = new LcdGdiText();

                message.Font   = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Regular);
                message.Margin = new MarginF(0, 3, 0, 0);
                message.Text   = "G15 AppStart is currently locked.\nTo continue operation\nclose Config application.";

                page.Children.AddRange(new LcdGdiObject[] { /*title,*/ message });

                return(page);
            }
        private void createColor()
        {
            settingsGdi_[0] = new LcdGdiText("shuffle: " + shuffle_, font3_);
            settingsGdi_[0].HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            settingsGdi_[0].Margin = new MarginF(5, 5, 5, 0);

            settingsGdi_[1] = new LcdGdiText("Auto DJ: " + autoDJ_, font3_);
            settingsGdi_[1].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            settingsGdi_[1].Margin = new MarginF(5, 30, 5, 0);

            settingsGdi_[2] = new LcdGdiText("Equalizer: " + equaliser_, font3_);
            settingsGdi_[2].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            settingsGdi_[2].Margin = new MarginF(5, 55, 5, 0);

            settingsGdi_[3] = new LcdGdiText("Repeat: " + repeat_, font3_);
            settingsGdi_[3].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            settingsGdi_[3].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            settingsGdi_[3].Margin = new MarginF(5, 80, 0, 0);

            settingsGdi_[4] = new LcdGdiText("Volume", font3_);
            settingsGdi_[4].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            settingsGdi_[4].VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            settingsGdi_[4].Margin = new MarginF(5, 105, 0, 0);

            volumeBarGdi_         = new LcdGdiProgressBar();
            volumeBarGdi_.Minimum = 0;
            volumeBarGdi_.Maximum = 100;
            volumeBarGdi_.Size    = new SizeF(310, 20);
            volumeBarGdi_.Margin  = new MarginF(5, 150, 5, 0);

            this.Children.Add(backgroundGdi_);
            this.Children.Add(settingsGdi_[0]);
            this.Children.Add(settingsGdi_[1]);
            this.Children.Add(settingsGdi_[2]);
            this.Children.Add(settingsGdi_[3]);
            this.Children.Add(settingsGdi_[4]);
            this.Children.Add(volumeBarGdi_);
        }
예제 #11
0
        // Update the Now Playing pagetext fields
        public void updateTextFields(LcdDevice device, LcdGdiPage page, LcdGdiScrollViewer scrollViewer,
            LcdGdiScrollViewer scrollViewer2, LcdGdiScrollViewer scrollViewer3, LcdGdiText playTime)
        {
            LcdGdiText track = (LcdGdiText)scrollViewer.Child;
            track.Text = m_playerDetails.currentTrack;

            LcdGdiText album = (LcdGdiText)scrollViewer2.Child;
            album.Text = m_playerDetails.currentAlbum;

            LcdGdiText artist = (LcdGdiText)scrollViewer3.Child;
            artist.Text = m_playerDetails.currentArtist;

            playTime.Text = m_playerDetails.playTime;
        }
        private void createMono()
        {
            titleGdi_ = new LcdGdiText(this.title_, font_);
            titleGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            titleGdi_.Margin = new MarginF(-2, -1, 0, 0);

            artistGdi_ = new LcdGdiText(this.artist_, font_);
            artistGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            artistGdi_.VerticalAlignment   = LcdGdiVerticalAlignment.Top;
            artistGdi_.Margin = new MarginF(-2, 12, 0, 0);

            positionGdi_ = new LcdGdiText(Conversions.timetoString(this.position_), font2_);
            positionGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            positionGdi_.Margin = new MarginF(10, 26, 0, 0);

            ratingGdi_ = new LcdGdiText("", font2_);
            ratingGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            ratingGdi_.Margin = new MarginF(0, 26, 0, 0);

            if (this.rating_ != 0)
            {
                ratingGdi_.Text = this.rating_.ToString() + " / 5";
            }
            else
            {
                ratingGdi_.Text = "";
            }

            durationGdi_ = new LcdGdiText(Conversions.timetoString(this.duration_), font2_);
            durationGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Right;
            durationGdi_.Margin = new MarginF(0, 26, 13, 0);

            progressBarGdi_         = new LcdGdiProgressBar();
            progressBarGdi_.Size    = new SizeF(136, 5);
            progressBarGdi_.Margin  = new MarginF(12, 38, 0, 0);
            progressBarGdi_.Minimum = 0;
            progressBarGdi_.Maximum = 100;

            titleScroll_                     = new LcdGdiScrollViewer(titleGdi_);
            titleScroll_.AutoScrollX         = true;
            titleScroll_.AutoScrollY         = false;
            titleScroll_.AutoScrollSpeedY    = 0;
            titleScroll_.AutoScrollSpeedX    = 10;
            titleScroll_.HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch;
            titleScroll_.VerticalAlignment   = LcdGdiVerticalAlignment.Top;

            artistScroll_                     = new LcdGdiScrollViewer(artistGdi_);
            artistScroll_.AutoScrollY         = false;
            artistScroll_.AutoScrollX         = true;
            artistScroll_.AutoScrollSpeedY    = 0;
            artistScroll_.AutoScrollSpeedX    = 10;
            artistScroll_.HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch;
            artistScroll_.VerticalAlignment   = LcdGdiVerticalAlignment.Top;

            this.Children.Add(titleGdi_);
            this.Children.Add(artistGdi_);
            this.Children.Add(titleScroll_);
            this.Children.Add(artistScroll_);
            this.Children.Add(positionGdi_);
            this.Children.Add(ratingGdi_);
            this.Children.Add(durationGdi_);
            this.Children.Add(progressBarGdi_);
        }
        private void createColor()
        {
            artistGdi_ = new LcdGdiText(this.artist_, font3_);
            artistGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            artistGdi_.Margin = new MarginF(5, 5, 5, 0);

            titleGdi_ = new LcdGdiText(this.title_, font3_);
            titleGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            titleGdi_.Margin = new MarginF(5, 30, 5, 0);

            albumGdi_ = new LcdGdiText(this.album_, font3_);
            albumGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            albumGdi_.Margin = new MarginF(5, 55, 5, 0);

            positionGdi_ = new LcdGdiText(Conversions.timetoString(this.position_), font4_);
            positionGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
            positionGdi_.Margin = new MarginF(5, 105, 0, 0);

            durationGdi_ = new LcdGdiText(Conversions.timetoString(this.duration_), font4_);
            durationGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Right;
            durationGdi_.Margin = new MarginF(0, 105, 5, 0);

            artworkGdi_ = new LcdGdiImage(Conversions.Base64ToImage(artwork_));
            artworkGdi_.HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
            artworkGdi_.Size   = new SizeF(130, 130);
            artworkGdi_.Margin = new MarginF(0, 105, 0, 0);

            progressBarGdi_         = new LcdGdiProgressBar();
            progressBarGdi_.Minimum = 0;
            progressBarGdi_.Maximum = 100;
            progressBarGdi_.Size    = new SizeF(310, 20);
            progressBarGdi_.Margin  = new MarginF(5, 80, 5, 0);

            titleScroll_                     = new LcdGdiScrollViewer(titleGdi_);
            titleScroll_.AutoScrollX         = true;
            titleScroll_.AutoScrollY         = false;
            titleScroll_.AutoScrollSpeedY    = 0;
            titleScroll_.AutoScrollSpeedX    = 10;
            titleScroll_.HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch;
            titleScroll_.VerticalAlignment   = LcdGdiVerticalAlignment.Top;

            artistScroll_                     = new LcdGdiScrollViewer(artistGdi_);
            artistScroll_.AutoScrollY         = false;
            artistScroll_.AutoScrollX         = true;
            artistScroll_.AutoScrollSpeedY    = 0;
            artistScroll_.AutoScrollSpeedX    = 10;
            artistScroll_.HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch;
            artistScroll_.VerticalAlignment   = LcdGdiVerticalAlignment.Top;

            albumScroll_                     = new LcdGdiScrollViewer(albumGdi_);
            albumScroll_.AutoScrollY         = false;
            albumScroll_.AutoScrollX         = true;
            albumScroll_.AutoScrollSpeedY    = 0;
            albumScroll_.AutoScrollSpeedX    = 10;
            albumScroll_.HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch;
            albumScroll_.VerticalAlignment   = LcdGdiVerticalAlignment.Top;

            fullStarImage_  = (Image)Resource.star_rating_full;
            halfStarImage_  = (Image)Resource.star_rating_half;
            emptyStarImage_ = (Image)Resource.star_rating_empty;
            emptyImage_     = (Image)Resource.empty;

            this.Children.Add(backgroundGdi_);
            this.Children.Add(titleGdi_);
            this.Children.Add(titleScroll_);
            this.Children.Add(artistGdi_);
            this.Children.Add(artistScroll_);
            this.Children.Add(positionGdi_);
            this.Children.Add(durationGdi_);
            this.Children.Add(progressBarGdi_);
            this.Children.Add(albumGdi_);
            this.Children.Add(albumScroll_);
            this.Children.Add(artworkGdi_);

            ratingColorGdi_ = new LcdGdiImage[5];

            float tempRating = this.rating_;

            for (int i = 0; i < 5; i++)
            {
                if (this.rating_ != 0)
                {
                    if (tempRating - 1 >= 0)
                    {
                        ratingColorGdi_[i] = new LcdGdiImage(fullStarImage_);
                        tempRating--;
                    }

                    else if (tempRating - 0.5f == 0)
                    {
                        ratingColorGdi_[i] = new LcdGdiImage(halfStarImage_);
                        tempRating        -= 0.5f;
                    }

                    else
                    {
                        ratingColorGdi_[i] = new LcdGdiImage(emptyStarImage_);
                    }
                }
                else
                {
                    ratingColorGdi_[i] = new LcdGdiImage(emptyStarImage_);
                }
                ratingColorGdi_[i].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
                ratingColorGdi_[i].Margin = new MarginF((18 * i) + 5, 215, 0, 0);
                this.Children.Add(ratingColorGdi_[i]);
            }
        }
        /// <summary>
        /// Event handler for button press on a device.
        /// </summary>
        /// <param name="sender">Device on which button was pressed</param>
        /// <param name="e">Button event arguments</param>
        private static void DeviceSoftButtonsChanged(object sender, LcdSoftButtonsEventArgs e)
        {
            LcdDeviceMonochrome device = (LcdDeviceMonochrome)sender;

            // First button
            if ((e.SoftButtons & LcdSoftButtons.Button0) == LcdSoftButtons.Button0)
            {
                if (button0Up)
                {
                    button0Up = false;

                    if (device.CurrentPage == device.Pages[0])
                    {
                        DecrementListState(ref devicesList);
                    }
                    else if (device.CurrentPage == device.Pages[2])
                    {
                        DecrementListState(ref entriesList);
                    }
                }
            }
            else
            {
                button0Up = true;
            }

            // Second button
            if ((e.SoftButtons & LcdSoftButtons.Button1) == LcdSoftButtons.Button1)
            {
                if (button1Up)
                {
                    button1Up = false;

                    if (device.CurrentPage == device.Pages[0])
                    {
                        IncrementListState(ref devicesList, 3);
                    }
                    else if (device.CurrentPage == device.Pages[2])
                    {
                        IncrementListState(ref entriesList, 3);
                    }
                }
            }
            else
            {
                button1Up = true;
            }

            // Third button
            if ((e.SoftButtons & LcdSoftButtons.Button2) == LcdSoftButtons.Button2)
            {
                if (button2Up)
                {
                    button2Up = false;

                    if (device.CurrentPage == device.Pages[0])
                    {
                        lock (devicesList.Lock)
                        {
                            if (devicesList.Items != null && devicesList.Items.Length > 0)
                            {
                                actions.Add(Action.Connect);
                                device.Pages[1].SetAsCurrentDevicePage();
                            }
                        }
                    }
                    else if (device.CurrentPage == device.Pages[1] && ccid == null)
                    {
                        actions.Add(Action.Connect);
                    }
                    else if (device.CurrentPage == device.Pages[2])
                    {
                        lock (entriesList.Lock)
                        {
                            if (entryCode.HasValue && !entryCode.Value.Credential.Name.Equals(entriesList.Items[entriesList.Selected].Name))
                            {
                                // Reset code object
                                entryCode = null;

                                // Reset text elements
                                LcdGdiPage         page       = (LcdGdiPage)device.Pages[3];
                                LcdGdiScrollViewer scrollView = (LcdGdiScrollViewer)page.Children[4];
                                LcdGdiText         textName   = (LcdGdiText)scrollView.Child;
                                LcdGdiText         textCode   = (LcdGdiText)page.Children[5];
                                textName.Text = null;
                                textCode.Text = null;
                            }
                        }

                        device.Pages[3].SetAsCurrentDevicePage();
                    }
                    else if (device.CurrentPage == device.Pages[3])
                    {
                        lock (entriesList.Lock)
                        {
                            LcdGdiPage  page        = (LcdGdiPage)device.Pages[3];
                            LcdGdiImage refreshIcon = (LcdGdiImage)page.Children[0];

                            if (refreshIcon.IsVisible)
                            {
                                entryCode = null;
                            }
                        }
                    }
                }
            }
            else
            {
                button2Up = true;
            }

            // Fourth button
            if ((e.SoftButtons & LcdSoftButtons.Button3) == LcdSoftButtons.Button3)
            {
                if (button3Up)
                {
                    button3Up = false;

                    if (device.CurrentPage == device.Pages[1] || device.CurrentPage == device.Pages[2])
                    {
                        device.Pages[0].SetAsCurrentDevicePage();
                    }
                    else if (device.CurrentPage == device.Pages[3])
                    {
                        device.Pages[2].SetAsCurrentDevicePage();
                    }
                }
            }
            else
            {
                button3Up = true;
            }
        }
        /// <summary>
        /// Updates the code page before rendering it.
        /// </summary>
        /// <param name="sender">Page being updated</param>
        /// <param name="e">Update event arguments</param>
        private static void UpdateEntryPage(object sender, UpdateEventArgs e)
        {
            LcdGdiPage         page        = (LcdGdiPage)sender;
            LcdGdiImage        refreshIcon = (LcdGdiImage)page.Children[0];
            LcdGdiProgressBar  progressBar = (LcdGdiProgressBar)page.Children[2];
            LcdGdiScrollViewer scrollView  = (LcdGdiScrollViewer)page.Children[4];
            LcdGdiText         textName    = (LcdGdiText)scrollView.Child;
            LcdGdiText         textCode    = (LcdGdiText)page.Children[5];

            lock (entriesList.Lock)
            {
                progressBar.IsVisible = false;

                if (!entryCodeRequested && !entryCode.HasValue)
                {
                    textName.Text      = entriesList.Items[entriesList.Selected].Name;
                    entryCodeRequested = true;

                    if (entriesList.Items[entriesList.Selected].Touch)
                    {
                        textCode.Text         = "Touch your YubiKey...";
                        refreshIcon.IsVisible = false;
                        return;
                    }
                }
                entryCodeRequested = false;

                DateTime time      = DateTime.UtcNow;
                Int32    timestamp = (Int32)(time.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                if (!entryCode.HasValue || entryCode.Value.ValidTo != 0 && entryCode.Value.ValidTo < timestamp && entriesList.Items[entriesList.Selected].Type == OATHController.Type.TOTP && !entriesList.Items[entriesList.Selected].Touch)
                {
                    try
                    {
                        entryCode     = oath.Calculate(entriesList.Items[entriesList.Selected], time);
                        textCode.Text = entryCode.Value.Value;
                    }
                    catch (UnexpectedResponseException ex)
                    {
                        entryCode = new OATHController.Code(); // Hack: Set empty code object to prevent code regen
                        if (ex.SW == APDUResponse.StatusWord.AUTH_REQUIRED)
                        {
                            textCode.Text = "Touch timeout.";
                        }
                        else
                        {
                            textCode.Text = "Error: " + ex.SW.ToString();
                        }
                        refreshIcon.IsVisible = true;
                        return;
                    }
                }

                if (entriesList.Items[entriesList.Selected].Type == OATHController.Type.TOTP && entryCode.HasValue && entryCode.Value.ValidTo != 0)
                {
                    if (entryCode.Value.ValidTo > timestamp)
                    {
                        progressBar.IsVisible = true;
                        progressBar.Value     = (int)(((float)(entryCode.Value.ValidTo - timestamp) / entriesList.Items[entriesList.Selected].Period) * 100);
                    }
                    else if (entriesList.Items[entriesList.Selected].Touch)
                    {
                        textCode.Text         = "Code expired.";
                        progressBar.IsVisible = false;
                        refreshIcon.IsVisible = true;
                    }
                }
            }
        }
        /// <summary>
        /// Updates the connection status page before rendering it.
        /// </summary>
        /// <param name="sender">Page being updated</param>
        /// <param name="e">Update event arguments</param>
        private static void UpdateConnectionStatusPage(object sender, UpdateEventArgs e)
        {
            LcdGdiPage         page             = (LcdGdiPage)sender;
            LcdGdiImage        refreshButton    = (LcdGdiImage)page.Children[0];
            LcdGdiImage        backButton       = (LcdGdiImage)page.Children[1];
            LcdGdiScrollViewer deviceScrollView = (LcdGdiScrollViewer)page.Children[3];
            LcdGdiText         deviceText       = (LcdGdiText)deviceScrollView.Child;
            LcdGdiText         statusText       = (LcdGdiText)page.Children[4];

            if (oath != null && oath.HasChallenge())
            {
                using (var dialog = new PasswordDialog())
                {
                    dialog.OKButton.Click += (_sender, _e) =>
                    {
                        try
                        {
                            oath.Validate(dialog.PasswordBox.Text);
                            statusText.Text = "Connected.";
                            CreateTimer("ConnectionStatusSwitchPage", 2);
                        }
                        catch (UnexpectedResponseException)
                        {
                            statusText.Text = "Invalid password, try again...";
                        }
                        dialog.Close();
                    };
                    dialog.CancelButton.Click += (_sender, _e) =>
                    {
                        oath = null;
                        ccid = null;
                        page.Device.Pages[0].SetAsCurrentDevicePage();
                        dialog.Close();
                    };
                    dialog.ShowDialog();
                }
            }

            if (CheckTimer("ConnectionStatusSwitchPage"))
            {
                // Update list items
                lock (entriesList.Lock)
                {
                    entriesList.Items   = oath.List();
                    entriesList.Changed = true;

                    // Calculate all keys and update touch info
                    var codes = oath.CalculateAll();
                    foreach (var code in codes)
                    {
                        if (code.Credential.Touch)
                        {
                            var idx = entriesList.Items.FindIndex(item => item.Name.Equals(code.Credential.Name));
                            if (idx != -1)
                            {
                                var item = entriesList.Items[idx];
                                item.Touch             = code.Credential.Touch;
                                entriesList.Items[idx] = item;
                            }
                        }
                    }
                }

                // Switch page
                page.Device.Pages[2].SetAsCurrentDevicePage();
                return;
            }

            lock (devicesList.Lock)
            {
                while (actions.TryTake(out Action a))
                {
                    switch (a)
                    {
                    case Action.Connect:
                        try
                        {
                            ccid                    = CCIDDriver.OpenDevice(devicesList.Items[devicesList.Selected]);
                            oath                    = new OATHController(ccid);
                            deviceText.Text         = devicesList.Items[devicesList.Selected];
                            backButton.IsVisible    = false;
                            refreshButton.IsVisible = false;

                            if (oath.HasChallenge())
                            {
                                statusText.Text = "Waiting for password...";
                            }
                            else
                            {
                                statusText.Text = "Connected.";
                                CreateTimer("ConnectionStatusSwitchPage", 2);
                            }
                        }
                        catch (ConnectionException)
                        {
                            oath                    = null;
                            ccid                    = null;
                            deviceText.Text         = devicesList.Items[devicesList.Selected];
                            statusText.Text         = "Unable to connect.";
                            backButton.IsVisible    = true;
                            refreshButton.IsVisible = true;
                        }
                        break;
                    }
                }
            }
        }