blob: aa7c13d6656e59907481f73523fcec952634dcc0 [file] [log] [blame]
Nicolas Jager998fbd72016-08-08 11:41:28 -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
Nicolas Jager8a85e1f2016-08-15 15:11:06 -040020#include "ContactsViewModel.h"
21#include "MessageTextPage.xaml.h"
Nicolas Jager998fbd72016-08-08 11:41:28 -040022#include "SmartPanel.xaml.h"
23#include "RingConsolePanel.xaml.h"
Nicolas Jagere069c412016-08-15 15:00:17 -040024#include "VideoPage.xaml.h"
Nicolas Jager998fbd72016-08-08 11:41:28 -040025#include "WelcomePage.xaml.h"
26
27#include "MainPage.xaml.h"
28
29using namespace RingClientUWP;
30using namespace RingClientUWP::Views;
Nicolas Jager8a85e1f2016-08-15 15:11:06 -040031using namespace RingClientUWP::ViewModel;
Nicolas Jager998fbd72016-08-08 11:41:28 -040032
33using namespace Platform;
Nicolas Jager15861202016-08-12 11:13:05 -040034using namespace Windows::ApplicationModel::Core;
Nicolas Jager998fbd72016-08-08 11:41:28 -040035using namespace Windows::Foundation;
36using namespace Windows::Foundation::Collections;
37using namespace Windows::UI::ViewManagement;
38using namespace Windows::UI::Xaml;
39using namespace Windows::UI::Xaml::Controls;
40using namespace Windows::UI::Xaml::Controls::Primitives;
41using namespace Windows::UI::Core;
42using namespace Windows::UI::Xaml::Data;
43using namespace Windows::UI::Xaml::Input;
44using namespace Windows::UI::Xaml::Interop;
Nicolas Jager998fbd72016-08-08 11:41:28 -040045using namespace Windows::UI::Xaml::Navigation;
46using namespace Windows::ApplicationModel::Activation;
47using namespace Windows::Graphics::Display;
48using namespace Windows::System;
49
50MainPage::MainPage()
51{
52 InitializeComponent();
53
Nicolas Jager15861202016-08-12 11:13:05 -040054 Window::Current->SetTitleBar(_titleBar_);
55
Nicolas Jager998fbd72016-08-08 11:41:28 -040056 _welcomeFrame_->Navigate(TypeName(RingClientUWP::Views::WelcomePage::typeid));
57 _smartPanel_->Navigate(TypeName(RingClientUWP::Views::SmartPanel::typeid));
58 _consolePanel_->Navigate(TypeName(RingClientUWP::Views::RingConsolePanel::typeid));
Nicolas Jagere069c412016-08-15 15:00:17 -040059 _videoFrame_->Navigate(TypeName(RingClientUWP::Views::VideoPage::typeid));
Nicolas Jager8a85e1f2016-08-15 15:11:06 -040060 _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 Jager998fbd72016-08-08 11:41:28 -040069}
70
71void
72MainPage::OnKeyDown(KeyRoutedEventArgs^ e)
73{
74 if (e->Key == VirtualKey::F5) {
75 _outerSplitView_->OpenPaneLength = Window::Current->Bounds.Width;
76 _outerSplitView_->IsPaneOpen = !_outerSplitView_->IsPaneOpen;
77 }
Nicolas Jager15861202016-08-12 11:13:05 -040078}
79
80void RingClientUWP::MainPage::_toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
81{
82 _innerSplitView_->IsPaneOpen = !_innerSplitView_->IsPaneOpen;
83}
Nicolas Jager8a85e1f2016-08-15 15:11:06 -040084
85void
86RingClientUWP::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}
atraczyk61b28422016-08-24 09:25:59 -0400101
102void
103RingClientUWP::MainPage::OnNavigatedTo(NavigationEventArgs ^ e)
104{
105 RingD::instance->startDaemon();
106}