Bonjour
je butte sur un problème que donc, je n'arrive pas à résoudre.
le principe (dans l'absolu) est simple.
J'ai une une fenêtre (WPF ou Formulaire) dans laquelle je veux faire apparaitre un gif ou un mp4. et durant l'affichage je veux envoyer ce fichier par mail. ces fichiers sont stockés dans un dossier "en_attente" et un fois traités ils sont copiés dans "envoye".
là ou je butte, c'est l'affichage de l'image animée (ou pas) qui n'apparait qu'a la fin du traitement mais je la veux du début à la fin du traitement.
voilà le xaml
et voilà le cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <Window x:Class="Envoi_mail.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="500" Width="800" > <Grid Background="White"> <MediaElement Name="a_envoyer" HorizontalAlignment="Center" Height="360" VerticalAlignment="Center" Width="640" ScrubbingEnabled="True" LoadedBehavior="Manual" /> <Label Name="enCoursEnvoi" Content="Labelddddd" HorizontalAlignment="Center" Margin="0,0,0,10" Width="640" Height="40" VerticalAlignment="Bottom" Background="{x:Null}" Foreground="Black" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="13"/> </Grid> </Window>
j'ai tout simplifié au maximum pour n'avoir que le minimum.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using System; using System.IO; using System.Windows; using System.Windows.Threading; namespace Envoi_mail { public partial class MainWindow : Window { private String lastfile = null; public MainWindow() { InitializeComponent(); initApp(); } public void initApp() { DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 5); dispatcherTimer.Start(); } private void dispatcherTimer_Tick(object sender, EventArgs e) { if (lastfile != null) { File.Move(lastfile, lastfile.Replace("en_attente", "envoye")); lastfile = null; } string path = "C:/mails/en_attente/"; string[] files = Directory.GetFiles(path); if (files.Length != 0) { a_envoyer.Source = new Uri(files[0]); a_envoyer.Play(); enCoursEnvoi.Content = files[0]; lastfile = files[0]; } } } }
merci de votre aide
Bruno
Partager