Пример #1
0
        internal static void SaveGlobalSettings()
        {
            bool keyAlt;
            bool keyCtrl;
            bool keyShift;
            bool keyWin;

            MemIniFile iniFile;

            iniFile = new MemIniFile(GlobalConfig.KrentoSettingsFileName);
            try
            {
                iniFile.Load();
                iniFile.WriteString(Sections.General, Parameters.MouseButton, MouseHook.ToString());

                if (!string.IsNullOrEmpty(IconName))
                {
                    iniFile.WriteString(Sections.General, Parameters.IconName, IconName);
                }

                string shortCircleName = FileOperations.UnExpandPath(CircleName);
                iniFile.WriteString(Sections.General, Parameters.CircleName, shortCircleName);

                iniFile.WriteBool(Sections.Shortcut, Parameters.CircleSelector, CircleSelector);
                iniFile.WriteBool(Sections.General, Parameters.UseKeyboardActivation, UseKeyboardActivation);
                iniFile.WriteBool(Sections.General, Parameters.UseMouseActivation, UseMouseActivation);

                iniFile.WriteBool(Sections.General, Parameters.ShowTrayIcon, ShowTrayIcon);
                iniFile.WriteBool(Sections.General, Parameters.ShowPopupAlerts, ShowPopupAlerts);
                iniFile.WriteString(Sections.General, Parameters.Language, Language);

                keyWin   = ((GlobalSettings.Modifiers & Keys.LWin) != 0);
                keyShift = ((GlobalSettings.Modifiers & Keys.Shift) != 0);
                keyAlt   = ((GlobalSettings.Modifiers & Keys.Alt) != 0);
                keyCtrl  = ((GlobalSettings.Modifiers & Keys.Control) != 0);

                iniFile.WriteBool(Sections.Shortcut, Parameters.Alt, keyAlt);
                iniFile.WriteBool(Sections.Shortcut, Parameters.Ctrl, keyCtrl);
                iniFile.WriteBool(Sections.Shortcut, Parameters.Win, keyWin);
                iniFile.WriteBool(Sections.Shortcut, Parameters.Shift, keyShift);

                iniFile.WriteString(Sections.Shortcut, Parameters.Key, Shortcut.ToString());

                keyShift = ((GlobalSettings.MouseModifiers & Keys.Shift) != 0);
                keyAlt   = ((GlobalSettings.MouseModifiers & Keys.Alt) != 0);
                keyCtrl  = ((GlobalSettings.MouseModifiers & Keys.Control) != 0);

                iniFile.WriteBool(Sections.Mouse, Parameters.ActivateCursor, ActivateCursor);
                iniFile.WriteBool(Sections.Mouse, Parameters.UseRightClick, UseRightClick);
                iniFile.WriteBool(Sections.Mouse, Parameters.DesktopClick, DesktopClick);

                iniFile.WriteBool(Sections.Mouse, Parameters.Alt, keyAlt);
                iniFile.WriteBool(Sections.Mouse, Parameters.Ctrl, keyCtrl);
                iniFile.WriteBool(Sections.Mouse, Parameters.Shift, keyShift);

                iniFile.WriteBool(Sections.General, Parameters.CheckUpdate, CheckUpdate);
                iniFile.WriteBool(Sections.General, Parameters.ShowSplashScreen, ShowSplashScreen);
                iniFile.WriteBool(Sections.General, Parameters.StartVisible, StartVisible);
                iniFile.WriteBool(Sections.General, Parameters.UseSound, UseSound);

                iniFile.WriteInteger(Sections.Help, Parameters.PortNumber, PortNumber);
                iniFile.WriteBool(Sections.Help, Parameters.ActivateServer, ActivateServer);

                iniFile.WriteBool(Sections.Manager, Parameters.HideOnClick, HideOnClick);
                iniFile.WriteInteger(Sections.Manager, Parameters.FadeDelay, FadeDelay);
                iniFile.WriteInteger(Sections.Manager, Parameters.WindowHeight, WindowHeight);
                iniFile.WriteInteger(Sections.Manager, Parameters.WindowWidth, WindowWidth);
                iniFile.WriteInteger(Sections.Manager, Parameters.StoneSize, StoneSize);
                iniFile.WriteInteger(Sections.Manager, Parameters.IconSize, IconSize);
                iniFile.WriteInteger(Sections.Manager, Parameters.Transparency, Transparency);
                iniFile.WriteInteger(Sections.Manager, Parameters.Raduis, Radius);
                iniFile.WriteBool(Sections.Manager, Parameters.RotateOnClick, RotateOnClick);
                iniFile.WriteBool(Sections.Manager, Parameters.IgnoreFullScreen, IgnoreFullScreen);
                iniFile.WriteBool(Sections.Manager, Parameters.ManagerButtons, ShowManagerButtons);
                iniFile.WriteInteger(Sections.Manager, Parameters.DefaultStonesNumber, DefaultStonesNumber);
                iniFile.WriteBool(Sections.Manager, Parameters.LiveReflection, LiveReflection);
                iniFile.WriteBool(Sections.Manager, Parameters.ShowStoneHint, ShowStoneHint);
                iniFile.WriteBool(Sections.Manager, Parameters.FlatRing, FlatRing);

                string shortMenuSkin = FileOperations.UnExpandPath(MenuSkin);
                if (!string.IsNullOrEmpty(shortMenuSkin))
                {
                    iniFile.WriteString(Sections.Menu, Parameters.Theme, shortMenuSkin);
                }
                else
                {
                    iniFile.DeleteKey(Sections.Menu, Parameters.Theme);
                }

                DefaultCircle = GlobalConfig.DefaultCircleName;
                string defaultCircleFile = FileOperations.UnExpandPath(DefaultCircle);
                if (!string.IsNullOrEmpty(defaultCircleFile))
                {
                    iniFile.WriteString(Sections.General, Parameters.DefaultCircle, defaultCircleFile);
                }
                else
                {
                    iniFile.DeleteKey(Sections.General, Parameters.DefaultCircle);
                }

                iniFile.Save();
            }
            finally
            {
                iniFile.Dispose();
            }
        }