Can now edit file info
This commit is contained in:
+3
-3
@@ -10,9 +10,9 @@
|
|||||||
x:DataType="vm:MainWindowViewModel"
|
x:DataType="vm:MainWindowViewModel"
|
||||||
Width="800"
|
Width="800"
|
||||||
MinWidth="400"
|
MinWidth="400"
|
||||||
Height="600"
|
Height="650"
|
||||||
MinHeight="400">
|
MinHeight="450">
|
||||||
<dialogHost:DialogHost CloseOnClickAway="True"
|
<dialogHost:DialogHost CloseOnClickAway="False"
|
||||||
Identifier="DialogHost">
|
Identifier="DialogHost">
|
||||||
<dialogHost:DialogHost.DialogContent>
|
<dialogHost:DialogHost.DialogContent>
|
||||||
<StackPanel/>
|
<StackPanel/>
|
||||||
|
|||||||
+16
-26
@@ -7,56 +7,46 @@ namespace ReceiptPDFBuilder.Models;
|
|||||||
class ReportFile : ChangeNotifier
|
class ReportFile : ChangeNotifier
|
||||||
{
|
{
|
||||||
private string _title;
|
private string _title;
|
||||||
private DateOnly _date;
|
private DateTime _receiptDateTime;
|
||||||
private DateTime _dateTime;
|
|
||||||
private DateTimeOffset _dto;
|
|
||||||
private string _notes;
|
private string _notes;
|
||||||
private string _filePath;
|
private string _filePath;
|
||||||
|
|
||||||
public ReportFile()
|
public ReportFile()
|
||||||
{
|
{
|
||||||
_title = "";
|
_title = "";
|
||||||
_date = DateOnly.FromDateTime(DateTime.Now);
|
_receiptDateTime = DateTime.Now;
|
||||||
_notes = "";
|
_notes = "";
|
||||||
_filePath = "";
|
_filePath = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReportFile(ReportFile other)
|
||||||
|
{
|
||||||
|
Title = _title = other.Title;
|
||||||
|
ReceiptDateTime = _receiptDateTime = other.ReceiptDateTime;
|
||||||
|
Notes = _notes = other.Notes;
|
||||||
|
FilePath = _filePath = other.FilePath;
|
||||||
|
}
|
||||||
|
|
||||||
public string Title
|
public string Title
|
||||||
{
|
{
|
||||||
get => _title;
|
get => _title;
|
||||||
set { _title = value; NotifyPropertyChanged(); }
|
set { _title = value; NotifyPropertyChanged(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateOnly Date
|
public DateTime ReceiptDateTime
|
||||||
{
|
{
|
||||||
get => _date;
|
get => _receiptDateTime;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_date = value;
|
_receiptDateTime = value;
|
||||||
DateTime = value.ToDateTime(TimeOnly.MinValue);
|
|
||||||
DTO = new DateTimeOffset(value.ToDateTime(TimeOnly.MinValue));
|
|
||||||
NotifyPropertyChanged();
|
NotifyPropertyChanged();
|
||||||
|
NotifyPropertyChanged(nameof(ReceiptDate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime DateTime
|
public DateOnly ReceiptDate
|
||||||
{
|
{
|
||||||
get => _dateTime;
|
get => DateOnly.FromDateTime(_receiptDateTime);
|
||||||
set
|
|
||||||
{
|
|
||||||
_dateTime = value;
|
|
||||||
NotifyPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTimeOffset DTO
|
|
||||||
{
|
|
||||||
get => _dto;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_dto = value;
|
|
||||||
NotifyPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Notes
|
public string Notes
|
||||||
|
|||||||
@@ -22,10 +22,32 @@ namespace ReceiptPDFBuilder.ViewModels;
|
|||||||
|
|
||||||
class EditFileViewModel : BaseViewModel
|
class EditFileViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
ReportFile _file;
|
ReportFile _clonedFile;
|
||||||
|
ReportFile _originalFile;
|
||||||
|
|
||||||
public EditFileViewModel(ReportFile file, IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
public EditFileViewModel(ReportFile file, IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
||||||
{
|
{
|
||||||
_file = file;
|
_clonedFile = new ReportFile(file);
|
||||||
|
_originalFile = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReportFile OriginalFile
|
||||||
|
{
|
||||||
|
get => _originalFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReportFile ClonedFile
|
||||||
|
{
|
||||||
|
get => _clonedFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cancel()
|
||||||
|
{
|
||||||
|
DialogHost.Close("DialogHost", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
DialogHost.Close("DialogHost", ClonedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
ReportFiles.Add(new ReportFile()
|
ReportFiles.Add(new ReportFile()
|
||||||
{
|
{
|
||||||
Title = Path.GetFileName(filePath),
|
Title = Path.GetFileName(filePath),
|
||||||
Date = DateOnly.FromDateTime(File.GetCreationTime(filePath)),
|
ReceiptDateTime = File.GetCreationTime(filePath),
|
||||||
Notes = "TEST NOTES",
|
Notes = "TEST NOTES",
|
||||||
FilePath = filePath,
|
FilePath = filePath,
|
||||||
});
|
});
|
||||||
@@ -125,6 +125,12 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
public async void EditFileProperties(ReportFile file)
|
public async void EditFileProperties(ReportFile file)
|
||||||
{
|
{
|
||||||
var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger));
|
var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger));
|
||||||
|
if (result != null && result is ReportFile updatedData)
|
||||||
|
{
|
||||||
|
file.Title = updatedData.Title;
|
||||||
|
file.ReceiptDateTime = updatedData.ReceiptDateTime;
|
||||||
|
file.Notes = updatedData.Notes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void BuildPDF()
|
public async void BuildPDF()
|
||||||
|
|||||||
+46
-11
@@ -2,19 +2,54 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d"
|
||||||
|
d:DesignWidth="800"
|
||||||
|
d:DesignHeight="450"
|
||||||
x:Class="ReceiptPDFBuilder.Views.EditFile"
|
x:Class="ReceiptPDFBuilder.Views.EditFile"
|
||||||
xmlns:models="clr-namespace:ReceiptPDFBuilder.Models"
|
xmlns:models="clr-namespace:ReceiptPDFBuilder.Models"
|
||||||
xmlns:vm="clr-namespace:ReceiptPDFBuilder.ViewModels"
|
xmlns:vm="clr-namespace:ReceiptPDFBuilder.ViewModels"
|
||||||
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
||||||
x:DataType="vm:EditFileViewModel">
|
x:DataType="vm:EditFileViewModel">
|
||||||
<StackPanel HorizontalAlignment="Stretch"
|
<ScrollViewer AllowAutoHide="False">
|
||||||
Margin="6"
|
<StackPanel Orientation="Vertical"
|
||||||
Spacing="8">
|
Spacing="4"
|
||||||
<Label Content="Edit File"
|
Margin="12,4,12,0">
|
||||||
HorizontalAlignment="Center"
|
<Label Content="Edit File Details"
|
||||||
FontSize="16"
|
HorizontalAlignment="Center"
|
||||||
FontWeight="Bold"/>
|
FontSize="16"
|
||||||
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
<Label Content="Title" />
|
||||||
</UserControl>
|
<TextBox Watermark="Title"
|
||||||
|
Text="{Binding ClonedFile.Title}"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<Label Content="Notes" />
|
||||||
|
<TextBox Watermark="Notes"
|
||||||
|
Text="{Binding ClonedFile.Notes}"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
ScrollViewer.AllowAutoHide="False"
|
||||||
|
Height="75" />
|
||||||
|
<Label Content="Receipt Date" />
|
||||||
|
<Calendar SelectionMode="SingleDate"
|
||||||
|
SelectedDate="{Binding ClonedFile.ReceiptDateTime}"
|
||||||
|
DisplayDate="{Binding ClonedFile.ReceiptDateTime}" />
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
Spacing="12"
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
HorizontalAlignment="Right">
|
||||||
|
<Button Command="{Binding Cancel}">
|
||||||
|
<TextBlock>
|
||||||
|
<Run Text=""
|
||||||
|
FontFamily="{StaticResource FontAwesomeSolid}" /> Cancel</TextBlock>
|
||||||
|
</Button>
|
||||||
|
<Button Command="{Binding Save}"
|
||||||
|
Classes="accent">
|
||||||
|
<TextBlock>
|
||||||
|
<Run Text=""
|
||||||
|
FontFamily="{StaticResource FontAwesomeSolid}" /> Save</TextBlock>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
</UserControl>
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
CanUserSortColumns="False"
|
CanUserSortColumns="False"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
VerticalScrollBarVisibility="Visible"
|
VerticalScrollBarVisibility="Visible"
|
||||||
HorizontalScrollBarVisibility="Disabled"
|
|
||||||
ScrollViewer.AllowAutoHide="False"
|
ScrollViewer.AllowAutoHide="False"
|
||||||
|
HorizontalScrollBarVisibility="Disabled"
|
||||||
HeadersVisibility="All"
|
HeadersVisibility="All"
|
||||||
BorderBrush="Gray">
|
BorderBrush="Gray">
|
||||||
<DataGrid.Styles>
|
<DataGrid.Styles>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
IsReadOnly="False"
|
IsReadOnly="False"
|
||||||
Width="*"/>
|
Width="*"/>
|
||||||
<DataGridTextColumn Header="Receipt Date"
|
<DataGridTextColumn Header="Receipt Date"
|
||||||
Binding="{Binding Date}"
|
Binding="{Binding ReceiptDate}"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Width="*"/>
|
Width="*"/>
|
||||||
<DataGridTextColumn Header="File Name"
|
<DataGridTextColumn Header="File Name"
|
||||||
@@ -130,7 +130,9 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ScrollViewer Margin="2"
|
<ScrollViewer Margin="2"
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
x:Name="LogScrollView">
|
x:Name="LogScrollView"
|
||||||
|
VerticalScrollBarVisibility="Visible"
|
||||||
|
AllowAutoHide="False">
|
||||||
<SelectableTextBlock Text="{Binding CreatePDFLog}"
|
<SelectableTextBlock Text="{Binding CreatePDFLog}"
|
||||||
Margin="2"
|
Margin="2"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
|
|||||||
Reference in New Issue
Block a user