Example #1
0
        private void butConnect_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if (sensorHandler == null)
            {
                sensorHandler = new SensorHandler();
                sensorHandler.HandDetected += new EventHandler<EventArgs>(sensorHandler_HandDetected);
                sensorHandler.HoverDetected += new EventHandler<SelectableSlider2DHoverEventArgs>(sensorHandler_HoverDetected);
                sensorHandler.SessionEnded += new EventHandler<EventArgs>(sensorHandler_SessionEnded);

                if (!sensorHandler.isOK)
                {
                    sensorHandler.Dispose();
                    sensorHandler = null;
                    Cursor = Cursors.Default;
                    return;
                }

                Properties.Settings.Default.IpAddress = tbIp.Text;
                Properties.Settings.Default.Save();

                if (checkBoxXBMC.Checked)
                {
                    ButtonCodes.SetType(ClientType.XBMC);

                    ButtonSender buttonSender = new ButtonSender(ClientType.XBMC, Properties.Settings.Default.IpAddress, 9777);
                    buttonSender.SendNotification("KinEmote v0.3", "Connected");
                }
                else if (checkBoxBoxee.Checked)
                {
                    ButtonCodes.SetType(ClientType.Boxee);

                    ButtonSender buttonSender = new ButtonSender(ClientType.Boxee, Properties.Settings.Default.IpAddress, 9770);
                    buttonSender.SendNotification("KinEmote v0.3", "Connected");
                }
                else if (checkBoxCustom.Checked)
                {
                    ButtonCodes.SetType(ClientType.Custom);
                }

                butConnect.Text = "Disconnect";
            }
            else
            {
                sensorHandler.Dispose();
                sensorHandler = null;
                butConnect.Text = "Connect";
            }

            Cursor = Cursors.Default;
        }
Example #2
0
 private void Main_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (sensorHandler != null)
     {
         sensorHandler.Dispose();
         sensorHandler = null;
     }
     if (streamViewer != null)
     {
         if (!streamViewer.IsDisposed)
         {
             streamViewer.Close();
         }
     }
 }