-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: preview markdown, images, and media resources.
- Loading branch information
Showing
21 changed files
with
345 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ OneDrive | |
- [x] 列表 | ||
- [x] 下载 | ||
- [x] 共享 | ||
- [ ] 预览 | ||
- [x] 预览 | ||
- [x] 下载进度 | ||
- [x] 上传 | ||
- [ ] 自动同步 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace SimpleList.Models | ||
{ | ||
public enum FileType | ||
{ | ||
Text, | ||
Markdown, | ||
Code, | ||
Image, | ||
Media, | ||
Office, | ||
Unknown | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using Microsoft.Graph.Models; | ||
using Microsoft.UI.Xaml.Media.Imaging; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Windows.Media.Core; | ||
using Windows.Storage.Streams; | ||
|
||
namespace SimpleList.ViewModels | ||
{ | ||
public partial class PreviewViewModel : ObservableObject | ||
{ | ||
public PreviewViewModel(FileViewModel file) | ||
{ | ||
_file = file; | ||
} | ||
|
||
[RelayCommand] | ||
public async Task LoadTextContent() | ||
{ | ||
IsLoading = true; | ||
Stream stram = await _file.Drive.Provider.GetItemContent(_file.Id); | ||
using StreamReader reader = new(stram); | ||
Text = await reader.ReadToEndAsync(); | ||
IsLoading = false; | ||
} | ||
|
||
[RelayCommand] | ||
public async Task LoadImageContent() | ||
{ | ||
IsLoading = true; | ||
Stream stream = await _file.Drive.Provider.GetItemContent(_file.Id); | ||
InMemoryRandomAccessStream randomAccessStream = new(); | ||
await RandomAccessStream.CopyAsync(stream.AsInputStream(), randomAccessStream); | ||
randomAccessStream.Seek(0); | ||
BitmapImage img = new(); | ||
await img.SetSourceAsync(randomAccessStream); | ||
Image = img; | ||
IsLoading = false; | ||
} | ||
|
||
public void LoadMediaSource() | ||
{ | ||
IsLoading = true; | ||
string downloadUri = _file.DownloadUrl; | ||
MediaSource mediaSource = MediaSource.CreateFromUri(new Uri(downloadUri)); | ||
Media = mediaSource; | ||
IsLoading = false; | ||
} | ||
|
||
private readonly FileViewModel _file; | ||
[ObservableProperty] private bool _isLoading = false; | ||
[ObservableProperty] private string _text; | ||
[ObservableProperty] private BitmapImage _image; | ||
[ObservableProperty] private MediaSource _media; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.