Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MixedRealityViewDialogViewModel" /> class.
        /// </summary>
        /// <param name="monitor">The HoloLensMonitor responsible for communication with this HoloLens.</param>
        public MixedRealityViewDialogViewModel(
            HoloLensMonitor monitor)
        {
            this.holoLensMonitor = monitor;

            this.StartLiveView();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HoloLensMonitorControl" /> class.
 /// </summary>
 /// <param name="monitor">The HoloLensMonitor that is responsible for communication with the HoloLens.</param>
 public HoloLensMonitorControl(
     HoloLensMonitor monitor)
 {
     this.DataContext = new HoloLensMonitorControlViewModel(
         this,
         monitor);
     this.InitializeComponent();
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManageAppsDialog" /> class.
 /// </summary>
 /// <param name="monitor">The HoloLensMonitor that is responsible for communication with the HoloLens.</param>
 /// <param name="monitorControl">The HoloLensMonitor control that launched this dialog.</param>
 public ManageAppsDialog(
     HoloLensMonitor monitor,
     HoloLensMonitorControl monitorControl)
 {
     this.DataContext = new ManageAppsDialogViewModel(
         monitor,
         monitorControl);
     this.InitializeComponent();
 }
Esempio n. 4
0
        /// <summary>
        /// Cleans up objects managed by the HoloLensMonitorControlViewModel.
        /// </summary>
        /// <remarks>
        /// Failure to call this method will result in the object not being collected until
        /// finalization occurs.
        /// </remarks>
        public void Dispose()
        {
            Debug.WriteLine("[HoloLensMonitorControlViewModel.Dispose]");
            this.holoLensMonitor.HeartbeatLost     -= HoloLens_HeartbeatLost;
            this.holoLensMonitor.HeartbeatReceived -= HoloLens_HeartbeatReceived;
            this.holoLensMonitor.AppInstallStatus  -= HoloLensMonitor_AppInstallStatus;
            this.holoLensMonitor.Dispose();
            this.holoLensMonitor = null;

            GC.SuppressFinalize(this);
        }
Esempio n. 5
0
 /// <summary>
 /// Handles the ApplicationInstallStatus event.
 /// </summary>
 /// <param name="sender">The object which sent this event.</param>
 /// <param name="args">Event arguments.</param>
 private void HoloLensMonitor_AppInstallStatus(
     HoloLensMonitor sender,
     ApplicationInstallStatusEventArgs args)
 {
     if (args.Status == ApplicationInstallStatus.Completed)
     {
         // Assigning the return value of RefreshInstalledAppsAsync to a Task object to avoid
         // warning 4014 (call is not awaited).
         Task t = this.RefreshInstalledAppsAsync();
     }
 }
        /// <summary>
        /// Implementation of the connect to device command.
        /// </summary>
        /// <param name="connectOptions">Options used when connecting to the HoloLens.</param>
        /// <param name="name">Descriptive name to assign to the HoloLens.</param>
        /// <param name="suppressDialog">True causes the connection dialog to not be shown./param>
        /// <returns>Task object used for tracking method completion.</returns>
        private async Task ConnectToDeviceAsync(
            ConnectOptions connectOptions,
            string name,
            bool suppressDialog = false)
        {
            this.StatusMessage = string.Empty;

            if (!suppressDialog)
            {
                ContentDialog       dialog = new ConnectToDeviceDialog(connectOptions);
                ContentDialogResult result = await dialog.ShowAsync().AsTask <ContentDialogResult>();

                // Primary button == "Ok"
                if (result != ContentDialogResult.Primary)
                {
                    // The user decided not to connect.
                    return;
                }
            }

            if (string.IsNullOrWhiteSpace(connectOptions.Address))
            {
                connectOptions.Address = DefaultConnectionAddress;
            }

            HoloLensMonitor monitor = new HoloLensMonitor(this.dispatcher);

            try
            {
                await monitor.ConnectAsync(connectOptions);

                await this.RegisterHoloLensAsync(
                    monitor,
                    name);

                await this.RefreshCommonAppsAsync();

                this.StatusMessage = string.Format(
                    "Connected to the HoloLens at {0}",
                    monitor.Address);
            }
            catch
            {
                string addr = connectOptions.Address;
                if (connectOptions.Address == "localhost:10080")
                {
                    addr = "the attached HoloLens";
                }

                this.StatusMessage = string.Format(
                    "Failed to connect to {0}. Is it powered on? Paired with the Windows Device Portal?",
                    addr);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HoloLensMonitorControlViewModel" /> class.
        /// </summary>
        /// <param name="control">The HoloLensMonitorControl to which this object is registered.</param>
        /// <param name="monitor">The HoloLensMonitor responsible for communication with this HoloLens.</param>
        public HoloLensMonitorControlViewModel(
            HoloLensMonitorControl control,
            HoloLensMonitor monitor)
        {
            this.holoLensMonitorControl = control;

            this.RegisterCommands();

            this.holoLensMonitor = monitor;
            this.holoLensMonitor.HeartbeatLost     += HoloLens_HeartbeatLost;
            this.holoLensMonitor.HeartbeatReceived += HoloLens_HeartbeatReceived;
            this.holoLensMonitor.AppInstallStatus  += HoloLensMonitor_AppInstallStatus;

            this.IsConnected = true;

            this.Address    = holoLensMonitor.Address;
            this.IsSelected = true;
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManageAppsDialogViewModel" /> class.
        /// </summary>
        /// <param name="monitor">The HoloLensMonitor responsible for communication with this HoloLens.</param>
        /// <param name="monitorControl">Instance of the control that launched this dialog.</param>
        public ManageAppsDialogViewModel(
            HoloLensMonitor monitor,
            HoloLensMonitorControl monitorControl)
        {
            this.holoLensMonitor                   = monitor;
            this.holoLensMonitorControl            = monitorControl;
            this.holoLensMonitor.AppInstallStatus += HoloLensMonitor_AppInstallStatus;

            this.InstalledApps = new ObservableCollection <string>();
            this.RunningApps   = new ObservableCollection <string>();

            this.RegisterCommands();

            // Assigning the return value of the following methods to a Task object to avoid
            // warning 4014 (call is not awaited).
            Task t = this.RefreshInstalledAppsAsync();

            t = this.RefreshRunningAppsAsync();
        }
Esempio n. 9
0
        /// <summary>
        /// Handles the HeartbeatLost event.
        /// </summary>
        /// <param name="sender">The object which sent this event.</param>
        private void HoloLens_HeartbeatLost(HoloLensMonitor sender)
        {
            this.IsConnected = false;

            this.StatusMessage = HeartbeatLostMessage;

            // Handle whether or not we were previously selected
            if (!this.oldIsSelected &&
                this.IsSelected)
            {
                this.IsSelected    = false;
                this.oldIsSelected = true;
            }

            // Update the heartbeat based UI
            this.PowerIndicator = OnBatteryLabel;
            this.BatteryLevel   = "--";
            this.ThermalStatus  = Visibility.Collapsed;
            this.Ipd            = "--";
        }
        /// <summary>
        /// Registers the HoloLensMonitor with the application.
        /// </summary>
        /// <param name="monitor">HoloLens to register.</param>
        /// <param name="name">Descriptive name of the HoloLens.</param>
        /// <returns>Task object used for tracking method completion.</returns>
        private async Task RegisterHoloLensAsync(
            HoloLensMonitor monitor,
            string name)
        {
            HoloLensMonitorControl holoLensMonitorControl = new HoloLensMonitorControl(monitor);

            holoLensMonitorControl.Disconnected += HoloLensMonitorControl_Disconnected;
            holoLensMonitorControl.TagChanged   += HoloLensMonitorControl_TagChanged;

            HoloLensMonitorControlViewModel viewModel = holoLensMonitorControl.DataContext as HoloLensMonitorControlViewModel;

            viewModel.Name = name;

            this.RegisteredDevices.Add(holoLensMonitorControl);
            if (this.RegisteredDevices.Count > 0)
            {
                this.HaveRegisteredDevices = true;
            }

            await this.SaveConnectionsAsync();
        }
Esempio n. 11
0
        /// <summary>
        /// Handles the HeartbeatReceived event.
        /// </summary>
        /// <param name="sender">The object which sent this event.</param>
        private void HoloLens_HeartbeatReceived(HoloLensMonitor sender)
        {
            this.IsConnected = true;

            // Did we recover from a heartbeat loss?
            if (this.StatusMessage == HeartbeatLostMessage)
            {
                this.StatusMessage = "";
            }

            // Handle whether or not we were previously selected
            if (this.oldIsSelected &&
                !this.IsSelected)
            {
                this.IsSelected    = true;
                this.oldIsSelected = false;
            }

            // Update the heartbeat based UI
            this.PowerIndicator = sender.BatteryState.IsOnAcPower ? OnAcPowerLabel : OnBatteryLabel;
            this.BatteryLevel   = string.Format("{0}%", sender.BatteryState.Level.ToString("#.00"));
            this.ThermalStatus  = (sender.ThermalStage == ThermalStages.Normal) ? Visibility.Collapsed : Visibility.Visible;
            this.Ipd            = sender.Ipd.ToString();
        }
Esempio n. 12
0
        /// <summary>
        /// Implementation of the connect to device command.
        /// </summary>
        /// <param name="address">The address of the HoloLens.</param>
        /// <param name="name">Descriptive name to assign to the HoloLens.</param>
        /// <returns>Task object used for tracking method completion.</returns>
        private async Task ConnectToDeviceAsync(
            string address,
            string name)
        {
            HoloLensMonitor monitor = new HoloLensMonitor(this.dispatcher);

            try
            {
                await monitor.ConnectAsync(
                    address,
                    this.UserName,
                    this.Password);

                await this.RegisterHoloLensAsync(
                    monitor,
                    name);

                await this.RefreshCommonAppsAsync();

                this.StatusMessage = string.Format(
                    "Connected to the HoloLens at {0}",
                    monitor.Address);
            }
            catch
            {
                string addr = address;
                if (address == "localhost:10080")
                {
                    addr = "the attached HoloLens";
                }

                this.StatusMessage = string.Format(
                    "Failed to connect to {0}. Is it powered on? Paired with the Windows Device Portal?",
                    addr);
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Handles the ApplicationInstallStatus event.
 /// </summary>
 /// <param name="sender">The object which sent this event.</param>
 /// <param name="args">Event arguments.</param>
 private void HoloLensMonitor_AppInstallStatus(
     HoloLensMonitor sender,
     ApplicationInstallStatusEventArgs args)
 {
     this.StatusMessage = args.Message;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MixedRealityViewDialog" /> class.
 /// </summary>
 /// <param name="monitor">The HoloLensMonitor that is responsible for communication with the HoloLens.</param>
 public MixedRealityViewDialog(HoloLensMonitor monitor)
 {
     this.DataContext = new MixedRealityViewDialogViewModel(
         monitor);
     this.InitializeComponent();
 }
Esempio n. 15
0
 public HoloLensInformationDialog(HoloLensMonitor monitor)
 {
     this.DataContext = new HoloLensInformationDialogViewModel(monitor);
     this.InitializeComponent();
 }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HoloLensInformationDialogViewModel" /> class.
 /// </summary>
 /// <param name="monitor">The HoloLensMonitor responsible for communication with this HoloLens.</param>
 public HoloLensInformationDialogViewModel(
     HoloLensMonitor monitor)
 {
     this.holoLensMonitor = monitor;
 }