Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 1 | /**************************************************************************
|
| 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 |
|
Nicolas Jager | 8a85e1f | 2016-08-15 15:11:06 -0400 | [diff] [blame] | 20 | #include "ContactsViewModel.h"
|
| 21 | #include "MessageTextPage.xaml.h"
|
Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 22 | #include "SmartPanel.xaml.h"
|
| 23 | #include "RingConsolePanel.xaml.h"
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 24 | #include "VideoPage.xaml.h"
|
Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 25 | #include "WelcomePage.xaml.h"
|
| 26 |
|
| 27 | #include "MainPage.xaml.h"
|
| 28 |
|
| 29 | using namespace RingClientUWP;
|
| 30 | using namespace RingClientUWP::Views;
|
Nicolas Jager | 8a85e1f | 2016-08-15 15:11:06 -0400 | [diff] [blame] | 31 | using namespace RingClientUWP::ViewModel;
|
Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 32 |
|
| 33 | using namespace Platform;
|
Nicolas Jager | 1586120 | 2016-08-12 11:13:05 -0400 | [diff] [blame] | 34 | using namespace Windows::ApplicationModel::Core;
|
Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 35 | using namespace Windows::Foundation;
|
| 36 | using namespace Windows::Foundation::Collections;
|
| 37 | using namespace Windows::UI::ViewManagement;
|
| 38 | using namespace Windows::UI::Xaml;
|
| 39 | using namespace Windows::UI::Xaml::Controls;
|
| 40 | using namespace Windows::UI::Xaml::Controls::Primitives;
|
| 41 | using namespace Windows::UI::Core;
|
| 42 | using namespace Windows::UI::Xaml::Data;
|
| 43 | using namespace Windows::UI::Xaml::Input;
|
| 44 | using namespace Windows::UI::Xaml::Interop;
|
Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 45 | using namespace Windows::UI::Xaml::Navigation;
|
| 46 | using namespace Windows::ApplicationModel::Activation;
|
| 47 | using namespace Windows::Graphics::Display;
|
| 48 | using namespace Windows::System;
|
| 49 |
|
| 50 | MainPage::MainPage()
|
| 51 | {
|
| 52 | InitializeComponent();
|
| 53 |
|
Nicolas Jager | 1586120 | 2016-08-12 11:13:05 -0400 | [diff] [blame] | 54 | Window::Current->SetTitleBar(_titleBar_);
|
| 55 |
|
Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 56 | _welcomeFrame_->Navigate(TypeName(RingClientUWP::Views::WelcomePage::typeid));
|
| 57 | _smartPanel_->Navigate(TypeName(RingClientUWP::Views::SmartPanel::typeid));
|
| 58 | _consolePanel_->Navigate(TypeName(RingClientUWP::Views::RingConsolePanel::typeid));
|
Nicolas Jager | e069c41 | 2016-08-15 15:00:17 -0400 | [diff] [blame] | 59 | _videoFrame_->Navigate(TypeName(RingClientUWP::Views::VideoPage::typeid));
|
Nicolas Jager | 8a85e1f | 2016-08-15 15:11:06 -0400 | [diff] [blame] | 60 | _messageTextFrame_->Navigate(TypeName(RingClientUWP::Views::MessageTextPage::typeid));
|
| 61 |
|
| 62 | /* connect to delegates */
|
| 63 | ContactsViewModel::instance->newContactSelected += ref new NewContactSelected([&]() {
|
| 64 | showFrame(_messageTextFrame_);
|
| 65 | });
|
| 66 | ContactsViewModel::instance->noContactSelected += ref new NoContactSelected([&]() {
|
| 67 | showFrame(_welcomeFrame_);
|
| 68 | });
|
Nicolas Jager | 998fbd7 | 2016-08-08 11:41:28 -0400 | [diff] [blame] | 69 | }
|
| 70 |
|
| 71 | void
|
| 72 | MainPage::OnKeyDown(KeyRoutedEventArgs^ e)
|
| 73 | {
|
| 74 | if (e->Key == VirtualKey::F5) {
|
| 75 | _outerSplitView_->OpenPaneLength = Window::Current->Bounds.Width;
|
| 76 | _outerSplitView_->IsPaneOpen = !_outerSplitView_->IsPaneOpen;
|
| 77 | }
|
Nicolas Jager | 1586120 | 2016-08-12 11:13:05 -0400 | [diff] [blame] | 78 | }
|
| 79 |
|
| 80 | void RingClientUWP::MainPage::_toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
| 81 | {
|
| 82 | _innerSplitView_->IsPaneOpen = !_innerSplitView_->IsPaneOpen;
|
| 83 | }
|
Nicolas Jager | 8a85e1f | 2016-08-15 15:11:06 -0400 | [diff] [blame] | 84 |
|
| 85 | void
|
| 86 | RingClientUWP::MainPage::showFrame(Windows::UI::Xaml::Controls::Frame^ frame)
|
| 87 | {
|
| 88 | _navGrid_->SetRow(_welcomeFrame_, 0);
|
| 89 | _navGrid_->SetRow(_messageTextFrame_, 0);
|
| 90 | _navGrid_->SetRow(_videoFrame_, 0);
|
| 91 |
|
| 92 | if (frame == _welcomeFrame_) {
|
| 93 | _navGrid_->SetRow(_welcomeFrame_, 1);
|
| 94 | } else if (frame == _videoFrame_) {
|
| 95 | _navGrid_->SetRow(_videoFrame_, 1);
|
| 96 | } else if (frame == _messageTextFrame_) {
|
| 97 | _navGrid_->SetRow(_messageTextFrame_, 1);
|
| 98 | dynamic_cast<MessageTextPage^>(_messageTextFrame_->Content)->updatePageContent();
|
| 99 | }
|
| 100 | }
|
atraczyk | 61b2842 | 2016-08-24 09:25:59 -0400 | [diff] [blame] | 101 |
|
| 102 | void
|
| 103 | RingClientUWP::MainPage::OnNavigatedTo(NavigationEventArgs ^ e)
|
| 104 | {
|
| 105 | RingD::instance->startDaemon();
|
| 106 | } |