# HG changeset patch # User PAMPHILE Jonathan # Date 1253717262 -7200 # Node ID 067f4a6c0ccad3aa079fbd8175c90a151c28a5f2 # Parent 841de52a9f83768919c388a591a1ec318d095e1a ListVideo diff -r 841de52a9f83 -r 067f4a6c0cca src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj --- a/src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj Wed Sep 23 12:08:58 2009 +0200 +++ b/src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj Wed Sep 23 16:47:42 2009 +0200 @@ -69,6 +69,7 @@ + ResXFileCodeGenerator diff -r 841de52a9f83 -r 067f4a6c0cca src/FingersDance.Control.ListVideo/ListVideoItem.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/FingersDance.Control.ListVideo/ListVideoItem.cs Wed Sep 23 16:47:42 2009 +0200 @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace FingersDance.Control.ListVideo +{ + [Serializable] + public class ListVideoItem + { + string _Name = ""; + string _Path = ""; + string _Preview = ""; + + public string Name + { + get { return _Name; } + set { _Name = value; } + } + + public string Path + { + get { return _Path; } + set { _Path = value; } + } + + public string Preview + { + get { return _Preview; } + set { _Preview = value; } + } + + public ListVideoItem() { } + } +} diff -r 841de52a9f83 -r 067f4a6c0cca src/FingersDance.Control.ListVideo/UserControlListVideo.xaml --- a/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml Wed Sep 23 12:08:58 2009 +0200 +++ b/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml Wed Sep 23 16:47:42 2009 +0200 @@ -6,18 +6,25 @@ mc:Ignorable="d" x:Class="FingersDance.Control.ListVideo.UserControlListVideo" x:Name="UserControl" - Width="404" Height="272.56" xmlns:Custom="http://schemas.microsoft.com/surface/2008" Background="{x:Null}"> + Width="478" Height="288.56" xmlns:Custom="http://schemas.microsoft.com/surface/2008" Background="{x:Null}"> - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff -r 841de52a9f83 -r 067f4a6c0cca src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs --- a/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs Wed Sep 23 12:08:58 2009 +0200 +++ b/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs Wed Sep 23 16:47:42 2009 +0200 @@ -7,21 +7,28 @@ using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Navigation; +using Microsoft.Surface; +using Microsoft.Surface.Presentation; +using Microsoft.Surface.Presentation.Controls; +using System.Collections.Generic; +using System.Windows.Media.Imaging; namespace FingersDance.Control.ListVideo { - public partial class UserControlListVideo - { + public partial class UserControlListVideo + { //Creation d'un Event pour Chaque Item Video public event EventHandler EH_ItemVideo1_ContactDown; public event EventHandler EH_ItemVideo2_ContactDown; - public UserControlListVideo() - { - this.InitializeComponent(); + List _Videos = new List(); - // Insert code required on object creation below this point. - } + public UserControlListVideo() + { + this.InitializeComponent(); + + // Insert code required on object creation below this point. + } private void ItemVideo1_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) { @@ -41,5 +48,77 @@ if (EH_ItemVideo1_ContactDown != null) EH_ItemVideo1_ContactDown(this, new EventArgs()); } - } + + private void ButtonImporter_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + AddVideoToList(); + } + + private void ButtonImporter_Click(object sender, System.Windows.RoutedEventArgs e) + { + AddVideoToList(); + } + + private void AddVideoToList() + { + try + { + string[] Files = new string[1]; + if (System.IO.Directory.Exists(PathImporter.Text)) + Files = System.IO.Directory.GetFiles(PathImporter.Text); + else + if (System.IO.File.Exists(PathImporter.Text)) + Files[0] = PathImporter.Text; + if (Files != null) + foreach (string elt in Files) + if (elt.ToLower().EndsWith(".wmv")) // ..... + try + { + Image item = getFirstPreview(elt); + if (item != null) + { + SurfaceListBoxItem Contener = new SurfaceListBoxItem(); + Contener.Content = item; + Contener.ContactHoldGesture += new ContactEventHandler(Contener_ContactHoldGesture); + stackPanel.Children.Add(Contener); + + _Videos.Add(elt); + } + } + catch (Exception ex) { } + } + catch (Exception) { } + } + + void Contener_ContactHoldGesture(object sender, ContactEventArgs e) + { + SurfaceContextMenu Menu = new SurfaceContextMenu(); + Menu.Items.Add("Supprimer"); + ((SurfaceListBoxItem)sender).ContextMenu = Menu; + + } + + Image getFirstPreview(string path) + { + MediaPlayer _player = new MediaPlayer(); + _player.Open(new Uri(path)); + _player.Play(); + _player.Position = new TimeSpan(0, 0, 5); + System.Threading.Thread.Sleep(800); + RenderTargetBitmap target = new RenderTargetBitmap(100, 100, 1 / 100, 1 / 100, PixelFormats.Pbgra32); + DrawingVisual visual = new DrawingVisual(); + DrawingContext context = visual.RenderOpen(); + Rect frameRect = new Rect(); + frameRect.Height = target.Height; + frameRect.Width = target.Width; + context.DrawVideo(_player, frameRect); + context.Close(); + target.Render(visual); + Image _prev = new Image(); + _prev.Source = BitmapFrame.Create(target).GetAsFrozen() as BitmapFrame; + _player.Stop(); + + return _prev; + } + } } \ No newline at end of file