Add remove all button
This commit is contained in:
@@ -103,6 +103,9 @@
|
|||||||
<DataTemplate DataType="{x:Type viewModels:ShutdownCheckViewModel}">
|
<DataTemplate DataType="{x:Type viewModels:ShutdownCheckViewModel}">
|
||||||
<views:ShutdownCheckView/>
|
<views:ShutdownCheckView/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type viewModels:ConfirmViewModel}">
|
||||||
|
<views:ConfirmView/>
|
||||||
|
</DataTemplate>
|
||||||
</Application.DataTemplates>
|
</Application.DataTemplates>
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#nullable enable
|
||||||
|
|
||||||
|
using DialogHostAvalonia;
|
||||||
|
using MayShow.Helpers;
|
||||||
|
|
||||||
|
namespace MayShow.ViewModels;
|
||||||
|
|
||||||
|
class ConfirmViewModel
|
||||||
|
{
|
||||||
|
private string _title;
|
||||||
|
private string _message;
|
||||||
|
private string _confirmTitle;
|
||||||
|
private string _declineTitle;
|
||||||
|
|
||||||
|
public ConfirmViewModel(string title, string message, string confirmTitle = "Yes", string declineTitle = "No")
|
||||||
|
{
|
||||||
|
_title = title;
|
||||||
|
_message = message;
|
||||||
|
_confirmTitle = confirmTitle;
|
||||||
|
_declineTitle = declineTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
get => _title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Message
|
||||||
|
{
|
||||||
|
get => _message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ConfirmTitle
|
||||||
|
{
|
||||||
|
get => _confirmTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DeclineTitle
|
||||||
|
{
|
||||||
|
get => _declineTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Confirm()
|
||||||
|
{
|
||||||
|
DialogHost.Close("DialogHost", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Decline()
|
||||||
|
{
|
||||||
|
DialogHost.Close("DialogHost", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -366,6 +366,17 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void RemoveAllItems()
|
||||||
|
{
|
||||||
|
var result = await DialogHost.Show(new ConfirmViewModel("Warning!", "Are you sure you want to remove all items from this report?", "Remove All Items", "Cancel"));
|
||||||
|
if (result != null && (bool)result)
|
||||||
|
{
|
||||||
|
ReportFiles.Clear();
|
||||||
|
HasUnsavedWork = true;
|
||||||
|
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void LocateFile(object f) => LocateFileImpl((ReportFile) f);
|
public void LocateFile(object f) => LocateFileImpl((ReportFile) f);
|
||||||
public async void LocateFileImpl(ReportFile reportFile)
|
public async void LocateFileImpl(ReportFile reportFile)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="MayShow.Views.ConfirmView"
|
||||||
|
xmlns:models="clr-namespace:MayShow.Models"
|
||||||
|
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
||||||
|
x:DataType="vm:ConfirmViewModel">
|
||||||
|
<StackPanel Orientation="Vertical"
|
||||||
|
Spacing="4">
|
||||||
|
<TextBlock TextAlignment="Center"
|
||||||
|
FontWeight="Bold"
|
||||||
|
FontSize="18"
|
||||||
|
Text="{Binding Title}"/>
|
||||||
|
<TextBlock TextAlignment="Center"
|
||||||
|
FontWeight="Bold"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
FontSize="14"
|
||||||
|
MaxWidth="350"
|
||||||
|
Text="{Binding Message}"/>
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
Spacing="12"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="4">
|
||||||
|
<Button Command="{Binding Decline}"
|
||||||
|
Content="{Binding DeclineTitle}"
|
||||||
|
HorizontalAlignment="Right"/>
|
||||||
|
<Button Command="{Binding Confirm}"
|
||||||
|
Classes="accent"
|
||||||
|
Content="{Binding ConfirmTitle}"
|
||||||
|
HorizontalAlignment="Right"/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace MayShow.Views;
|
||||||
|
|
||||||
|
public partial class ConfirmView : UserControl
|
||||||
|
{
|
||||||
|
public ConfirmView()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -226,24 +226,28 @@
|
|||||||
IsEnabled="{Binding CanAddItem}">
|
IsEnabled="{Binding CanAddItem}">
|
||||||
<TextBlock><Run Text="+" FontFamily="{StaticResource FontAwesomeSolid}"/> Add Item(s)</TextBlock>
|
<TextBlock><Run Text="+" FontFamily="{StaticResource FontAwesomeSolid}"/> Add Item(s)</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding SaveInterimReportInfo}"
|
<Button Command="{Binding RemoveAllItems}"
|
||||||
IsEnabled="{Binding HasWorkingFolderAndNotMakingPDF}">
|
IsEnabled="{Binding IsCreatePDFButtonEnabled}"
|
||||||
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Save Report Info</TextBlock>
|
Classes="Danger">
|
||||||
|
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Remove All Items</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding ResortPDFItemsByDate}"
|
<Button Command="{Binding ResortPDFItemsByDate}"
|
||||||
IsEnabled="{Binding IsCreatePDFButtonEnabled}">
|
IsEnabled="{Binding IsCreatePDFButtonEnabled}">
|
||||||
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Re-sort PDF Items</TextBlock>
|
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Re-sort PDF Items</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding BuildPDF}"
|
<Button Command="{Binding SaveInterimReportInfo}"
|
||||||
Classes="accent"
|
IsEnabled="{Binding HasWorkingFolderAndNotMakingPDF}">
|
||||||
IsEnabled="{Binding IsCreatePDFButtonEnabled}">
|
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Save Report Info</TextBlock>
|
||||||
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Create Report PDF</TextBlock>
|
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
IsVisible="{Binding IsCreatingPDF}"
|
|
||||||
Spacing="6"
|
Spacing="6"
|
||||||
HorizontalAlignment="Center">
|
HorizontalAlignment="Center">
|
||||||
|
<Button Command="{Binding BuildPDF}"
|
||||||
|
Classes="accent"
|
||||||
|
IsEnabled="{Binding IsCreatePDFButtonEnabled}">
|
||||||
|
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Create Report PDF</TextBlock>
|
||||||
|
</Button>
|
||||||
<Label Content="Creating PDF..."
|
<Label Content="Creating PDF..."
|
||||||
IsVisible="{Binding IsCreatingPDF}"
|
IsVisible="{Binding IsCreatingPDF}"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user