예제 #1
0
        public override void Load()
        {
            try
            {
                DeviceList    = Device.GetLookupList(null, "Measurement", true);
                CurrentDevice = DeviceList.First();

                lock (m_subscribedMeasurementsLock)
                {
                    if ((object)m_currentSubscribedMeasurementsPage != null && m_currentSubscribedMeasurementsPage.Count > 0)
                    {
                        m_authorizationQuery.RequestAuthorizationStatus(m_currentSubscribedMeasurementsPage.Select(measurement => measurement.SignalID));
                    }
                }

                m_refreshTimer.Start();
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    Popup(ex.Message + Environment.NewLine + "Inner Exception: " + ex.InnerException.Message, "Load " + DataModelName + " Exception:", MessageBoxImage.Error);
                    CommonFunctions.LogException(null, "Load " + DataModelName, ex.InnerException);
                }
                else
                {
                    Popup(ex.Message, "Load " + DataModelName + " Exception:", MessageBoxImage.Error);
                    CommonFunctions.LogException(null, "Load " + DataModelName, ex);
                }
            }
        }
        public WindowsSession()
        {
            IDeviceList list = new DeviceList();

            list.Scan();
            IDevice device = list.First() ?? throw new ApplicationException("Could not find a device");

            this.stateHandler = new StateHandler.StateHandler(device, FocusState.Low, PhysicalPresence.Present);

            this.Initialize();
        }
예제 #3
0
파일: Program.cs 프로젝트: Djuuu/LuxaforCli
        public static IDevice GetDevice()
        {
            IDeviceList list = new DeviceList();
            list.Scan();

            if (list.Count() == 0)
            {
                throw new Exception("No Luxafor device found");
            }

            return list.First();
        }
예제 #4
0
        private static void setColor()
        {
            if (IsAudioPlaying(audioDevice))
            {
                return;
            }
            IDeviceList list = new DeviceList();

            list.Scan();
            var device = list.First();

            device.SetColor(LedTarget.All, defaultColor);
        }
예제 #5
0
        public MainView()
        {
            IDeviceList listOfDevices = new DeviceList();

            listOfDevices.Scan();
            device = listOfDevices.First();
            InitializeComponent();

            colorsBox.DataSource    = new BindingSource(colors.ColorsMap, null);
            colorsBox.DisplayMember = "Key";
            colorsBox.ValueMember   = "Value";
            pomodoroPanel.Visible   = true;
            settingsPanel.Visible   = false;
        }
예제 #6
0
        private bool ConnectLuxafor()
        {
            try
            {
                IDeviceList list = new DeviceList();
                list.Scan();
                _device = list.First();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message.ToString());
                return(false);
            }

            return(true);
        }
예제 #7
0
        private bool ConnectLuxafor()
        {
            try
            {
                IDeviceList list = new DeviceList();
                list.Scan();
                _device = list.First();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message.ToString());
                setStatusText("Error: Can't find Luxafor device.");
                return(false);
            }

            ToggleAutomatic();
            return(true);
        }
 private void ServiceWorkerThread(object state)
 {
     while (!this.isStopping)
     {
         IDeviceList list = new DeviceList();
         list.Scan();
         IDevice device = list.First();
         if (device != null && IsAudioPlaying(audioDevice))
         {
             device.SetColor(LedTarget.All, new Color(255, 255, 0));
         }
         else if (device != null)
         {
             device.SetColor(LedTarget.All, new Color(0, 255, 0));
         }
         Thread.Sleep(500);
     }
 }
예제 #9
0
 private static void ServiceWorkerThread(object state)
 {
     while (!isStopping)
     {
         IDeviceList list = new DeviceList();
         list.Scan();
         if (list.Any())
         {
             var device = list.First();
             if (device != null && IsAudioPlaying(audioDevice))
             {
                 device.SetColor(LedTarget.All, yellow);
             }
             else
             {
                 device?.SetColor(LedTarget.All, defaultColor);
             }
         }
         Thread.Sleep(500);
     }
 }
        private void LoadDevices(JObject payload)
        {
            _devIdNameMap = new Dictionary<string, Device>();
            List<Device> temp = new List<Device>();

            foreach (var deviceToken in payload["deviceInfos"])
            {
                Device device = new Device()
                {
                    DeviceId = deviceToken["id"].ToString(),
                    DisplayName = deviceToken["extendedDisplayName"].ToString()
                };

                _devIdNameMap.Add(deviceToken["id"].ToString(), device);
                temp.Add(device);
            }

            DeviceList = temp;

            RefreshBattery();

            SelectedDevice = DeviceList.SingleOrDefault(x => x.DeviceId == Settings.Default.LastDeviceId) ?? DeviceList.First();

            SelectedDevice.IsChecked = true;
        }