Ejemplo n.º 1
0
        private void Main_Load(object sender, EventArgs e)
        {
            Log.Clear();
            Settings.Load();

            //Global keyboard hook logic by https://github.com/gmamaladze/globalmousekeyhook/blob/vNext/Demo/Main.cs
            Subscribe();

            //Add Firewall exception
            AddException();

            //Load languages to combobox:
            LoadLanguages();

            //Check plugins:
            CheckPlugins();

            //Load the keys:
            nextKeyTextBox.Text          = Settings.NextKey;
            previousKeyTextBox.Text      = Settings.PreviousKey;
            stopKeyTextBox.Text          = Settings.StopKey;
            volumeUpKeyTextBox.Text      = Settings.VolumeUpKey;
            volumeDownKeyTextBox.Text    = Settings.VolumeDownKey;
            makeFavouriteKeyTextbox.Text = Settings.MakeFavouriteKey;
            goToFavouriteKeyTextbox.Text = Settings.GoToFavouriteKey;

            nextButtonTextBox.Text          = Settings.NextButton;
            previousButtonTextBox.Text      = Settings.PreviousButton;
            stopButtonTextBox.Text          = Settings.StopButton;
            volumeUpButtonTextBox.Text      = Settings.VolumeUpButton;
            volumeDownButtonTextBox.Text    = Settings.VolumeDownButton;
            makeFavouriteButtonTextbox.Text = Settings.MakeFavouriteButton;
            goToFavouriteButtonTextbox.Text = Settings.GoToFavouriteButton;

            comboController.SelectedText = Settings.Controller;

            //Load favourites
            Favourites.Load();

            //Start telemetry grabbing:
            Telemetry       = new Ets2SdkTelemetry(250);
            Telemetry.Data += Telemetry_Data;

            if (Telemetry.Error != null)
            {
                MessageBox.Show(
                    "General info:\r\nFailed to open memory map " + Telemetry.Map +
                    " - on some systems you need to run the client (this app) with elevated permissions, because e.g. you're running Steam/ETS2 with elevated permissions as well. .NET reported the following Exception:\r\n" +
                    Telemetry.Error.Message + "\r\n\r\nStacktrace:\r\n" + Telemetry.Error.StackTrace);
            }

            //Open server:
            myServer = new SimpleHTTPServer(Directory.GetCurrentDirectory() + "\\web", Settings.Port);
            writeFile("none", "0", "0");

            //Load IP addresses:
            LoadAddresses();

            if (AttachJoystick())
            {
                foreach (var item in joystick.AvailableDevices)
                {
                    comboController.Items.Add(item.InstanceName);
                }
            }
            AttachJoystick();

            currentGameTimer.Start();

            //Add handlers:
            nextKeyTextBox.KeyDown          += keyInput;
            previousKeyTextBox.KeyDown      += keyInput;
            stopKeyTextBox.KeyDown          += keyInput;
            volumeUpKeyTextBox.KeyDown      += keyInput;
            volumeDownKeyTextBox.KeyDown    += keyInput;
            makeFavouriteKeyTextbox.KeyDown += keyInput;
            goToFavouriteKeyTextbox.KeyDown += keyInput;

            //Remove key binding:
            nextKeyTextBox.KeyDown          += removeBinding;
            previousKeyTextBox.KeyDown      += removeBinding;
            stopKeyTextBox.KeyDown          += removeBinding;
            volumeUpKeyTextBox.KeyDown      += removeBinding;
            volumeDownKeyTextBox.KeyDown    += removeBinding;
            makeFavouriteKeyTextbox.KeyDown += removeBinding;
            goToFavouriteKeyTextbox.KeyDown += removeBinding;

            nextButtonTextBox.KeyDown          += removeBinding;
            previousButtonTextBox.KeyDown      += removeBinding;
            stopButtonTextBox.KeyDown          += removeBinding;
            volumeUpButtonTextBox.KeyDown      += removeBinding;
            volumeDownButtonTextBox.KeyDown    += removeBinding;
            makeFavouriteButtonTextbox.KeyDown += removeBinding;
            goToFavouriteButtonTextbox.KeyDown += removeBinding;
        }
