first step of search mode : add choice panel and integrate the annotation mode.
authorcavaliet
Wed, 18 Nov 2009 13:06:55 +0100
changeset 208 0699cab5cbb3
parent 207 6405d0b7d085
child 209 09c4d30fe8d1
first step of search mode : add choice panel and integrate the annotation mode.
src/FingersDance.Control.Screen/UserControlScreen.xaml.cs
src/FingersDance.Control.SessionInput/FingersDance.Control.SessionInput.csproj
src/FingersDance.Control.SessionInput/UserControlAnnotationOrSearch.xaml
src/FingersDance.Control.SessionInput/UserControlAnnotationOrSearch.xaml.cs
src/FingersDance.Control.SessionInput/UserControlListProject.xaml.cs
--- a/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Tue Nov 17 13:40:58 2009 +0100
+++ b/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Wed Nov 18 13:06:55 2009 +0100
@@ -22,6 +22,7 @@
         public int id = 0;
         public event EventHandler UC_Screen_NewCutting;
         private MainViewModel _mainViewModel;
+        private String AnnotationOrSearchMode;
         public Cutting Cutting;
 
         private String videoName;
@@ -65,20 +66,21 @@
             {
                 try { LayoutRoot.Children.Add(uie); }
                 catch(Exception){}
-            }          
+            }
         }
 
         private void ListVideo_EH_ItemVideo_ContactDown(object sender, EventArgs e)
         {
             try
             {
-                //1 renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo
+                // 1- renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo
                 videoName = ((UserControlListVideo)sender).VideoName;
                 videoPath = ((UserControlListVideo)sender).path;
-                _mainViewModel.CreateProject(videoName, videoPath);
-                //2-Supression du UC List Video
+                // 2-Supression du UC List Video
                 LayoutRoot.Children.Remove((UserControlListVideo)sender);
-                OpenProjectList();
+                // 3 - Choose between Annotation Or Search Mode
+                GetAnnotationOrSearchMode();
+                //OpenProjectList();
             }
             catch (Exception ex)
             {
@@ -88,22 +90,41 @@
             }
         }
 
+        private void GetAnnotationOrSearchMode()
+        {
+            UserControlAnnotationOrSearch AnnotOrSearch = new UserControlAnnotationOrSearch();
+            AnnotOrSearch.ModeChosen += new EventHandler<AnnotationOrSearchEventArg>(AnnotOrSearch_ModeChosen);
+            this.AddToGrid(AnnotOrSearch);
+        }
+
+        void AnnotOrSearch_ModeChosen(object sender, AnnotationOrSearchEventArg e)
+        {
+            // We remove the UserControlAnnotationOrSearch
+            LayoutRoot.Children.Remove((UserControlAnnotationOrSearch)sender);
+            // We show the project list and send the chosen mode
+            AnnotationOrSearchMode = e.ChosenMode;
+            OpenProjectList();
+        }
+
         private void OpenProjectList()
         {
             try
             {
-                // We get all the ldt/project files from the current directory...
-                List<String> existingProjects = new List<String>();
-                foreach (String filename in Directory.GetFiles("./"))
-                {
-                    if (filename.Substring(filename.Length-4).ToLower()==".ldt")
-                        existingProjects.Add(filename.Substring(2, filename.Length - 6));
-                }
-                // ... and display them the the select box UserControlListProject
-                UserControlListProject listProject = new UserControlListProject(existingProjects);
-                listProject.Name = "ListProject";
-                LayoutRoot.Children.Add(listProject);
-                listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown);
+                    // First We create the project if we are in annotation mode
+                    if(AnnotationOrSearchMode=="Annotation")
+                        _mainViewModel.CreateProject(videoName, videoPath);
+                    // We get all the ldt/project files from the current directory...
+                    List<String> existingProjects = new List<String>();
+                    foreach (String filename in Directory.GetFiles("./"))
+                    {
+                        if (filename.Substring(filename.Length-4).ToLower()==".ldt")
+                            existingProjects.Add(filename.Substring(2, filename.Length - 6));
+                    }
+                    // ... and display them the the select box UserControlListProject
+                    UserControlListProject listProject = new UserControlListProject(existingProjects, AnnotationOrSearchMode);
+                    listProject.Name = "ListProject";
+                    LayoutRoot.Children.Add(listProject);
+                    listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown);
             }
             catch (Exception)
             {
@@ -154,8 +175,11 @@
                         loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value,cuttingNode.Element("title").Value,la));
                     }
                     // We define the loaded project as the current session's project.
-                    _mainViewModel.Project = new ProjectViewModel(loadedProject);
-                    OpenProject();
+                    if (AnnotationOrSearchMode == "Annotation")
+                    {
+                        _mainViewModel.Project = new ProjectViewModel(loadedProject);
+                        OpenProject();
+                    }
                 }
             }
             catch (Exception)
--- a/src/FingersDance.Control.SessionInput/FingersDance.Control.SessionInput.csproj	Tue Nov 17 13:40:58 2009 +0100
+++ b/src/FingersDance.Control.SessionInput/FingersDance.Control.SessionInput.csproj	Wed Nov 18 13:06:55 2009 +0100
@@ -89,6 +89,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Resource>
+    <Page Include="UserControlAnnotationOrSearch.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="UserControlListCutting.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -127,6 +131,9 @@
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
       <DependentUpon>Settings.settings</DependentUpon>
     </Compile>
