Ejemplo n.º 1
0
        /// <summary>
        /// Implementation of the forget all connections command.
        /// </summary>
        /// <returns>Task object used for tracking method completion.</returns>
        private async Task ForgetAllConnectionsAsync()
        {
            YesNoMessageDialog messageDialog = new YesNoMessageDialog(
                "Are you sure you want to remove all connected HoloLens devices?",
                "HoloLens Commander");

            if (MessageDialogButtonId.Yes != await messageDialog.ShowAsync())
            {
                return;
            }

            this.suppressSave = true;

            foreach (HoloLensMonitorControl monitor in this.GetCopyOfRegisteredDevices())
            {
                monitor.Disconnect();
            }

            this.suppressSave = false;

            this.ClearRegisteredDevices();

            await this.SaveConnectionsAsync();

            this.StatusMessage = "";
        }
        /// <summary>
        /// Implementation of the forget connections command.
        /// </summary>
        /// <returns>Task object used for tracking method completion.</returns>
        private async Task ForgetAllConnectionsAsync()
        {
            YesNoMessageDialog messageDialog = new YesNoMessageDialog(
                "Are you sure you want to unregister the selected devices?");

            if (MessageDialogButtonId.Yes != await messageDialog.ShowAsync())
            {
                return;
            }

            this.suppressSave = true;

            foreach (DeviceMonitorControl monitor in this.GetCopyOfRegisteredDevices())
            {
                DeviceMonitorControlViewModel viewModel = (DeviceMonitorControlViewModel)monitor.DataContext;
                if (viewModel.IsSelected)
                {
                    monitor.Disconnect();
                    this.RegisteredDevices.Remove(monitor);
                }
            }

            this.suppressSave = false;

            await this.SaveConnectionsAsync();

            this.StatusMessage = string.Empty;
        }
        /// <summary>
        /// Implementation of the clear device status command.
        /// </summary>
        private async Task ClearDeviceStatus()
        {
            YesNoMessageDialog messageDialog = new YesNoMessageDialog(
                "Are you sure you want to clear the status for the selected devices?");

            if (MessageDialogButtonId.Yes != await messageDialog.ShowAsync())
            {
                return;
            }

            foreach (DeviceMonitorControl monitor in this.GetCopyOfRegisteredDevices())
            {
                monitor.ClearStatusMessage();
            }
        }
        /// <summary>
        /// Implementation of the shutdown devices command.
        /// </summary>
        private async Task ShutdownDevicesAsync()
        {
            YesNoMessageDialog messageDialog = new YesNoMessageDialog(
                "Are you sure you want to shutdown the selected devices?");

            if (MessageDialogButtonId.Yes != await messageDialog.ShowAsync())
            {
                return;
            }

            foreach (DeviceMonitorControl monitor in this.GetCopyOfRegisteredDevices())
            {
                // Assigning the return value of ShutdownAsync to a Task object to avoid
                // warning 4014 (call is not awaited).
                Task t = monitor.ShutdownAsync();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Implementation of the reboot devices command.
        /// </summary>
        /// <returns>Task object used for tracking method completion.</returns>
        private async Task RebootDevicesAsync()
        {
            YesNoMessageDialog messageDialog = new YesNoMessageDialog(
                "Are you sure you want to reboot the selected HoloLens devices?",
                "HoloLens Commander");

            if (MessageDialogButtonId.Yes != await messageDialog.ShowAsync())
            {
                return;
            }

            foreach (HoloLensMonitorControl monitor in this.GetCopyOfRegisteredDevices())
            {
                // Assigning the return value of RebootAsync to a Task object to avoid
                // warning 4014 (call is not awaited).
                Task t = monitor.RebootAsync();
            }
        }