# HG changeset patch # User PAMPHILE Jonathan # Date 1253842702 -7200 # Node ID 8af72b302e0a27ad82ab6cce6e7d8c1be50c15ca # Parent b489c2756a131e57699cfcf6c14cfbe282ff611d Singletton ListVideos diff -r b489c2756a13 -r 8af72b302e0a src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj --- a/src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj Fri Sep 25 02:57:58 2009 +0200 +++ b/src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj Fri Sep 25 03:38:22 2009 +0200 @@ -70,6 +70,7 @@ + diff -r b489c2756a13 -r 8af72b302e0a src/FingersDance.Control.ListVideo/ListVideo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/FingersDance.Control.ListVideo/ListVideo.cs Fri Sep 25 03:38:22 2009 +0200 @@ -0,0 +1,51 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; +using System.Reflection; + +namespace FingersDance.Control.ListVideo +{ + public class ListVideo + { + static Dictionary _Videos; + + public ListVideo() + { } + + public Dictionary GetVideos() + { + if (_Videos == null) + { + _Videos = new Dictionary(); + LoadList(); + } + return _Videos; + } + + void LoadList() + { + _Videos.Clear(); + StreamReader reader = null; + FileInfo assemblyPath = new FileInfo(Assembly.GetExecutingAssembly().Location); + DirectoryInfo info = assemblyPath.Directory; + try + { + reader = new StreamReader(info.FullName.ToString() + "\\Resources\\videos.xml"); + XmlSerializer serializer = new XmlSerializer(typeof(List)); + List temp = (List)serializer.Deserialize(reader); + foreach (ListVideoItem elt in temp) + if (!elt.Preview.Equals("") && !_Videos.ContainsKey(elt.Path)) + _Videos.Add(elt.Path, elt); + reader.Close(); + } + catch (Exception e) + { + if (reader != null) + reader.Close(); + } + } + } +} diff -r b489c2756a13 -r 8af72b302e0a src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs --- a/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs Fri Sep 25 02:57:58 2009 +0200 +++ b/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs Fri Sep 25 03:38:22 2009 +0200 @@ -13,7 +13,6 @@ using System.Collections.Generic; using System.Windows.Media.Imaging; using System.Xml.Serialization; - using System.Reflection; namespace FingersDance.Control.ListVideo @@ -22,15 +21,12 @@ { //Creation d'un Event pour Chaque Item Video public event EventHandler EH_ItemVideo1_ContactDown; - public event EventHandler EH_ItemVideo2_ContactDown; public string path = ""; - static Dictionary _Videos = new Dictionary(); - + public UserControlListVideo() { this.InitializeComponent(); - LoadList(); UpdateList(); // Insert code required on object creation below this point. @@ -67,6 +63,7 @@ { try { + Dictionary _Videos = (new ListVideo()).GetVideos(); string[] Files = new string[1]; if (System.IO.Directory.Exists(PathImporter.Text)) Files = System.IO.Directory.GetFiles(PathImporter.Text); @@ -122,41 +119,19 @@ private void RefreshButton_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) { - LoadList(); UpdateList(); } private void RefreshButton_Click(object sender, System.Windows.RoutedEventArgs e) { - LoadList(); UpdateList(); } - void LoadList() - { - _Videos.Clear(); - StreamReader reader = null; - FileInfo assemblyPath = new FileInfo(Assembly.GetExecutingAssembly().Location); - DirectoryInfo info = assemblyPath.Directory; - try - { - reader = new StreamReader(info.FullName.ToString() + "\\Resources\\videos.xml"); - XmlSerializer serializer = new XmlSerializer(typeof(List)); - List temp = (List)serializer.Deserialize(reader); - foreach (ListVideoItem elt in temp) - if (!elt.Preview.Equals("") && !_Videos.ContainsKey(elt.Path)) - _Videos.Add(elt.Path, elt); - reader.Close(); - } - catch (Exception e) - { - if (reader != null) - reader.Close(); - } - } + void SaveList() { + Dictionary _Videos = (new ListVideo()).GetVideos(); StreamWriter writter = null; FileInfo assemblyPath = new FileInfo(Assembly.GetExecutingAssembly().Location); DirectoryInfo info = assemblyPath.Directory; @@ -179,6 +154,7 @@ void UpdateList() { + Dictionary _Videos = (new ListVideo()).GetVideos(); stackPanel.Children.Clear(); foreach (KeyValuePair elt in _Videos) { diff -r b489c2756a13 -r 8af72b302e0a src/FingersDance/Resources/videos.xml --- a/src/FingersDance/Resources/videos.xml Fri Sep 25 02:57:58 2009 +0200 +++ b/src/FingersDance/Resources/videos.xml Fri Sep 25 03:38:22 2009 +0200 @@ -2,12 +2,12 @@ Butterfly - C:\Users\Jonathan.PIAF\Desktop\IRI\src\FingersDance\Resources\Butterfly.wmv - C:\Users\Jonathan.PIAF\Desktop\IRI\src\FingersDance\Resources\Butterfly.jpg + C:\Users\Piaf\Desktop\Développement\IRI\src\FingersDance\bin\Debug\Resources\Butterfly.wmv + C:\Users\Piaf\Desktop\Développement\IRI\src\FingersDance\bin\Debug\Resources\Butterfly.jpg Lake - C:\Users\Jonathan.PIAF\Desktop\IRI\src\FingersDance\Resources\Lake.wmv - C:\Users\Jonathan.PIAF\Desktop\IRI\src\FingersDance\Resources\Lake.jpg + C:\Users\Piaf\Desktop\Développement\IRI\src\FingersDance\bin\Debug\Resources\Lake.wmv + C:\Users\Piaf\Desktop\Développement\IRI\src\FingersDance\bin\Debug\Resources\Lake.jpg \ No newline at end of file