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); }
internal static void LoadGlobalSettings() { MemIniFile iniFile; bool keyAlt; bool keyCtrl; bool keyShift; bool keyWin; int goodNumber; iniFile = new MemIniFile(GlobalConfig.KrentoSettingsFileName); try { iniFile.Load(); try { MouseHook = (MouseHookButton)Enum.Parse(typeof(MouseHookButton), iniFile.ReadString(Sections.General, "MouseButton", "Wheel")); } catch { MouseHook = MouseHookButton.Wheel; } try { Shortcut = (Keys)Enum.Parse(typeof(Keys), iniFile.ReadString(Sections.Shortcut, Parameters.Key, "S")); } catch { Shortcut = Keys.S; } CircleSelector = iniFile.ReadBool(Sections.Shortcut, Parameters.CircleSelector, false); UseKeyboardActivation = iniFile.ReadBool(Sections.General, Parameters.UseKeyboardActivation, true); UseMouseActivation = iniFile.ReadBool(Sections.General, Parameters.UseMouseActivation, true); keyAlt = iniFile.ReadBool(Sections.Shortcut, Parameters.Alt, false); keyCtrl = iniFile.ReadBool(Sections.Shortcut, Parameters.Ctrl, false); keyWin = iniFile.ReadBool(Sections.Shortcut, Parameters.Win, true); keyShift = iniFile.ReadBool(Sections.Shortcut, Parameters.Shift, false); if ((Shortcut == Keys.None)) { keyAlt = false; keyWin = true; keyCtrl = false; keyShift = false; Shortcut = Keys.S; } //for previous version compatibility if (keyWin && (Shortcut == Keys.C)) { Shortcut = Keys.S; } Modifiers = Keys.None; if (keyAlt) { Modifiers = Modifiers | Keys.Alt; } if (keyCtrl) { Modifiers = Modifiers | Keys.Control; } if (keyShift) { Modifiers = Modifiers | Keys.Shift; } if (keyWin) { Modifiers = Modifiers | Keys.LWin; } keyAlt = iniFile.ReadBool(Sections.Mouse, Parameters.Alt, false); keyCtrl = iniFile.ReadBool(Sections.Mouse, Parameters.Ctrl, false); keyShift = iniFile.ReadBool(Sections.Mouse, Parameters.Shift, false); MouseModifiers = Keys.None; if (keyAlt) { MouseModifiers = MouseModifiers | Keys.Alt; } if (keyCtrl) { MouseModifiers = MouseModifiers | Keys.Control; } if (keyShift) { MouseModifiers = MouseModifiers | Keys.Shift; } ActivateCursor = iniFile.ReadBool(Sections.Mouse, Parameters.ActivateCursor, false); UseRightClick = iniFile.ReadBool(Sections.Mouse, Parameters.UseRightClick, false); DesktopClick = iniFile.ReadBool(Sections.Mouse, Parameters.DesktopClick, false); DefaultCircle = iniFile.ReadString(Sections.General, Parameters.DefaultCircle, GlobalConfig.DefaultCircleName); DefaultCircle = FileOperations.StripFileName(DefaultCircle); GlobalConfig.DefaultCircleName = DefaultCircle; CircleName = iniFile.ReadString(Sections.General, Parameters.CircleName, DefaultCircle); CircleName = FileOperations.StripFileName(CircleName); StartVisible = iniFile.ReadBool(Sections.General, Parameters.StartVisible, false); CheckUpdate = iniFile.ReadBool(Sections.General, Parameters.CheckUpdate, true); ShowPopupAlerts = iniFile.ReadBool(Sections.General, Parameters.ShowPopupAlerts, true); ShowTrayIcon = iniFile.ReadBool(Sections.General, Parameters.ShowTrayIcon, true); ShowSplashScreen = iniFile.ReadBool(Sections.General, Parameters.ShowSplashScreen, true); Language = iniFile.ReadString(Sections.General, Parameters.Language, CultureInfo.CurrentCulture.Name); UseSound = iniFile.ReadBool(Sections.General, Parameters.UseSound, true); IconName = iniFile.ReadString(Sections.General, Parameters.IconName, null); GlyphName = iniFile.ReadString(Sections.General, Parameters.GlyphName, null); SplashName = iniFile.ReadString(Sections.General, Parameters.SplashName, null); AboutBoxName = iniFile.ReadString(Sections.General, Parameters.AboutBoxName, null); AboutStoneName = iniFile.ReadString(Sections.General, Parameters.AboutStoneName, null); // read web server settings PortNumber = iniFile.ReadInteger(Sections.Help, Parameters.PortNumber, 8053); ActivateServer = iniFile.ReadBool(Sections.Help, Parameters.ActivateServer, true); HideOnClick = iniFile.ReadBool(Sections.Manager, Parameters.HideOnClick, false); FadeDelay = iniFile.ReadInteger(Sections.Manager, Parameters.FadeDelay, 100); WindowWidth = iniFile.ReadInteger(Sections.Manager, Parameters.WindowWidth, 300); WindowHeight = iniFile.ReadInteger(Sections.Manager, Parameters.WindowHeight, 80); RotateOnClick = iniFile.ReadBool(Sections.Manager, Parameters.RotateOnClick, false); IgnoreFullScreen = iniFile.ReadBool(Sections.Manager, Parameters.IgnoreFullScreen, true); DefaultStonesNumber = iniFile.ReadInteger(Sections.Manager, Parameters.DefaultStonesNumber, 0); goodNumber = Math.Max(DefaultStonesNumber, 0); DefaultStonesNumber = Math.Min(64, goodNumber); StoneSize = iniFile.ReadInteger(Sections.Manager, Parameters.StoneSize, 128); goodNumber = Math.Min(StoneSize, 512); StoneSize = Math.Max(64, goodNumber); IconSize = iniFile.ReadInteger(Sections.Manager, Parameters.IconSize, 64); goodNumber = Math.Min(IconSize, 512); IconSize = Math.Max(64, goodNumber); FileImage.ImageSize = IconSize; Transparency = iniFile.ReadInteger(Sections.Manager, Parameters.Transparency, 230); goodNumber = Math.Min(Transparency, 255); Transparency = Math.Max(10, goodNumber); Radius = iniFile.ReadInteger(Sections.Manager, Parameters.Raduis, 200); goodNumber = Math.Min(Radius, 1000); Radius = Math.Max(100, goodNumber); ShowManagerButtons = iniFile.ReadBool(Sections.Manager, Parameters.ManagerButtons, true); LiveReflection = iniFile.ReadBool(Sections.Manager, Parameters.LiveReflection, false); ShowStoneHint = iniFile.ReadBool(Sections.Manager, Parameters.ShowStoneHint, true); FlatRing = iniFile.ReadBool(Sections.Manager, Parameters.FlatRing, false); MenuSkin = iniFile.ReadString(Sections.Menu, Parameters.Theme, string.Empty); KrentoMenu.SkinFileName = FileOperations.StripFileName(MenuSkin); } finally { iniFile.Dispose(); } }