Exemplo n.º 1
0
        public void saveSettings(bool newOvelay, DISPLAY_MODES newDisplayMode, bool newShortcut, KeyboardHook.VKeys newOpen,
                                 KeyboardHook.VKeys newPos, KeyboardHook.VKeys newDist, KeyboardHook.VKeys newResult)
        {
            File.WriteAllText(PATH, OVERLAY_ON + "=" + newOvelay.ToString() + "\n" + DISPLAY_MODE + "=" + newDisplayMode.ToString() + "\n" +
                              ALLOW_SHORTCUTS + "=" + newShortcut.ToString() + "\n" + OPEN_SHORTCUT + "=" + newOpen.ToString() + "\n" + POS_SHORTCUT + "=" +
                              newPos.ToString() + "\n" + DIST_SHORTCUT + "=" + newDist.ToString() + "\n" + RESULT_SHORTCUT + "=" + newResult.ToString());

            loadSettings();
        }
Exemplo n.º 2
0
        private void loadSettings()
        {
            string[] lines = File.ReadAllLines(PATH);

            if (lines.Length < 7)
            {
                throw new Exception("Bad formatting of settings file!");
            }

            foreach (string line in lines)
            {
                var splitted = line.Split("=");
                if (splitted[0].Equals(OVERLAY_ON))
                {
                    isOverlayOn = bool.Parse(splitted[1]);
                    continue;
                }
                else if (splitted[0].Equals(DISPLAY_MODE))
                {
                    displayMode = (DISPLAY_MODES)Enum.Parse(typeof(DISPLAY_MODES), splitted[1]);
                    continue;
                }
                else if (splitted[0].Equals(ALLOW_SHORTCUTS))
                {
                    allowShortcuts = bool.Parse(splitted[1]);
                    continue;
                }
                else if (splitted[0].Equals(OPEN_SHORTCUT))
                {
                    openShortcut = (KeyboardHook.VKeys)Enum.Parse(typeof(KeyboardHook.VKeys), splitted[1]);
                    continue;
                }
                else if (splitted[0].Equals(POS_SHORTCUT))
                {
                    posShortcut = (KeyboardHook.VKeys)Enum.Parse(typeof(KeyboardHook.VKeys), splitted[1]);
                    continue;
                }
                else if (splitted[0].Equals(DIST_SHORTCUT))
                {
                    disShortcut = (KeyboardHook.VKeys)Enum.Parse(typeof(KeyboardHook.VKeys), splitted[1]);
                    continue;
                }
                else if (splitted[0].Equals(RESULT_SHORTCUT))
                {
                    resultShortcut = (KeyboardHook.VKeys)Enum.Parse(typeof(KeyboardHook.VKeys), splitted[1]);
                    continue;
                }
            }
        }