예제 #1
0
        public bool LoadFromFile()
        {
            string iniFileName;

            if (!File.Exists(skinFileName))
            {
                return(false);
            }

            iniFileName = skinFileName;


            MemIniFile ini = new MemIniFile(iniFileName);

            try
            {
                ini.Load();
                ColorConverter cc = new ColorConverter();
                imageSize         = ini.ReadInteger("Menu", "ImageSize", 16);
                itemHeight        = ini.ReadInteger("Menu", "ItemHeight", 20);
                leftMargin        = ini.ReadInteger("Menu", "LeftMargin", 38);
                topMargin         = ini.ReadInteger("Menu", "TopMargin", 28);
                TextTopMargin     = ini.ReadInteger("Menu", "TextTopMargin", 28);
                TextBottomMargin  = ini.ReadInteger("Menu", "TextBottomMargin", 28);
                bottomMargin      = ini.ReadInteger("Menu", "BottomMargin", topMargin);
                textLeftMargin    = ini.ReadInteger("Menu", "TextLeftMargin", 28);
                textRightMargin   = ini.ReadInteger("Menu", "TextRightMargin", 24);
                textOffset        = ini.ReadInteger("Menu", "TextOffset", 4);
                outerBorderLeft   = ini.ReadInteger("Menu", "OuterBorderLeft", 21);
                outerBorderTop    = ini.ReadInteger("Menu", "OuterBorderTop", 21);
                scrollDividerSize = ini.ReadInteger("Menu", "DividerSize", 6);
                springBottom      = ini.ReadBool("Menu", "SpringBottom", false);

                fontName = ini.ReadString("Krento", "FontName", "Tahoma");
                fontSize = ini.ReadInteger("Krento", "FontSize", 12);
                caption  = ini.ReadString("Krento", "Caption", Path.GetFileNameWithoutExtension(Path.GetDirectoryName(skinFileName)));

                foreColor     = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "ForeColor", "White"));
                selectedColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "SelectedColor",
                                                                                    "238, 175, 238, 238"));
                disabledColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "DisabledColor", "Gray"));


                string backgroundName = ini.ReadString("Menu", "Image", string.Empty);

                if (!string.IsNullOrEmpty(backgroundName))
                {
                    if (background != null)
                    {
                        background.Dispose();
                        background = null;
                    }
                    try
                    {
                        string skinFolder = Path.GetDirectoryName(skinFileName);
                        background = FastBitmap.FromFile(Path.Combine(skinFolder, backgroundName));
                    }
                    catch
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }


                string highlightName = ini.ReadString("Menu", "Highlight", string.Empty);

                if (!string.IsNullOrEmpty(highlightName))
                {
                    if (highlight != null)
                    {
                        highlight.Dispose();
                        highlight = null;
                    }
                    try
                    {
                        string skinFolder = Path.GetDirectoryName(skinFileName);
                        highlight = FastBitmap.FromFile(Path.Combine(skinFolder, highlightName));
                    }
                    catch
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            finally
            {
                ini.Dispose();
            }

            return(true);
        }
예제 #2
0
 public static void LoadThemeLibrary(string fileName)
 {
     FastBitmap.LoadThemeLibrary(fileName);
 }
