-
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.
Merge pull request #14 from izzappel/feature/print-person-detail
Feature/print person detail
- Loading branch information
Showing
14 changed files
with
442 additions
and
38 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
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,8 @@ | ||
<FlowDocument x:Class="ZuegerAdressbook.Printing.PersonDetail" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:ZuegerAdressbook.Printing"> | ||
<Section x:Name="Section"></Section> | ||
</FlowDocument> |
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,113 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
using ZuegerAdressbook.ViewModels; | ||
|
||
namespace ZuegerAdressbook.Printing | ||
{ | ||
/// <summary> | ||
/// Interaction logic for PersonDetail.xaml | ||
/// </summary> | ||
public partial class PersonDetail : FlowDocument | ||
{ | ||
private List<PersonViewModel> _persons; | ||
|
||
public PersonDetail(IList<PersonViewModel> persons) | ||
{ | ||
InitializeComponent(); | ||
PagePadding = new Thickness(20); | ||
_persons = new List<PersonViewModel>(persons); | ||
|
||
var table = new Table(); | ||
table.FontFamily = new FontFamily(new Uri("pack://application:,,,/ZuegerAddressbook.Name;component/Resources/Fonts/"), "#Frutiger LT Com 55 Roman"); | ||
table.FontSize = 11; | ||
table.CellSpacing = 0; | ||
var tableRowGroup = new TableRowGroup(); | ||
|
||
tableRowGroup.Rows.Add(CreateHeaderRow()); | ||
tableRowGroup.Rows.Add(CreateEmptyRow()); | ||
tableRowGroup.Rows.Add(CreateRow("Anrede", person => person.Title)); | ||
tableRowGroup.Rows.Add(CreateRow("Name", person => person.Lastname)); | ||
tableRowGroup.Rows.Add(CreateRow("Vorname", person => person.Firstname)); | ||
tableRowGroup.Rows.Add(CreateRow("Strasse / Hausnr.", person => person.Street1)); | ||
tableRowGroup.Rows.Add(CreateRow("PLZ / Ort", person => person.Plz + " " + person.City)); | ||
tableRowGroup.Rows.Add(CreateEmptyRow()); | ||
tableRowGroup.Rows.Add(CreateRow("Festnetz", person => person.PhoneNumber)); | ||
tableRowGroup.Rows.Add(CreateRow("Mobile", person => person.MobileNumber)); | ||
tableRowGroup.Rows.Add(CreateRow("E-Mail", person => person.EmailAddress)); | ||
tableRowGroup.Rows.Add(CreateEmptyRow()); | ||
tableRowGroup.Rows.Add(CreateRow("Geburtsdatum", person => person.Birthdate.HasValue ? person.Birthdate.Value.ToShortDateString() : "-")); | ||
tableRowGroup.Rows.Add(CreateEmptyRow()); | ||
tableRowGroup.Rows.Add(CreateRow("SBB-Ermässigung", person => "-")); | ||
tableRowGroup.Rows.Add(CreateEmptyRow()); | ||
tableRowGroup.Rows.Add(CreateRow("Passnummer", person => person.PassportNumber)); | ||
tableRowGroup.Rows.Add(CreateRow("Pass gültig bis", person => "")); | ||
tableRowGroup.Rows.Add(CreateEmptyRow()); | ||
tableRowGroup.Rows.Add(CreateRow("Bemerkungen", person => person.Notes)); | ||
tableRowGroup.Rows.Add(CreateEmptyRow()); | ||
|
||
table.RowGroups.Add(tableRowGroup); | ||
Section.Blocks.Add(table); | ||
} | ||
|
||
private TableRow CreateRow(string title, Func<PersonViewModel, string> personPropertySelector) | ||
{ | ||
var row = new TableRow(); | ||
row.Cells.Add(Cell(Text(title))); | ||
_persons.ForEach(person => row.Cells.Add(Cell(Text(personPropertySelector(person))))); | ||
|
||
return row; | ||
} | ||
|
||
private TableRow CreateHeaderRow() | ||
{ | ||
var headerRow = new TableRow(); | ||
headerRow.FontWeight = FontWeights.Bold; | ||
headerRow.Background = new SolidColorBrush(Colors.Yellow); | ||
headerRow.Cells.Add(Cell(Text("Stammdaten"))); | ||
var personEnumerator = _persons.GetEnumerator(); | ||
for (var index = 1; personEnumerator.MoveNext() == true; index++) | ||
{ | ||
headerRow.Cells.Add(Cell(Text(string.Format("{0}. Person", index)))); | ||
} | ||
|
||
return headerRow; | ||
} | ||
|
||
private TableRow CreateEmptyRow() | ||
{ | ||
var emptyRow = new TableRow(); | ||
emptyRow.Cells.Add(Cell(Text(string.Empty))); | ||
_persons.ForEach(person => emptyRow.Cells.Add(Cell(Text(string.Empty)))); | ||
|
||
return emptyRow; | ||
} | ||
|
||
private TableCell Cell(Block inlineElement) | ||
{ | ||
var cell = new TableCell(inlineElement); | ||
cell.Padding = new Thickness(5); | ||
cell.BorderBrush = new SolidColorBrush(Colors.Black); | ||
cell.BorderThickness = new Thickness(0.5); | ||
|
||
return cell; | ||
} | ||
|
||
private Paragraph Text(string text) | ||
{ | ||
return new Paragraph(new Run(text)); | ||
} | ||
|
||
} | ||
} |
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,29 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using ZuegerAdressbook.ViewModels; | ||
|
||
namespace ZuegerAdressbook.Printing | ||
{ | ||
public class PersonDetailViewModel : ViewModelBase | ||
{ | ||
public ObservableCollection<PersonViewModel> Persons { get; set; } | ||
|
||
public PersonDetailViewModel() | ||
{ | ||
Persons = new ObservableCollection<PersonViewModel>(); | ||
} | ||
|
||
public PersonDetailViewModel(IList<PersonViewModel> persons) | ||
{ | ||
Persons = new ObservableCollection<PersonViewModel>(persons); | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
foreach (var person in persons) | ||
{ | ||
Persons.Add(person); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
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,106 @@ | ||
<Window x:Class="ZuegerAdressbook.View.PrintPersonDetailsDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
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" | ||
xmlns:zugab="clr-namespace:ZuegerAdressbook" | ||
xmlns:local="clr-namespace:ZuegerAdressbook.View" | ||
xmlns:vm="clr-namespace:ZuegerAdressbook.ViewModels" | ||
xmlns:converter="clr-namespace:ZuegerAdressbook.Converters" | ||
mc:Ignorable="d" | ||
Icon="../Icons/48/address-book.png" | ||
Title="Drucken" Height="500" Width="500" | ||
d:DataContext="{d:DesignInstance vm:PrintPersonDetailsViewModel, IsDesignTimeCreatable=True}"> | ||
<Window.Resources> | ||
</Window.Resources> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="50"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
|
||
<Border Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Background="#FFF9F9F9" BorderThickness="0,0,0,1" BorderBrush="#FF333333" SnapsToDevicePixels="True"> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Padding="20" FontSize="15pt">Bitte Personen zum Drucken auswählen:</TextBlock> | ||
</StackPanel> | ||
</Border> | ||
|
||
<ListBox Grid.Column="0" Grid.Row="1" ItemsSource="{Binding Persons}" SelectedItem="{Binding SelectedListPerson}" Margin="5 5 0 0"> | ||
<ListBox.ItemTemplate> | ||
<DataTemplate> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="20" /> | ||
<ColumnDefinition Width="5" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource FontAwesomeIcon}" Visibility="{Binding Gender, ConverterParameter=Female, Converter={StaticResource enumVisibilityConverter}}"><Run Text=""/></TextBlock> | ||
<TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource FontAwesomeIcon}" Visibility="{Binding Gender, ConverterParameter=Male, Converter={StaticResource enumVisibilityConverter}}"><Run Text=""/></TextBlock> | ||
|
||
<TextBlock Grid.Column="2" Grid.Row="0" VerticalAlignment="Center"> | ||
<Run Text="{Binding Lastname}" /> | ||
<Run Text="{Binding Firstname}" /> | ||
</TextBlock> | ||
<TextBlock Visibility="{Binding Birthdate, Converter={StaticResource nullableVisibilityConverter}}" Grid.Column="3" Grid.Row="0" Margin="5,0,0,0" VerticalAlignment="Center"> | ||
<Run Text="{Binding Birthdate, StringFormat=({0:dd. MMMM yyyy})}" /> | ||
</TextBlock> | ||
</Grid> | ||
</DataTemplate> | ||
</ListBox.ItemTemplate> | ||
</ListBox> | ||
|
||
<StackPanel Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Margin="5 0 5 0"> | ||
<Button Command="{Binding AddSelectedToSelectedPersonsCommand}" Margin="0 5 0 5"> | ||
<StackPanel Orientation="Vertical"> | ||
<Image Source="../Icons/48/sign-right.png"/> | ||
</StackPanel> | ||
</Button> | ||
<Button Command="{Binding RemoveSelectedFromSelectedPersonsCommand}" Margin="0 5 0 5"> | ||
<StackPanel Orientation="Vertical"> | ||
<Image Source="../Icons/48/sign-left.png"/> | ||
</StackPanel> | ||
</Button> | ||
</StackPanel> | ||
|
||
<ListBox Grid.Column="2" Grid.Row="1" ItemsSource="{Binding SelectedPersons}" SelectedItem="{Binding SelectedSelectedPerson}" Margin="0 5 5 0"> | ||
<ListBox.ItemTemplate> | ||
<DataTemplate> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="20" /> | ||
<ColumnDefinition Width="5" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource FontAwesomeIcon}" Visibility="{Binding Gender, ConverterParameter=Female, Converter={StaticResource enumVisibilityConverter}}"><Run Text=""/></TextBlock> | ||
<TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource FontAwesomeIcon}" Visibility="{Binding Gender, ConverterParameter=Male, Converter={StaticResource enumVisibilityConverter}}"><Run Text=""/></TextBlock> | ||
|
||
<TextBlock Grid.Column="2" Grid.Row="0" VerticalAlignment="Center"> | ||
<Run Text="{Binding Lastname}" /> | ||
<Run Text="{Binding Firstname}" /> | ||
</TextBlock> | ||
<TextBlock Visibility="{Binding Birthdate, Converter={StaticResource nullableVisibilityConverter}}" Grid.Column="3" Grid.Row="0" Margin="5,0,0,0" VerticalAlignment="Center"> | ||
<Run Text="{Binding Birthdate, StringFormat=({0:dd. MMMM yyyy})}" /> | ||
</TextBlock> | ||
</Grid> | ||
</DataTemplate> | ||
</ListBox.ItemTemplate> | ||
</ListBox> | ||
|
||
<StackPanel Grid.Column="3" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 5 5 5"> | ||
<Button Command="{Binding PrintPersonDetailCommand}" Padding="5"> | ||
<StackPanel Orientation="Horizontal"> | ||
<Image Source="../Icons/48/sign-check.png"/> | ||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"><Run Text="Drucken"/></TextBlock> | ||
</StackPanel> | ||
</Button> | ||
</StackPanel> | ||
</Grid> | ||
</Window> |
Oops, something went wrong.