示例#1
0
        private static void ThreadActivateTheme(object param)
        {
            if (!(param is ThreadParams))
            {
                Log.Error("param at ThreadActivateTheme has wrong type");
                return;
            }
            ThreadParams threadParams = (ThreadParams)param;

            GUIWaitCursor.Show();

            // Need to initialize fonts and references if they change based on the theme.
            // Check current theme.
            bool initFonts      = (GUIGraphicsContext.HasThemeSpecificSkinFile(@"\fonts.xml"));
            bool initReferences = (GUIGraphicsContext.HasThemeSpecificSkinFile(@"\references.xml"));

            // Change the theme and save this new setting.
            SetTheme(threadParams._themeName);
            SkinSettings.Save();

            // Check new theme.
            initFonts      = initFonts || GUIGraphicsContext.HasThemeSpecificSkinFile(@"\fonts.xml");
            initReferences = initReferences || GUIGraphicsContext.HasThemeSpecificSkinFile(@"\references.xml");

            // Reset fonts if needed.
            if (initFonts)
            {
                // Reinitializing the device while changing fonts freezes the UI.
                // Add some sleep() to present the wait cursor animation for at least some user feedback.
                Thread.Sleep(500);
                GUIFontManager.ClearFontCache();
                GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
                GUIFontManager.InitializeDeviceObjects();
                Thread.Sleep(500);
            }

            // Force a reload of the control references if needed.
            if (initReferences)
            {
                GUIControlFactory.ClearReferences();
            }

            // Reactivate the current window and refocus on the control used to change the theme.
            // This applies the new theme to the current window immediately.
            GUIWindowManager.ResetAllControls();
            GUIWindowManager.SendThreadCallbackAndWait((p1, p2, p3) =>
            {
                GUIWindowManager.ActivateWindow(p1, true, true, (int)p3);
                return(0);
            }, GUIWindowManager.ActiveWindow, 0, threadParams._focusControlId);

            GUIWaitCursor.Hide();
        }
