#pragma once


namespace SamplePreview {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace SensorTechnology;

	/// <summary>
	/// Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
		}

	protected:
		/// <summary>
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  btnPreview;
	protected: 

	private:
		/// <summary>
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// </summary>
		void InitializeComponent(void)
		{
			this->btnPreview = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// btnPreview
			// 
			this->btnPreview->Location = System::Drawing::Point(13, 13);
			this->btnPreview->Name = L"btnPreview";
			this->btnPreview->Size = System::Drawing::Size(75, 23);
			this->btnPreview->TabIndex = 0;
			this->btnPreview->Text = L"Preview";
			this->btnPreview->UseVisualStyleBackColor = true;
			this->btnPreview->Click += gcnew System::EventHandler(this, &Form1::btnPreview_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 262);
			this->Controls->Add(this->btnPreview);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &Form1::Form1_FormClosed);
			this->ResumeLayout(false);

		}
#pragma endregion
	private: StCam::HANDLE m_hCamera;
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
				m_hCamera = StCam::Open(0);
			 }
	private: System::Void Form1_FormClosed(System::Object^  sender, System::Windows::Forms::FormClosedEventArgs^  e) {
				 if(m_hCamera != IntPtr::Zero) StCam::Close(m_hCamera);
			 }
	private: System::Void btnPreview_Click(System::Object^  sender, System::EventArgs^  e) {
				StCam::CreatePreviewWindow(
					m_hCamera,
					"Preview",
					StCam::WS_OVERLAPPEDWINDOW | StCam::WS_VISIBLE,
					0,0,0,0,System::IntPtr::Zero,System::IntPtr::Zero,
					false);
				StCam::StartTransfer(m_hCamera);
			 }
	};
}

