diff --git a/AccountsViewModel.h b/AccountsViewModel.h index b9c8d645578ca1eb45af4bdb56108ab892b97002..0aa5977619ee861dbd42a4bbeaeafe972940432a 100644 --- a/AccountsViewModel.h +++ b/AccountsViewModel.h @@ -24,6 +24,9 @@ using namespace Platform::Collections; namespace RingClientUWP { +delegate void NewAccountSelected(); +delegate void NoAccountSelected(); + namespace ViewModel { public ref class AccountsViewModel sealed { @@ -43,6 +46,23 @@ internal: void clearAccountList(); /* properties */ + property Account^ selectedAccount + { + Account^ get() + { + return currentItem_; + } + void set(Account^ value) + { + oldItem_ = currentItem_; + currentItem_ = value; + if (value) + newAccountSelected(); + else + noAccountSelected(); + } + } + property Vector<Account^>^ accountsList { Vector<Account^>^ get() @@ -52,10 +72,15 @@ internal: } /* events */ + event NewAccountSelected^ newAccountSelected; + event NoAccountSelected^ noAccountSelected; private: AccountsViewModel(); // singleton Vector<Account^>^ accountsList_; + Account^ currentItem_; + Account^ oldItem_; + }; } } diff --git a/RingD.cpp b/RingD.cpp index 2d4ef7391b98bc7b2a4d51317966baf4bcca1fa1..922b6d14dbb4f215b7e44fe6d5ef4806d38d343a 100644 --- a/RingD.cpp +++ b/RingD.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * -* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * * Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> * * * * This program is free software; you can redistribute it and/or modify * @@ -27,6 +27,8 @@ #include "account_schema.h" +#include "SmartPanel.xaml.h" + using namespace Windows::ApplicationModel::Core; using namespace Windows::Storage; using namespace Windows::UI::Core; @@ -184,4 +186,4 @@ RingD::dequeueTasks() } tasksList_.pop(); } -} \ No newline at end of file +} diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 41d32d96117cc390491485f830d1c44ec27d745f..0be508501ce5c3c67b9c4dd10640bac15dd6adc6 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -181,7 +181,8 @@ Height="80"/> <StackPanel Grid.Column="1" VerticalAlignment="Bottom"> - <TextBlock Text="TOT fdsfds fdsO" + <TextBlock x:Name="_selectedAccountName_" + Text="default name" Margin="10" Style="{StaticResource TextStyle2}"/> <StackPanel Orientation="Horizontal"> @@ -224,6 +225,7 @@ </Grid.RowDefinitions> <ListBox x:Name="_accountsList_" Grid.Row="0" + SelectionChanged="_accountList__SelectionChanged" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollMode="Enabled" Width="320" diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 99731d9cf053bb985023ac4640fe49c37378023f..b77347730ed82e770f3de3444677559207383713 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -41,6 +41,16 @@ SmartPanel::SmartPanel() _smartList_->ItemsSource = ContactsViewModel::instance->contactsList; } +void +RingClientUWP::Views::SmartPanel::updatePageContent() +{ + auto account = AccountsViewModel::instance->selectedAccount; + if (!account) + return; + + _selectedAccountName_->Text = account->name_; +} + void RingClientUWP::Views::SmartPanel::_accountsMenuButton__Checked(Object^ sender, RoutedEventArgs^ e) { _shareMenuButton_->IsChecked = false; @@ -151,6 +161,15 @@ SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI:: ContactsViewModel::instance->selectedContact = contact; } +void +SmartPanel::_accountList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e) +{ + auto listbox = safe_cast<ListBox^>(sender); + auto account = safe_cast<Account^>(listbox->SelectedItem); + AccountsViewModel::instance->selectedAccount = account; + updatePageContent(); +} + void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) { /* add contact, test purpose but will be reused later in some way */ @@ -158,4 +177,4 @@ void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyDown(Platform::Object^ sen ContactsViewModel::instance->addNewContact(_ringTxtBx_->Text, _ringTxtBx_->Text); _ringTxtBx_->Text = ""; } -} +} diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h index e5d36011021cf68c9943a013f1fe44ce92ffaa49..f65b213dbc26c2cd99997d2b187ebfa164091c82 100644 --- a/SmartPanel.xaml.h +++ b/SmartPanel.xaml.h @@ -31,6 +31,7 @@ public ref class SmartPanel sealed { public: SmartPanel(); + void updatePageContent(); internal: enum class Mode { Minimized, Normal }; @@ -51,6 +52,7 @@ private: void _createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); + void _accountList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); void _ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); }; }