예제 #3
0
        public bool LoadFromFile()
        {
            string iniFileName = "";
            string stoneName;
            string backgroundName;
            string skinFolder = "";

            if (!File.Exists(skinFileName))
            {
                return(false);
            }
            else
            {
                iniFileName = skinFileName;
                skinFolder  = Path.GetDirectoryName(skinFileName);
            }


            MemIniFile ini = new MemIniFile(iniFileName);

            try
            {
                ini.Load();

                MenuSkin = ini.ReadString("Menu", "Theme", null);

                ColorConverter     cc = new ColorConverter();
                RectangleConverter rc = new RectangleConverter();
                fontName = ini.ReadString("Info", "FontName", "Tahoma");
                fontSize = ini.ReadInteger("Info", "FontSize", 14);
                try
                {
                    foreColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Info", "Color", "White"));
                }
                catch
                {
                    foreColor = Color.White;
                }

                try
                {
                    HintOutlineColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Hint", "OutlineColor", "Black"));
                }
                catch
                {
                    HintOutlineColor = Color.Black;
                }

                try
                {
                    HintBorderColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Hint", "BorderColor", "Gainsboro"));
                }
                catch
                {
                    HintBorderColor = Color.Gainsboro;
                }

                try
                {
                    HintBodyColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Hint", "BodyColor", "Black"));
                }
                catch
                {
                    HintBodyColor = Color.Black;
                }

                ButtonStoneSize  = ini.ReadInteger("Hint", "ButtonSize", 26);
                ButtonStoneSpace = ini.ReadInteger("Hint", "ButtonSpace", 4);

                try
                {
                    MenuBorderColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "BorderColor", "Gainsboro"));
                }
                catch
                {
                    MenuBorderColor = Color.Gainsboro;
                }

                try
                {
                    MenuOutlineColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "OutlineColor", "Black"));
                }
                catch
                {
                    MenuOutlineColor = Color.Black;
                }

                try
                {
                    MenuBodyColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "BodyColor", "Black"));
                }
                catch
                {
                    MenuBodyColor = Color.Black;
                }

                try
                {
                    MenuNormalTextColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "NormalTextColor", "White"));
                }
                catch
                {
                    MenuNormalTextColor = Color.White;
                }

                try
                {
                    MenuDisabledTextColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "DisabledTextColor", "Gray"));
                }
                catch
                {
                    MenuDisabledTextColor = Color.Gray;
                }

                try
                {
                    MenuSelectedTextColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "SelectedTextColor", "Black"));
                }
                catch
                {
                    MenuSelectedTextColor = Color.Black;
                }

                MenuFontSize = ini.ReadInteger("Menu", "FontSize", 12);

                MenuFontName = ini.ReadString("Menu", "FontName", "Tahoma");

                try
                {
                    MenuHighlightColor = (Color)cc.ConvertFromInvariantString(ini.ReadString("Menu", "HighlightColor", "Orange"));
                }
                catch
                {
                    MenuHighlightColor = Color.Orange;
                }


                ButtonStoneAbout = ini.ReadString("Hint", "ButtonStoneAbout", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneAbout))
                {
                    ButtonStoneAbout = Path.Combine(skinFolder, ButtonStoneAbout);
                }


                ButtonStoneSelect = ini.ReadString("Hint", "ButtonStoneSelect", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneSelect))
                {
                    ButtonStoneSelect = Path.Combine(skinFolder, ButtonStoneSelect);
                }


                ButtonStoneEdit = ini.ReadString("Hint", "ButtonStoneEdit", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneEdit))
                {
                    ButtonStoneEdit = Path.Combine(skinFolder, ButtonStoneEdit);
                }

                ButtonStoneDelete = ini.ReadString("Hint", "ButtonStoneDelete", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStoneDelete))
                {
                    ButtonStoneDelete = Path.Combine(skinFolder, ButtonStoneDelete);
                }


                ButtonBackNormal = ini.ReadString("ButtonBack", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonBackNormal))
                {
                    ButtonBackNormal = Path.Combine(skinFolder, ButtonBackNormal);
                }

                ButtonBackFocused = ini.ReadString("ButtonBack", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonBackFocused))
                {
                    ButtonBackFocused = Path.Combine(skinFolder, ButtonBackFocused);
                }

                ButtonBackPressed = ini.ReadString("ButtonBack", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonBackPressed))
                {
                    ButtonBackPressed = Path.Combine(skinFolder, ButtonBackPressed);
                }


                ButtonStartMenuNormal = ini.ReadString("ButtonStartMenu", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStartMenuNormal))
                {
                    ButtonStartMenuNormal = Path.Combine(skinFolder, ButtonStartMenuNormal);
                }

                ButtonStartMenuFocused = ini.ReadString("ButtonStartMenu", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStartMenuFocused))
                {
                    ButtonStartMenuFocused = Path.Combine(skinFolder, ButtonStartMenuFocused);
                }

                ButtonStartMenuPressed = ini.ReadString("ButtonStartMenu", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonStartMenuPressed))
                {
                    ButtonStartMenuPressed = Path.Combine(skinFolder, ButtonStartMenuPressed);
                }

                ButtonForwardNormal = ini.ReadString("ButtonForward", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonForwardNormal))
                {
                    ButtonForwardNormal = Path.Combine(skinFolder, ButtonForwardNormal);
                }
                else
                {
                    ButtonForwardFocused = ini.ReadString("ButtonForward", "Focused", string.Empty);
                }
                if (!string.IsNullOrEmpty(ButtonForwardFocused))
                {
                    ButtonForwardFocused = Path.Combine(skinFolder, ButtonForwardFocused);
                }

                ButtonForwardPressed = ini.ReadString("ButtonForward", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonForwardPressed))
                {
                    ButtonForwardPressed = Path.Combine(skinFolder, ButtonForwardPressed);
                }

                ButtonPowerNormal = ini.ReadString("ButtonPower", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonPowerNormal))
                {
                    ButtonPowerNormal = Path.Combine(skinFolder, ButtonPowerNormal);
                }

                ButtonPowerFocused = ini.ReadString("ButtonPower", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonPowerFocused))
                {
                    ButtonPowerFocused = Path.Combine(skinFolder, ButtonPowerFocused);
                }

                ButtonPowerPressed = ini.ReadString("ButtonPower", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonPowerPressed))
                {
                    ButtonPowerPressed = Path.Combine(skinFolder, ButtonPowerPressed);
                }

                ButtonHomeNormal = ini.ReadString("ButtonHome", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonHomeNormal))
                {
                    ButtonHomeNormal = Path.Combine(skinFolder, ButtonHomeNormal);
                }

                ButtonHomeFocused = ini.ReadString("ButtonHome", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonHomeFocused))
                {
                    ButtonHomeFocused = Path.Combine(skinFolder, ButtonHomeFocused);
                }

                ButtonHomePressed = ini.ReadString("ButtonHome", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonHomePressed))
                {
                    ButtonHomePressed = Path.Combine(skinFolder, ButtonHomePressed);
                }

                ButtonLauncherNormal = ini.ReadString("ButtonLauncher", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonLauncherNormal))
                {
                    ButtonLauncherNormal = Path.Combine(skinFolder, ButtonLauncherNormal);
                }

                ButtonLauncherFocused = ini.ReadString("ButtonLauncher", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonLauncherFocused))
                {
                    ButtonLauncherFocused = Path.Combine(skinFolder, ButtonLauncherFocused);
                }

                ButtonLauncherPressed = ini.ReadString("ButtonLauncher", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonLauncherPressed))
                {
                    ButtonLauncherPressed = Path.Combine(skinFolder, ButtonLauncherPressed);
                }

                ButtonSettingsNormal = ini.ReadString("ButtonSettings", "Normal", string.Empty);
                if (!string.IsNullOrEmpty(ButtonSettingsNormal))
                {
                    ButtonSettingsNormal = Path.Combine(skinFolder, ButtonSettingsNormal);
                }

                ButtonSettingsFocused = ini.ReadString("ButtonSettings", "Focused", string.Empty);
                if (!string.IsNullOrEmpty(ButtonSettingsFocused))
                {
                    ButtonSettingsFocused = Path.Combine(skinFolder, ButtonSettingsFocused);
                }

                ButtonSettingsPressed = ini.ReadString("ButtonSettings", "Pressed", string.Empty);
                if (!string.IsNullOrEmpty(ButtonSettingsPressed))
                {
                    ButtonSettingsPressed = Path.Combine(skinFolder, ButtonSettingsPressed);
                }

                ManagerWidth  = ini.ReadInteger("Background", "ManagerWidth", GlobalSettings.WindowWidth);
                ManagerHeight = ini.ReadInteger("Background", "ManagerHeight", GlobalSettings.WindowHeight);
                Radius        = ini.ReadInteger("Background", "Radius", GlobalSettings.Radius);

                string sectionName = "Background";

                if (ini.SectionExists("Background"))
                {
                    sectionName = "Background";
                }
                else
                if (ini.SectionExists("Tile"))
                {
                    sectionName = "Tile";
                }
                else
                if (ini.SectionExists("BackgroundTop"))
                {
                    sectionName = "BackgroundTop";
                }
                else
                if (ini.SectionExists("BackgroundBottom"))
                {
                    sectionName = "BackgroundBottom";
                }

                if (ini.ValueExists(sectionName, "LeftMargin"))
                {
                    leftMargin = ini.ReadInteger(sectionName, "LeftMargin", 0);
                }
                else
                {
                    leftMargin = ini.ReadInteger(sectionName, "LeftWidth", 0);
                }

                textOffset = ini.ReadInteger("Background", "TextOffset", leftMargin);

                if (ini.ValueExists(sectionName, "RightMargin"))
                {
                    rightMargin = ini.ReadInteger(sectionName, "RightMargin", 0);
                }
                else
                {
                    rightMargin = ini.ReadInteger(sectionName, "RightWidth", 0);
                }

                if (ini.ValueExists(sectionName, "TopMargin"))
                {
                    topMargin = ini.ReadInteger(sectionName, "TopMargin", 0);
                }
                else
                {
                    topMargin = ini.ReadInteger(sectionName, "TopHeight", 0);
                }

                if (ini.ValueExists(sectionName, "BottomMargin"))
                {
                    bottomMargin = ini.ReadInteger(sectionName, "BottomMargin", 0);
                }
                else
                {
                    bottomMargin = ini.ReadInteger(sectionName, "BottomHeight", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-LeftMargin"))
                {
                    outsideLeftMargin = ini.ReadInteger(sectionName, "Outside-LeftMargin", 0);
                }
                else
                {
                    outsideLeftMargin = ini.ReadInteger(sectionName, "OutsideBorderLeft", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-TopMargin"))
                {
                    outsideTopMargin = ini.ReadInteger(sectionName, "Outside-TopMargin", 0);
                }
                else
                {
                    outsideTopMargin = ini.ReadInteger(sectionName, "OutsideBorderTop", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-BottomMargin"))
                {
                    outsideBottomMargin = ini.ReadInteger(sectionName, "Outside-BottomMargin", 0);
                }
                else
                {
                    outsideBottomMargin = ini.ReadInteger(sectionName, "OutsideBorderBottom", 0);
                }

                if (ini.ValueExists(sectionName, "Outside-RightMargin"))
                {
                    outsideRightMargin = ini.ReadInteger(sectionName, "Outside-RightMargin", 0);
                }
                else
                {
                    outsideRightMargin = ini.ReadInteger(sectionName, "OutsideBorderRight", 0);
                }

                backgroundName = ini.ReadString(sectionName, "Image", string.Empty);

                ButtonSize = ini.ReadInteger("Background", "ButtonSize", 60);


                //read stone info
                indicatorRect   = (Rectangle)rc.ConvertFromInvariantString(ini.ReadString("Stone", "Indicator-Rect", "0, 0, 100, 100"));
                IndicatorLeft   = ini.ReadInteger("Stone", "Indicator-Left", 0);
                IndicatorBottom = ini.ReadInteger("Stone", "Indicator-Bottom", 0);

                indicatorImageName = ini.ReadString("Stone", "Indicator", string.Empty);
                if (!string.IsNullOrEmpty(indicatorImageName))
                {
                    indicatorImageName = Path.Combine(skinFolder, indicatorImageName);
                }


                if (ini.SectionExists("Stone"))
                {
                    stoneMarginTop    = ini.ReadInteger("Stone", "OutsideBorderTop", 0);
                    stoneMarginBottom = ini.ReadInteger("Stone", "OutsideBorderBottom", 0);
                    stoneMarginLeft   = ini.ReadInteger("Stone", "OutsideBorderLeft", 0);
                    stoneMarginRight  = ini.ReadInteger("Stone", "OutsideBorderRight", 0);
                    stoneBorder       = ini.ReadInteger("Stone", "Border", 0);
                    stoneName         = ini.ReadString("Stone", "Image", backgroundName);
                }
                else
                {
                    stoneMarginTop    = outsideTopMargin;
                    stoneMarginBottom = outsideBottomMargin;
                    stoneMarginLeft   = outsideLeftMargin;
                    stoneMarginRight  = outsideRightMargin;
                    stoneName         = backgroundName;
                    stoneBorder       = 0;
                }

                if (string.IsNullOrEmpty(backgroundName))
                {
                    return(false);
                }
                else
                {
                    if (background != null)
                    {
                        background.Dispose();
                        background = null;
                    }
                    try
                    {
                        background = FastBitmap.FromFile(Path.Combine(skinFolder, backgroundName));
                        if (background == null)
                        {
                            return(false);
                        }
                    }
                    catch
                    {
                        return(false);
                    }
                }

                if (string.IsNullOrEmpty(stoneName))
                {
                    return(false);
                }
                else
                {
                    if (stone != null)
                    {
                        stone.Dispose();
                        stone = null;
                    }
                    try
                    {
                        stone = FastBitmap.FromFile(Path.Combine(skinFolder, stoneName));
                        if (stone == null)
                        {
                            return(false);
                        }
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
            finally
            {
                ini.Dispose();
            }
            return(true);
        }