ContextualLinkBinder From ClickMenu
authorMatthieu Totet
Wed, 25 Nov 2009 09:39:26 +0100
changeset 13 b5ee436add3d
parent 12 513caf1637bf
child 14 a48c44bc825b
ContextualLinkBinder From ClickMenu
client/src/Iri.Modernisation.Controls/View/AnnotationMaker/AnnotationMaker.xaml
client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelAnnoter.xaml.cs
client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml
client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml.cs
client/src/Iri.Modernisation.Controls/View/ContextualBinderLayer/ContextualBinderLayer.xaml.cs
client/src/Iri.Modernisation.Controls/View/ContextualLinkBinder.xaml.cs
client/src/Iri.Modernisation.Controls/View/Main/Main.xaml.cs
client/src/Iri.Modernisation.Controls/ViewModel/Main/MainVM.cs
--- a/client/src/Iri.Modernisation.Controls/View/AnnotationMaker/AnnotationMaker.xaml	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/AnnotationMaker/AnnotationMaker.xaml	Wed Nov 25 09:39:26 2009 +0100
@@ -67,7 +67,6 @@
 			<TextBlock  Style="{StaticResource CommonTextBlock}" x:Name="KeyWordLabel"  Text="{Binding RefTags, Converter={StaticResource TagConvert}}" TextWrapping="Wrap" Margin="12,79,0,22"/>
 			
 		</Grid>
-		
 		<StackPanel x:Name="AnnotationContextualLinkPanel" Height="74" Margin="0,0,8,0" VerticalAlignment="Bottom">
 			<TextBlock  Style="{StaticResource CommonTextBlock}" x:Name="AnnotationContextualLinkLabel"  Text="{Binding AnnotationMakerAddLinkLabel, Source={StaticResource LangLabels}}" TextWrapping="Wrap"/>
 			<TextBlock  Style="{StaticResource CommonTextBlock}" x:Name="AnnotationContextualBindedLabel"  TextWrapping="Wrap" HorizontalAlignment="Left" Width="295" Text="{Binding PolemicRelation.ToElement.Title}" Height="26"/>
