#pragma once

// LMI grabber parameters dialog
class LMIParamDialog : public CDialog
{
public:
  LMIParamDialog(std::string mode, float e, float f, float x, float m, float xs, float zs, float l) : CDialog(IDD_LMI_PARAMETERS),
    acquisition_mode(mode), exposure_time(e), frequency(f), x_field_of_view(x), measurement_range(m), x_start(xs), z_start(zs), surface_length(l)
  {}

protected:
  DECLARE_MESSAGE_MAP()
  virtual void DoDataExchange(CDataExchange* pDX)
  {
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_ACQUISITION_MODE, acquisition_mode_ctrl);
    DDX_Control(pDX, IDC_EXPOSURETIME, exposure_time_ctrl);
    DDX_Control(pDX, IDC_FREQUENCY, frequency_ctrl);
    DDX_Control(pDX, IDC_X_FIELD_OF_VIEW, x_field_of_view_ctrl);
    DDX_Control(pDX, IDC_MEASUREMENT_RANGE, measurement_range_ctrl);
    DDX_Control(pDX, IDC_X_START, x_start_ctrl);
    DDX_Control(pDX, IDC_Z_START, z_start_ctrl);
    DDX_Control(pDX, IDC_SURFACE_LENGTH, surface_length_ctrl);
  }

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

    acquisition_mode_ctrl.SetWindowText(CString(acquisition_mode.c_str()));
    exposure_time_ctrl.SetWindowText(std::to_wstring(exposure_time).c_str());
    frequency_ctrl.SetWindowText(std::to_wstring(frequency).c_str());
    x_field_of_view_ctrl.SetWindowText(std::to_wstring(x_field_of_view).c_str());
    measurement_range_ctrl.SetWindowText(std::to_wstring(measurement_range).c_str());
    x_start_ctrl.SetWindowText(std::to_wstring(x_start).c_str());
    z_start_ctrl.SetWindowText(std::to_wstring(z_start).c_str());
    surface_length_ctrl.SetWindowText(std::to_wstring(surface_length).c_str());

    return TRUE;
  }

  void OnOK()
  {
    CString str = _T("");
    acquisition_mode_ctrl.GetWindowTextW(str);
    acquisition_mode = CT2CA(str);

    exposure_time_ctrl.GetWindowTextW(str);
    exposure_time = (float)_wtof(str);

    frequency_ctrl.GetWindowTextW(str);
    frequency = (float)_wtof(str);

    x_field_of_view_ctrl.GetWindowTextW(str);
    x_field_of_view = (float)_wtof(str);

    measurement_range_ctrl.GetWindowTextW(str);
    measurement_range = (float)_wtof(str);

    x_start_ctrl.GetWindowTextW(str);
    x_start = (float)_wtof(str);

    z_start_ctrl.GetWindowTextW(str);
    z_start = (float)_wtof(str);

    surface_length_ctrl.GetWindowTextW(str);
    surface_length = (float)_wtof(str);

    CDialog::EndDialog(1);
  }

  // Edit controls
  CEdit acquisition_mode_ctrl;
  CEdit exposure_time_ctrl;
  CEdit frequency_ctrl;
  CEdit x_field_of_view_ctrl;
  CEdit measurement_range_ctrl;
  CEdit x_start_ctrl;
  CEdit z_start_ctrl;
  CEdit surface_length_ctrl;

public:
  std::string acquisition_mode;
  float exposure_time;
  float frequency;
  float x_field_of_view;
  float measurement_range;
  float x_start;
  float z_start;
  float surface_length;
};

BEGIN_MESSAGE_MAP(LMIParamDialog, CDialog)
END_MESSAGE_MAP()
