Пример #1
0
 private static bool SearchSkinElement(DXS.Skin skin, out DXS.SkinElement element, params string[] keys)
 {
     foreach (string key in keys)
     {
         element = skin[key];
         if (element != null)
         {
             return(true);
         }
     }
     element = null;
     return(false);
 }
Пример #2
0
        /// <summary>
        /// Set app look and feel
        /// </summary>
        /// <param name="lookAndFeelName"></param>
        /// <param name="userLookAndFeel"></param>

        public static Color SetLookAndFeel(
            string lookAndFeelName,
            UserLookAndFeel userLookAndFeel)
        {
            if (!SkinningEnabled)
            {
                //DevExpress.UserSkins.OfficeSkins.Register(); // (obsolete in V12)
                //BonusSkinsRegister();
                SkinManager.EnableFormSkins();                 // paint XtraForms with current skin
                SkinningEnabled = true;
            }

            Color fontColor = SystemColors.ControlText;             // default font color

            if (lookAndFeelName == "Classic Windows 3D Style")
            {
                userLookAndFeel.Style             = LookAndFeelStyle.Style3D;
                userLookAndFeel.UseWindowsXPTheme = true;
            }

            else if (lookAndFeelName == "Flat")             // not used
            {
                userLookAndFeel.Style             = LookAndFeelStyle.Flat;
                userLookAndFeel.UseWindowsXPTheme = true;
            }

            else if (lookAndFeelName == "UltraFlat")             // not used
            {
                userLookAndFeel.Style             = LookAndFeelStyle.UltraFlat;
                userLookAndFeel.UseWindowsXPTheme = true;
            }

            else             // use a skin
            {
                SkinInfoMx si = GetSkinFromInternalName(lookAndFeelName);
                if (si == null)
                {
                    si = GetSkinFromInternalName("Blue");
                }
                if (si == null)
                {
                    return(fontColor);                            // shouldn't happen
                }
                // Dynamically load the BonusSkinsAssembly if requested and not already loaded

                if (si.Bonus && !BonusSkinsRegistered)                 // be sure bonus skins are registered
                {
                    if (!BonusSkinsRegister())
                    {
                        lookAndFeelName = "Blue";                         // default to blue on error
                        si = GetSkinFromInternalName(lookAndFeelName);
                    }
                }

                userLookAndFeel.Style = LookAndFeelStyle.Skin;
                userLookAndFeel.SetSkinStyle(lookAndFeelName);

                //UserLookAndFeel.Default.Style = LookAndFeelStyle.Skin; // set for static default object
                //UserLookAndFeel.Default.SetSkinStyle(lookAndFeelName);

                DevExpress.Skins.Skin currentSkin = DevExpress.Skins.CommonSkins.GetSkin(userLookAndFeel);
                Color captionColor = currentSkin.Colors.GetColor(DevExpress.Skins.CommonSkins.SkinGroupPanelCaptionTop);
                fontColor = currentSkin.Colors.GetColor(DevExpress.Skins.CommonColors.ControlText);

                if (Lex.Contains(lookAndFeelName, "Black") ||                 // if a black look set white font color
                    Lex.Contains(lookAndFeelName, "Dark") || Lex.Contains(lookAndFeelName, "Sharp"))
                {
                    fontColor = Color.White;
                }
            }

            return(fontColor);
        }