Esempio n. 1
0
        public async void SendWorkerUpdates()
        {
            return;

            List <Task> task = new List <Task>();

            if (Mqtt.IsConnected == false)
            {
                Mqtt.Connect();
            }

            if (Mqtt.IsConnected)
            {
                if (Utils.Settings.SensorIsComputerUsedEnabled)
                {
                    task.Add(Task.Run(() => PublishStatus()));
                }
                if (Utils.Settings.SensorBatteryEnabled)
                {
                    task.Add(Task.Run(() => PublishBattery()));
                }
                if (Utils.Settings.WebCamPublishEnabled)
                {
                    task.Add(Task.Run(() => PublishCamera()));
                }
                if (Utils.Settings.ScreenshotEnable)
                {
                    task.Add(Task.Run(() => PublishScreenshot()));
                }
            }
            await Task.WhenAll(task).ConfigureAwait(false);
        }
Esempio n. 2
0
 private void PublishCamera()
 {
     if (Camera.Save(GLocalWebcamFile))
     {
         Mqtt.Publish(new MqttImageMessage("webcamera", GLocalWebcamFile));
     }
     else
     {
         MessageBox.Show($"Failed to save image");
     }
 }
Esempio n. 3
0
        private void PublishScreenshot()
        {
            if (NetworkUp())
            {
                using (var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb))
                {
                    using (var gfxScreenshot = Graphics.FromImage(bmpScreenshot))
                    {
                        gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);


                        bmpScreenshot.Save(GLocalScreetshotFile, ImageFormat.Png);

                        Mqtt.Publish(new MqttImageMessage("screenshot", GLocalWebcamFile));
                    }
                }
            }
        }