Redimensionner le contenu d'une grid en vue d'une impression
Bonjour à tous et à toutes, je suis novice ici mais j'ai soif d'apprendre :)
On m'a confié un petit projet, redimensionner un contenu pour une impression format A4.
Pour les besoins du projet je travail avec du WPF, j'ai donc une partie XAML et une partie VB.
J'ai réussi à faire apparaitre une invite d'impression windows, mais pas à redimensionner l'image que j'ai incorporée en tant que test.
L'image n'est donc pas là où elle doit être.
J'aurais donc besoin d'aide pour redimensionner cette grid.
Je vous colle mon XAML et mon VB:
XAML:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| <Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Name="Printforwin" AllowsTransparency="False" UseLayoutRounding="True" d:DesignHeight="350" d:DesignWidth="525" SizeToContent="WidthAndHeight">
<Grid Name="Hors_Impression" Height="313" Width="513">
<Button Content="Imprimer" Height="auto" HorizontalAlignment="Left" Margin="446,279,0,0" Name="B_Imprimer" VerticalAlignment="Top" Width="auto" />
<Grid Name="view" Margin="14,12,35,50">
<Image Source="C:\Users\ikari\Desktop\test.jpg" Height="251" HorizontalAlignment="Left" Name="Img" Stretch="Fill" VerticalAlignment="Top" Width="464" />
</Grid>
</Grid>
</Window> |
VB:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Class MainWindow
'Routine pour imprimer un document
Private Sub B_Impprimer_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles B_Imprimer.Click
Dim printDlg As New PrintDialog()
Dim pageSize As Size = New Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight)
view.Measure(pageSize)
view.Arrange(New Rect(400, 150, 0, 0))
Dim print As Boolean = printDlg.ShowDialog()
If print = True Then
printDlg.PrintVisual(view, "Impression")
ElseIf print = True Then
Exit Sub
End If
End Sub |
Merci d'avance si vous trouvez la moindre piste pour m'avancer :)
P.S: même si vous ne trouvez pas merci de m'avoir lu^^