Ejemplo n.º 1
0
        private void FMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            HueLogic.PutBridge(1, true, 0, 0, 50);
            HueLogic.PutBridge(2, true, 0, 0, 50);

            if (oSerialPort != null)
            {
                CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Write("OUT00");
                CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Write("OUT10");
                oSerialPort.Close();
            }

            //this.Close();
        }
Ejemplo n.º 2
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            HueLogic.PutBridge(1, true, 0, 0, 50);
            HueLogic.PutBridge(2, true, 0, 0, 50);

            if (oSerialPort != null)
            {
                CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Write("OUT00");
                CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Write("OUT10");
                oSerialPort.Close();
            }

            this.Close();
        }
Ejemplo n.º 3
0
        private void configurarLâmpadasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FConfigBridge oConfigBridge = new FConfigBridge();

            oConfigBridge.ShowDialog();

            if (oConfigBridge.IP != "")
            {
                string sIP = oConfigBridge.IP;

                HueLogic.FindBridgeIP(sIP);
                MessageBox.Show("Aperte o botão da Philips Bridge.");
                HueLogic.ConnectBridge("Philips hue");
                HueLogic.GetBridge();
            }
        }
Ejemplo n.º 4
0
        private void StartEffect(string EffectStream)
        {
            SoundPlayer player      = new SoundPlayer();
            var         mediaPlayer = new MediaPlayer.MediaPlayer();

            player.Stop();
            mediaPlayer.Stop();

            string[] codes       = EffectStream.Split('|');
            string   sEffectType = "";
            string   sEffect     = "";


            foreach (var code in codes)
            {
                if (code != "")
                {
                    sEffectType = code.Substring(0, 1);
                    sEffect     = CConfig.Instance.GetEffect(code);
                }

                try
                {
                    switch (sEffectType)
                    {
                    case "H":


                        if (sEffect.Contains("mp3"))
                        {
                            mediaPlayer.FileName = sEffect;
                            mediaPlayer.Play();
                        }
                        else
                        {
                            player.SoundLocation = sEffect;
                            player.Play();
                        }
                        break;

                    case "L":
                        int iBrightness1 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Brightness1=") + "Brightness1=".Length, 3));
                        int iBrightness2 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Brightness2=") + "Brightness2=".Length, 3));
                        int iSaturation1 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Saturation1=") + "Saturation1=".Length, 3));
                        int iSaturation2 = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Saturation2=") + "Saturation2=".Length, 3));
                        int iHue1        = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Hue1=") + "Hue1=".Length, 5));
                        int iHue2        = Convert.ToInt32(sEffect.Substring(sEffect.IndexOf("Hue2=") + "Hue2=".Length, 5));

                        HueLogic.PutBridge(1, true, iSaturation1, iBrightness1, iHue1);
                        HueLogic.PutBridge(2, true, iSaturation2, iBrightness2, iHue2);

                        break;

                    case "O":
                    case "A":
                        try
                        {
                            CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Write(sEffect);
                        }
                        catch
                        {
                            CConfig.Instance.InterfaceSerial.InterfaceSerialPort.Close();
                            return;
                        }

                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                }
            }
        }