Ejemplo n.º 1
0
        private void ProcessUpdates()
        {
            try
            {
                _UpdateThreadExit = false;

                while (_Connection.GetConnectionState() && !_UpdateThreadExit)
                {
                    // ----- Check if user is idle
                    if (_IdleTime != 0 && Win32Library.GetUserIdleTime() > _IdleTime)
                    {
                        if (!_IsIdle)
                        {
                            _Connection.SwitchOff();
                            _IsIdle = true;
                        }
                    }
                    else
                    {
                        if (_IsIdle)
                        {
                            _Connection.SwitchOn();
                            _Connection.ShowAll();
                            _Connection.SetBrightness(_Brightness);
                            _IsIdle = false;
                        }
                    }


                    // ----- Update plugins
                    if (_PluginManager != null)
                    {
                        _PluginManager.Update();
                    }


                    // ----- Update key state
                    byte lKeyState = _Connection.GetKeyState();
                    _KeyState[0].Update((lKeyState & 1) == 1);
                    _KeyState[1].Update((lKeyState & 2) == 2);
                    _KeyState[2].Update((lKeyState & 4) == 4);


                    // ----- Short break
                    Thread.Sleep(10);
                }

                _UpdateThreadExit = true;
                Terminate();
            }
            catch (ThreadAbortException)
            {
            }
        }
Ejemplo n.º 2
0
        private void ProcessUpdates()
        {
            try
            {
                _UpdateThreadExit = false;

                while (_Connection.GetConnectionState() && !_UpdateThreadExit)
                {
                    // ----- Check if user is idle
                    if (_IdleTime != 0 && Win32Library.GetUserIdleTime() > _IdleTime)
                    {
                        if (!_IsIdle)
                        {
                            _Connection.SwitchOff();
                            _IsIdle = true;
                        }
                    }
                    else
                    {
                        if (_IsIdle)
                        {
                            _Connection.SwitchOn();
                            _Connection.ShowAll();
                            _Connection.SetBrightness(_Brightness);
                            _IsIdle = false;
                        }
                    }


                    // ----- Update plugins
                    for (byte i = 0; i < 3; i++)
                    {
                        // Update plugins
                        OptimusMiniPluginWorkerBase lPlugin = _Plugins[i];
                        if (lPlugin != null)
                        {
                            // Check for updated images
                            if (lPlugin._Bitmap != null)
                            {
                                Bitmap lBitmap = lPlugin._Bitmap;
                                lPlugin._Bitmap = null;

                                _LastImage[i] = lBitmap.Clone(new Rectangle(0, 0, 96, 96), PixelFormat.Format24bppRgb);
                                RotateImage(lBitmap);
                                _Connection.SetImage(MapKeyIndex(i), lBitmap);
                                lBitmap.Dispose();
                            }

                            // Start update
                            if (lPlugin.IsNextUpdateDue())
                            {
                                ThreadPool.QueueUserWorkItem(new WaitCallback(lPlugin.Update));
                                //lPlugin.Update(null);
                            }
                        }


                        // ----- Update key state
                        byte lKeyState = _Connection.GetKeyState();
                        _KeyState[0].Update((lKeyState & 1) == 1);
                        _KeyState[1].Update((lKeyState & 2) == 2);
                        _KeyState[2].Update((lKeyState & 4) == 4);
                    }

                    Thread.Sleep(10);
                }

                _UpdateThreadExit = true;
                Terminate();
            }
            catch (ThreadAbortException)
            {
            }
        }