Exemplo n.º 1
0
 private async void LightComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         await HueHelper.SelectLight((string)e.AddedItems[0]);
     }
 }
Exemplo n.º 2
0
 private async void LightBrightness_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
 {
     if (HueHelper != null)
     {
         await HueHelper.ChangeBrightness((byte)e.NewValue);
     }
 }
Exemplo n.º 3
0
        public MainPage()
        {
            this.InitializeComponent();

            ranOnLaunchInternetTasks        = false;
            currentNetworkConnectivityLevel = NetworkInformation.GetInternetConnectionProfile().GetNetworkConnectivityLevel();
            Window.Current.Activated       += Current_Activated;

            NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;

            string deviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily;

            if (deviceFamily.Contains("Mobile"))
            {
                device = Device.Mobile;
            }
            else if (deviceFamily.Contains("Desktop"))
            {
                device = Device.Desktop;
            }
            else
            {
                device = Device.Other;
            }

            mediaPlayer              = new MediaPlayer();
            mediaPlayer.MediaEnded  += MediaPlayer_MediaEnded;
            mediaPlayer.MediaFailed += MediaPlayer_MediaFailed;
            mediaPlayerElement.SetMediaPlayer(mediaPlayer);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
            httpClient           = new HttpClient();
            appleMovieDownloader = new AppleMovieDownloader(httpClient);
            sunrise          = DateTime.MinValue;
            sunset           = DateTime.MinValue;
            lastPositions    = new Queue <TimeSpan>();
            SpotifyHelper    = new SpotifyHelper();
            HueHelper        = new HueHelper();
            AirQualityHelper = new AirQualityHelper();
            CalendarHelper   = new CalendarHelper();

            rotationBuffer = 0;
            lightMode      = LightMode.Brightness;

            if (device == Device.Desktop)
            {
                dial = RadialController.CreateForCurrentView();
                dial.RotationResolutionInDegrees = 5;
                dial.UseAutomaticHapticFeedback  = false;
                dialConfig            = RadialControllerConfiguration.GetForCurrentView();
                menuItems             = new List <RadialControllerMenuItem>();
                isWindowFocused       = true;
                dial.ButtonClicked   += Dial_ButtonClicked;
                dial.RotationChanged += Dial_RotationChanged;
                dial.ControlAcquired += Dial_ControlAcquired;
                dial.ControlLost     += Dial_ControlLost;
            }
        }
Exemplo n.º 4
0
 private async Task FlushRotation()
 {
     if (rotationBuffer != 0)
     {
         short rotation = (short)rotationBuffer;
         if (lightMode == LightMode.Temperature)
         {
             await HueHelper.IncreaseDecreaseTemperature((short)-rotation);
         }
         else if (lightMode == LightMode.Color)
         {
             await HueHelper.IncreaseDecreaseColor((short)(rotation * 182));
         }
         else if (lightMode == LightMode.Brightness)
         {
             LightBrightness.Value += rotation;
         }
         rotationBuffer = 0;
     }
 }
Exemplo n.º 5
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            GeolocationAccessStatus accessStatus = await Geolocator.RequestAccessAsync();

            await RunOnLaunchInternetTasks();

            await HueHelper.Setup();

            if (device == Device.Desktop)
            {
                BuildDialMenu();
            }
            Task refreshLightStatus        = HueHelper.RefreshStatus();
            Task updateClockTask           = UpdateClockUI();
            Task checkFrozenVideo          = CheckFrozenVideo();
            Task processRotationBufferTask = ProcessRotationBuffer();

            _ = AirQualityHelper.Run();
            _ = CalendarHelper.Run();

            base.OnNavigatedTo(e);
        }
Exemplo n.º 6
0
 private async void LightSwitch_Click(object sender, RoutedEventArgs e)
 {
     await HueHelper.ToggleLight();
 }
Exemplo n.º 7
0
 private async void Dial_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
 {
     await HueHelper.ToggleLight();
 }