-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeView.xaml.cpp
More file actions
90 lines (75 loc) · 1.97 KB
/
CodeView.xaml.cpp
File metadata and controls
90 lines (75 loc) · 1.97 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "pch.h"
#include "CodeView.xaml.h"
#if __has_include("CodeView.g.cpp")
#include "CodeView.g.cpp"
#endif
#include "paragraphcode.hpp"
using namespace winrt;
using namespace Microsoft::UI::Xaml;
using namespace Microsoft::UI::Xaml::Controls;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace winrt::VisualWinUI3::implementation
{
void CodeView::LVC(IInspectable lv, IInspectable)
{
auto li = lv.try_as<SelectorBar>();
if (!li)
return;
auto it = li.SelectedItem().as<SelectorBarItem>();
if (!it)
return;
auto name = it.Name();
if (name == L"si0") _selected_index = 0;
if (name == L"si1") _selected_index = 1;
if (name == L"si2") _selected_index = 2;
if (name == L"si3") _selected_index = 3;
PopulateRB();
}
void CodeView::CopyCode(IInspectable const&, IInspectable const&)
{
std::wstring txt;
if (_selected_index == 0) txt = _t_idl;
if (_selected_index == 1) txt = _t_xaml;
if (_selected_index == 2) txt = _t_h;
if (_selected_index == 3) txt = _t_cpp;
if (txt.empty())
return;
void ToClip(HWND MainWindow, const wchar_t* t, bool Empty);
ToClip(0, txt.c_str(), true);
}
void CodeView::PopulateRB()
{
auto top = Content().as<Panel>();
auto rtb = top.FindName(L"rtb").as<RichTextBlock>();
rtb.Blocks().Clear();
if (_selected_index == 0)
{
// Plain IDL
auto p1 = PreParagraph(_t_idl.c_str());
for(auto& pp : p1)
rtb.Blocks().Append(pp);
}
if (_selected_index == 1)
{
// Plain XAML
auto p1 = PreParagraph(_t_xaml.c_str());
for (auto& pp : p1)
rtb.Blocks().Append(pp);
}
if (_selected_index == 2)
{
// Plain H
auto p1 = PreParagraph(_t_h.c_str());
for (auto& pp : p1)
rtb.Blocks().Append(pp);
}
if (_selected_index == 3)
{
// Plain CPP
auto p1 = PreParagraph(_t_cpp.c_str());
for (auto& pp : p1)
rtb.Blocks().Append(pp);
}
}
}