--- a/client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelAnnoter.xaml.cs	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelAnnoter.xaml.cs	Wed Nov 25 09:39:26 2009 +0100
@@ -17,6 +17,7 @@
 		{
 			// Required to initialize variables
 			InitializeComponent();
+            
             _annoterItem.ClickMenuItemHooverSelected += new EventHandler<ClickMenuItemHooverEventArgs>(Item_ClickMenuItemHooverSelected);
             _textItem.ClickMenuItemHooverSelected += new EventHandler<ClickMenuItemHooverEventArgs>(Item_ClickMenuItemHooverSelected);
             _videoItem.ClickMenuItemHooverSelected += new EventHandler<ClickMenuItemHooverEventArgs>(Item_ClickMenuItemHooverSelected);
--- a/client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml	Wed Nov 25 09:39:26 2009 +0100
@@ -9,7 +9,7 @@
 
 	<Grid x:Name="Panel" Background="#00842B2B" Canvas.ZIndex="4" MouseLeave="Grid_MouseLeave">
 		<local:ClickMenuItem Orientation="Up" Title="Contextualiser" x:Name="_contextualiserItem" HorizontalAlignment="Left" Margin="1,0,0,0" Width="32" Canvas.ZIndex="10" VerticalAlignment="Top" d:LayoutOverrides="Height" MouseEnter="Grid_MouseEnter"/>
-		<Grid x:Name="Hidden" HorizontalAlignment="Left" Width="80" Background="#0041024D" Height="56" VerticalAlignment="Top" Visibility="Collapsed">
+		<Grid x:Name="Hidden" HorizontalAlignment="Left" Width="80" Background="#0041024D" Height="56" VerticalAlignment="Top">
 			<local:ClickMenuItem Orientation="Down" Title="Polemic" x:Name="_polemicItem" HorizontalAlignment="Left" Margin="1,24,0,0" Width="32" Canvas.ZIndex="5" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top" d:LayoutOverrides="HorizontalAlignment"/>
 			
 			<local:ClickMenuItem Title="Adhesion" Orientation="Up" x:Name="_adhesionItem" Margin="23,17,28,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Canvas.ZIndex="5"/>
@@ -17,6 +17,7 @@
 			<local:ClickMenuItem Title="Reference" Orientation="Down" x:Name="_referenceItem" HorizontalAlignment="Left" Margin="46,25,0,0" VerticalAlignment="Top" Width="32" RenderTransformOrigin="0.5,0.5" Canvas.ZIndex="5"/>
 			
 			<local:ClickMenuItem Title="Question" Orientation="Up" x:Name="_questionItem" Margin="0,18,-14,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Canvas.ZIndex="5" HorizontalAlignment="Right"/>
+			<local:ContextualLinkBinder Margin="0,28,0,0" x:Name="_polemicBinder" PolemicType="Polemic" Canvas.ZIndex="10" VerticalAlignment="Top" HorizontalAlignment="Left" Height="22" Width="30"/>
 		</Grid>
 	</Grid>
 </UserControl>
\ No newline at end of file
--- a/client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml.cs	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml.cs	Wed Nov 25 09:39:26 2009 +0100
@@ -7,7 +7,9 @@
 using System.Windows.Media;
 using System.Windows.Media.Animation;
 using System.Windows.Shapes;
-
+using Iri.Modernisation.BaseMVVM.Commands;
+using Iri.Modernisation.Controls.ViewModel;
+using Iri.Modernisation.Data.Models;
 namespace Iri.Modernisation.Controls.View
 {
 	public partial class ClickMenuPanelContextualiser : UserControl
@@ -16,7 +18,9 @@
 		public ClickMenuPanelContextualiser()
 		{
 			// Required to initialize variables
-			InitializeComponent();
+
+            InitializeComponent();
+            //_polemicItem.ClickMenuItemSelected += new EventHandler<ClickMenuItemSelectedEventArgs>(_polemicItem_ClickMenuItemSelected);
             _contextualiserItem.ClickMenuItemHooverSelected += new EventHandler<ClickMenuItemHooverEventArgs>(Item_ClickMenuItemHooverSelected);
             _referenceItem.ClickMenuItemHooverSelected += new EventHandler<ClickMenuItemHooverEventArgs>(Item_ClickMenuItemHooverSelected);
             _questionItem.ClickMenuItemHooverSelected += new EventHandler<ClickMenuItemHooverEventArgs>(Item_ClickMenuItemHooverSelected);
@@ -24,6 +28,8 @@
             _adhesionItem.ClickMenuItemHooverSelected += new EventHandler<ClickMenuItemHooverEventArgs>(Item_ClickMenuItemHooverSelected);
 		}
 
+       
+
         void Item_ClickMenuItemHooverSelected(object sender, ClickMenuItemHooverEventArgs e)
         {
             ClickMenuItemHooverSelected(sender, e);
--- a/client/src/Iri.Modernisation.Controls/View/ContextualBinderLayer/ContextualBinderLayer.xaml.cs	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ContextualBinderLayer/ContextualBinderLayer.xaml.cs	Wed Nov 25 09:39:26 2009 +0100
@@ -21,9 +21,11 @@
         private Line _linkLine;
         private bool _active = false;
         private System.Windows.Threading.DispatcherTimer myDispatcherTimer;
+        private Point _menuAnnotationPoint;
         public ContextualBinderLayer()
         {
             InitializeComponent();
+            Commands.PolemicElement.ElementSelected.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(ElementSelected_Executed);
             Commands.ContextualBinderLayer.EndBind.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EndBind_Executed);
             MouseLeftButtonUp += new MouseButtonEventHandler(ContextualBinderLayer_MouseLeftButtonUp);
             MouseMove += new MouseEventHandler(ContextualBinderLayer_MouseMove);
@@ -33,6 +35,11 @@
             myDispatcherTimer.Tick +=new EventHandler(myDispatcherTimer_Tick);
         }
 
+        void ElementSelected_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
+        {
+            _menuAnnotationPoint = ((MouseButtonEventArgs)e.Parameter).GetPosition(Application.Current.RootVisual);
+        }
+
         void  myDispatcherTimer_Tick(object sender, EventArgs e)
         {
  	          LayoutRoot.Background = PolemicTypeColorConverter.Convert(_movingBinder.PolemicType);
@@ -79,19 +86,28 @@
 
         void BeginBind_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
+            Point temp;
+            if(e.Source ==null)
+            {
+               temp = _menuAnnotationPoint;
+            }
+            else
+            {
+                temp  =  ((MouseButtonEventArgs)e.Source).GetPosition(Application.Current.RootVisual);
+            }
             LayoutRoot.Children.Clear();
             _movingBinder =new ContextualLinkBinder( ((ContextualLinkBinder)e.Parameter));  
             _movingBinder.Margin = new Thickness(
-             ((MouseButtonEventArgs)e.Source).GetPosition(this).X - _movingBinder.Width/ 2,
-             ((MouseButtonEventArgs)e.Source).GetPosition(this).Y - _movingBinder.Height/2 ,
+             temp.X - _movingBinder.Width/ 2,
+             temp.Y - _movingBinder.Height / 2,
               _movingBinder.Margin.Right,
                _movingBinder.Margin.Bottom);
             _linkLine = new Line()
             {
-                X1 = ((MouseButtonEventArgs)e.Source).GetPosition(this).X,
-                Y1 = ((MouseButtonEventArgs)e.Source).GetPosition(this).Y,
-                X2 = ((MouseButtonEventArgs)e.Source).GetPosition(this).X,
-                Y2 = ((MouseButtonEventArgs)e.Source).GetPosition(this).Y,
+                X1 = temp.X,
+                Y1 = temp.Y,
+                X2 = temp.X,
+                Y2 = temp.Y,
                 Stroke = PolemicTypeColorConverter.Convert(_movingBinder.PolemicType),
                 StrokeThickness = 2
             };
--- a/client/src/Iri.Modernisation.Controls/View/ContextualLinkBinder.xaml.cs	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ContextualLinkBinder.xaml.cs	Wed Nov 25 09:39:26 2009 +0100
@@ -45,9 +45,16 @@
             // Required to initialize variables
               InitializeComponent();
               MouseLeftButtonDown += Commands.ContextualBinderLayer.BeginBind.Execute;
+              MouseLeftButtonUp += new MouseButtonEventHandler(ContextualLinkBinder_MouseLeftButtonUp);
+              
 
 
         }
+
+        void ContextualLinkBinder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            Commands.ContextualBinderLayer.BeginBind.Execute(sender, null);
+        }
         public ContextualLinkBinder(ContextualLinkBinder copy)
         {
             InitializeComponent();
--- a/client/src/Iri.Modernisation.Controls/View/Main/Main.xaml.cs	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/Main/Main.xaml.cs	Wed Nov 25 09:39:26 2009 +0100
@@ -16,6 +16,7 @@
     {
         public Main()
         {
+
             InitializeComponent();
             Commands.FlipView.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(FlipView_Executed);
           
@@ -23,9 +24,6 @@
         void FlipView_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
             Commands.VideoViewer.Pause.Execute();
-
-
-
             FlipTest.ExecuteFlip();
         }
     }
--- a/client/src/Iri.Modernisation.Controls/ViewModel/Main/MainVM.cs	Tue Nov 24 10:42:26 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/Main/MainVM.cs	Wed Nov 25 09:39:26 2009 +0100
@@ -74,6 +74,7 @@
 
         public MainVM(List<VideoBook> videoBooks)
         {
+
             InitializeCommands();
             List<VideoBook> SelectedVideoBooks = videoBooks;