blob: c32650428d22bd1b97ac0d7ba2f24354a1ba63fb [file] [log] [blame]
Nicolas Jager8a85e1f2016-08-15 15:11:06 -04001/**************************************************************************
2* Copyright (C) 2016 by Savoir-faire Linux *
3* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
4* *
5* This program is free software; you can redistribute it and/or modify *
6* it under the terms of the GNU General Public License as published by *
7* the Free Software Foundation; either version 3 of the License, or *
8* (at your option) any later version. *
9* *
10* This program is distributed in the hope that it will be useful, *
11* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13* GNU General Public License for more details. *
14* *
15* You should have received a copy of the GNU General Public License *
16* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17**************************************************************************/
18#include "pch.h"
19
20#include "ContactsViewModel.h"
21#include "MainPage.xaml.h"
22
23#include "MessageTextPage.xaml.h"
24
25using namespace RingClientUWP::Views;
26using namespace RingClientUWP::ViewModel;
27
28using namespace Platform;
29using namespace Windows::Foundation;
30using namespace Windows::Foundation::Collections;
31using namespace Windows::UI::Xaml;
32using namespace Windows::UI::Xaml::Controls;
33using namespace Windows::UI::Xaml::Controls::Primitives;
34using namespace Windows::UI::Xaml::Data;
35using namespace Windows::UI::Xaml::Documents;
36using namespace Windows::UI::Xaml::Input;
37using namespace Windows::UI::Xaml::Media;
38using namespace Windows::UI::Xaml::Navigation;
39
40MessageTextPage::MessageTextPage()
41{
42 InitializeComponent();
43}
44
45void
46RingClientUWP::Views::MessageTextPage::OnNavigatedTo(NavigationEventArgs ^ e)
47{
48 updatePageContent();
49}
50
51void
52RingClientUWP::Views::MessageTextPage::updatePageContent()
53{
54 auto contact = ContactsViewModel::instance->selectedContact;
55 if (!contact)
56 return;
57
58 _title_->Text = contact->name_;
59
60 _messagesWindowOutput_->Children->Clear();
61}
62
63void
64RingClientUWP::Views::MessageTextPage::_sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
65{
66 sendMessage();
67}
68
69void
70RingClientUWP::Views::MessageTextPage::_messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
71{
72 if (e->Key == Windows::System::VirtualKey::Enter) {
73 sendMessage();
74 }
75}
76
77void
78RingClientUWP::Views::MessageTextPage::sendMessage()
79{
80 auto contact = ContactsViewModel::instance->selectedContact;
81 auto txt = _messageTextBox_->Text;
82
83 /* empty the textbox */
84 _messageTextBox_->Text = "";
85
86 if (!contact || txt->IsEmpty())
87 return;
88
89}