#include "stdafx.h"

#include "xtr/dialog/ImportWSDialog.h"

#include "resource.h"

namespace xtr::dialog {

#pragma warning( push )
#pragma warning( disable : 26440 26436 26454 )

BEGIN_MESSAGE_MAP(ImportWSDialog, CDialog)
  ON_BN_CLICKED(IDOK, &ThisClass::OnBnClickedOk)
END_MESSAGE_MAP()

#pragma warning( pop )

ImportWSDialog::ImportWSDialog(std::vector<CString> wsList, CWnd* pParent)
  : CDialog(IXTRD_WORKSHEET, pParent), m_List(std::move(wsList)) {}

void ImportWSDialog::DoDataExchange(CDataExchange* pDX) {
  CDialog::DoDataExchange(pDX);
  ::DDX_Control(pDX, IXTRC_WSLIST, m_ListControl);
}

BOOL ImportWSDialog::OnInitDialog() {
  CDialog::OnInitDialog();

  m_ListControl.ResetContent();
  for (const auto& label : m_List) {
    m_ListControl.AddString(label);
  }
  return TRUE;
}

void ImportWSDialog::OnBnClickedOk() {
  UpdateData();
  selection = m_ListControl.GetCurSel();
  CDialog::OnOK();
}

} // namespace xtr::dialog