private void UpdateValues()
        {
            IMJCurPlaylistAutomation currentPlaylist      = MJ.GetCurPlaylist();
            IMJFileAutomation        currentTrack         = currentPlaylist.GetFile(currentPlaylist.Position);
            IMJPlaybackAutomation    currentPlaybackTrack = MJ.GetPlayback();

            // Update values
            if (currentPlaylist.Position == 0 && !currentPlaylist.Continuous)
            {
                m_PreviousTrackTextControl.Text = "-";
            }
            else
            {
                m_PreviousTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetPreviousFile()).Name;
            }
            m_CurrentTrackTextControl.Text = currentTrack.Name;
            if (!currentPlaylist.GetCanPlayNext() || (currentPlaylist.Position >= (currentPlaylist.GetNumberFiles() - 1) && !currentPlaylist.Continuous))
            {
                m_NextTrackTextControl.Text = "-";
            }
            else
            {
                m_NextTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetNextFile()).Name;
            }

            m_CurrentTrackProgressControl.Min     = 0;
            m_CurrentTrackProgressControl.Max     = currentTrack.Duration;
            m_CurrentTrackProgressControl.Current = currentPlaybackTrack.Position;

            m_CurrentTrackPositionTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentPlaybackTrack.Position)).ToString("g");
            m_CurrentTrackDurationTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentTrack.Duration)).ToString("g");

            if (m_RaisePriorityUntil > DateTime.Now)
            {
                if (!QvgaDevice.ForegroundApplet)
                {
                    QvgaDevice.ForegroundApplet = true;
                }
                m_UpdatePriority = UpdatePriorities.Alert;
            }
            else
            {
                if (QvgaDevice.ForegroundApplet)
                {
                    QvgaDevice.ForegroundApplet = false;
                }
                m_UpdatePriority = UpdatePriorities.Normal;
            }
        }
Example #2
0
        public bool Update(UpdatePriorities updatePriority = UpdatePriorities.Normal, UpdateStyles updateStyle = UpdateStyles.Async, bool avoidNotConnectedExceptions = true)
        {
            EnsureAttached();
            EnsureImageUpdaterNotNull();

            uint result = MethodsWrapper.UpdateBitmap(openByTypeContext.device, ImageUpdater.UnmanagedBitmapHeaderPointer, ((uint)updateStyle) | ((uint)updatePriority));

            switch (result)
            {
            case (uint)Errors.ERROR_SUCCESS:
                break;

            case (uint)Errors.ERROR_SERVICE_NOT_ACTIVE:
                throw new DeviceException(result, "Lglcd.Initialize() has not been called yet");

            case (uint)Errors.ERROR_INVALID_PARAMETER:
                throw new DeviceException(result, "Device handle is invalid or image is invalid");

            case (uint)Errors.ERROR_DEVICE_NOT_CONNECTED:
                // We try to avoid throwing this exception type because it happens really often
                if (avoidNotConnectedExceptions)
                {
                    return(false);
                }
                // Not connected means it has been usb-removed, that's why I don't use "detached"
                throw new DeviceException(result, "Device not connected");

            case (uint)Errors.ERROR_ACCESS_DENIED:
                throw new DeviceException(result, "Synchronous operation was not displayed on the LCD within the frame interval (30 ms). Error happens only with UpdateStyles.SyncComplete");

            default:
                throw new DeviceException(result, "Problems updating device image");
            }

            return(true);
        }
Example #3
0
        public bool Update(UpdatePriorities updatePriority = UpdatePriorities.Normal, UpdateStyles updateStyle = UpdateStyles.Async, bool avoidNotConnectedExceptions = true)
        {
            EnsureAttached();
            EnsureImageUpdaterNotNull();

            uint result = MethodsWrapper.UpdateBitmap(openByTypeContext.device, ImageUpdater.UnmanagedBitmapHeaderPointer, ((uint)updateStyle) | ((uint)updatePriority));
            switch (result)
            {
                case (uint)Errors.ERROR_SUCCESS:
                    break;
                case (uint)Errors.ERROR_SERVICE_NOT_ACTIVE:
                    throw new DeviceException(result, "Lglcd.Initialize() has not been called yet");
                case (uint)Errors.ERROR_INVALID_PARAMETER:
                    throw new DeviceException(result, "Device handle is invalid or image is invalid");
                case (uint)Errors.ERROR_DEVICE_NOT_CONNECTED:
                    // We try to avoid throwing this exception type because it happens really often
                    if (avoidNotConnectedExceptions)
                        return false;
                    // Not connected means it has been usb-removed, that's why I don't use "detached"
                    throw new DeviceException(result, "Device not connected");
                case (uint)Errors.ERROR_ACCESS_DENIED:
                    throw new DeviceException(result, "Synchronous operation was not displayed on the LCD within the frame interval (30 ms). Error happens only with UpdateStyles.SyncComplete");
                default:
                    throw new DeviceException(result, "Problems updating device image");
            }

            return true;
        }
        private void UpdateValues()
        {
            IMJCurPlaylistAutomation currentPlaylist = MJ.GetCurPlaylist();
            IMJFileAutomation currentTrack = currentPlaylist.GetFile(currentPlaylist.Position);
            IMJPlaybackAutomation currentPlaybackTrack = MJ.GetPlayback();

            // Update values
            if (currentPlaylist.Position == 0 && !currentPlaylist.Continuous)
                m_PreviousTrackTextControl.Text = "-";
            else
                m_PreviousTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetPreviousFile()).Name;
            m_CurrentTrackTextControl.Text = currentTrack.Name;
            if (!currentPlaylist.GetCanPlayNext() || (currentPlaylist.Position >= (currentPlaylist.GetNumberFiles() - 1) && !currentPlaylist.Continuous))
                m_NextTrackTextControl.Text = "-";
            else
                m_NextTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetNextFile()).Name;

            m_CurrentTrackProgressControl.Min = 0;
            m_CurrentTrackProgressControl.Max = currentTrack.Duration;
            m_CurrentTrackProgressControl.Current = currentPlaybackTrack.Position;

            m_CurrentTrackPositionTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentPlaybackTrack.Position)).ToString("g");
            m_CurrentTrackDurationTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentTrack.Duration)).ToString("g");

            if (m_RaisePriorityUntil > DateTime.Now)
            {
                if (!QvgaDevice.ForegroundApplet)
                    QvgaDevice.ForegroundApplet = true;
                m_UpdatePriority = UpdatePriorities.Alert;
            }
            else
            {
                if (QvgaDevice.ForegroundApplet)
                    QvgaDevice.ForegroundApplet = false;
                m_UpdatePriority = UpdatePriorities.Normal;
            }
        }