示例#2
0
        public override void OnAction(Action action)
        {
            if (action.wID == Action.ActionType.ACTION_HOME || action.wID == Action.ActionType.ACTION_SWITCH_HOME)
            {
                return;
            }

            if ((DateTime.Now.Ticks / 10000) - m_dwLastTime > 500)
            {
                m_iSpeed  = 1;
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
            }
            m_dwLastTime = (DateTime.Now.Ticks / 10000);

            int x, y;

            if (m_iControl == (int)Controls.CONTROL_TOP_LEFT)
            {
                x = GUIGraphicsContext.OverScanLeft;
                y = GUIGraphicsContext.OverScanTop;
            }
            else if (m_iControl == (int)Controls.CONTROL_BOTTOM_RIGHT)
            {
                x = GUIGraphicsContext.OverScanWidth + GUIGraphicsContext.OverScanLeft;
                y = GUIGraphicsContext.OverScanHeight + GUIGraphicsContext.OverScanTop;
            }
            else if (m_iControl == (int)Controls.CONTROL_SUBTITLES)
            {
                x = 0;
                y = GUIGraphicsContext.Subtitles;
            }
            else if (m_iControl == (int)Controls.CONTROL_OSD)
            {
                x = 0;
                y = (GUIGraphicsContext.Height + GUIGraphicsContext.OSDOffset);
            }
            else // (m_iControl == (int)Controls.CONTROL_PIXEL_RATIO)
            {
                y = 256;
                x = (int)(256.0f / GUIGraphicsContext.PixelRatio);
            }

            float fPixelRatio = GUIGraphicsContext.PixelRatio;

            if (m_iSpeed > 10)
            {
                m_iSpeed = 10; // Speed limit for accellerated cursors
            }

            switch (action.wID)
            {
            case Action.ActionType.ACTION_PREVIOUS_MENU:
            {
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            case Action.ActionType.ACTION_MOVE_LEFT:
            {
                if (m_iCountL == 0)
                {
                    m_iSpeed = 1;
                }
                x -= m_iSpeed;
                m_iCountL++;
                if (m_iCountL > 5 && m_iSpeed < 10)
                {
                    m_iSpeed += 1;
                    m_iCountL = 1;
                }
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountR = 0;
                if (m_iControl == (int)Controls.CONTROL_PIXEL_RATIO)
                {
                    fPixelRatio -= 0.01f;
                }
            }
            break;

            case Action.ActionType.ACTION_MOVE_RIGHT:
            {
                if (m_iCountR == 0)
                {
                    m_iSpeed = 1;
                }
                x += m_iSpeed;
                m_iCountR++;
                if (m_iCountR > 5 && m_iSpeed < 10)
                {
                    m_iSpeed += 1;
                    m_iCountR = 1;
                }
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
                if (m_iControl == (int)Controls.CONTROL_PIXEL_RATIO)
                {
                    fPixelRatio += 0.01f;
                }
            }
            break;

            case Action.ActionType.ACTION_MOVE_UP:
            {
                if (m_iCountU == 0)
                {
                    m_iSpeed = 1;
                }
                y -= m_iSpeed;
                m_iCountU++;
                if (m_iCountU > 5 && m_iSpeed < 10)
                {
                    m_iSpeed += 1;
                    m_iCountU = 1;
                }
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
                if (m_iControl == (int)Controls.CONTROL_PIXEL_RATIO)
                {
                    fPixelRatio -= 0.05f;
                }
            }
            break;

            case Action.ActionType.ACTION_MOVE_DOWN:
            {
                if (m_iCountD == 0)
                {
                    m_iSpeed = 1;
                }
                y += m_iSpeed;
                m_iCountD++;
                if (m_iCountD > 5 && m_iSpeed < 10)
                {
                    m_iSpeed += 1;
                    m_iCountD = 1;
                }
                m_iCountU = 0;
                m_iCountL = 0;
                m_iCountR = 0;
                if (m_iControl == (int)Controls.CONTROL_PIXEL_RATIO)
                {
                    fPixelRatio += 0.05f;
                }
            }
            break;

            case Action.ActionType.ACTION_CALIBRATE_SWAP_ARROWS:
                m_iControl++;
                if (m_iControl > (int)Controls.CONTROL_OSD)
                {
                    m_iControl = (int)Controls.CONTROL_TOP_LEFT;
                }
                m_iSpeed  = 1;
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
                return;


            case Action.ActionType.ACTION_CALIBRATE_RESET:
                //GUIGraphicsContext.ResetScreenParameters(m_Res[m_iCurRes]);
                GUIGraphicsContext.OverScanLeft = 0;
                GUIGraphicsContext.OverScanTop  = 0;
                GUIGraphicsContext.PixelRatio   = 1.0f;
                GUIGraphicsContext.OSDOffset    = 0;
                GUIGraphicsContext.Subtitles    = 530;

                GUIGraphicsContext.OverScanWidth  = GUIGraphicsContext.Width;
                GUIGraphicsContext.OverScanHeight = GUIGraphicsContext.Height;
                m_iSpeed  = 1;
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
                GUIWindowManager.ResetAllControls();

                return;


            case Action.ActionType.ACTION_CHANGE_RESOLUTION:
                // choose the next resolution in our list
                //m_iCurRes++;
                //if (m_iCurRes == m_Res.size())
                //  m_iCurRes = 0;
                //Sleep(1000);
                //GUIGraphicsContext.SetGUIResolution(m_Res[m_iCurRes]);
                GUIWindowManager.ResetAllControls();
                return;


            case Action.ActionType.ACTION_ANALOG_MOVE:
                x += (int)(2 * action.fAmount1);
                y -= (int)(2 * action.fAmount2);
                break;
            }
            // do the movement
            switch (m_iControl)
            {
            case (int)Controls.CONTROL_TOP_LEFT:
                if (x < 0)
                {
                    x = 0;
                }
                if (y < 0)
                {
                    y = 0;
                }
                if (x > 128)
                {
                    x = 128;
                }
                if (y > 128)
                {
                    y = 128;
                }
                GUIGraphicsContext.OverScanWidth  += GUIGraphicsContext.OverScanLeft - x;
                GUIGraphicsContext.OverScanHeight += GUIGraphicsContext.OverScanTop - y;
                GUIGraphicsContext.OverScanLeft    = x;
                GUIGraphicsContext.OverScanTop     = y;
                break;

            case (int)Controls.CONTROL_BOTTOM_RIGHT:
                if (x > GUIGraphicsContext.Width)
                {
                    x = GUIGraphicsContext.Width;
                }
                if (y > GUIGraphicsContext.Height)
                {
                    y = GUIGraphicsContext.Height;
                }
                if (x < GUIGraphicsContext.Width - 128)
                {
                    x = GUIGraphicsContext.Width - 128;
                }
                if (y < GUIGraphicsContext.Height - 128)
                {
                    y = GUIGraphicsContext.Height - 128;
                }
                GUIGraphicsContext.OverScanWidth  = x - GUIGraphicsContext.OverScanLeft;
                GUIGraphicsContext.OverScanHeight = y - GUIGraphicsContext.OverScanTop;
                break;

            case (int)Controls.CONTROL_SUBTITLES:
                if (y > GUIGraphicsContext.Height)
                {
                    y = GUIGraphicsContext.Height;
                }
                if (y < GUIGraphicsContext.Height - 128)
                {
                    y = GUIGraphicsContext.Height - 128;
                }
                GUIGraphicsContext.Subtitles = y;
                break;

            case (int)Controls.CONTROL_OSD:
                GUIGraphicsContext.OSDOffset = (y - GUIGraphicsContext.Height);
                GUIWindow window = GUIWindowManager.GetWindow((int)Window.WINDOW_OSD);
                window.ResetAllControls();
                break;

            case (int)Controls.CONTROL_PIXEL_RATIO:
                GUIGraphicsContext.PixelRatio = fPixelRatio;
                break;
            }
            base.OnAction(action);
        }
示例#3
0
        public override void OnAction(Action action)
        {
            if (action.wID == Action.ActionType.ACTION_HOME || action.wID == Action.ActionType.ACTION_SWITCH_HOME)
            {
                return;
            }

            if ((DateTime.Now.Ticks / 10000) - m_dwLastTime > 500)
            {
                m_iSpeed      = 1;
                m_iCountU     = 0;
                m_iCountD     = 0;
                m_iCountL     = 0;
                m_iCountR     = 0;
                m_bModeLocked = false;
            }
            m_dwLastTime = (DateTime.Now.Ticks / 10000);

            bool bChanged = false;
            int  iXOff    = GUIGraphicsContext.OffsetX;
            int  iYOff    = GUIGraphicsContext.OffsetY;

            int iLogWidthMin  = (int)((float)GUIGraphicsContext.Width * ZOOM_MIN);
            int iLogWidthMax  = (int)((float)GUIGraphicsContext.Width * ZOOM_MAX);
            int iLogHeightMin = (int)((float)GUIGraphicsContext.Height * ZOOM_MIN);
            int iLogHeightMax = (int)((float)GUIGraphicsContext.Height * ZOOM_MAX);

            // Check if screen res change has invalidated
            // the current sizes.
            if (ClampLogicalScreenSize())
            {
                bChanged = true;
            }

            if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU)
            {
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (m_iSpeed > 10)
            {
                m_iSpeed = 10; // Speed limit for accellerated cursors
            }

            switch (action.wID)
            {
            case Action.ActionType.ACTION_SELECT_ITEM:
            {
                // Cycle modes
                // Only 0,1 currently.
                if (!m_bModeLocked)
                {
                    m_iMode       = 1 - m_iMode;
                    m_bModeLocked = true;
                    bChanged      = true;
                }
            }
            break;

            case Action.ActionType.ACTION_MOVE_LEFT:
            {
                if (m_iCountL == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogWidth > iLogWidthMin)
                    {
                        m_iLogWidth -= m_iSpeed;
                        bChanged     = true;
                        m_iCountL++;
                        if (m_iCountL > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountL = 1;
                        }
                    }
                }
                else
                {
                    // Offset
                    if (iXOff > -128)
                    {
                        iXOff   -= m_iSpeed;
                        bChanged = true;
                        m_iCountL++;
                        if (m_iCountL > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountL = 1;
                        }
                    }
                }
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountR = 0;
            }
            break;

            case Action.ActionType.ACTION_MOVE_RIGHT:
            {
                if (m_iCountR == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogWidth < iLogWidthMax)
                    {
                        m_iLogWidth += m_iSpeed;
                        bChanged     = true;
                        m_iCountR++;
                        if (m_iCountR > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountR = 1;
                        }
                    }
                }
                else
                {
                    // Offset
                    if (iXOff < 128)
                    {
                        iXOff   += m_iSpeed;
                        bChanged = true;
                        m_iCountR++;
                        if (m_iCountR > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountR = 1;
                        }
                    }
                }

                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
            }
            break;

            case Action.ActionType.ACTION_MOVE_UP:
            {
                if (m_iCountU == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogHeight > iLogHeightMin)
                    {
                        m_iLogHeight -= m_iSpeed;
                        bChanged      = true;
                        m_iCountU++;
                        if (m_iCountU > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountU = 1;
                        }
                    }
                }
                else
                {
                    // Offset
                    if (iYOff > -128)
                    {
                        iYOff   -= m_iSpeed;
                        bChanged = true;
                        m_iCountU++;
                        if (m_iCountU > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountU = 1;
                        }
                    }
                }
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
            }
            break;

            case Action.ActionType.ACTION_MOVE_DOWN:
            {
                if (m_iCountD == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogHeight < iLogHeightMax)
                    {
                        m_iLogHeight += m_iSpeed;
                        bChanged      = true;
                        m_iCountD++;
                        if (m_iCountD > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountD = 1;
                        }
                    }
                }
                else
                {
                    if (iYOff < 128)
                    {
                        iYOff   += m_iSpeed;
                        bChanged = true;
                        m_iCountD++;
                        if (m_iCountD > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountD = 1;
                        }
                    }
                }
                m_iCountU = 0;
                m_iCountL = 0;
                m_iCountR = 0;
            }
            break;

            case Action.ActionType.ACTION_CALIBRATE_RESET:
                //if (m_iMode == 1)
                //{
                m_iLogWidth  = GUIGraphicsContext.Width;
                m_iLogHeight = GUIGraphicsContext.Height;
                //}
                //else
                //{
                iXOff = 0;
                iYOff = 0;
                //}
                bChanged  = true;
                m_iSpeed  = 1;
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
                break;

            case Action.ActionType.ACTION_ANALOG_MOVE:
                float fX = 2 * action.fAmount1;
                float fY = 2 * action.fAmount2;
                if (fX != 0.0 || fY != 0.0)
                {
                    bChanged = true;
                    if (m_iMode == 1)
                    {
                        m_iLogWidth  += (int)fX;
                        m_iLogHeight -= (int)fY;
                    }
                    else
                    {
                        iXOff += (int)fX;
                        if (iXOff < -128)
                        {
                            iXOff = -128;
                        }
                        if (iXOff > 128)
                        {
                            iXOff = 128;
                        }

                        iYOff -= (int)fY;
                        if (iYOff < -128)
                        {
                            iYOff = -128;
                        }
                        if (iYOff > 128)
                        {
                            iYOff = 128;
                        }
                    }
                }
                break;
            }
            // do the movement
            if (bChanged)
            {
                ClampLogicalScreenSize();
                GUIGraphicsContext.OffsetX = iXOff;
                GUIGraphicsContext.OffsetY = iYOff;

                float fZoomHorz = (float)m_iLogWidth / (float)GUIGraphicsContext.Width;
                float fZoomVert = (float)m_iLogHeight / (float)GUIGraphicsContext.Height;

                GUIGraphicsContext.ZoomHorizontal = fZoomHorz;
                GUIGraphicsContext.ZoomVertical   = fZoomVert;

                GUIGraphicsContext.OffsetX        = GUIGraphicsContext.OffsetX;
                GUIGraphicsContext.OffsetY        = GUIGraphicsContext.OffsetY;
                GUIGraphicsContext.ZoomHorizontal = GUIGraphicsContext.ZoomHorizontal;
                GUIGraphicsContext.ZoomVertical   = GUIGraphicsContext.ZoomVertical;

                GUIWindowManager.OnResize();
                GUIWindowManager.PreInit();
                UpdateControlLabel();

                ResetAllControls();
                GUIWindowManager.ResetAllControls();
            }
            base.OnAction(action);
        }