From 9fce87235fe379bb55537cad135d00830fbe21f0 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 16 Dec 2016 01:13:16 +0100 Subject: [PATCH] refactoring --- BookAStar/BookAStar/App.xaml | 14 +++-- BookAStar/BookAStar/App.xaml.cs | 1 - BookAStar/BookAStar/BookAStar.csproj | 3 ++ BookAStar/BookAStar/Images/Chat/talk.png | Bin 0 -> 1588 bytes .../Model/Social/Chat/ChatMessage.cs | 11 +++- BookAStar/BookAStar/Pages/Chat/ChatPage.xaml | 29 ++++++----- .../BookAStar/Pages/Chat/ChatPage.xaml.cs | 34 +++++++------ .../BookAStar/Pages/Chat/PrivateChatPage.xaml | 3 +- BookAStar/BookAStar/Pages/DocSigning.xaml | 3 +- .../EstimatePages/EstimatesProviderPage.xaml | 3 +- .../Pages/UserProfile/AccountChooserPage.xaml | 3 +- .../Pages/UserProfile/DashboardPage.xaml | 2 +- .../ViewModels/Messaging/ChatUserInfo.cs | 26 +++++++++- BookAStar/BookAStar/Views/UserListView.xaml | 38 +++++++++++--- .../BookAStar/Views/UserListView.xaml.cs | 48 ++++++++++++++---- 15 files changed, 162 insertions(+), 56 deletions(-) create mode 100644 BookAStar/BookAStar/Images/Chat/talk.png diff --git a/BookAStar/BookAStar/App.xaml b/BookAStar/BookAStar/App.xaml index a9fb0040..aee77e6f 100644 --- a/BookAStar/BookAStar/App.xaml +++ b/BookAStar/BookAStar/App.xaml @@ -9,6 +9,8 @@ #FFAAAAFF + #FFCCCCFF + #80FFFFFF #FFFFFFFF #FFFFFFFF @@ -24,7 +26,10 @@ #207AFAFA #800080 #404040 + #909090 + #ffffff + @@ -90,11 +95,14 @@ - - + + \ No newline at end of file diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index 00809aa3..36361d35 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -357,7 +357,6 @@ namespace BookAStar msg ); DataManager.Instance.ChatUsers.OnPrivateMessage(msg); - }); } diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj index c9d2a431..898fa16d 100644 --- a/BookAStar/BookAStar/BookAStar.csproj +++ b/BookAStar/BookAStar/BookAStar.csproj @@ -513,6 +513,9 @@ Designer + + + diff --git a/BookAStar/BookAStar/Images/Chat/talk.png b/BookAStar/BookAStar/Images/Chat/talk.png new file mode 100644 index 0000000000000000000000000000000000000000..abc005767cedd87fff67e34718834601e5664a33 GIT binary patch literal 1588 zcmZXUeKgYx7{`C}vl*L<6eI7~MxtyeyJ*O~grQJaHAXa&ybi^0qF5y*YhGKWqLN-| zUQSaNbtqlukY@Oq-h@nV+ezxqz4xEaJV36dH#By^DPOc`DkhwY5)MB>F4XU zRjJT&qEX8FXj62bQcyAeK3>4j*#_u&sqFrS0_?t>Wn=-WwM0Xy;eeZ(Mjp7VImRIK-3E-by}w zhw){S#XTPuUFH4#mE?Iy+Y@bGsBN*1m8vj3AtHKuuPMR}__U*+Fvs4B^yn02pk*eOykQQya z7S@+9Vd|&s#1}P#dRvOQJ=QYS;ObUIlc;xvz)BW?-<5{NY6- z-ErH6!%{kYxzP~u9?FAbhn%c8fN8V+(N}d~R*9+Q6<|B9dmV$rGO&%ix3(4Y4#*rC zgU}~+U>v-DLI?INF?IYBzIlG9dov5?+PN3|{NgucP>>HLb)%bcjguVsb}9~zJ(5|7~tQY@T1AnD^w5uP04I8pH|u?ZKEhio(Qxv_D@n;*Zm z5;Pp3A@#HerK3+B#)e^%NR_z0>#Gw;A-^$JrEMu|$2i0MT+EZ?I-xHLM+whKni?w= z>gT-56BFgNCPIoG7r{-}lks|U$6HLFzs`tA8oa;pdvZGBBP+KxI||#4ccs~0PK?~z77P6@luWsu zb*4%B2NH4(p<`~T16IJtO&DCy-SVtUCOo?8+Y3g-{>NA2cp6A7^PM=F2rUw3EUp}L6+R!!(~&FP@*(p~bi2I{3f z^!(?cH#dLBy0S-R$I{_QxcrQ8ku&OicPz&$#pTT!jfyjnvHQ8HsKKlHU|F$F4q$eruqbdze$>Z=x}d0@!{TSYG$*UGVMtMsUQNn7m)_ z!)&*0%2;itD$eZXZJQ8mU3aueZ$=37iknHo_ML|rR(o_<5#aq@SaDIrxaC7Qgv9S| zLX6j^&Wx^1UWnv9V}W_0r!cE$Qf7+yTwUU|tT0(jcX)uy82w#W`j^njV>+XaqVn-} z`_3%9dmPg(S+j|B-hdrq5o*gTn_H0;e?ug3F$?)vvX8I#x#)rp8?B(K#EAo!bWUfu z_SNRV-T@SeM+xr_Z%A&hbtj>Qb&EyXuvzyx#`U+FIYpiEurraAuwI&Ud%;e&>gN}d z2G7!=81Hia7W)3G2OF9#7~paJYT|%&8hjQ?o^lYebxr*_YLGCYXj?i;k$*g<&XVAY zUaEHBX2 + Style="{StaticResource PageStyle}" > @@ -100,18 +100,15 @@ - - + Orientation = "Horizontal"> - - - + + + + + + diff --git a/BookAStar/BookAStar/Pages/Chat/ChatPage.xaml.cs b/BookAStar/BookAStar/Pages/Chat/ChatPage.xaml.cs index fe7c15bb..bc630dcd 100644 --- a/BookAStar/BookAStar/Pages/Chat/ChatPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/Chat/ChatPage.xaml.cs @@ -44,25 +44,29 @@ namespace BookAStar.Pages.Chat }; chatUserList.BindingContext = DataManager.Instance.ChatUsers; - /* + sendPVButton.Clicked += async (sender, args) => { - string userName = contactPicker.SelectedItem as string; - if (string.IsNullOrEmpty(userName)) return; - var user = DataManager.Current.Contacts.Single( - c => c.UserName == userName); - IsBusy = true; - try - { - await App.ChatHubProxy.Invoke("SendPV", user.ChatHubConnectionId, pvEntry.Text); - pvEntry.Text = null; - } - catch (Exception ex) + var dest = chatUserList.SelectedUser; + if (dest!=null) { - Debug.WriteLine(ex); + IsBusy = true; + try + { + foreach (var cx in dest.ObservableConnections) + { + if (cx.Connected) + await App.ChatHubProxy.Invoke("SendPV", cx.ConnectionId, pvEntry.Text); + } + pvEntry.Text = null; + } + catch (Exception ex) + { + Debug.WriteLine(ex); + } + IsBusy = false; } - IsBusy = false; - };*/ + }; } diff --git a/BookAStar/BookAStar/Pages/Chat/PrivateChatPage.xaml b/BookAStar/BookAStar/Pages/Chat/PrivateChatPage.xaml index 795bbfc1..8fda0eb7 100644 --- a/BookAStar/BookAStar/Pages/Chat/PrivateChatPage.xaml +++ b/BookAStar/BookAStar/Pages/Chat/PrivateChatPage.xaml @@ -1,6 +1,7 @@  + x:Class="BookAStar.Pages.Chat.PrivateChatPage" + Style="{StaticResource PageStyle}"> \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/DocSigning.xaml b/BookAStar/BookAStar/Pages/DocSigning.xaml index 284d5707..636171f3 100644 --- a/BookAStar/BookAStar/Pages/DocSigning.xaml +++ b/BookAStar/BookAStar/Pages/DocSigning.xaml @@ -3,7 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:signature="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms" xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar" - x:Class="BookAStar.ViewModels.Signing.Signing"> + x:Class="BookAStar.ViewModels.Signing.Signing" + Style="{StaticResource PageStyle}"> + x:Class="BookAStar.Pages.EstimatesProviderPage" + Style="{StaticResource PageStyle}"> diff --git a/BookAStar/BookAStar/Pages/UserProfile/AccountChooserPage.xaml b/BookAStar/BookAStar/Pages/UserProfile/AccountChooserPage.xaml index e263319c..e405395f 100644 --- a/BookAStar/BookAStar/Pages/UserProfile/AccountChooserPage.xaml +++ b/BookAStar/BookAStar/Pages/UserProfile/AccountChooserPage.xaml @@ -3,7 +3,8 @@ xmlns:local="clr-namespace:BookAStar;assembly=BookAStar" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="BookAStar.Pages.UserProfile.AccountChooserPage" - Title="{x:Static local:Strings.UserAccounts}" Style="{StaticResource PageStyle}" + Title="{x:Static local:Strings.UserAccounts}" + Style="{StaticResource PageStyle}" xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms" xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms"> diff --git a/BookAStar/BookAStar/Pages/UserProfile/DashboardPage.xaml b/BookAStar/BookAStar/Pages/UserProfile/DashboardPage.xaml index b5fb276b..8b3ccc0f 100644 --- a/BookAStar/BookAStar/Pages/UserProfile/DashboardPage.xaml +++ b/BookAStar/BookAStar/Pages/UserProfile/DashboardPage.xaml @@ -7,7 +7,7 @@ x:Class="BookAStar.Pages.UserProfile.DashboardPage" xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms" xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms" - Style="{StaticResource PageStyle}"> + Style="{StaticResource DashboardPageStyle}"> + + + + + + + + + + + + + - + - - - diff --git a/BookAStar/BookAStar/Views/UserListView.xaml.cs b/BookAStar/BookAStar/Views/UserListView.xaml.cs index 507f7fef..e4b080b0 100644 --- a/BookAStar/BookAStar/Views/UserListView.xaml.cs +++ b/BookAStar/BookAStar/Views/UserListView.xaml.cs @@ -1,4 +1,5 @@ using BookAStar.Model; +using BookAStar.Model.Social.Chat; using BookAStar.ViewModels.Messaging; using System; using System.Collections; @@ -18,22 +19,36 @@ namespace BookAStar.Views "ItemsSource", typeof(ChatUserCollection), typeof(UserListView), default(ChatUserCollection), BindingMode.OneWay); - public BindableProperty ItemSelectedProperty = BindableProperty.Create( - "ItemSelected", typeof(ICommand), typeof(UserListView), default(ICommand)); + public BindableProperty ItemSelectedCommandProperty = BindableProperty.Create( + "ItemSelectedCommand", typeof(ICommand), typeof(UserListView), default(ICommand)); public BindableProperty DisableSelectionProperty = BindableProperty.Create( "DisableSelection", typeof(bool), typeof(UserListView), false); + public BindableProperty HasASelectionProperty = BindableProperty.Create( + "HasASelection", typeof(bool), typeof(UserListView), false); + + public BindableProperty SelectedUserProperty = BindableProperty.Create( + "SelectedUser", typeof(ChatUserInfo), typeof(UserListView), default(ChatUserInfo)); + public ChatUserCollection ItemsSource { get { return (ChatUserCollection) GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); } } - - public ICommand ItemSelected + + public ChatUserInfo SelectedUser + { + get + { + return (ChatUserInfo) GetValue(SelectedUserProperty); + } + } + + public ICommand ItemSelectedCommand { - get { return (ICommand) GetValue(ItemSelectedProperty); } - set { SetValue(ItemSelectedProperty, value); } + get { return (ICommand) GetValue(ItemSelectedCommandProperty); } + set { SetValue(ItemSelectedCommandProperty, value); } } public bool DisableSelection @@ -42,12 +57,18 @@ namespace BookAStar.Views set { SetValue(DisableSelectionProperty, value); } } + public bool HasASelection + { + get { return (bool)GetValue(HasASelectionProperty); } + set { SetValue(HasASelectionProperty, value); } + } + public UserListView() { InitializeComponent(); list.ItemSelected += OnUserSelected; - } + protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); @@ -58,14 +79,19 @@ namespace BookAStar.Views list.EndRefresh(); }); } + public void OnUserSelected(object sender, SelectedItemChangedEventArgs ev) { - if (ItemSelected != null) - if (ItemSelected.CanExecute(ev.SelectedItem)) + if (ItemSelectedCommand != null) + if (ItemSelectedCommand.CanExecute(ev.SelectedItem)) { - ItemSelected.Execute(ev.SelectedItem); + ItemSelectedCommand.Execute(ev.SelectedItem); } - if (DisableSelection) list.SelectedItem = null; + if (DisableSelection) + list.SelectedItem = null; + SetValue(SelectedUserProperty, list.SelectedItem); + HasASelection = list.SelectedItem != null; } + } }