public async Task MigrateToDictionaryAsync() { var listJson = ApplicationData.Current.LocalSettings.Values["PlayHistory"] as string; if (String.IsNullOrEmpty(listJson)) { return; } var historyList = JsonConvert.DeserializeObject <List <PlayHistoryItem> >(listJson); var files = await historyList.SelectAsync(async i => new { Item = i, File = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(i.Token) }); var historyDictionary = files .GroupBy(f => StorageFileViewModel.DetermineMediaType(f.File.ContentType)) .ToDictionary(g => g.Key, g => g.Select(i => i.Item).ToList()); var dictionaryJson = JsonConvert.SerializeObject(historyDictionary); ApplicationData.Current.LocalSettings.Values["PlayHistory"] = dictionaryJson; }
public async Task <object?> CreateAsync(StorageFileViewModel item) { if (item.Parent is null) { return(null); } string scenePath = Path.GetFileNameWithoutExtension(item.Name); StorageFolderViewModel rootFolder = item.Parent; StorageFileViewModel? projectFile = (await rootFolder.GetFilesAsync()).FirstOrDefault(s => Path.GetExtension(s.Name).Contains("proj")); while (projectFile is null && rootFolder.Parent != null) { scenePath = Path.Combine(rootFolder.Name, scenePath); rootFolder = rootFolder.Parent; projectFile = (await rootFolder.GetFilesAsync()).FirstOrDefault(s => Path.GetExtension(s.Name).Contains("proj")); } if (projectFile != null) { await LoadAssemblyAsync(rootFolder.Model, Path.GetFileNameWithoutExtension(projectFile.Name)); } return(new SceneEditorViewModel(rootFolder, scenePath)); }
public async Task <object?> CreateAsync(StorageFileViewModel item) { using Stream stream = await item.Model.OpenStreamForReadAsync(); Type?type = ContentManager.GetRootObjectType(stream); if (type != null && factories.TryGetValue(type, out IEditorViewFactory factory)) { return(await factory.CreateAsync(item)); } return(null); }
public Task <object?> CreateAsync(StorageFileViewModel item) { if (item.Parent is null) { return(Task.FromResult <object?>(null)); } string path = Path.GetFileNameWithoutExtension(item.Name); StorageFolderViewModel rootFolder = item.Parent; while (rootFolder.Parent != null) { path = Path.Combine(rootFolder.Name, path); rootFolder = rootFolder.Parent; } SceneView sceneView = new SceneView(rootFolder); Task sceneTask = sceneView.ViewModel.LoadAsync(path); return(Task.FromResult <object?>(sceneView)); }
public void Add(StorageFileViewModel fileViewModel) { var token = StorageApplicationPermissions.FutureAccessList.Add(fileViewModel.File); var item = new PlayHistoryItem { Token = token, PlayedOn = DateTime.Now }; var history = GetPlayHistory(); if (history.ContainsKey(fileViewModel.MediaType)) { history[fileViewModel.MediaType].Add(item); } else { history[fileViewModel.MediaType] = new List <PlayHistoryItem> { item }; } SetPlayHistory(history); }
public MediaSelectedEventArgs(StorageFileViewModel storageFile) { this.storageFile = storageFile; }
public Task <object?> CreateAsync(StorageFileViewModel item) { return(Task.FromResult <object?>(new CodeEditorViewModel(item))); }