public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
 {
     // We still receive events from previous device, so this check is important
     // to filter events from device relevant/selected device only
     if (Device != null && Device == sender as DeviceViewModel)
     {
         Сonnected.State     = StateControlViewModel.BoolToState(Device.IsConnected);
         Initialized.State   = StateControlViewModel.BoolToState(Device.IsInitialized);
         Authorized.State    = StateControlViewModel.BoolToState(Device.IsAuthorized);
         StorageLoaded.State = StateControlViewModel.BoolToState(Device.IsStorageLoaded);
     }
     return(true);
 }
        public DeviceSettingsPageViewModel(IServiceProxy serviceProxy, IWindowsManager windowsManager, IActiveDevice activeDevice, IMetaPubSub metaMessenger)
        {
            this.serviceProxy   = serviceProxy;
            this.windowsManager = windowsManager;
            _metaMessenger      = metaMessenger;

            _metaMessenger.Subscribe <ActiveDeviceChangedMessage>(OnActiveDeviceChanged);

            Сonnected = new StateControlViewModel
            {
                Name    = "Status.Device.Сonnected",
                Visible = true,
            };
            Initialized = new StateControlViewModel
            {
                Name    = "Status.Device.Initialized",
                Visible = true,
            };
            Authorized = new StateControlViewModel
            {
                Name    = "Status.Device.Authorized",
                Visible = true,
            };
            StorageLoaded = new StateControlViewModel
            {
                Name    = "Status.Device.StorageLoaded",
                Visible = true,
            };

            Indicators.Add(Сonnected);
            Indicators.Add(Initialized);
            Indicators.Add(Authorized);
            Indicators.Add(StorageLoaded);

            this.WhenAnyValue(x => x.Device).Where(d => d != null).Subscribe(d =>
            {
                PropertyChangedEventManager.AddListener(Device, this, nameof(Device.IsConnected));
                PropertyChangedEventManager.AddListener(Device, this, nameof(Device.IsInitialized));
                PropertyChangedEventManager.AddListener(Device, this, nameof(Device.IsAuthorized));
                PropertyChangedEventManager.AddListener(Device, this, nameof(Device.IsStorageLoaded));

                Сonnected.State     = StateControlViewModel.BoolToState(Device.IsConnected);
                Initialized.State   = StateControlViewModel.BoolToState(Device.IsInitialized);
                Authorized.State    = StateControlViewModel.BoolToState(Device.IsAuthorized);
                StorageLoaded.State = StateControlViewModel.BoolToState(Device.IsStorageLoaded);
            });

            this.WhenAnyValue(x => x.LockProximity, x => x.UnlockProximity).Where(t => t.Item1 != 0 && t.Item2 != 0).Subscribe(o => ProximityHasChanges = true);

            Device = activeDevice.Device != null ? new DeviceViewModel(activeDevice.Device) : null;
        }