public void SetCurrentDevice(HoloDevice device)
 {
     CurrentDevice = device;
     if (CurrentDeviceChanged != null)
     {
         CurrentDeviceChanged(this, CurrentDevice);
     }
 }
Пример #2
0
        private async void ChangeIPDMode(Mode newMode)
        {
            switch (_currentMode)
            {
            case Mode.DeviceList:
            case Mode.NFCReader:
                _holoDeviceManager.CurrentDeviceChanged -= _holoDeviceManager_CurrentDeviceChanged;
                _holoDeviceManager.ShutDown();
                break;
            }

            _currentMode = newMode;

            switch (_currentMode)
            {
            case Mode.DeviceList:
                _holoDeviceManager           = new HoloDeviceManager();
                DeviceList.ItemsSource       = _holoDeviceManager.Devices;
                SelectDeviceList.ItemsSource = _holoDeviceManager.Devices;

                // Enable this to automatically add a LocalHost hololens with a known username and password
                if (false)
                {
                    var newDevice = new HoloDevice("LocalHost", "http://127.0.0.1:10080", "user", "password");
                    await newDevice.Initialize(false);

                    if (newDevice.Portal != null && newDevice.Portal.ConnectionHttpStatusCode != System.Net.HttpStatusCode.OK)
                    {
                        MessageBox.Show("Failed to connect to HoloLens: \n" + newDevice.Portal.ConnectionFailedDescription);
                    }

                    _holoDeviceManager.AddDevice(newDevice);
                }
                break;

            case Mode.NFCReader:
                _holoDeviceManager = new NFCHoloDeviceManager();
                break;
            }
            if (_holoDeviceManager != null)
            {
                _holoDeviceManager.CurrentDeviceChanged += _holoDeviceManager_CurrentDeviceChanged;
                _holoDeviceManager_CurrentDeviceChanged(_holoDeviceManager, _holoDeviceManager.CurrentDevice);
            }

            DeviceListContainer.Visibility    = _currentMode == Mode.DeviceList ? Visibility.Visible : Visibility.Hidden;
            CurrentDeviceContainer.Visibility = _currentMode != Mode.DisplayOnly ? Visibility.Visible : Visibility.Hidden;
            SelectDeviceList.Visibility       = _currentMode == Mode.DeviceList ? Visibility.Visible : Visibility.Hidden;
        }
 public void RemoveDevice(HoloDevice device)
 {
     Devices.Remove(device);
     if (CurrentDevice == null)
     {
         if (Devices.Count > 0)
         {
             SetCurrentDevice(Devices[0]);
         }
         else
         {
             SetCurrentDevice(null);
         }
     }
 }
Пример #4
0
        private async void setCredentials_Click(object sender, RoutedEventArgs e)
        {
            var newDevice    = new HoloDevice();
            var dialogResult = await newDevice.Initialize(true);

            if (dialogResult)
            {
                if (newDevice.Portal != null && newDevice.Portal.ConnectionHttpStatusCode != System.Net.HttpStatusCode.OK)
                {
                    MessageBox.Show("Failed to connect to HoloLens: \n" + newDevice.Portal.ConnectionFailedDescription);
                }
                else
                {
                    _holoDeviceManager.AddDevice(newDevice);
                }
            }
        }
Пример #5
0
        private void _holoDeviceManager_CurrentDeviceChanged(object sender, HoloDevice currentDevice)
        {
            if (currentDevice != null)
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    CurrentDeviceNameText.Text = currentDevice.ToString();
                }));
            }
            switch (_currentMode)
            {
            case Mode.DeviceList:
                SelectDeviceList.SelectedItem = currentDevice;
                break;

            case Mode.NFCReader:
                if (currentDevice == null)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        CurrentDeviceNameText.Text = "Waiting for NFC tag.";
                    }));
                }
                else if (!currentDevice.IsValid)
                {
                    Dispatcher.Invoke(new Action(async() =>
                    {
                        if (MessageBox.Show("Press OK to program the NFC tag.", "Format NFC", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                        {
                            await currentDevice.Initialize(true);
                            if (!currentDevice.Save())
                            {
                                MessageBox.Show("Couldn't write the data to the NFC tag.", "Error", MessageBoxButton.OK);
                            }
                            _holoDeviceManager.SetCurrentDevice(currentDevice);
                        }
                    }));
                }
                break;
            }
        }
 public void AddDevice(HoloDevice newDevice)
 {
     Devices.Add(newDevice);
     SetCurrentDevice(newDevice);
 }