//update the controller color for each of the items
 void SetControllerDotColor(Label dot, int controller)
 {
     if (!ControllerWork.IsControllerConnected(controller))
     {
         dot.ForeColor = Color.Gray;
     }
     else if (ControlState.GetControllerEnabled(controller))
     {
         dot.ForeColor = Color.Green;
     }
     else
     {
         dot.ForeColor = Color.Gray;
     }
 }
Пример #2
0
        //when the application loads
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //hide the window and the taskbar icon
            Visible       = false;
            ShowInTaskbar = false;

            //run the controller code
            bool   run = true;
            Thread t   =
                new Thread(
                    delegate() {
                while (run)
                {
                    ControllerWork.Update();
                    KeyboardWork.Update();
                    Thread.Sleep(1000 / 60);
                }
            }
                    );

            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            //run the loop here
            while (!this.IsDisposed)
            {
                if (ControlState.GetSystemEnabled())
                {
                    _icon.Icon = XMouse.Properties.Resources.trayIcon_sm_enabled;
                }
                else
                {
                    _icon.Icon = XMouse.Properties.Resources.trayIcon_sm_disabled;
                }

                //allow the form app to call it events
                Application.DoEvents();

                Thread.Sleep(200);
            }

            //stop the thread
            run = false;
        }