Example #1
0
        private void LoadFeatures(List <DeviceViewModel> deviceList = null)
        {
            if (deviceList == null)
            {
                var registeredDevices = Settings.RegisteredDevices;
                // Generate View Models for devices and assign to Device Collection
                deviceList    = DeviceViewModel.GetViewModels(registeredDevices);
                NumberDevices = deviceList.Count;
            }
            int index = 0;

            if (deviceList != null)
            {
                _fullFeatureLists = new List <List <FeaturesViewModel> > (0);
                foreach (DeviceViewModel device in deviceList)
                {
                    var fullFeatureList = FeaturesViewModel.GetFeaturesViewModels(device.DeviceFeatures, this);
                    _fullFeatureLists.Add(fullFeatureList);
                }
                FullFeatureCollection = new ObservableCollection <List <FeaturesViewModel> >(_fullFeatureLists);
                if (deviceList.Count > 0)
                {
                    if (CurrentDeviceSelection == -1)
                    {
                        index = (int)Math.Round((deviceList.Count - 1.0) / 2, 1);
                        CurrentDeviceSelection = index;  // will load Feature Collection
                    }
                    else
                    {
                        index             = CurrentDeviceSelection;
                        FeatureCollection = new ObservableCollection <FeaturesViewModel>(_fullFeatureLists[index].Where(f => !f.FeatureType.Equals(FeatureType.SubType) || f.Expanded));
                    }
                }
            }
        }
        public static List <DeviceViewModel> GetViewModels(List <Device> devices)
        {
            List <DeviceViewModel> viewModels = new List <DeviceViewModel>();

            foreach (Device device in devices)
            {
                var vm = new DeviceViewModel(device);
                viewModels.Add(vm);
            }
            return(viewModels);
        }
Example #3
0
        private void LoadDevices()
        {
            // get the current registered devices from storage
            // (note: if demo this should have been padded with dummy devices to ensure at least 3
            var registeredDevices = Settings.RegisteredDevices;

            // Generate View Models for devices and assign to Device Collection
            DeviceList       = DeviceViewModel.GetViewModels(registeredDevices);
            NumberDevices    = DeviceList.Count;
            DeviceCollection = new ObservableCollection <DeviceViewModel>(DeviceList);
        }