-
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.
- Loading branch information
Showing
8 changed files
with
103 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using CommunityToolkit.Mvvm.Input; | ||
using SimpleList.Services; | ||
using System.Threading.Tasks; | ||
|
||
namespace SimpleList.ViewModels | ||
{ | ||
public class DeleteFileViewModel : ObservableObject | ||
{ | ||
public DeleteFileViewModel(FileViewModel file) | ||
{ | ||
File = file; | ||
DeleteFileCommand = new AsyncRelayCommand(DeleteFile); | ||
} | ||
|
||
public async Task DeleteFile() | ||
{ | ||
OneDrive drive = Ioc.Default.GetService<OneDrive>(); | ||
if (PermanentDelete) | ||
{ | ||
await drive.PermanentDeleteItem(File.Id); | ||
} else | ||
{ | ||
await drive.DeleteItem(File.Id); | ||
} | ||
await File.Cloud.Refresh(); | ||
} | ||
|
||
private bool _permanentDelete; | ||
|
||
public FileViewModel File; | ||
public AsyncRelayCommand DeleteFileCommand { get; } | ||
public bool PermanentDelete | ||
{ | ||
get => _permanentDelete; | ||
set => SetProperty(ref _permanentDelete, value); | ||
} | ||
} | ||
} |
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,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ContentDialog | ||
x:Class="SimpleList.Views.DeleteFileView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:vm="using:SimpleList.ViewModels" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
d:DataContext="{x:Bind vm:DeleteFileViewModel}" | ||
Title="Delete item" | ||
PrimaryButtonText="Delete" | ||
CloseButtonText="Cancel" | ||
PrimaryButtonCommand="{Binding DeleteFileCommand}" | ||
DefaultButton="Primary"> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
|
||
<TextBlock> | ||
<Run Text="Are you sure to delete" /> | ||
<Run Text="{Binding File.Name}" /> | ||
</TextBlock> | ||
|
||
<CheckBox Grid.Row="1" Content="Permanent Delete" IsChecked="{Binding PermanentDelete, Mode=TwoWay}" /> | ||
</Grid> | ||
</ContentDialog> |
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,12 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace SimpleList.Views | ||
{ | ||
public sealed partial class DeleteFileView : ContentDialog | ||
{ | ||
public DeleteFileView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
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