Exemplo n.º 1
0
        public override async Task Initialize()
        {
            DeviceLocator.OnDeviceFound += OnDeviceFound;
            await DeviceLocator.Discover();

            var keyboard = Service.Get <Keyboard>();

            keyboard.KeyPress += OnKeyPress;

            _lightsTimer = new QueuedTimer(async x => await OnLightsTimer(), TimerInterval);
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            if (_initialized)
            {
                throw new Exception("Initialize has already been invoked.");
            }

            // poll connections once per second starting immediately
            _connectionTimer = new QueuedTimer(
                state => EnsureConnection(),
                1000
                );

            _device.OnInitialize(this);

            DeviceList.Local.Changed += OnDeviceListChanged;

            _initialized = true;
        }
Exemplo n.º 3
0
        private static async Task Main(string[] args)
        {
            var displays = DisplayHandler.GetAll();

            var width  = 0;
            var height = 0;

            foreach (var display in displays)
            {
                width  += display.Width;
                height += display.Height;
            }

            _area = new Rectangle(
                0,
                0,
                width,
                height
                );

            _widgetService = new WidgetService();
            await _widgetService.Initialize();

            _bufferedGraphicsContext = new BufferedGraphicsContext();

            DesktopHandler.Initialize();

            var updateTimer = new QueuedTimer(async x => await Update(), UpdateInterval);
            var renderTimer = new QueuedTimer(async x => await Render(), RenderInterval);

            GC.KeepAlive(updateTimer);
            GC.KeepAlive(renderTimer);

            AppDomain.CurrentDomain.ProcessExit        += OnProcessExit;
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            SystemEvents.SessionEnded += OnSessionEnded;

            new ManualResetEvent(false).WaitOne();
        }
Exemplo n.º 4
0
        public override void OnInitialize(Connector connector)
        {
            var batteryProcessor = new BatteryReportProcessor(this);

            batteryProcessor.BatteryUpdated += OnBatteryUpdated;

            var errorProcessor = new ErrorReportProcessor();

            errorProcessor.ErrorReceived += connector.Reset;

            Processors = new ReportProcessor[]
            {
                batteryProcessor,
                errorProcessor
            };

            // poll battery status once per minute starting after 3 seconds
            _batteryTimer = new QueuedTimer(
                state => connector.IssueReport((byte)ReportSize.Short, DeviceId, (byte)ReportType.Battery),
                3000,
                60000
                );
        }