blob: d34a52a4ee15053c9216b14387c7e653e309bb98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include "pch.h"
#include "ChatView.xaml.h"
#include "MainPage.xaml.h"
#include <string>
using namespace chat;
using namespace std;
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::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
ChatView::ChatView()
{
InitializeComponent();
MainPage::instance()->_chatView = this;
}
void
ChatView::setError(String^ err)
{
appendMessage(L"<system-message> " + err);
}
void
ChatView::appendMessage(String^ message)
{
messages->Text += message + L"\n";
messages->UpdateLayout();
Scroller->ScrollToVerticalOffset(Scroller->ScrollableHeight);
}
void chat::ChatView::inputKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if(e->Key == Windows::System::VirtualKey::Enter && !input->Text->IsEmpty())
{
string msg = IceUtil::wstringToString(input->Text->Data());
input->Text = "";
MainPage::instance()->coordinator()->say(msg);
}
}
|