2015-08-06 14:24:47 +00:00
|
|
|
|
//
|
|
|
|
|
|
// SelectFilesPane.xaml.cpp
|
|
|
|
|
|
// Implementation of the SelectFilesPane class
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
|
|
#include "SelectFilesPane.xaml.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace VBA10;
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Platform;
|
|
|
|
|
|
using namespace Platform::Collections;
|
|
|
|
|
|
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;
|
|
|
|
|
|
using namespace Windows::Storage;
|
2015-08-19 17:01:35 +00:00
|
|
|
|
using namespace Windows::UI::Popups;
|
2015-09-25 21:45:30 +00:00
|
|
|
|
using namespace Windows::ApplicationModel::Resources;
|
2015-08-06 14:24:47 +00:00
|
|
|
|
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
|
|
|
|
|
|
|
|
SelectFilesPane::SelectFilesPane(IVector<Platform::String^>^ list, Platform::String^ title) :initdone(false)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
this->txtTitle->Text = title;
|
|
|
|
|
|
|
|
|
|
|
|
this->FileListvs->Source = list;
|
|
|
|
|
|
this->fileList->SelectedItem = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
if (list->Size > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this->fileList->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
|
|
|
|
|
this->txtNoFile->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this->fileList->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
|
|
|
|
|
this->txtNoFile->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
2015-10-06 04:54:26 +00:00
|
|
|
|
this->txtNoFile->Text = ResourceLoader::GetForViewIndependentUse()->GetString("NoSupportedFileText");
|
2015-08-06 14:24:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
initdone = true;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-08-19 17:01:35 +00:00
|
|
|
|
void SelectFilesPane::CancelBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
//close the pane
|
|
|
|
|
|
auto dp = this->Parent;
|
|
|
|
|
|
Popup^ pop = (Popup^)dp;
|
|
|
|
|
|
pop->IsOpen = false;
|
|
|
|
|
|
}
|
2015-08-06 14:24:47 +00:00
|
|
|
|
|
|
|
|
|
|
void SelectFilesPane::OkBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
2015-08-19 17:01:35 +00:00
|
|
|
|
if (this->fileList->SelectedItems->Size == 0)
|
|
|
|
|
|
{
|
2015-10-06 04:54:26 +00:00
|
|
|
|
MessageDialog ^dialog = ref new MessageDialog(ResourceLoader::GetForViewIndependentUse()->GetString("NoFileSelectedText"));
|
2015-08-19 17:01:35 +00:00
|
|
|
|
dialog->ShowAsync();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-08-08 03:13:27 +00:00
|
|
|
|
this->fileList->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
|
|
|
|
|
this->txtNoFile->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
|
|
|
|
|
this->OkBtn->IsEnabled = false;
|
2015-10-06 04:54:26 +00:00
|
|
|
|
this->txtNoFile->Text = ResourceLoader::GetForViewIndependentUse()->GetString("ProcessingText");
|
2015-08-08 03:13:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
2015-08-08 02:00:51 +00:00
|
|
|
|
Vector<int>^ selectedIndices = ref new Vector<int> ();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < this->fileList->SelectedItems->Size; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
String^ selectedName = (String^)this->fileList->SelectedItems->GetAt(i);
|
|
|
|
|
|
//find the index of this item
|
|
|
|
|
|
for (int j = 0; j < this->fileList->Items->Size; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
String^ name = (String^)this->fileList->Items->GetAt(j);
|
|
|
|
|
|
if (selectedName == name)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedIndices->Append(j);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-19 17:01:35 +00:00
|
|
|
|
|
2015-08-08 02:00:51 +00:00
|
|
|
|
|
|
|
|
|
|
//return the file to whatever windows that call it
|
|
|
|
|
|
if (this->FilesSelectedCallback)
|
|
|
|
|
|
FilesSelectedCallback(selectedIndices);
|
2015-08-06 14:24:47 +00:00
|
|
|
|
}
|
2015-08-08 03:59:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|