-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMainWindow.xaml
221 lines (219 loc) · 15.2 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<Window x:Class="PDFPages.MainWindow" 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:local="clr-namespace:PDFPages"
xmlns:ex="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:vm="clr-namespace:PDFPages.ViewModels" mc:Ignorable="d" Title="PDF Pages" Height="850" Width="800">
<Window.DataContext>
<vm:MainVM />
</Window.DataContext>
<Grid>
<Button Content="Single Output File" HorizontalAlignment="Left" Margin="7,6,0,0" VerticalAlignment="Top"
Width="131" Command="{Binding MergeCommand}" />
<TextBlock HorizontalAlignment="Left" Margin="10,32,0,0" Text="Split" TextWrapping="Wrap"
VerticalAlignment="Top" />
<ex:IntegerUpDown HorizontalAlignment="Left" Margin="38,32,0,0"
Value="{Binding SplitNPages, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="50" />
<TextBlock HorizontalAlignment="Left" Margin="90,32,0,0" Text="page(s) per file" TextWrapping="Wrap"
VerticalAlignment="Top" />
<Button Content="One File Per Page" HorizontalAlignment="Left" Margin="7,33,0,0" VerticalAlignment="Top"
Width="132" Command="{Binding SplitCommand}" Visibility="Hidden" />
<TextBlock HorizontalAlignment="Left" Margin="158,7,0,0" Text="Output Folder" TextWrapping="Wrap"
VerticalAlignment="Top" />
<TextBox HorizontalAlignment="Stretch" Margin="237,7,30,0" Text="{Binding OutputPath}" TextWrapping="NoWrap"
VerticalAlignment="Top" />
<Button Content="..." HorizontalAlignment="Right" Margin="0,7,10,0" VerticalAlignment="Top" Width="20"
Height="18" Command="{Binding SelectFolderCommand}" />
<Slider HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Margin="178,34,0,0"
Value="{Binding RowHeight}" ToolTip="Thumbnail Size" Minimum="30" Maximum="500" />
<Button Content="Save Output Files" HorizontalAlignment="Left" Margin="290,33,0,0" VerticalAlignment="Top"
Width="132" Command="{Binding SaveCommand}" />
<Grid Margin="0,60,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150*" />
<ColumnDefinition Width="150*" />
<ColumnDefinition Width="150*" />
<ColumnDefinition Width="150*" />
</Grid.ColumnDefinitions>
<DataGrid ItemsSource="{Binding Files}" Style="{StaticResource DefaultDataGridStyle}" AlternationCount="3"
dd:DragDrop.UseDefaultDragAdorner="True" dd:DragDrop.DropTargetAdornerBrush="Blue"
SelectionMode="Extended" Sorting="dgFiles_Sorting" SelectedItem="{Binding SelectedFile}"
dd:DragDrop.DragHandler="{Binding}" dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.DragDropContext="Files" dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"
Grid.ColumnSpan="1" Margin="0,0,0,0">
<DataGrid.InputBindings>
<KeyBinding Key="Delete" Command="{Binding DeleteItemsCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
</DataGrid.InputBindings>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Input Files" Width="*" SortMemberPath="FileName">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid ToolTip="{Binding FullPath}">
<TextBlock Text="{Binding FileName}" Padding="5,0" />
<Border HorizontalAlignment="Right" BorderBrush="DarkBlue" Background="LightBlue"
Margin="0.5" BorderThickness="1" CornerRadius="5">
<TextBlock Text="{Binding Pages.Count}" Foreground="DarkBlue" Padding="2,0"
FontWeight="Bold" />
</Border>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Left" Background="Transparent" />
<DataGrid ItemsSource="{Binding SelectedFile.Pages}" Style="{StaticResource DefaultDataGridStyle}"
Margin="5,0,0,0" AlternationCount="3" dd:DragDrop.UseDefaultDragAdorner="True"
ScrollViewer.PanningMode="None" dd:DragDrop.DropTargetAdornerBrush="Blue"
RowHeight="{Binding RowHeight}" SelectionMode="Extended" VirtualizingPanel.ScrollUnit="Pixel"
dd:DragDrop.DragHandler="{Binding}" dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True" Grid.ColumnSpan="1" Grid.Column="1">
<DataGrid.InputBindings>
<KeyBinding Key="Delete" Command="{Binding DeleteItemsCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
</DataGrid.InputBindings>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="0,0,0,.5" />
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Pages" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding PageImage}">
<Image.InputBindings>
<MouseBinding Gesture="RightClick"
Command="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=DataContext.PreviewCommand}"
CommandParameter="{Binding}" />
</Image.InputBindings>
</Image>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<GridSplitter Grid.Column="2" Width="5" HorizontalAlignment="Left" Background="Transparent" />
<DataGrid ItemsSource="{Binding OutputFiles}" Style="{StaticResource DefaultDataGridStyle}"
AlternationCount="3" dd:DragDrop.UseDefaultDragAdorner="True"
dd:DragDrop.DropTargetAdornerBrush="Blue" Sorting="dgOutputFiles_Sorting" SelectionMode="Extended"
SelectedItem="{Binding SelectedOutputFile}" dd:DragDrop.IsDragSource="True" IsReadOnly="False"
dd:DragDrop.DragHandler="{Binding}" dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDropTarget="True" Grid.ColumnSpan="1" Margin="5,0,0,0" Grid.Column="2">
<DataGrid.InputBindings>
<KeyBinding Key="Delete" Command="{Binding DeleteItemsCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
</DataGrid.InputBindings>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Output Files" Width="*" SortMemberPath="FileName" IsReadOnly="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid ToolTip="{Binding FullPath}">
<TextBlock Text="{Binding FileName}" Padding="5,0" />
<Border HorizontalAlignment="Right" BorderBrush="DarkBlue" Background="LightBlue"
Margin="0.5" BorderThickness="1" CornerRadius="5">
<TextBlock Text="{Binding Pages.Count}" Foreground="DarkBlue" Padding="2,0"
FontWeight="Bold" />
</Border>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding FileName, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<GridSplitter Grid.Column="3" Width="5" HorizontalAlignment="Left" Background="Transparent" />
<DataGrid ItemsSource="{Binding SelectedOutputFile.Pages}" Style="{StaticResource DefaultDataGridStyle}"
Margin="5,0,0,0" AlternationCount="3" dd:DragDrop.UseDefaultDragAdorner="True"
dd:DragDrop.DragHandler="{Binding}" dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.DropTargetAdornerBrush="Blue" RowHeight="{Binding RowHeight}" SelectionMode="Extended"
VirtualizingPanel.ScrollUnit="Pixel" dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"
Grid.ColumnSpan="1" Grid.Column="3">
<DataGrid.InputBindings>
<KeyBinding Key="Delete" Command="{Binding DeleteItemsCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
</DataGrid.InputBindings>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="0,0,0,.5" />
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Pages" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.InputBindings>
<MouseBinding Gesture="RightClick"
Command="{Binding RelativeSource={RelativeSource AncestorType=DataGrid, Mode=FindAncestor}, Path=DataContext.PreviewCommand}"
CommandParameter="{Binding}" />
</Grid.InputBindings>
<Image Source="{Binding PageImage}">
<Image.LayoutTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="{Binding Rotation}" />
<TranslateTransform />
</TransformGroup>
</Image.LayoutTransform>
</Image>
<Button x:Name="RotateButton"
Command="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=DataContext.RotateCommand}"
CommandParameter="{Binding}" HorizontalAlignment="Right"
VerticalAlignment="Top" Width="22" Height="22">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource ButtonBase}">
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<DataTrigger
Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridCell, Mode=FindAncestor}, Path=IsMouseOver}"
Value="true">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.Content>
<!--<TextBlock Text="{Binding Rotation}" />-->
<Image Source="pack://application:,,,/Resources/rotate-image-icon-11.jpg"
Width="18" Height="18" HorizontalAlignment="Left"
VerticalAlignment="Top" />
</Button.Content>
</Button>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<Button Content="+" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Top" Width="21"
Height="21" Command="{Binding AddFileCommand}" ToolTip="Add Files" />
</Grid>
<Popup IsOpen="{Binding PreviewOpen}" StaysOpen="False" Placement="MousePoint" AllowsTransparency="True">
<Grid>
<Border x:Name="popupBorder" CornerRadius="10" BorderBrush="DimGray" BorderThickness="1"
Width="{Binding PreviewWidth}" Height="{Binding PreviewHeight}">
<Border.LayoutTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="{Binding PreviewRotation}" />
<TranslateTransform />
</TransformGroup>
</Border.LayoutTransform>
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="{Binding PreviewImage}" />
</Border.Background>
</Border>
</Grid>
</Popup>
</Grid>
</Window>