Пример #1
0
        private async Task Loader()
        {
            _lightsMainNode.Nodes.Clear();

            DeviceLocator.UseAllAvailableMulticastAddresses = _settings.AppSettings.MulticastLookup;

            var devices = await DeviceLocator.DiscoverAsync();

            foreach (Device device in devices.OrderBy(m => m.Name))
            {
                Guid pageGuid = Guid.NewGuid();

                Aside.Invoke((MethodInvoker) delegate()
                {
                    Aside.CreateChildNode(_lightsMainNode, AddPage(new LightPage(
                                                                       new DeviceViewModel
                    {
                        Device   = device,
                        Hostname = device.Hostname,
                        Name     = device.Name,
                        IsOn     = device.Properties.FirstOrDefault(m => m.Key == "power").Value.ToString(),
                        PageGuid = pageGuid
                    }), pageGuid));
                });
            }
            Aside.Invoke((MethodInvoker) delegate()
            {
                Aside.SelectFirst();
            });

            _lightsMainNode.Expand();
        }