Ejemplo n.º 2
0
        private void Main_Load(object sender, EventArgs e)
        {
            Log.Clear();

            //Global keyboard hook logic by https://github.com/gmamaladze/globalmousekeyhook/blob/vNext/Demo/Main.cs
            Subscribe();

            //Add Firewall exception
            AddException();

            //Load languages to combobox:
            LoadLanguages();

            //Check plugins:
            if (PluginExists("ats"))
            {
                installAtsButton.Image = Resources.check;
            }
            if (PluginExists("ets2"))
            {
                installEts2Button.Image = Resources.check;
            }
            if (!PluginExists("ats") && !PluginExists("ets2"))
            {
                groupInfo.Enabled     = false;
                groupSettings.Enabled = false;
            }

            //Load the keys:
            nextKeyTextBox.Text          = ConfigurationManager.AppSettings["NextKey"];
            previousKeyTextBox.Text      = ConfigurationManager.AppSettings["PreviousKey"];
            stopKeyTextBox.Text          = ConfigurationManager.AppSettings["StopKey"];
            volumeUpKeyTextBox.Text      = ConfigurationManager.AppSettings["VolumeUpKey"];
            volumeDownKeyTextBox.Text    = ConfigurationManager.AppSettings["VolumeDownKey"];
            makeFavouriteKeyTextbox.Text = ConfigurationManager.AppSettings["MakeFavouriteKey"];

            nextButtonTextBox.Text          = ConfigurationManager.AppSettings["NextButton"];
            previousButtonTextBox.Text      = ConfigurationManager.AppSettings["PreviousButton"];
            stopButtonTextBox.Text          = ConfigurationManager.AppSettings["StopButton"];
            volumeUpButtonTextBox.Text      = ConfigurationManager.AppSettings["VolumeUpButton"];
            volumeDownButtonTextBox.Text    = ConfigurationManager.AppSettings["VolumeDownButton"];
            makeFavouriteButtonTextbox.Text = ConfigurationManager.AppSettings["MakeFavouriteButton"];

            comboController.SelectedText = ConfigurationManager.AppSettings["Controller"];

            //Start telemetry grabbing:
            Telemetry       = new Ets2SdkTelemetry(250);
            Telemetry.Data += Telemetry_Data;

            if (Telemetry.Error != null)
            {
                MessageBox.Show(
                    "General info:\r\nFailed to open memory map " + Telemetry.Map +
                    " - on some systems you need to run the client (this app) with elevated permissions, because e.g. you're running Steam/ETS2 with elevated permissions as well. .NET reported the following Exception:\r\n" +
                    Telemetry.Error.Message + "\r\n\r\nStacktrace:\r\n" + Telemetry.Error.StackTrace);
            }

            //Open server:
            myServer = new SimpleHTTPServer(Directory.GetCurrentDirectory() + "\\web", Int32.Parse(ConfigurationManager.AppSettings["Port"]));
            writeFile("none", "0", "0");

            //Load IP addresses:
            LoadAddresses();

            if (AttachJoystick())
            {
                foreach (var item in joystick.AvailableDevices)
                {
                    comboController.Items.Add(item.InstanceName);
                }
            }

            currentGameTimer.Start();

            //Add handlers:
            nextKeyTextBox.KeyDown          += keyInput;
            previousKeyTextBox.KeyDown      += keyInput;
            stopKeyTextBox.KeyDown          += keyInput;
            volumeUpKeyTextBox.KeyDown      += keyInput;
            volumeDownKeyTextBox.KeyDown    += keyInput;
            makeFavouriteKeyTextbox.KeyDown += keyInput;

            /*
             * nextButtonTextBox.KeyDown += keyInput;
             * previousButtonTextBox.KeyDown += keyInput;
             * stopButtonTextBox.KeyDown += keyInput;
             * volumeUpButtonTextBox.KeyDown += keyInput;
             * volumeDownButtonTextBox.KeyDown += keyInput;
             * makeFavouriteButtonTextbox.KeyDown += keyInput;
             */
            //Remove key binding:
            nextKeyTextBox.KeyDown          += removeBinding;
            previousKeyTextBox.KeyDown      += removeBinding;
            stopKeyTextBox.KeyDown          += removeBinding;
            volumeUpKeyTextBox.KeyDown      += removeBinding;
            volumeDownKeyTextBox.KeyDown    += removeBinding;
            makeFavouriteKeyTextbox.KeyDown += removeBinding;

            nextButtonTextBox.KeyDown          += removeBinding;
            previousButtonTextBox.KeyDown      += removeBinding;
            stopButtonTextBox.KeyDown          += removeBinding;
            volumeUpButtonTextBox.KeyDown      += removeBinding;
            volumeDownButtonTextBox.KeyDown    += removeBinding;
            makeFavouriteButtonTextbox.KeyDown += removeBinding;
        }