Update main UI a bit
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
#nullable enable
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia.Platform.Storage;
|
||||||
|
using Avalonia.Themes.Fluent;
|
||||||
|
using DialogHostAvalonia;
|
||||||
|
using ImageMagick;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using PdfSharp.Fonts;
|
||||||
|
using PdfSharp.Pdf.IO;
|
||||||
|
using PdfSharp.Snippets.Font;
|
||||||
|
using ReceiptPDFBuilder.Interfaces;
|
||||||
|
using ReceiptPDFBuilder.Models;
|
||||||
|
|
||||||
|
namespace ReceiptPDFBuilder.ViewModels;
|
||||||
|
|
||||||
|
class EditFileViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
ReportFile _file;
|
||||||
|
|
||||||
|
public EditFileViewModel(ReportFile file, IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
||||||
|
{
|
||||||
|
_file = file;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -103,30 +103,6 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveItemUp(ReportFile file)
|
|
||||||
{
|
|
||||||
var idx = ReportFiles.IndexOf(file);
|
|
||||||
if (idx != 0)
|
|
||||||
{
|
|
||||||
// .Move() is not observed -_-
|
|
||||||
// https://github.com/AvaloniaUI/Avalonia.Controls.DataGrid/issues/74
|
|
||||||
// ReportFiles.Move(idx, idx - 1);
|
|
||||||
// So, remove and insert.
|
|
||||||
ReportFiles.RemoveAt(idx);
|
|
||||||
ReportFiles.Insert(idx - 1, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveItemDown(ReportFile file)
|
|
||||||
{
|
|
||||||
var idx = ReportFiles.IndexOf(file);
|
|
||||||
if (idx != ReportFiles.Count - 1)
|
|
||||||
{
|
|
||||||
ReportFiles.RemoveAt(idx);
|
|
||||||
ReportFiles.Insert(idx + 1, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void RemoveFile(ReportFile file)
|
public async void RemoveFile(ReportFile file)
|
||||||
{
|
{
|
||||||
var result = await DialogHost.Show(new WarningDeleteItemModel(file));
|
var result = await DialogHost.Show(new WarningDeleteItemModel(file));
|
||||||
@@ -140,6 +116,11 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void EditFileProperties(ReportFile file)
|
||||||
|
{
|
||||||
|
var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger));
|
||||||
|
}
|
||||||
|
|
||||||
private async void BuildPDF()
|
private async void BuildPDF()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
+24
-14
@@ -9,22 +9,23 @@
|
|||||||
xmlns:vm="clr-namespace:ReceiptPDFBuilder.ViewModels"
|
xmlns:vm="clr-namespace:ReceiptPDFBuilder.ViewModels"
|
||||||
xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing"
|
xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing"
|
||||||
x:DataType="vm:MainViewModel">
|
x:DataType="vm:MainViewModel">
|
||||||
<Grid ColumnDefinitions="Auto, *"
|
<Grid ColumnDefinitions="*"
|
||||||
RowDefinitions="Auto, Auto, *, *">
|
RowDefinitions="Auto, 2*, Auto, *">
|
||||||
|
<StackPanel Orientation="Vertical"
|
||||||
|
Spacing="4">
|
||||||
<Label Content="Easy Receipt Folder -> PDF Builder"
|
<Label Content="Easy Receipt Folder -> PDF Builder"
|
||||||
FontSize="16"
|
FontSize="20"
|
||||||
Grid.Row="0"
|
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"/>
|
||||||
|
<Button Content="Choose Receipt Folder"
|
||||||
|
Command="{Binding ChooseFolder}"
|
||||||
|
IsEnabled="{Binding !IsCreatingPDF}" />
|
||||||
|
</StackPanel>
|
||||||
<StackPanel Orientation="Vertical"
|
<StackPanel Orientation="Vertical"
|
||||||
Spacing="2"
|
Spacing="2"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Margin="2">
|
Margin="2">
|
||||||
<Button Content="Choose Receipt Folder"
|
|
||||||
Command="{Binding ChooseFolder}"
|
|
||||||
IsEnabled="{Binding !IsCreatingPDF}" />
|
|
||||||
<Label Content="Creating PDF..."
|
<Label Content="Creating PDF..."
|
||||||
IsVisible="{Binding IsCreatingPDF}"/>
|
IsVisible="{Binding IsCreatingPDF}"/>
|
||||||
<progRing:ProgressRing Width="80"
|
<progRing:ProgressRing Width="80"
|
||||||
@@ -37,7 +38,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<DataGrid x:Name="FilesGrid"
|
<DataGrid x:Name="FilesGrid"
|
||||||
Classes="DragAndDrop ItemsDragAndDrop"
|
Classes="DragAndDrop ItemsDragAndDrop"
|
||||||
Grid.Row="2"
|
Grid.Row="1"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Margin="2"
|
Margin="2"
|
||||||
@@ -66,7 +67,7 @@
|
|||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Title"
|
<DataGridTextColumn Header="Title"
|
||||||
Binding="{Binding Title}"
|
Binding="{Binding Title}"
|
||||||
IsReadOnly="True"
|
IsReadOnly="False"
|
||||||
Width="*"/>
|
Width="*"/>
|
||||||
<DataGridTextColumn Header="Receipt Date"
|
<DataGridTextColumn Header="Receipt Date"
|
||||||
Binding="{Binding Date}"
|
Binding="{Binding Date}"
|
||||||
@@ -83,13 +84,22 @@
|
|||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Spacing="4">
|
Spacing="4">
|
||||||
|
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).EditFileProperties}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Classes="accent"
|
||||||
|
Margin="2"
|
||||||
|
IsEnabled="True">
|
||||||
|
<Button.Content>
|
||||||
|
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Edit</TextBlock>
|
||||||
|
</Button.Content>
|
||||||
|
</Button>
|
||||||
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).RemoveFile}"
|
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).RemoveFile}"
|
||||||
CommandParameter="{Binding}"
|
CommandParameter="{Binding}"
|
||||||
Classes="Danger"
|
Classes="Danger"
|
||||||
Margin="2"
|
Margin="2"
|
||||||
IsEnabled="True">
|
IsEnabled="True">
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Remove Item</TextBlock>
|
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Remove</TextBlock>
|
||||||
</Button.Content>
|
</Button.Content>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -98,9 +108,9 @@
|
|||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<ScrollViewer Grid.Column="0"
|
<GridSplitter Grid.Row="2"
|
||||||
Grid.ColumnSpan="2"
|
Background="LightGray"/>
|
||||||
Margin="2"
|
<ScrollViewer Margin="2"
|
||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
x:Name="LogScrollView">
|
x:Name="LogScrollView">
|
||||||
<SelectableTextBlock Text="{Binding CreatePDFLog}"
|
<SelectableTextBlock Text="{Binding CreatePDFLog}"
|
||||||
|
|||||||
Reference in New Issue
Block a user