示例#1
0
        private void OnSkinChanged()
        {
            // Backup the buttons, needed later
            BackupButtons();

            // Set the skin to the selected skin and reload GUI
            GUIGraphicsContext.Skin = _btnSkin.Label;
            SaveSettings();
            GUITextureManager.Clear();
            GUITextureManager.Init();
            SkinSettings.Load();
            GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml"));
            GUIWindowManager.OnResize();
            GUIWindowManager.ActivateWindow(GetID);
            GUIControl.FocusControl(GetID, _btnSkin.GetID);

            // Apply the selected buttons again, since they are cleared when we reload
            RestoreButtons();
            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                if (!GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        var border = new Size(GUIGraphicsContext.form.Width - GUIGraphicsContext.form.ClientSize.Width,
                                              GUIGraphicsContext.form.Height - GUIGraphicsContext.form.ClientSize.Height);
                        if (GUIGraphicsContext.SkinSize.Width + border.Width <= GUIGraphicsContext.currentScreen.WorkingArea.Width &&
                            GUIGraphicsContext.SkinSize.Height + border.Height <= GUIGraphicsContext.currentScreen.WorkingArea.Height)
                        {
                            GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                        }
                        else
                        {
                            double ratio = Math.Min((double)(GUIGraphicsContext.currentScreen.WorkingArea.Width - border.Width) / GUIGraphicsContext.SkinSize.Width,
                                                    (double)(GUIGraphicsContext.currentScreen.WorkingArea.Height - border.Height) / GUIGraphicsContext.SkinSize.Height);
                            GUIGraphicsContext.form.ClientSize = new Size((int)(GUIGraphicsContext.SkinSize.Width * ratio), (int)(GUIGraphicsContext.SkinSize.Height * ratio));
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }
            if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null)
            {
                BassMusicPlayer.Player.VisualizationWindow.Reinit();
            }

            // Send a message that the skin has changed.
            var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SKIN_CHANGED, 0, 0, 0, 0, 0, null);

            GUIGraphicsContext.SendMessage(msg);
        }
        public void RevertSkin()
        {
            //int ActiveWindowID = GUIWindowManager.ActiveWindow;
            // Change skin back to OutdatedSkinName
            GUIGraphicsContext.Skin = _userSkin;
            GUITextureManager.Clear();
            GUITextureManager.Init();
            SkinSettings.Load();
            GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml"));
            GUIWindowManager.OnResize();
            //GUIWindowManager.ActivateWindow(ActiveWindowID);

            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                if (!GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }
        }
示例#3
0
 private void OnLanguageChanged()
 {
     // Backup the buttons, needed later
     BackupButtons();
     SaveSettings();
     GUILocalizeStrings.ChangeLanguage(_btnLanguage.Label);
     GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
     GUIFontManager.InitializeDeviceObjects();
     GUIWindowManager.OnResize();
     GUIWindowManager.ActivateWindow(GetID); // without this you cannot change skins / lang any more..
     GUIControl.FocusControl(GetID, _btnLanguage.GetID);
     // Apply the selected buttons again, since they are cleared when we reload
     RestoreButtons();
 }
        private void OnSkinChanged()
        {
            // Backup the buttons, needed later
            BackupButtons();

            // Set the skin to the selected skin and reload GUI
            GUIGraphicsContext.Skin = btnSkin.Label;
            SaveSettings();
            GUITextureManager.Clear();
            GUITextureManager.Init();
            SkinSettings.Load();
            GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml"));
            GUIWindowManager.OnResize();
            GUIWindowManager.ActivateWindow(GetID);
            GUIControl.FocusControl(GetID, btnSkin.GetID);

            // Apply the selected buttons again, since they are cleared when we reload
            RestoreButtons();
            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                bool autosize = xmlreader.GetValueAsBool("gui", "autosize", true);
                if (autosize && !GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                        //Form.ActiveForm.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }
            if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null)
            {
                BassMusicPlayer.Player.VisualizationWindow.Reinit();
            }

            // Send a message that the skin has changed.
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SKIN_CHANGED, 0, 0, 0, 0, 0, null);

            GUIGraphicsContext.SendMessage(msg);
        }
示例#5
0
        public override bool OnMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
            {
                GUIWindowManager.OnResize();
                GUIWindowManager.PreInit();
                GUIGraphicsContext.Save();
                if (m_orgZoomVertical != GUIGraphicsContext.ZoomVertical) // only vertical zoom affects font sizes
                {
                    GUIDialogNotify dlgNotify =
                        (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                    if (dlgNotify != null)
                    {
                        dlgNotify.Reset();
                        dlgNotify.ClearAll();
                        dlgNotify.SetHeading(213);                       // UI Calibration
                        dlgNotify.SetText(GUILocalizeStrings.Get(2650)); // Reloading fonts, please wait...
                        dlgNotify.TimeOut = 1;
                        dlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                    }
                    GUIFontManager.LoadFonts(Config.GetFile(Config.Dir.Skin, GUIGraphicsContext.Skin, "fonts.xml"));
                    GUIFontManager.InitializeDeviceObjects();
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
            {
                base.OnMessage(message);
                m_iSpeed          = 1;
                m_iCountU         = 0;
                m_iCountD         = 0;
                m_iCountL         = 0;
                m_iCountR         = 0;
                m_iMode           = 0;
                m_bModeLocked     = true;
                m_orgZoomVertical = GUIGraphicsContext.ZoomVertical;
                m_iLogWidth       = (int)Math.Round((float)GUIGraphicsContext.Width * (float)GUIGraphicsContext.ZoomHorizontal);
                m_iLogHeight      = (int)Math.Round((float)GUIGraphicsContext.Height * (float)GUIGraphicsContext.ZoomVertical);
                ClampLogicalScreenSize();
                UpdateControlLabel();
                return(true);
            }
            }
            return(base.OnMessage(message));
        }
        public void RevertSkin()
        {
            //int ActiveWindowID = GUIWindowManager.ActiveWindow;
            // Change skin back to OutdatedSkinName
            GUIGraphicsContext.Skin = _userSkin;
            GUITextureManager.Clear();
            GUITextureManager.Init();
            GUIFontManager.LoadFonts(GUIGraphicsContext.Skin + @"\fonts.xml");
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.Skin + @"\references.xml");
            GUIWindowManager.OnResize();
            //GUIWindowManager.ActivateWindow(ActiveWindowID);
            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                bool autosize = xmlreader.GetValueAsBool("gui", "autosize", true);
                if (autosize && !GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                        //Form.ActiveForm.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }

            if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null)
            {
                BassMusicPlayer.Player.VisualizationWindow.Reinit();
            }
        }
示例#7
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);
        }