# HG changeset patch # User Matthieu Totet # Date 1259138366 -3600 # Node ID b5ee436add3dd5027e733482f63c2fd1d11bdb24 # Parent 513caf1637bf32d7268b5fc7b15fb125895d99fe ContextualLinkBinder From ClickMenu diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/View/AnnotationMaker/AnnotationMaker.xaml --- 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 @@ - diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelAnnoter.xaml.cs --- 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(Item_ClickMenuItemHooverSelected); _textItem.ClickMenuItemHooverSelected += new EventHandler(Item_ClickMenuItemHooverSelected); _videoItem.ClickMenuItemHooverSelected += new EventHandler(Item_ClickMenuItemHooverSelected); diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml --- 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 @@ - + @@ -17,6 +17,7 @@ + \ No newline at end of file diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/View/ClickMenu/ClickMenuPanelContextualiser.xaml.cs --- 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(_polemicItem_ClickMenuItemSelected); _contextualiserItem.ClickMenuItemHooverSelected += new EventHandler(Item_ClickMenuItemHooverSelected); _referenceItem.ClickMenuItemHooverSelected += new EventHandler(Item_ClickMenuItemHooverSelected); _questionItem.ClickMenuItemHooverSelected += new EventHandler(Item_ClickMenuItemHooverSelected); @@ -24,6 +28,8 @@ _adhesionItem.ClickMenuItemHooverSelected += new EventHandler(Item_ClickMenuItemHooverSelected); } + + void Item_ClickMenuItemHooverSelected(object sender, ClickMenuItemHooverEventArgs e) { ClickMenuItemHooverSelected(sender, e); diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/View/ContextualBinderLayer/ContextualBinderLayer.xaml.cs --- 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(ElementSelected_Executed); Commands.ContextualBinderLayer.EndBind.Executed += new EventHandler(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 }; diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/View/ContextualLinkBinder.xaml.cs --- 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(); diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/View/Main/Main.xaml.cs --- 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(FlipView_Executed); @@ -23,9 +24,6 @@ void FlipView_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) { Commands.VideoViewer.Pause.Execute(); - - - FlipTest.ExecuteFlip(); } } diff -r 513caf1637bf -r b5ee436add3d client/src/Iri.Modernisation.Controls/ViewModel/Main/MainVM.cs --- 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 videoBooks) { + InitializeCommands(); List SelectedVideoBooks = videoBooks;