--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.Control.ListVideo/CustomListBoxItem.cs Wed Sep 23 22:22:52 2009 +0200
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Surface;
+using Microsoft.Surface.Presentation;
+using Microsoft.Surface.Presentation.Controls;
+
+namespace FingersDance.Control.ListVideo
+{
+ public class CustomListBoxItem:SurfaceListBoxItem
+ {
+ public string Name = "";
+ public string Path = "";
+ }
+}
--- a/src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj Wed Sep 23 17:11:43 2009 +0200
+++ b/src/FingersDance.Control.ListVideo/FingersDance.Control.ListVideo.csproj Wed Sep 23 22:22:52 2009 +0200
@@ -69,6 +69,7 @@
<Resource Include="Lake.jpg" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="CustomListBoxItem.cs" />
<Compile Include="ListVideoItem.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
--- a/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml Wed Sep 23 17:11:43 2009 +0200
+++ b/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml Wed Sep 23 22:22:52 2009 +0200
@@ -21,10 +21,9 @@
</StackPanel.RenderTransform>
</StackPanel>
</Custom:SurfaceListBox>
- <Custom:SurfaceTextBox x:Name="PathImporter" Margin="152,0,104.427,71.81" VerticalAlignment="Bottom" TextWrapping="Wrap" Height="20" d:LayoutOverrides="VerticalAlignment"/>
+ <Custom:SurfaceTextBox x:Name="PathImporter" Margin="152,0,186.4,71.81" VerticalAlignment="Bottom" TextWrapping="Wrap" Height="20" d:LayoutOverrides="VerticalAlignment"/>
<Label x:Name="LabelImporter" HorizontalAlignment="Left" Margin="14,0,0,67.81" VerticalAlignment="Bottom" Width="122" Height="28" Content="Importer une vidéo :" d:LayoutOverrides="VerticalAlignment"/>
- <Custom:SurfaceButton x:Name="ButtonImporter" HorizontalAlignment="Right" Margin="0,0,14,66" VerticalAlignment="Bottom" Width="76" Height="17.96" Content="Importer" d:LayoutOverrides="VerticalAlignment" ContactDown="ButtonImporter_ContactDown" Click="ButtonImporter_Click"/>
- <Custom:SurfaceButton HorizontalAlignment="Right" Margin="0,0,104.427,8" VerticalAlignment="Bottom" Width="76" Height="21" Content="Ok"/>
- <Custom:SurfaceButton HorizontalAlignment="Right" Margin="0,0,14,8" VerticalAlignment="Bottom" Width="76" Height="30" Content="Annuler"/>
+ <Custom:SurfaceButton x:Name="ButtonImporter" HorizontalAlignment="Right" Margin="0,0,98,66" VerticalAlignment="Bottom" Width="76" Height="17.96" Content="Importer" d:LayoutOverrides="VerticalAlignment" ContactDown="ButtonImporter_ContactDown" Click="ButtonImporter_Click"/>
+ <Custom:SurfaceButton x:Name="RefreshButton" HorizontalAlignment="Right" Margin="0,0,18,66" VerticalAlignment="Bottom" Width="76" Height="21" Content="Actualiser" ContactDown="RefreshButton_ContactDown" Click="RefreshButton_Click"/>
</Grid>
</UserControl>
\ No newline at end of file
--- a/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs Wed Sep 23 17:11:43 2009 +0200
+++ b/src/FingersDance.Control.ListVideo/UserControlListVideo.xaml.cs Wed Sep 23 22:22:52 2009 +0200
@@ -12,6 +12,9 @@
using Microsoft.Surface.Presentation.Controls;
using System.Collections.Generic;
using System.Windows.Media.Imaging;
+using System.Xml.Serialization;
+
+using System.Reflection;
namespace FingersDance.Control.ListVideo
{
@@ -21,32 +24,33 @@
public event EventHandler EH_ItemVideo1_ContactDown;
public event EventHandler EH_ItemVideo2_ContactDown;
- List<string> _Videos = new List<string>();
+ 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.
}
- private void ItemVideo1_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
+ //Event appelé lors de la selection d'un Item dans la Video List
+ private void ItemVideo_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
{
+ path = ((CustomListBoxItem)sender).Path;
if (EH_ItemVideo1_ContactDown != null)
EH_ItemVideo1_ContactDown(this, new EventArgs());
+
}
- private void ItemVideo2_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
+ private void ItemVideo_Click(object sender, System.Windows.RoutedEventArgs e)
{
- if (EH_ItemVideo2_ContactDown != null)
- EH_ItemVideo2_ContactDown(this, new EventArgs());
- }
-
- //Event appelé lors de la selection d'un Item dans la Video List
- private void ItemVideo1_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
- {
+ path = ((CustomListBoxItem)sender).Path;
if (EH_ItemVideo1_ContactDown != null)
EH_ItemVideo1_ContactDown(this, new EventArgs());
+
}
private void ButtonImporter_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
@@ -70,34 +74,29 @@
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
{
+ ListVideoItem newItem = new ListVideoItem();
Image item = getFirstPreview(elt);
- if (item != null)
+ if (item != null && !_Videos.ContainsKey(elt))
{
- SurfaceListBoxItem Contener = new SurfaceListBoxItem();
- Contener.Content = item;
- Contener.ContactHoldGesture += new ContactEventHandler(Contener_ContactHoldGesture);
- stackPanel.Children.Add(Contener);
-
- _Videos.Add(elt);
+ newItem.Name = elt.Split('\\')[elt.Split('\\').Length - 1].Split('.')[0];
+ newItem.Path = elt;
+ newItem.Preview = elt.Replace(".wmv", ".jpg");
+ _Videos.Add(newItem.Path, newItem);
}
}
catch (Exception ex) { }
+ UpdateList();
+ SaveList();
+ }
}
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();
@@ -120,5 +119,88 @@
return _prev;
}
+
+ 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()
+ {
+ StreamWriter writter = null;
+ FileInfo assemblyPath = new FileInfo(Assembly.GetExecutingAssembly().Location);
+ DirectoryInfo info = assemblyPath.Directory;
+ try
+ {
+ writter = new StreamWriter(info.FullName.ToString() + "\\Resources\\videos.xml");
+ XmlSerializer serializer = new XmlSerializer(typeof(List<ListVideoItem>));
+ List<ListVideoItem> temp = new List<ListVideoItem>();
+ foreach (KeyValuePair<string, ListVideoItem> elt in _Videos)
+ temp.Add(elt.Value);
+ serializer.Serialize(writter, temp);
+ writter.Close();
+ }
+ catch (Exception e)
+ {
+ if (writter != null)
+ writter.Close();
+ }
+ }
+
+ void UpdateList()
+ {
+ stackPanel.Children.Clear();
+ foreach (KeyValuePair<string, ListVideoItem> elt in _Videos)
+ {
+ try
+ {
+ if (!elt.Value.Preview.Equals(""))
+ {
+ MediaElement item = new MediaElement();
+ item.Source = new Uri(elt.Value.Preview);
+ item.Width = 100;
+ item.Height = 100;
+ CustomListBoxItem Contener = new CustomListBoxItem();
+ Contener.Content = item;
+ Contener.Path = elt.Value.Path;
+ Contener.Name = elt.Value.Name;
+ Contener.ContactTapGesture += ItemVideo_ContactTapGesture;
+ stackPanel.Children.Add(Contener);
+ }
+ }
+ catch (Exception e)
+ { }
+ }
+ }
}
}
\ No newline at end of file
--- a/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs Wed Sep 23 17:11:43 2009 +0200
+++ b/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs Wed Sep 23 22:22:52 2009 +0200
@@ -38,13 +38,8 @@
try
{
reader = new StreamReader(info.FullName.ToString() + "\\Resources\\menu.xml");
- }
- catch (Exception e)
- {
- // do nothing
- }
- XmlSerializer serializer = new XmlSerializer(typeof(Menu));
- Menu temp = (Menu)serializer.Deserialize(reader);
+ XmlSerializer serializer = new XmlSerializer(typeof(Menu));
+ Menu temp = (Menu)serializer.Deserialize(reader);
foreach (Item elt in temp.Items)
try
{
@@ -52,6 +47,11 @@
}
catch (Exception) { }
reader.Close();
+ }
+ catch (Exception e)
+ {
+ // do nothing
+ }
}
public StackPanel CreateMenuItem(Item item)
--- a/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs Wed Sep 23 17:11:43 2009 +0200
+++ b/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs Wed Sep 23 22:22:52 2009 +0200
@@ -13,6 +13,8 @@
public partial class UserControlScreen
{
public String contexteGrid;
+ public string Path = "";
+
public UserControlScreen()
{
this.InitializeComponent();
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs Wed Sep 23 17:11:43 2009 +0200
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Wed Sep 23 22:22:52 2009 +0200
@@ -336,16 +336,17 @@
SessionInput.Name = "SessionInput";
try{
- //2-Recuperer la Grid qui contient le UCListVideo et l'ajouter.
+ //2-Recuperer la Grid (Layout root du UC screen)qui contient le UCListVideo et l'ajouter.
Grid actualGrid = (Grid)(((UserControlListVideo)sender).Parent);
actualGrid.Children.Add(SessionInput);
-
+
+ //2.5 rensegner la video choisie au screen
+ ((UserControlScreen)actualGrid.Parent).Path = ((CustomListBoxItem)sender).Path;
//3-Creation des Events
SessionInput.EH_SurfaceButtonSubmit_ContactDown += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown);
//4-Supression du UC List Video
actualGrid.Children.Remove((UserControlListVideo)sender);
-
//Init Scatter View Properties and Add it to the scatter view.
/*scatterViewItemSessionInput.Content = SessionInput;
scatterViewItemSessionInput.CanMove = true;