src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs
changeset 123 8af72b302e0a
parent 117 c1222ecbf1b1
child 143 9f157d9c725b
--- 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<string, ListVideoItem> _Videos = new Dictionary<string, ListVideoItem>();
-
+        
         public UserControlListVideo()
         {
             this.InitializeComponent();
-            LoadList();
             UpdateList();
 
             // Insert code required on object creation below this point.
@@ -67,6 +63,7 @@
         {
             try
             {
+                Dictionary<string, ListVideoItem> _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<ListVideoItem>));
-                List<ListVideoItem> temp = (List<ListVideoItem>)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<string, ListVideoItem> _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<string, ListVideoItem> _Videos = (new ListVideo()).GetVideos();
             stackPanel.Children.Clear();
             foreach (KeyValuePair<string, ListVideoItem> elt in _Videos)
             {