Exemplo n.º 1
0
        private void Ambilight_Load(object sender, EventArgs e)
        {
            //All the control windows
            videoForm   = new VideoForm(config);
            audioForm   = new AudioForm(config);
            colorForm   = new ColorForm(config);
            ambientForm = new AmbientForm(config);

            //Makes our life easier with the multithreading
            Control.CheckForIllegalCrossThreadCalls = false;

            config.setDefaultConfiguration();                    //Set configuration to default to avoid errors
            LoadConfig();                                        //Load the configuration file

            packageData = new byte[config.numberOfLeds * 3 + 1]; //Update the size of data

            port = new SerialPort(config.port, config.baud, Parity.None, 8, StopBits.One);
            try
            {
                port.Open(); //Try to open the port
            }
            catch
            {
                //If the open fails the program will quit and xml-file must be changed
                MessageBox.Show("Could not open port, check config or arduino.");
                exitApplication();
            }

            //Start all the background workers
            backgroundWorkerDataSender.RunWorkerAsync();
            backgroundWorkerVideo.RunWorkerAsync();
            backgroundWorkerAudio.RunWorkerAsync();
            backgroundWorkerColor.RunWorkerAsync();
            backgroundWorkerAmbient.RunWorkerAsync();

            //Initiate all child forms
            this.IsMdiContainer = true;
            videoForm.MdiParent = audioForm.MdiParent = colorForm.MdiParent = ambientForm.MdiParent = this;

            colorForm.BackColor = Color.FromArgb(config.redAmount, config.greenAmount, config.blueAmount);

            //Open the form corresponding to the mode
            if (config.currentMode == Settings.mode.video)
            {
                currentForm = videoForm;
                videoForm.Show();
            }
            if (config.currentMode == Settings.mode.audio)
            {
                currentForm = audioForm;
                audioForm.Show();
            }
            if (config.currentMode == Settings.mode.color)
            {
                currentForm = colorForm;
                colorForm.Show();
            }
            if (config.currentMode == Settings.mode.ambient)
            {
                currentForm = ambientForm;
                ambientForm.Show();
            }
        }
Exemplo n.º 2
0
        private void Ambilight_Load(object sender, EventArgs e)
        {
            //All the control windows
            videoForm = new VideoForm(config);
            audioForm = new AudioForm(config);
            colorForm = new ColorForm(config);
            ambientForm = new AmbientForm(config);

            //Makes our life easier with the multithreading
            Control.CheckForIllegalCrossThreadCalls = false;

            config.setDefaultConfiguration(); //Set configuration to default to avoid errors
            LoadConfig(); //Load the configuration file

            packageData = new byte[config.numberOfLeds * 3 + 1]; //Update the size of data

            port = new SerialPort(config.port, config.baud, Parity.None, 8, StopBits.One);
            try
            {
                port.Open(); //Try to open the port
            }
            catch
            {
                //If the open fails the program will quit and xml-file must be changed
                MessageBox.Show("Could not open port, check config or arduino.");
                exitApplication();
            }

            //Start all the background workers
            backgroundWorkerDataSender.RunWorkerAsync();
            backgroundWorkerVideo.RunWorkerAsync();
            backgroundWorkerAudio.RunWorkerAsync();
            backgroundWorkerColor.RunWorkerAsync();
            backgroundWorkerAmbient.RunWorkerAsync();

            //Initiate all child forms
            this.IsMdiContainer = true;
            videoForm.MdiParent = audioForm.MdiParent = colorForm.MdiParent = ambientForm.MdiParent = this;

            colorForm.BackColor = Color.FromArgb(config.redAmount, config.greenAmount, config.blueAmount);

            //Open the form corresponding to the mode
            if (config.currentMode == Settings.mode.video)
            {
                currentForm = videoForm;
                videoForm.Show();
            }
            if (config.currentMode == Settings.mode.audio)
            {
                currentForm = audioForm;
                audioForm.Show();
            }
            if (config.currentMode == Settings.mode.color)
            {
                currentForm = colorForm;
                colorForm.Show();
            }
            if (config.currentMode == Settings.mode.ambient)
            {
                currentForm = ambientForm;
                ambientForm.Show();
            }
        }