Пример #1
0
 public LifxGroup(string json, LifxManager manager)
 {
     this.manager = manager;
     JToken bulbData = JToken.Parse(json);
     this.name = bulbData.Value<string>("name");
     this.id = bulbData.Value<string>("id");
 }
Пример #2
0
 public LifxLocation(string json, LifxManager manager)
 {
     this.manager = manager;
       var bulbData = JToken.Parse(json);
     this.name = bulbData.Value<string>("name");
     this.id = bulbData.Value<string>("id");
 }
Пример #3
0
        public LifxLocation(string json, LifxManager manager)
        {
            this.manager = manager;
            var bulbData = JToken.Parse(json);

            this.name = bulbData.Value <string>("name");
            this.id   = bulbData.Value <string>("id");
        }
Пример #4
0
        public LifxGroup(string json, LifxManager manager)
        {
            this.manager = manager;
            JToken bulbData = JToken.Parse(json);

            this.name = bulbData.Value <string>("name");
            this.id   = bulbData.Value <string>("id");
        }
 public LightsDetailPage(LifxBulb bulb)
 {
     InitializeComponent();
     lifxManager           = new LifxManager();
     thisBulb              = bulb;
     LightLabel.Text       = bulb.Label;
     LightSwitch.IsToggled = bulb.Power;
 }
Пример #6
0
        public LightsPage()
        {
            this.InitializeComponent();
            lifxManager = new LifxManager();
            items       = new List <LifxBulb>();
            bulbs       = new ObservableCollection <LifxBulb>();

            Device.BeginInvokeOnMainThread(async() =>
            {
                items                       = await lifxManager.listBulbs();
                ListView lstView            = new ListView();
                lstView.RowHeight           = 60;
                this.Title                  = "Lights";
                lstView.ItemTemplate        = new DataTemplate(typeof(CustomLightsCell));
                lstView.GroupHeaderTemplate = new DataTemplate(typeof(CustomLightsGroupedCell));

                if (items.Count > 0)
                {
                    var grouped = new ObservableCollection <LifxStairs>();

                    var rdc = new LifxStairs()
                    {
                        Title = "Rez de chaussée", ShortName = "RDC"
                    };
                    var etage = new LifxStairs()
                    {
                        Title = "1er Etage", ShortName = "1Et"
                    };

                    foreach (var item in items)
                    {
                        if (item.Group.name.Equals("RDC"))
                        {
                            rdc.Add(item);
                        }
                        else if (item.Group.name.Equals("Etage"))
                        {
                            etage.Add(item);
                        }
                    }
                    ;

                    grouped.Add(rdc);
                    grouped.Add(etage);

                    lstView.ItemsSource            = grouped;
                    lstView.IsGroupingEnabled      = true;
                    lstView.GroupDisplayBinding    = new Binding("Title");
                    lstView.IsPullToRefreshEnabled = true;
                    lstView.ItemSelected          += OnItemSelected;
                    lstView.IsPullToRefreshEnabled = true;
                    lstView.Refreshing            += OnItemRefresh;
                    Content = lstView;
                }
            });
        }
Пример #7
0
 public LifxBulb(string json, LifxManager manager)
 {
     JToken bulbData = JObject.Parse(json);
         this.manager = manager;
         id = bulbData.Value<string>("id");
         uuid = bulbData.Value<string>("uuid");
         label = bulbData.Value<string>("label");
         connected = bulbData.Value<bool>("connected");
         power = bulbData.Value<string>("power");
         brightness = bulbData.Value<float>("brightness");
         color = new LifxColor(bulbData.Value<JToken>("color").ToString());
         group = new LifxGroup(bulbData.Value<JToken>("group").ToString(), manager);
         location = new LifxLocation(bulbData.Value<JToken>("location").ToString(), manager);
         productName = bulbData.Value<string>("product_name");
         capabilities = new LifxCapability(bulbData.Value<JToken>("capabilities").ToString());
         lastSeen = bulbData.Value<string>("last_seen");
         secondsSinceSeen = bulbData.Value<double>("seconds_since_seen");
 }
Пример #8
0
        public LifxBulb(string json, LifxManager manager)
        {
            JToken bulbData = JObject.Parse(json);

            this.manager = manager;
            id           = bulbData.Value <string>("id");
            Uuid         = bulbData.Value <string>("uuid");
            Label        = bulbData.Value <string>("label");
            Connected    = bulbData.Value <bool>("connected") ? "Online" : "Offline";
            Power        = bulbData.Value <string>("power").Equals("on") && Connected.Equals("Online") ? true : false;
            Brightness   = bulbData.Value <float>("brightness");
            Color        = new LifxColor(bulbData.Value <JToken>("color").ToString());
            Group        = new LifxGroup(bulbData.Value <JToken>("group").ToString(), manager);
            Location     = new LifxLocation(bulbData.Value <JToken>("location").ToString(), manager);
            ProductName  = bulbData.Value <string>("product_name");
            //Capabilities = new LifxCapability(bulbData.Value<JToken>("capabilities").ToString());
            LastSeen         = bulbData.Value <string>("last_seen");
            SecondsSinceSeen = bulbData.Value <double>("seconds_since_seen");
        }