コード例 #1
0
        /// <summary>
        /// Wipes camera roll contents on this device.
        /// </summary>
        /// <returns>Task object used for tracking method completion.</returns>
        internal async Task WipeCameraRollAsync()
        {
            if (this.IsConnected && this.IsSelected)
            {
                try
                {
                    MrcFileList fileList = await this.deviceMonitor.GetMixedRealityFileListAsync();

                    foreach (MrcFileInformation fileInfo in fileList.Files)
                    {
                        await this.deviceMonitor.DeleteMixedRealityFile(fileInfo.FileName);
                    }
                    this.StatusMessage = "Camera roll wiped successfully.";
                }
                catch (Exception e)
                {
                    this.StatusMessage = string.Format("Unable to delete all camera roll files. {0} ", e.Message);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the list of capture files
        /// </summary>
        /// <returns>List of the capture files</returns>
        /// <remarks>This method is only supported on HoloLens.</remarks>
        public async Task <MrcFileList> GetMrcFileListAsync()
        {
            if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
            {
                throw new NotSupportedException("This method is only supported on HoloLens.");
            }

            MrcFileList mrcFileList = await this.GetAsync <MrcFileList>(MrcFileListApi);

            foreach (MrcFileInformation mfi in mrcFileList.Files)
            {
                try
                {
                    mfi.Thumbnail = await this.GetMrcThumbnailDataAsync(mfi.FileName);
                }
                catch
                {
                }
            }

            return(mrcFileList);
        }
コード例 #3
0
        public void GetMrcFileList_HoloLens_1607()
        {
            TestHelpers.MockHttpResponder.AddMockResponse(
                DevicePortal.MrcFileListApi,
                this.PlatformType,
                this.FriendlyOperatingSystemVersion,
                HttpMethods.Get);

            Task <MrcFileList> getTask = TestHelpers.Portal.GetMrcFileList();

            getTask.Wait();

            Assert.AreEqual(TaskStatus.RanToCompletion, getTask.Status);

            // Check some known things about this response.
            MrcFileList fileList = getTask.Result;

            Assert.AreEqual(4, fileList.Files.Count);
            Assert.AreEqual(131139576909916579, fileList.Files[1].CreationTimeRaw);
            Assert.AreEqual("20160725_150130_HoloLens.jpg", fileList.Files[1].FileName);
            Assert.AreEqual((uint)290929, fileList.Files[1].FileSize);
        }
コード例 #4
0
        /// <summary>
        /// Downloads mixed reality files from the HoloLens.
        /// </summary>
        /// <param name="parentFolder">The parent folder which will contain the HoloLens specific folder.</param>
        /// <param name="deleteAfterDownload">Value indicating whether or not files are to be deleted
        /// from the HoloLens after they have been downloaded.</param>
        /// <returns>The name of the folder in to which the files were downloaded.</returns>
        internal async Task <string> GetMixedRealityFilesAsync(
            StorageFolder parentFolder,
            bool deleteAfterDownload)
        {
            string folderName = null;

            if (this.IsConnected && this.IsSelected)
            {
                try
                {
                    MrcFileList fileList = await this.holoLensMonitor.GetMixedRealityFileListAsync();

                    if (fileList.Files.Count != 0)
                    {
                        // Create the folder for this HoloLens' files.
                        StorageFolder folder = await parentFolder.CreateFolderAsync(
                            (string.IsNullOrWhiteSpace(this.Name) ? this.Address : this.Name),
                            CreationCollisionOption.OpenIfExists);

                        folderName = folder.Name;

                        foreach (MrcFileInformation fileInfo in fileList.Files)
                        {
                            try
                            {
                                byte[] fileData = await this.holoLensMonitor.GetMixedRealityFileAsync(fileInfo.FileName);

                                StorageFile file = await folder.CreateFileAsync(
                                    fileInfo.FileName,
                                    CreationCollisionOption.ReplaceExisting);

                                using (Stream stream = await file.OpenStreamForWriteAsync())
                                {
                                    await stream.WriteAsync(fileData, 0, fileData.Length);

                                    await stream.FlushAsync();
                                }

                                this.StatusMessage = string.Format(
                                    "{0} downloaded",
                                    fileInfo.FileName);

                                if (deleteAfterDownload)
                                {
                                    await this.holoLensMonitor.DeleteMixedRealityFile(fileInfo.FileName);
                                }
                            }
                            catch (Exception e)
                            {
                                this.StatusMessage = string.Format(
                                    "Failed to download {0} - {1}",
                                    fileInfo.FileName,
                                    e.Message);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    this.StatusMessage = string.Format(
                        "Failed to get mixed reality files - {0}",
                        e.Message);
                }
            }

            return(folderName);
        }