blob: 70eed4ac71466934852b2901097bfaa575ff94fa [file] [log] [blame]
atraczyke9919eb2016-09-15 15:58:18 -04001/**************************************************************************
2* Copyright (C) 2016 by Savoir-faire Linux *
3* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
4* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
5* *
6* This program is free software; you can redistribute it and/or modify *
7* it under the terms of the GNU General Public License as published by *
8* the Free Software Foundation; either version 3 of the License, or *
9* (at your option) any later version. *
10* *
11* This program is distributed in the hope that it will be useful, *
12* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14* GNU General Public License for more details. *
15* *
16* You should have received a copy of the GNU General Public License *
17* along with this program. If not, see <http://www.gnu.org/licenses/>. *
18**************************************************************************/
Nicolas Jagere069c412016-08-15 15:00:17 -040019#include "pch.h"
20
21#include "VideoPage.xaml.h"
22
23using namespace RingClientUWP::Views;
24
25using namespace Concurrency;
26using namespace Platform;
27using namespace Windows::Devices::Enumeration;
28using namespace Windows::Foundation;
29using namespace Windows::Foundation::Collections;
30using namespace Windows::UI::Xaml;
31using namespace Windows::UI::Xaml::Controls;
32using namespace Windows::UI::Xaml::Controls::Primitives;
33using namespace Windows::UI::Xaml::Data;
34using namespace Windows::UI::Xaml::Input;
35using namespace Windows::UI::Xaml::Media;
36using namespace Windows::UI::Xaml::Navigation;
37using namespace Windows::Media::Capture;
atraczyke9919eb2016-09-15 15:58:18 -040038using namespace Windows::ApplicationModel::Core;
39using namespace Windows::UI::Core;
Nicolas Jagere069c412016-08-15 15:00:17 -040040
41VideoPage::VideoPage()
42{
43 InitializeComponent();
44}
45
atraczyke9919eb2016-09-15 15:58:18 -040046void
47RingClientUWP::Views::VideoPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e)
48{
atraczyk5c395ea2016-09-20 17:28:09 -040049 RingD::instance->incomingAccountMessage += ref new IncomingAccountMessage([&](String^ accountId,
50 String^ from, String^ payload) {
51 scrollDown();
52 });
53
atraczyke9919eb2016-09-15 15:58:18 -040054 updatePageContent();
55}
Nicolas Jagere069c412016-08-15 15:00:17 -040056
atraczyke9919eb2016-09-15 15:58:18 -040057void RingClientUWP::Views::VideoPage::updatePageContent()
58{
59 auto selectedContact = ViewModel::ContactsViewModel::instance->selectedContact;
60 Contact^ contact = selectedContact?
61 ViewModel::SmartPanelItemsViewModel::instance->findItem(selectedContact)->_contact:
62 nullptr;
63 if (!contact)
64 return;
65
66 _callee_->Text = contact->name_;
atraczyk5c395ea2016-09-20 17:28:09 -040067
68 _messagesList_->ItemsSource = contact->_conversation->_messages;
69
70 scrollDown();
71}
72
73void RingClientUWP::Views::VideoPage::scrollDown()
74{
75 _scrollView_->UpdateLayout();
76 _scrollView_->ScrollToVerticalOffset(_scrollView_->ScrollableHeight);
77}
78
79void
80RingClientUWP::Views::VideoPage::_sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
81{
82 sendMessage();
83}
84
85void
86RingClientUWP::Views::VideoPage::_messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
87{
88 if (e->Key == Windows::System::VirtualKey::Enter) {
89 sendMessage();
90 }
91}
92
93void
94RingClientUWP::Views::VideoPage::sendMessage()
95{
96 auto contact = ViewModel::ContactsViewModel::instance->selectedContact;
97 auto txt = _messageTextBox_->Text;
98
99 /* empty the textbox */
100 _messageTextBox_->Text = "";
101
102 if (!contact || txt->IsEmpty())
103 return;
104
105 RingD::instance->sendAccountTextMessage(txt);
106 scrollDown();
atraczyke9919eb2016-09-15 15:58:18 -0400107}
Nicolas Jagere069c412016-08-15 15:00:17 -0400108
109void RingClientUWP::Views::VideoPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
110{
111}
112
113
114void RingClientUWP::Views::VideoPage::_btnCancel__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
115{
116
117}
118
119void RingClientUWP::Views::VideoPage::_btnHangUp__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
120{
atraczyke9919eb2016-09-15 15:58:18 -0400121 Contact^ selectedContact = ViewModel::ContactsViewModel::instance->selectedContact;
122 Call^ call = selectedContact?
123 ViewModel::SmartPanelItemsViewModel::instance->findItem(selectedContact)->_call:
124 nullptr;
125 if (call)
126 RingD::instance->hangUpCall(call);
Nicolas Jagere069c412016-08-15 15:00:17 -0400127 pressHangUpCall();
128}
129
130
131void RingClientUWP::Views::VideoPage::_btnPause__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
132{
133 pauseCall();
134}
135
136
137void RingClientUWP::Views::VideoPage::_btnChat__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
138{
atraczyk5c395ea2016-09-20 17:28:09 -0400139 chatOpen = !chatOpen;
140 if (chatOpen) {
141 _rowChatBx_->Height = 200;
142 chatPanelCall();
143 }
144 else {
145 _rowChatBx_->Height = 0;
146 }
Nicolas Jagere069c412016-08-15 15:00:17 -0400147}
148
149
150void RingClientUWP::Views::VideoPage::_btnAddFriend__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
151{
152 addContactCall();
153}
154
155
156void RingClientUWP::Views::VideoPage::_btnSwitch__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
157{
158 transferCall();
159}
160
161
162void RingClientUWP::Views::VideoPage::_btnMicrophone__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
163{
164 switchMicrophoneStateCall();
165}
166
167
168void RingClientUWP::Views::VideoPage::_btnMemo__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
169{
170 reccordVideoCall();
171}
172
173
174void RingClientUWP::Views::VideoPage::_btnHQ__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
175{
176 qualityVideoLevelCall();
177}
178
179
180void RingClientUWP::Views::VideoPage::_btnVideo__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
181{
182 switchVideoStateCall();
183}
184
185
186void RingClientUWP::Views::VideoPage::_videoControl__PointerMoved(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
187{
188 if (barFading)
189 myStoryboard->Begin();
190 barFading_ = true;
191}
192
193
194void RingClientUWP::Views::VideoPage::btnAny_entered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
195{
196 barFading_ = false;
197 myStoryboard->Stop();
198}
199
200
201void RingClientUWP::Views::VideoPage::btnAny_exited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
202{
203 barFading_ = true;
Nicolas Jagere069c412016-08-15 15:00:17 -0400204}