#pragma once

// AT grabber parameters dialog
class AzureKinectParamDialog : public CDialog
{
public:
  AzureKinectParamDialog(k4a_depth_mode_t d, k4a_fps_t f) : CDialog(IDD_AZUREKINECT_PARAMETERS),
    depth_mode(d), frame_rate(f)
  {}

protected:
  DECLARE_MESSAGE_MAP()

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

    CString depth_mode_string;
    switch (depth_mode)
    {
    case K4A_DEPTH_MODE_NFOV_2X2BINNED: depth_mode_string = "NFOV 2X2 BINNED"; break;
    case K4A_DEPTH_MODE_NFOV_UNBINNED: depth_mode_string = "NFOV UNBINNED"; break;
    case K4A_DEPTH_MODE_WFOV_2X2BINNED: depth_mode_string = "WFOV 2X2 BINNED"; break;
    case K4A_DEPTH_MODE_WFOV_UNBINNED: depth_mode_string = "WFOV UNBINNED"; break;
    }
    ((CEdit*)GetDlgItem(IDC_DEPTH_MODE))->SetWindowText(depth_mode_string);

    CString frame_rate_string;
    switch (frame_rate)
    {
    case K4A_FRAMES_PER_SECOND_5: frame_rate_string = "5 FPS"; break;
    case K4A_FRAMES_PER_SECOND_15: frame_rate_string = "15 FPS"; break;
    case K4A_FRAMES_PER_SECOND_30: frame_rate_string = "30 FPS"; break;
    }
    ((CEdit*)GetDlgItem(IDC_FRAME_RATE))->SetWindowText(frame_rate_string);

    return TRUE;
  }

  void OnOK()
  {
    CString str;
    ((CEdit*)GetDlgItem(IDC_DEPTH_MODE))->GetWindowText(str);

    if (str == "NFOV 2X2 BINNED")
      depth_mode = K4A_DEPTH_MODE_NFOV_2X2BINNED;
    else if (str == "NFOV UNBINNED")
      depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
    else if (str == "WFOV 2X2 BINNED")
      depth_mode = K4A_DEPTH_MODE_WFOV_2X2BINNED;
    else if (str == "WFOV UNBINNED")
      depth_mode = K4A_DEPTH_MODE_WFOV_UNBINNED;

    ((CEdit*)GetDlgItem(IDC_FRAME_RATE))->GetWindowText(str);

    if (str == "5 FPS")
      frame_rate = K4A_FRAMES_PER_SECOND_5;
    else if (str == "15 FPS")
      frame_rate = K4A_FRAMES_PER_SECOND_15;
    else if (str == "30 FPS")
      frame_rate = K4A_FRAMES_PER_SECOND_30;

    CDialog::EndDialog(1);
  }

public:
  k4a_depth_mode_t depth_mode;
  k4a_fps_t frame_rate;
};

BEGIN_MESSAGE_MAP(AzureKinectParamDialog, CDialog)
END_MESSAGE_MAP()
