Example #1
0
 private void colorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (config.currentMode != Settings.mode.color) //If current mode is same, do nothing
     {
         currentForm.Hide();                        //Hide the current form
         colorForm.Show();                          //Show new form
         currentForm = colorForm;                   //Set currentForm to the new form
         lastRed--;                                 //Change lastRed to force the color to update
         config.currentMode = Settings.mode.color;  //Set current mode to new mode
     }
 }
Example #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();
            }
        }
Example #3
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();
            }
        }