#include "Stdafx.h"
#include "UserInterface.h"

namespace Domination {
	namespace Unmanaged {
		namespace OpenCV 
		{		
			void UserInterface::imshow(const System::String^ winname, Mat^ mat)
			{
				cv::Mat lmat = *mat->ref;

				System::IntPtr p = Marshal::StringToHGlobalAnsi(const_cast<System::String^>(winname));
				char *pNewCharStr = static_cast<char*>(p.ToPointer());
				cv::imshow(pNewCharStr, lmat);
				Marshal::FreeHGlobal(p);
			}

			void UserInterface::namedWindow(const System::String^ winname, WindowProperties flags)
			{
				System::IntPtr p = Marshal::StringToHGlobalAnsi(const_cast<System::String^>(winname));
				char *pNewCharStr = static_cast<char*>(p.ToPointer());
				cv::namedWindow(pNewCharStr, (int)flags);
				Marshal::FreeHGlobal(p);
			}

			void UserInterface::destroyWindow(const System::String^ winname)
			{
				System::IntPtr p = Marshal::StringToHGlobalAnsi(const_cast<System::String^>(winname));
				char *pNewCharStr = static_cast<char*>(p.ToPointer());
				cv::destroyWindow(pNewCharStr);
				Marshal::FreeHGlobal(p);
			}

			void UserInterface::destroyAllWindows()
			{
				cv::destroyAllWindows();
			}

			int UserInterface::waitKey(int delay)
			{
				return cv::waitKey(delay);
			}
		}
	}
}