Esempio n. 1
0
        public static void Init()
        {
            string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            dir = Path.Combine(dir, "Onuprova");
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            dir = Path.Combine(dir, "KeyCur");
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            string path = Path.Combine(dir, "preference2.json");

            //System.Windows.Forms.MessageBox.Show(path);

            Preference = Preference.Load(path);
        }
Esempio n. 2
0
        public static Preference Load(string path)
        {
            if (!File.Exists(path))
            {
                Preference p = new Preference();
                p.Path = path;
                return(p);
            }
            else
            {
                string data = File.ReadAllText(path);

                Preference p = Util.DeserializeJSON <Preference>(data);
                if (p == null)
                {
                    p = new Preference();
                }

                if (p.LMB == null)
                {
                    p.LMB = new ExtendedKey(Keys.NumPad0);
                }
                if (p.RMB == null)
                {
                    p.RMB = new ExtendedKey(Keys.Decimal);
                }
                if (p.MMB == null)
                {
                    p.MMB = new ExtendedKey(Keys.NumPad5);
                }
                if (p.WheelUp == null)
                {
                    p.WheelUp = new ExtendedKey(Keys.Z);
                }
                if (p.WheelDown == null)
                {
                    p.WheelDown = new ExtendedKey(Keys.X);
                }
                if (p.Left == null)
                {
                    p.Left = new ExtendedKey(Keys.NumPad4);
                }
                if (p.Right == null)
                {
                    p.Right = new ExtendedKey(Keys.NumPad6);
                }
                if (p.Up == null)
                {
                    p.Up = new ExtendedKey(Keys.NumPad8);
                }
                if (p.Down == null)
                {
                    p.Down = new ExtendedKey(Keys.NumPad2);
                }
                if (p.Left == null)
                {
                    p.UpLeft = new ExtendedKey(Keys.NumPad7);
                }
                if (p.Right == null)
                {
                    p.UpRight = new ExtendedKey(Keys.NumPad9);
                }
                if (p.Left == null)
                {
                    p.DownLeft = new ExtendedKey(Keys.NumPad1);
                }
                if (p.Right == null)
                {
                    p.DownRight = new ExtendedKey(Keys.NumPad3);
                }
                if (p.Activation == null)
                {
                    p.Activation = new ExtendedKey(Keys.F11);
                }
                if (p.LMB == null)
                {
                    p.DoubleClick = new ExtendedKey(Keys.Add);
                }
                if (p.LMB == null)
                {
                    p.Drag = new ExtendedKey(Keys.Subtract);
                }

                if (p.ClickSpeed == 0)
                {
                    p.ClickSpeed = 50;
                }
                if (p.DoubleClickDelay == 0)
                {
                    p.DoubleClickDelay = 100;
                }
                if (p.MovementAcceleration == 0)
                {
                    p.MovementAcceleration = 1;
                }
                if (p.MaxSpeed == 0)
                {
                    p.MaxSpeed = 30;
                }
                if (p.WheelAcceleration == 0)
                {
                    p.WheelAcceleration = 1;
                }
                if (p.MaxWheelSpeed == 0)
                {
                    p.MaxWheelSpeed = 100;
                }

                p.Path = path;

                return(p);
            }
        }