#pragma once

#include "../Common/Resource.h"


// IDS Ensenso grabber parameters dialog
class PhotoneoParamDialog : public CDialog
{
public:
  PhotoneoParamDialog(std::string q, int res, int shutter, int scan): 
  CDialog(IDD_PHOTONEO_PARAMETERS), quality(q), resolution(res), shutterM(shutter), scanM(scan)
  {}

protected:
  DECLARE_MESSAGE_MAP()

  virtual void DoDataExchange(CDataExchange* pDX)
  {
    CDialog::DoDataExchange(pDX);

    DDX_Control(pDX, IDC_COMBO_PHOTONEO_QUALITY, quality_ctrl);
    DDX_Control(pDX, IDC_COMBO_PHOTONEO_RESOLUTION, resolution_ctrl);

    DDX_Control(pDX, IDC_EDIT_PHOTONEO_SHUTTER, shutter_ctrl);
    DDX_Control(pDX, IDC_EDIT_PHOTONEO_SCAN, scan_ctrl);
  }

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

    shutter_ctrl.SetWindowText(std::to_wstring(shutterM).c_str());
    scan_ctrl.SetWindowText(std::to_wstring(scanM).c_str());

    quality_ctrl.AddString(_T("Fast"));
    quality_ctrl.AddString(_T("High"));
    quality_ctrl.AddString(_T("Ultra"));

    if (quality == "Fast")
      quality_ctrl.SetCurSel(0);
    else if (quality == "High")
      quality_ctrl.SetCurSel(1);
    else
      quality_ctrl.SetCurSel(2);

    resolution_ctrl.AddString(_T("2064x1544"));
    resolution_ctrl.AddString(_T("1032x772"));
    resolution_ctrl.SetCurSel(1-resolution);

    return TRUE;
  }

  void OnOK()
  {
    CString str = _T("");

    shutter_ctrl.GetWindowTextW(str);
    shutterM = _wtoi(str);

    scan_ctrl.GetWindowTextW(str);
    scanM = _wtoi(str);

    quality_ctrl.GetWindowTextW(str);
    std::wstring ws(str);
    quality = std::string(ws.begin(), ws.end());

    resolution = 1 - resolution_ctrl.GetCurSel();

    CDialog::EndDialog(1);
  }

  // edit controls
  CEdit shutter_ctrl, scan_ctrl;
  CComboBox quality_ctrl, resolution_ctrl;

public:
  std::string quality;
  int resolution, shutterM, scanM;
};

BEGIN_MESSAGE_MAP(PhotoneoParamDialog, CDialog)
END_MESSAGE_MAP()