+    <Compile Include="UserControlAnnotationOrSearch.xaml.cs">
+      <DependentUpon>UserControlAnnotationOrSearch.xaml</DependentUpon>
+    </Compile>
     <Compile Include="UserControlListCutting.xaml.cs">
       <DependentUpon>UserControlListCutting.xaml</DependentUpon>
     </Compile>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.Control.SessionInput/UserControlAnnotationOrSearch.xaml	Wed Nov 18 13:06:55 2009 +0100
@@ -0,0 +1,13 @@
+<UserControl x:Class="FingersDance.Control.SessionInput.UserControlAnnotationOrSearch"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    Height="200" Width="300" x:Name="UCAnnotationOrSearch"
+    xmlns:Custom="http://schemas.microsoft.com/surface/2008">
+    <Grid>
+    	<Custom:SurfaceButton Margin="0,0,73,0" x:Name="annotBtn" VerticalAlignment="Top" Height="73" Content="Annotation" FontFamily="Cordia New" FontSize="36" Background="Black" 
+                              Foreground="White" Click="annotBtn_Click" ContactDown="annotBtn_ContactDown" />
+    	<Custom:SurfaceButton Margin="0,76,73,0" x:Name="searchBtn" VerticalAlignment="Top" Height="73" Content="Recherche" FontFamily="Cordia New" FontSize="36" Background="Black" 
+                              Foreground="White" Click="searchBtn_Click" ContactDown="searchBtn_ContactDown"/>
+            
+    </Grid>
+</UserControl>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.Control.SessionInput/UserControlAnnotationOrSearch.xaml.cs	Wed Nov 18 13:06:55 2009 +0100
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace FingersDance.Control.SessionInput
+{
+
+    /// <summary>
+    /// Interaction logic for UserControlAnnotationOrSearch.xaml
+    /// </summary>
+    public partial class UserControlAnnotationOrSearch : UserControl
+    {
+        public event EventHandler<AnnotationOrSearchEventArg> ModeChosen;
+
+        public UserControlAnnotationOrSearch()
+        {
+            InitializeComponent();
+        }
+
+        private void annotBtn_Click(object sender, RoutedEventArgs e)
+        {
+            ModeChosen(this, new AnnotationOrSearchEventArg("Annotation"));
+        }
+
+        private void annotBtn_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
+        {
+            ModeChosen(this, new AnnotationOrSearchEventArg("Annotation"));
+        }
+
+        private void searchBtn_Click(object sender, RoutedEventArgs e)
+        {
+            ModeChosen(this, new AnnotationOrSearchEventArg("Search"));
+        }
+
+        private void searchBtn_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
+        {
+            ModeChosen(this, new AnnotationOrSearchEventArg("Search"));
+        }
+    }
+
+
+    /// <summary>
+    /// AnnotationOrSearchEventArg
+    /// </summary>
+    public class AnnotationOrSearchEventArg : EventArgs
+    {
+        public String ChosenMode
+        {
+            get;
+            set;
+        }
+
+        public AnnotationOrSearchEventArg(String chosenMode)
+        {
+
+            ChosenMode = chosenMode;
+
+        }
+
+    }
+}
--- a/src/FingersDance.Control.SessionInput/UserControlListProject.xaml.cs	Tue Nov 17 13:40:58 2009 +0100
+++ b/src/FingersDance.Control.SessionInput/UserControlListProject.xaml.cs	Wed Nov 18 13:06:55 2009 +0100
@@ -25,25 +25,29 @@
         public event EventHandler EH_ListProject_ContactDown;
         public string SelectedItem = "";
 
-        public UserControlListProject(List<String> projectNames)
+        public UserControlListProject(List<String> projectNames, String AnnotationOrSearchMode)
         {
             InitializeComponent();
-            OpenProjects(projectNames);
+            OpenProjects(projectNames, AnnotationOrSearchMode);
         }
 
-        private void OpenProjects(List<String> projectNames)
+        private void OpenProjects(List<String> projectNames, String AnnotationOrSearchMode)
         {
-            CustomListBoxItem Contener = new CustomListBoxItem();
-            Contener.Name = "New Project";
-            UserControlCustomLabel l = new UserControlCustomLabel("New Project");
-            Contener.Content = l;
-            stackPanel.Children.Add(Contener);
-            Contener.ContactTapGesture += Item_ContactTapGesture;
+            // We add the "new project" item only if we are in "Annotation" mode. Search mode only needs existing projects
+            if (AnnotationOrSearchMode == "Annotation")
+            {
+                CustomListBoxItem Contener = new CustomListBoxItem();
+                Contener.Name = "New Project";
+                UserControlCustomLabel l = new UserControlCustomLabel("New Project");
+                Contener.Content = l;
+                stackPanel.Children.Add(Contener);
+                Contener.ContactTapGesture += Item_ContactTapGesture;
+            }
             foreach (String projectName in projectNames)
             {
-                Contener = new CustomListBoxItem();
+                CustomListBoxItem Contener = new CustomListBoxItem();
                 Contener.Name = projectName;
-                l = new UserControlCustomLabel(projectName);
+                UserControlCustomLabel l = new UserControlCustomLabel(projectName);
                 Contener.Content = l;
                 stackPanel.Children.Add(Contener);
                 Contener.ContactTapGesture += Item_ContactTapGesture;