#pragma once
#include <Windows.h>

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Collections::Generic;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Text;
using namespace System::Globalization;
using namespace System::Runtime::InteropServices;

#include "CustomRichTextBoxType.h"
#pragma comment(lib,"User32.lib")

namespace ObjDataEdit
{
	namespace CustomRichTextBox
	{        
#pragma region class CustomRichTextBox
		/// <summary>
		/// Summary for CustomRichTextBoxControl
		/// </summary>
		///
		/// WARNING: If you change the name of this class, you will need to change the
		///          'Resource File Name' property for the managed resource compiler tool
		///          associated with all .resx files this class depends on.  Otherwise,
		///          the designers will not be able to interact properly with localized
		///          resources associated with this form.
		public __gc class CustomRichTextBox : public System::Windows::Forms::RichTextBox
		{
		private:
			CMirrorRichTextBox* mMirror;	
			bool mParsing;
			bool mStartComposition;
			bool mImeEndStart;
			bool mImeUpdated;

		public:
			static const int EM_GETSCROLLPOS  = (WM_USER + 221);
			static const int EM_SETSCROLLPOS  = (WM_USER + 222);

		protected:
			System::Data::SqlClient::SqlCommand*  sqlCommand_Base;
			System::Data::SqlClient::SqlConnection*  sqlConnection_Base;

		public:
			CustomRichTextBox(void);

		protected:
			~CustomRichTextBox(){};

#pragma region Property
		public:
			__property String* get_Text(){ return mMirror->Text; }
			__property void set_Text(String* val)
			{
				mMirror->Text = val;
				mMirror->TransletText();
				Rtf = mMirror->TranslatedText;
				SelectionStart = Text->Length;
			}
#pragma endregion

#pragma region Member function
		private:
			void MirrorWndProc(Message* m);
			void TextChange(EventArgs* e);
		public:
			void KeyWord( const char* pszKeyWord, char* pszSourceText, int& iType );
#pragma endregion 


#pragma region Overriden methods
		protected:
			void WndProc(Message* m);
			void OnVScroll(EventArgs* e);
			void OnTextChanged(EventArgs* e);

#pragma endregion

#pragma region Scrollbar positions functions
		private:
			POINT* GetScrollPos();
			void SetScrollPos(POINT* point);
#pragma endregion
		private: System::Void InitializeComponent(){
					 this->sqlCommand_Base = (new System::Data::SqlClient::SqlCommand());
					 this->sqlConnection_Base = (new System::Data::SqlClient::SqlConnection());
					 this->SuspendLayout();
					 // 
					 // sqlCommand_Base
					 // 
					 this->sqlCommand_Base->Connection = this->sqlConnection_Base;
					 // 
					 // sqlConnection_Base
					 // 
					 this->sqlConnection_Base->FireInfoMessageEventOnUserErrors = false;
					 this->ResumeLayout(false);

				 }
		};
#pragma endregion 

	}
}
