diff --git a/ContactsViewModel.h b/ContactsViewModel.h index b4757fd866df11ac9fb0f4e842cfce4f0c54ac48..95feadf455693b8e0e7fb4e8303d295e454735ab 100644 --- a/ContactsViewModel.h +++ b/ContactsViewModel.h @@ -21,7 +21,7 @@ using namespace Platform::Collections; namespace RingClientUWP { -delegate void NewContactSelected(Contact^ contact); +delegate void NewContactSelected(); delegate void NoContactSelected(); namespace ViewModel { @@ -55,7 +55,7 @@ internal: oldItem_ = currentItem_; currentItem_ = value; if (value) - newContactSelected(currentItem_); + newContactSelected(); else noContactSelected(); } diff --git a/MainPage.xaml b/MainPage.xaml index 2fed2bc2a0c84917aedee5ccd1c0b04d0daff87a..718f292ed1009149d057875e00bfab1e0aff0482 100644 --- a/MainPage.xaml +++ b/MainPage.xaml @@ -62,15 +62,24 @@ <Frame x:Name="_smartPanel_"/> </SplitView.Pane> <SplitView.Content> - <StackPanel> - <Frame x:Name="_welcomeFrame_" - Visibility="Visible"/> - <Frame x:Name="_messageTextFrame_" - Visibility="Collapsed"/> - <Frame x:Name="_videoFrame_" - Visibility="Collapsed"/> - </StackPanel> - </SplitView.Content> + <Grid x:Name="_navGrid_"> + <Grid.RowDefinitions> + <!-- stores the hidden frames. --> + <RowDefinition Height="0"/> + <!-- nesting the showed frame. --> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> + <Frame x:Name="_welcomeFrame_" + Grid.Row="1" + Visibility="Visible"/> + <Frame x:Name="_messageTextFrame_" + Grid.Row="0" + Visibility="Visible"/> + <Frame x:Name="_videoFrame_" + Grid.Row="0" + Visibility="Visible"/> + </Grid> + </SplitView.Content> </SplitView> </SplitView.Content> </SplitView> diff --git a/MainPage.xaml.cpp b/MainPage.xaml.cpp index 32f3bbd78299edb79fcb2d69a9c2698055cdf714..d0e1d25b29f5d6ffb7173deb618c9e77fcd05e0b 100644 --- a/MainPage.xaml.cpp +++ b/MainPage.xaml.cpp @@ -17,6 +17,8 @@ **************************************************************************/ #include "pch.h" +#include "ContactsViewModel.h" +#include "MessageTextPage.xaml.h" #include "SmartPanel.xaml.h" #include "RingConsolePanel.xaml.h" #include "VideoPage.xaml.h" @@ -26,6 +28,7 @@ using namespace RingClientUWP; using namespace RingClientUWP::Views; +using namespace RingClientUWP::ViewModel; using namespace Platform; using namespace Windows::ApplicationModel::Core; @@ -54,6 +57,15 @@ MainPage::MainPage() _smartPanel_->Navigate(TypeName(RingClientUWP::Views::SmartPanel::typeid)); _consolePanel_->Navigate(TypeName(RingClientUWP::Views::RingConsolePanel::typeid)); _videoFrame_->Navigate(TypeName(RingClientUWP::Views::VideoPage::typeid)); + _messageTextFrame_->Navigate(TypeName(RingClientUWP::Views::MessageTextPage::typeid)); + + /* connect to delegates */ + ContactsViewModel::instance->newContactSelected += ref new NewContactSelected([&]() { + showFrame(_messageTextFrame_); + }); + ContactsViewModel::instance->noContactSelected += ref new NoContactSelected([&]() { + showFrame(_welcomeFrame_); + }); } void @@ -69,3 +81,20 @@ void RingClientUWP::MainPage::_toggleSmartBoxButton__Click(Platform::Object^ sen { _innerSplitView_->IsPaneOpen = !_innerSplitView_->IsPaneOpen; } + +void +RingClientUWP::MainPage::showFrame(Windows::UI::Xaml::Controls::Frame^ frame) +{ + _navGrid_->SetRow(_welcomeFrame_, 0); + _navGrid_->SetRow(_messageTextFrame_, 0); + _navGrid_->SetRow(_videoFrame_, 0); + + if (frame == _welcomeFrame_) { + _navGrid_->SetRow(_welcomeFrame_, 1); + } else if (frame == _videoFrame_) { + _navGrid_->SetRow(_videoFrame_, 1); + } else if (frame == _messageTextFrame_) { + _navGrid_->SetRow(_messageTextFrame_, 1); + dynamic_cast<MessageTextPage^>(_messageTextFrame_->Content)->updatePageContent(); + } +} diff --git a/MainPage.xaml.h b/MainPage.xaml.h index 868add8f38d8df6aa19306e426fb4c32a1da56e4..e2a9e0fd2954ee1709cce1564c49f38fe44870ba 100644 --- a/MainPage.xaml.h +++ b/MainPage.xaml.h @@ -18,6 +18,7 @@ **************************************************************************/ #include "MainPage.g.h" +using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Input; namespace RingClientUWP @@ -33,5 +34,6 @@ protected: virtual void OnKeyDown(KeyRoutedEventArgs^ e) override; private: void _toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void showFrame(Windows::UI::Xaml::Controls::Frame^ frame); }; } \ No newline at end of file diff --git a/MessageTextPage.xaml b/MessageTextPage.xaml new file mode 100644 index 0000000000000000000000000000000000000000..b505878bf3628667da3aa612cdc660073b67273d --- /dev/null +++ b/MessageTextPage.xaml @@ -0,0 +1,147 @@ +<Page + x:Class="RingClientUWP.Views.MessageTextPage" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="using:RingClientUWP" + xmlns:ctl="using:RingClientUWP.Controls" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="d"> + + <Page.Resources> + <!--<DataTemplate x:Key="MessageTemplate" x:DataType="local:RingInstantMessage"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="70" /> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + <Image x:Name="_contactAvatar_" + Margin="2,2" + Source="ms-appx:///contact-avatar-test.png" + VerticalAlignment="Center" HorizontalAlignment="Center"/> + <TextBlock x:Name="_msgContent_" Text="{x:Bind msg_}"/> + </Grid> + </DataTemplate>--> + + + <!-- barre d'envoi de message --> + <Style TargetType="TextBox"> + <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" /> + <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" /> + <Setter Property="Foreground" Value="Black" /> + <Setter Property="Background" Value="white" /> + <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" /> + <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" /> + <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" /> + <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" /> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" /> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" /> + <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" /> + <Setter Property="Padding" Value="4,4"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="TextBox"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="Auto" /> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + </Grid.RowDefinitions> + <Border x:Name="BackgroundElement" + Grid.Row="1" + Background="{TemplateBinding Background}" + Margin="{TemplateBinding BorderThickness}" + Opacity="1" + Grid.ColumnSpan="2" + BorderBrush="LightBlue" + BorderThickness="1" + Grid.RowSpan="1"/> + <ScrollViewer x:Name="ContentElement" + Grid.Row="1" + HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" + HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" + VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" + VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" + IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" + IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" + IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" + Margin="{TemplateBinding BorderThickness}" + Padding="{TemplateBinding Padding}" + IsTabStop="False" + AutomationProperties.AccessibilityView="Raw" + ZoomMode="Disabled" /> + + <Button x:Name="_sendBtn_" + Background="Transparent" + Grid.Row="1" + FontFamily="Segoe MDL2 Assets" + Foreground="LightBlue" + Content="" + IsTabStop="False" + Grid.Column="1" + Click="_sendBtn__Click" + Visibility="Visible" + MinWidth="34" + FontSize="20" + VerticalAlignment="Stretch"/> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </Page.Resources> + + <Grid Background="White"> + <Grid.RowDefinitions> + <RowDefinition Height="auto" /> + <RowDefinition Height="*"/> + <RowDefinition Height="auto" /> + </Grid.RowDefinitions> + <StackPanel Grid.Row="0" + Background="White" + Height="70" + Orientation="Horizontal" + Padding="10,10"> + <Image Source="ms-appx:///contact-avatar-test.png" /> + <StackPanel> + <TextBlock x:Name="_title_" + Text="[TEXT MISSING]" + TextWrapping="NoWrap" + VerticalAlignment="Center" + FontSize="20" + Margin="20,0" /> + </StackPanel> + + </StackPanel> + <ScrollViewer BorderThickness="0,1,0,1" + BorderBrush="LightBlue" + Grid.Row="1"> + <StackPanel x:Name="_messagesWindowOutput_" + Background="#FFF2F2F2"> + + </StackPanel> + </ScrollViewer> + <Grid Height="50" + Grid.Row="2" + Margin="0" + Padding="0" + Background="#FFF2F2F2"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="30" /> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="30" /> + </Grid.ColumnDefinitions> + <TextBox x:Name="_messageTextBox_" + Grid.Column="1" + HorizontalAlignment="Stretch" + TextWrapping="NoWrap" + VerticalAlignment="Center" + Margin="10" + Background="White" + KeyDown="_messageTextBox__KeyDown"/> + </Grid> + </Grid> +</Page> diff --git a/MessageTextPage.xaml.cpp b/MessageTextPage.xaml.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c32650428d22bd1b97ac0d7ba2f24354a1ba63fb --- /dev/null +++ b/MessageTextPage.xaml.cpp @@ -0,0 +1,89 @@ +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +**************************************************************************/ +#include "pch.h" + +#include "ContactsViewModel.h" +#include "MainPage.xaml.h" + +#include "MessageTextPage.xaml.h" + +using namespace RingClientUWP::Views; +using namespace RingClientUWP::ViewModel; + +using namespace Platform; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Documents; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +MessageTextPage::MessageTextPage() +{ + InitializeComponent(); +} + +void +RingClientUWP::Views::MessageTextPage::OnNavigatedTo(NavigationEventArgs ^ e) +{ + updatePageContent(); +} + +void +RingClientUWP::Views::MessageTextPage::updatePageContent() +{ + auto contact = ContactsViewModel::instance->selectedContact; + if (!contact) + return; + + _title_->Text = contact->name_; + + _messagesWindowOutput_->Children->Clear(); +} + +void +RingClientUWP::Views::MessageTextPage::_sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + sendMessage(); +} + +void +RingClientUWP::Views::MessageTextPage::_messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) +{ + if (e->Key == Windows::System::VirtualKey::Enter) { + sendMessage(); + } +} + +void +RingClientUWP::Views::MessageTextPage::sendMessage() +{ + auto contact = ContactsViewModel::instance->selectedContact; + auto txt = _messageTextBox_->Text; + + /* empty the textbox */ + _messageTextBox_->Text = ""; + + if (!contact || txt->IsEmpty()) + return; + +} diff --git a/MessageTextPage.xaml.h b/MessageTextPage.xaml.h new file mode 100644 index 0000000000000000000000000000000000000000..ac87884bd20426ec7f15599aef87cd6a75622d1b --- /dev/null +++ b/MessageTextPage.xaml.h @@ -0,0 +1,41 @@ +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +**************************************************************************/ +#pragma once + +#include "MessageTextPage.g.h" + +namespace RingClientUWP +{ +namespace Views +{ +public ref class MessageTextPage sealed +{ +public: + MessageTextPage(); + void updatePageContent(); + +protected: + virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; + +private: + void _sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void _messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); + void sendMessage(); +}; +} +} diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 780d6a559109f35797186cc201629661cc3cae72..810edb5b9938678161048879dc5fc12c8c2b87cf 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -333,18 +333,19 @@ <RowDefinition Height="*"/> </Grid.RowDefinitions> <TextBox x:Name="_ringTxtBx_" - HorizontalAlignment="Center" + HorizontalAlignment="Center" VerticalAlignment="Center" Width="320" - TextWrapping="Wrap" + TextWrapping="Wrap" Style="{StaticResource TextBoxStyle1}" - Text=""/> + Text=""/> <ListBox x:Name="_smartList_" Grid.Row="1" Margin="0" Padding="0" - ScrollViewer.HorizontalScrollBarVisibility="Auto" - ScrollViewer.HorizontalScrollMode="Enabled" + SelectionChanged="_smartList__SelectionChanged" + ScrollViewer.HorizontalScrollBarVisibility="Auto" + ScrollViewer.HorizontalScrollMode="Enabled" ItemContainerStyle="{StaticResource contactsListBoxStyle}" ItemTemplate="{StaticResource ContactTemplate}"/> </Grid> diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 42c8415032b28ef6e0341d8b43cef33cab6db717..f2614f3a62e7e551ce4f8a4702d8c92411d3857d 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -1,4 +1,4 @@ -/************************************************************************** +/*************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> * * * @@ -146,3 +146,12 @@ void RingClientUWP::Views::SmartPanel::_avatarWebcamCaptureBtn__Click(Platform:: }); } + + +void +SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e) +{ + auto listbox = safe_cast<ListBox^>(sender); + auto contact = safe_cast<Contact^>(listbox->SelectedItem); + ContactsViewModel::instance->selectedContact = contact; +} diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h index 2ef2cc68e9c3c69b848141a321d6157c7ef7ab83..168f3407683419ac91ea40440448bad81a040278 100644 --- a/SmartPanel.xaml.h +++ b/SmartPanel.xaml.h @@ -50,6 +50,7 @@ private: void _createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); 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); }; } } \ No newline at end of file diff --git a/ring-client-uwp.vcxproj b/ring-client-uwp.vcxproj index 1b76f4f5f1e6e67f659500f38e6364532ac444af..ec7a626a65bfa02e2129c5b4b64f870157d9e8ab 100644 --- a/ring-client-uwp.vcxproj +++ b/ring-client-uwp.vcxproj @@ -162,6 +162,9 @@ <ClInclude Include="AccountsViewModel.h" /> <ClInclude Include="Contact.h" /> <ClInclude Include="ContactsViewModel.h" /> + <ClInclude Include="MessageTextPage.xaml.h"> + <DependentUpon>MessageTextPage.xaml</DependentUpon> + </ClInclude> <ClInclude Include="pch.h" /> <ClInclude Include="App.xaml.h"> <DependentUpon>App.xaml</DependentUpon> @@ -175,6 +178,9 @@ <ClInclude Include="SmartPanel.xaml.h"> <DependentUpon>SmartPanel.xaml</DependentUpon> </ClInclude> + <ClInclude Include="VideoPage.xaml.h"> + <DependentUpon>VideoPage.xaml</DependentUpon> + </ClInclude> <ClInclude Include="WelcomePage.xaml.h"> <DependentUpon>WelcomePage.xaml</DependentUpon> </ClInclude> @@ -186,9 +192,11 @@ <Page Include="MainPage.xaml"> <SubType>Designer</SubType> </Page> + <Page Include="MessageTextPage.xaml" /> <Page Include="RingConsolePanel.xaml" /> <Page Include="SmartPanel.xaml" /> <Page Include="Styles.xaml" /> + <Page Include="VideoPage.xaml" /> <Page Include="WelcomePage.xaml" /> </ItemGroup> <ItemGroup> @@ -241,6 +249,9 @@ <ClCompile Include="MainPage.xaml.cpp"> <DependentUpon>MainPage.xaml</DependentUpon> </ClCompile> + <ClCompile Include="MessageTextPage.xaml.cpp"> + <DependentUpon>MessageTextPage.xaml</DependentUpon> + </ClCompile> <ClCompile Include="pch.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> @@ -255,6 +266,9 @@ <ClCompile Include="SmartPanel.xaml.cpp"> <DependentUpon>SmartPanel.xaml</DependentUpon> </ClCompile> + <ClCompile Include="VideoPage.xaml.cpp"> + <DependentUpon>VideoPage.xaml</DependentUpon> + </ClCompile> <ClCompile Include="WelcomePage.xaml.cpp"> <DependentUpon>WelcomePage.xaml</DependentUpon> </ClCompile> diff --git a/ring-client-uwp.vcxproj.filters b/ring-client-uwp.vcxproj.filters index 88b0355f5583dbe17400d21bae8f321d1c2b8999..4b8a43392b6b23ca955c1a763f97532165f209a5 100644 --- a/ring-client-uwp.vcxproj.filters +++ b/ring-client-uwp.vcxproj.filters @@ -152,6 +152,9 @@ <Page Include="VideoPage.xaml"> <Filter>Views</Filter> </Page> + <Page Include="MessageTextPage.xaml"> + <Filter>Views</Filter> + </Page> </ItemGroup> <ItemGroup> <PRIResource Include="localization\US-en\Resources.resw">