MCPcopy Create free account
hub / github.com/M2Team/NanaBox / LaunchVirtualMachineButtonClick

Method LaunchVirtualMachineButtonClick

NanaBox/QuickStartPage.cpp:64–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 }
63
64 void QuickStartPage::LaunchVirtualMachineButtonClick(
65 winrt::IInspectable const& sender,
66 winrt::RoutedEventArgs const& e)
67 {
68 UNREFERENCED_PARAMETER(sender);
69 UNREFERENCED_PARAMETER(e);
70
71 winrt::handle(Mile::CreateThread([=]()
72 {
73 try
74 {
75 if (!this->m_ConfigurationFilePath)
76 {
77 return;
78 }
79
80 winrt::com_ptr<IFileDialog> FileDialog =
81 winrt::create_instance<IFileDialog>(CLSID_FileOpenDialog);
82
83 DWORD Flags = 0;
84 winrt::check_hresult(FileDialog->GetOptions(&Flags));
85 Flags |= FOS_FORCEFILESYSTEM;
86 Flags |= FOS_NOCHANGEDIR;
87 Flags |= FOS_DONTADDTORECENT;
88 winrt::check_hresult(FileDialog->SetOptions(Flags));
89
90 std::wstring FileTypeName = Mile::FormatWideString(
91 L"%s (*.7b)",
92 Mile::WinRT::GetLocalizedString(
93 L"QuickStartPage/ConfigurationFileTypeName",
94 L"[NanaBox Virtual Machine Configuration]").c_str());
95
96 COMDLG_FILTERSPEC SupportedFileTypes[] =
97 {
98 {
99 FileTypeName.c_str(),
100 L"*.7b"
101 }
102 };
103 winrt::check_hresult(FileDialog->SetFileTypes(
104 ARRAYSIZE(SupportedFileTypes),
105 SupportedFileTypes));
106
107 winrt::check_hresult(FileDialog->Show(this->m_WindowHandle));
108
109 *this->m_ConfigurationFilePath = ::GetFileSystemPathFromFileDialog(
110 FileDialog.get());
111 if (!this->m_ConfigurationFilePath->empty())
112 {
113 ::PostMessageW(this->m_WindowHandle, WM_CLOSE, 0, 0);
114 }
115 }
116 catch (...)
117 {
118
119 }
120 }));
121 }

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected