#include "stdafx.h"
#include "ReaderFrame.h"
#include <exdisp.h>
#include <comdef.h>
#include "BookmarkListUI.h"
#include "DialogCallbackEx.h"
#include "MyPDFBook.h"
#include "UIHeader.h"
#include "SkinBuilder.h"
#include "NoteListUI.h"
#include <winuser.h>
#include "MyReader-DUI-MFC.h"
#include "Toolbar_pop.h"
#include "AppLogger.h"
#include "AppConst.h"
#include "Util.h"
#include "AttachInfo.h"
#include <windef.h>
#include "MainFrm.h"
#include "DuiMainFrame.h"
#include "NoteExchange.h"
#include "PDFNoteInfo.h"
#include "ExportEngine.h"
#include <algorithm>
#include "Function.h"
#include "CloudNoteDao.h"
#include "DuiMessageBox.h"
#include "GlobalUI.h"
#include "PracticeBrowserEventHandler.h"

#include "PreviewLineNoteFrame.h"
#include "PreviewNoteFrame.h"

#include "UIMenu.h"
#include "SearchFrame.h"
#include "PracticeWebBrowser.h"
#include "DrawNotes.h"
#include "HttpClient.h"
#include "BookDir/BookDir.h"
#include "UserInfo.h"       //Add By Ray 2018-05-30
#include "DlgWmplayer.h"
#include "HttpClient.h"
#include "ShareNoteFrame.h"
#include "ShareTeacherNoteFrame.h"
#include "LabelManageFrame.h"
#include "ShareteacherAddFolderFrame.h"
#include "ShareNoteMoveFrame.h"
#include "SearchFrame.h"
#include "AddAttachFileSelectPageFrame.h"
#include "DlgWebBrowser.h"
#include "../curl/CURL_download.h"
#include <regex>
#include <direct.h>
#include "ViewImageFrame.h"
#include "DownLoadFrame.h"

#include "DownFrame.h"

#include "TextNoteFrame.h"
#include "AttachFileNoteFrame.h"

#include "LineNoteEditFrame.h"
#include "md5/md5.h"
#include "URLEncode.h"
#include "Dlg_WebView.h"
#include "WebviewFrame.h"

#define PIECES_SIZE_X 40
#define PIECES_SIZE_Y 40
#define PIECES_NUM 10
#define PIECES_BIANJU 5
#define PAGE_BIAOZHUN_WIDTH 180





//#define CLOSE_CLOUDFRASH_VISIBLE  1

#define  LABEL_ROW_NUM 3
#define  STUDENT_ROW_NUM 5
#define  NOTE_CLOUD   1
#define  NOTE_SHARE    2
#define  MSG_TYPE_YESNO    1
#define  MSG_TYPE_NOTICE   2

struct TouchState {
	bool    panStarted;
	POINTS  panPos;
	SIZE     panScrollOrig;
	double  startArg;
};

TouchState      g_touchState;

int g_isErasing = 0;
long g_cur_note = -1;
int g_noteFlag = 0;

std::vector<double> g_note_pt;
CString g_sel_txt = L"";

//extern DrawLineNotify* g_drawNotify;
DuiLib::CReaderFrame* g_pFrame;
extern TP_NOTES_TYPE g_penNote_state;



CString GetMSOfficePath(CString fileName)
{
	CString office_path = _T("");

	if (_T("")==fileName || fileName.GetLength()<4)
	{
		return office_path;
	}

	fileName = fileName.Right(4).MakeLower();
	CString exe_name = _T("");

	if (_T(".doc")==fileName || _T("docx")==fileName)
	{
		exe_name = _T("winword.exe");
	} 
	else if (_T(".xls")==fileName || _T("xlsx")==fileName)
	{
		exe_name = _T("excel.exe");
	}
	else if (_T(".ppt")==fileName || _T("pptx")==fileName)
	{
		exe_name = _T("powerpnt.exe");
	}

	if (_T("")==exe_name)
	{
		return office_path;
	}

	//looks inside CURRENT_USER:
	CRegKey   key;
	CString RegKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" + exe_name;
	TCHAR   v_name[MAX_PATH];
	DWORD vLen = MAX_PATH;

	int iret = key.Open(HKEY_CURRENT_USER, RegKey);
	if  (iret ==ERROR_SUCCESS)
	{
		ZeroMemory(v_name,MAX_PATH);
		vLen = MAX_PATH;
		if (key.QueryValue(v_name, _T(""), &vLen)==ERROR_SUCCESS)
		{
			office_path = v_name;
		}

		key.Close();
	}

	if (_T("")!=office_path)
	{
		return office_path;
	}

	//if not found, looks inside LOCAL_MACHINE:
	iret = key.Open(HKEY_LOCAL_MACHINE, RegKey);
	if  (iret ==ERROR_SUCCESS)
	{
		ZeroMemory(v_name,MAX_PATH);
		vLen = MAX_PATH;
		if (key.QueryValue(v_name, _T(""), &vLen)==ERROR_SUCCESS)
		{
			office_path = v_name;
		}

		key.Close();
	}

	return office_path;
}
//Add By Ray 2018-07-06

CString GetWPSPath(CString fileName)
{
	CString office_path = _T("");
	if (_T("")==fileName || fileName.GetLength()<4)
	{
		return office_path;
	}

	fileName = fileName.Right(4).MakeLower();
	CString exe_name = _T("");

	if (_T(".doc")==fileName || _T("docx")==fileName)
	{
		exe_name = _T("wps.exe");
	} 
	else if (_T(".xls")==fileName || _T("xlsx")==fileName)
	{
		exe_name = _T("et.exe");
	}
	else if (_T(".ppt")==fileName || _T("pptx")==fileName)
	{
		exe_name = _T("wpp.exe");
	}

	if (_T("")==exe_name)
	{
		return office_path;
	}

	//looks inside CURRENT_USER:
	CRegKey   key;
	CString RegKey = L"SOFTWARE\\Kingsoft\\Office\\6.0\\common ";
	TCHAR   v_name[MAX_PATH];
	DWORD vLen = MAX_PATH;

	int iret = key.Open(HKEY_CURRENT_USER, RegKey);
	if  (iret ==ERROR_SUCCESS)
	{
		ZeroMemory(v_name,MAX_PATH);
		vLen = MAX_PATH;
		if (key.QueryValue(v_name, _T("InstallRoot"), &vLen)==ERROR_SUCCESS)
		{
			office_path.Format(_T("%s\\%s"), v_name, exe_name);
		}

		key.Close();
	}

	if (_T("")!=office_path)
	{
		return office_path;
	}

	//if not found, looks inside LOCAL_MACHINE:
	iret = key.Open(HKEY_LOCAL_MACHINE, RegKey);
	if  (iret ==ERROR_SUCCESS)
	{
		ZeroMemory(v_name,MAX_PATH);
		vLen = MAX_PATH;
		if (key.QueryValue(v_name, _T("InstallRoot"), &vLen)==ERROR_SUCCESS)
		{
			office_path.Format(_T("%s\\%s"), v_name, exe_name);
		}

		key.Close();
	}
	return office_path;
}

CString GetOfficePath(CString fileName)
{
	CString office_path = _T("");

	office_path = GetMSOfficePath(fileName);

	return office_path;
}

void StringSplit(CString source, CStringArray& dest, char division)
{
	if (source.IsEmpty())
	{

	}
	else
	{
		int pos = source.Find(division);
		if (pos == -1)
		{
			dest.Add(source);
		}
		else
		{
			dest.Add(source.Left(pos));
			source = source.Mid(pos + 1);
			StringSplit(source, dest, division);
		}
	}
}
volatile BOOL m_bRun;
volatile BOOL m_bShow;
int StrCoord2Point(CString strPoint, std::vector<double> &Points)
{
	CStringArray str_rects;

	StringSplit(strPoint, str_rects, ';');


	for (int num = 0; num < str_rects.GetSize(); num++)
	{
		CStringArray str_points;
		StringSplit(str_rects[num], str_points, ',');

		for (int i = 0; i < str_points.GetSize(); i++)
		{
			Points.push_back(_ttof(str_points[i]));
		}
	}

	return Points.size();
}

int Point2RectPT(std::vector<double> &Points)
{
	if (Points.size()%4!=0)
	{
		return -1;
	}

	for (int i = 0; i < Points.size(); i+=4)
	{
		Points[i+2]-=Points[i];
		Points[i+3]-=Points[i+1];
	}

	return Points.size();
}

int RectPT2Point(std::vector<double> &Points)
{
	if (Points.size()%4!=0)
	{
		return -1;
	}

	for (int i = 0; i < Points.size(); i+=4)
	{
		Points[i+2]+=Points[i];
		Points[i+3]+=Points[i+1];
	}

	return Points.size();
}

CString FloatStr2Floar(std::string str,float ratio_x,float ratio_y,int size)
{
	float f_temp=atof(str.c_str());
	if(size==0 || size%2==0)
		f_temp*=ratio_x;
	else
		f_temp*=ratio_y;
	CString temp;
	temp.Format(_T("%.2f"),f_temp);
	//f_temp = ( (float)( (int)( (f_temp + 0.005) * 100 ) ) ) / 100;
	return temp;
}
void SplitString2Float(CString sourceStr,float ratio_x,float ratio_y,CString& newStr)
{
	sourceStr.Replace(_T(";"),_T(""));
	std::string temp1=CT2A(sourceStr.GetBuffer());
	std::vector<CString> list;
	int pos=sourceStr.Find(_T(","));
	while(pos>0)
	{
		CString temp=sourceStr.Mid(0,pos);
		int size=list.size();
		std::string temp1=CT2A(temp.GetBuffer());
		temp.ReleaseBuffer();
		CString f_temp=FloatStr2Floar(temp1,ratio_x,ratio_y,size);
		list.push_back(f_temp);
		sourceStr=sourceStr.Mid(pos+1,sourceStr.GetLength()-pos-1);
		pos=sourceStr.Find(_T(","));
		if(pos<0)
		{
			size=list.size();
			std::string temp11=CT2A(sourceStr.GetBuffer());
			CString f1_temp=FloatStr2Floar(temp11,ratio_x,ratio_y,size);
			sourceStr.ReleaseBuffer();
			list.push_back(f1_temp);
		}
	}
	for(int i=0;i<list.size();i++)
	{
		int size = newStr.GetLength();
		if(size>0)
		{
			newStr=newStr+_T(",")+list.at(i);
		}
		else
			newStr=list.at(i);
	}
}


// ������   x,y,x1,y1....;
int Point2Str(std::vector<double> Points, CString &strPoint)
{
	strPoint = L"";
	if (Points.size()%2!=0)
	{
		return -1;
	}

	CString str = L"";

	for (int i = 0; i < Points.size(); i++)
	{
		str.Format(L"%.2f,", Points[i]);

		strPoint+=str;
	}

	strPoint.Delete(strPoint.GetLength()-1);
	strPoint+=L";";
	return 0;
}

// �������� L T R B
int Point2StrCoord(std::vector<double> Points, CString &strPoint)
{
	strPoint = L"";
	if (Points.size()%4!=0)
	{
		return -1;
	}

	CString str = L"";

	for (int i = 0; i < Points.size(); i+=4)
	{
		str.Format(L"%.2f,%.2f,%.2f,%.2f;", Points[i], Points[i+1], Points[i+2], Points[i+3]);

		strPoint+=str;
	}

	return 0;
}

vector<CPDFNoteInfo*>::iterator GetCurNotePos(vector<CPDFNoteInfo*> noteInfoList, int page)
{
	vector<CPDFNoteInfo*>::iterator iter = noteInfoList.begin();
	while (iter != noteInfoList.end()) 
	{
		if ((*iter)->pageIndex==page)
		{
			return iter;
		}

		iter++;
	}

	return noteInfoList.end();
}

RectF GetMaxRect(std::vector<double> &note_pt)
{
	if (note_pt.size()<4)
	{
		return RectF(0,0,0,0);
	}
	double x1=note_pt[0],y1=note_pt[1],x2=note_pt[0],y2=note_pt[1];

	int i = 2;
	while (i < note_pt.size())
	{
		if (x1>note_pt[i]) x1=note_pt[i];
		if (x2<note_pt[i]) x2=note_pt[i];
		if (y1>note_pt[i+1]) y1=note_pt[i+1];
		if (y2<note_pt[i+1]) y2=note_pt[i+1];

		i += 2;
	}

	RectF rt(x1,y1,x2-x1,y2-y1);
	return rt;
}

BOOL rtPosCompare(std::vector<double> &page_pos, std::vector<double> &screen_pos)
{
	if(page_pos.size() ==screen_pos.size())
	{
		for(int i = 0; i < page_pos.size(); i++)
		{
			if(page_pos[i] != screen_pos[i])
				return FALSE;
		}
		return TRUE;
	}
	return FALSE;
}

long GetCurSelNote(std::vector<double> &note_pt, int page)
{
	//Comment By Ray 2018-06-01
	//���ɻ��ʵĵ�ѡ����
	long note_pos=-1;
	for (int num=0;num<g_pFrame->m_pdfNoteInfoList_drawPdf.size();num++)
	{
		CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf.at(num);
		if (info->pageIndex==page)
		{
			std::vector<double> screen_note_pos = info->coord_pt;

			switch (info->pdfNoteType)
			{
			case NoteLine://     =	9,   //	  ���߱ʼǣ�
				{
					if(g_pFrame->m_isShowNotes==false)
					{
						return -1;
					}
					RectPT2Point(screen_note_pos);

					int i = 0;
					while (i < info->coord_pt.size())
					{
						if ( note_pt[0]>=screen_note_pos[i]&&note_pt[0]<=screen_note_pos[i+2] &&
							note_pt[1]>=screen_note_pos[i+1]&&note_pt[1]<=screen_note_pos[i+3])
						{
							//return note_pos;
							//haveNoteLine=true;
							//temp_pos=note_pos;
							note_pos=num;
							return note_pos;

						}

						i += 4;
					}
				}

				break;
			case NoteNone:
			case NoteExercise:
				{
					if(info->noteOrigin==PDFNoteInfoOrigin::ORIGIN_SYSTEM)
					{
						POINT pt = {note_pt.at(0),note_pt.at(1)};
						//std::vector<double> temp_point_list=(*iter)->coord_pt;
						//PDF_Rect2Screen((*iter)->coord_pt, temp_point_list, (*iter)->pageIndex+1);
						RECT temp;
						temp.left=info->coord_pt.at(0)-PIECES_SIZE_X/2;
						temp.top=info->coord_pt.at(1)-PIECES_SIZE_Y/2;
						if(temp.top<0)
							temp.top =0;
						temp.bottom=temp.top+PIECES_SIZE_Y;
						temp.right=temp.left+PIECES_SIZE_X;

						if (PtInRect(&temp, pt))
						{
							 note_pos=num;
							 return note_pos;
						}

					}



				}
				break;
			case NoteFile://         =	11,  //	  �����ļ���	
			case NoteImage:
			case NoteAudio:
			case NoteTextBox:
			case NoteLink:
			case NoteVideo:
			case NoteDoc:
			case NoteExcel:
			case NotePpt:
			case NotePdf:
				{

					POINT pt = {note_pt.at(0),note_pt.at(1)};
					RECT temp;
					temp.left=info->coord_pt.at(0)-PIECES_SIZE_X/2;
					temp.top=info->coord_pt.at(1)-PIECES_SIZE_Y/2;
					temp.bottom=temp.top+PIECES_SIZE_Y;
					temp.right=temp.left+PIECES_SIZE_X;

					if (PtInRect(&temp, pt))
					{
						if(g_pFrame->m_isShowNotes==false)
						{
							return -1;
						}
						note_pos=num;
						return note_pos;
					}
				}break;		
			default:
				break;
			}
		}
	}
	return note_pos;
}

long ShowTooltips(std::vector<double> &note_pt, int page)
{
	vector<CPDFNoteInfo*>::iterator iter = g_pFrame->m_pdfNoteInfoList_drawPdf.begin();
	long note_pos = 0;
	while (iter != g_pFrame->m_pdfNoteInfoList_drawPdf.end()) 
	{
		if ((*iter)->pageIndex==page)
		{

			std::vector<double> screen_note_pos = (*iter)->coord_pt;
			POINT pt = {(long)note_pt[0],(long)note_pt[1]};
			RectPT2Point(screen_note_pos);
			switch ((*iter)->pdfNoteType)
			{
			case NoteLine:
			{
				int index=0;
				int i = 0;
				RECT temp;
				temp.left=temp.right=temp.bottom=temp.top=0;
				while (i < (*iter)->coord_pt.size())
				{
					RECT rc;
					rc.left=screen_note_pos[i];
					rc.top=screen_note_pos[i+1];
					rc.right=screen_note_pos[i+2];
					rc.bottom=screen_note_pos[i+3];
					if(temp.left==0 && temp.top==0)
						temp=rc;
					if(temp.left>rc.left)
						temp.left=rc.left;
					if(temp.top>rc.top)
						temp.top=rc.top;
					if(temp.right<rc.right)
						temp.right=rc.right;
					if(temp.bottom<rc.bottom)
						temp.bottom=rc.bottom;
					i += 4;
				}
				if (PtInRect(&temp, pt))
				{
					::ZeroMemory(&g_pFrame->m_ToolTip, sizeof(TOOLINFO));
					g_pFrame->m_ToolTip.cbSize = sizeof(TOOLINFO);
					g_pFrame->m_ToolTip.uFlags = TTF_IDISHWND;
					g_pFrame->m_ToolTip.hwnd = g_pFrame->m_hMainWnd;
					g_pFrame->m_ToolTip.uId = (UINT_PTR) g_pFrame->m_hMainWnd;
					g_pFrame->m_ToolTip.hinst = g_pFrame->m_pm.GetInstance();
					CString str = (*iter)->GetStringByNoteText();
					//if(str.GetLength() > 30)
					//	str = str.Left(30);
					g_pFrame->m_ToolTip.lpszText = str.GetBuffer();
					//g_pFrame->m_ToolTip.rect = rt;
					if( g_pFrame->m_hwndTooltip == NULL ) {
						g_pFrame->m_hwndTooltip = ::CreateWindowEx(0, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, g_pFrame->m_hMainWnd, NULL, g_pFrame->m_pm.GetInstance(), NULL);
						::SendMessage(g_pFrame->m_hwndTooltip, TTM_ADDTOOL, 0, (LPARAM) &g_pFrame->m_ToolTip);
					}
					::SendMessage(g_pFrame->m_hwndTooltip,TTM_SETMAXTIPWIDTH,0, 300);
					::SendMessage(g_pFrame->m_hwndTooltip, TTM_SETTOOLINFO, 0, (LPARAM) &g_pFrame->m_ToolTip);
					::SendMessage(g_pFrame->m_hwndTooltip, TTM_TRACKACTIVATE, TRUE, (LPARAM) &g_pFrame->m_ToolTip);
					str.ReleaseBuffer();
					return -1;
				}
			}
			break;
			case NoteFile:
			case NoteImage:
			case NoteAudio:
			case NoteVideo:
			case NoteLink:
			case NoteDoc:
			case NoteExcel:
			case NotePpt:
			case NotePdf:
			case NoteTextBox:
				{
					RECT rt;
					rt.left = (int)(screen_note_pos[0])-PIECES_SIZE_X/2;
					rt.top = (int)(screen_note_pos[1])-PIECES_SIZE_Y/2;
					rt.right = rt.left + PIECES_SIZE_X;
					rt.bottom = rt.top + PIECES_SIZE_Y;

					POINT pt = {(long)note_pt[0],(long)note_pt[1]};
					if (PtInRect(&rt, pt))
					{
						::ZeroMemory(&g_pFrame->m_ToolTip, sizeof(TOOLINFO));
						g_pFrame->m_ToolTip.cbSize = sizeof(TOOLINFO);
						g_pFrame->m_ToolTip.uFlags = TTF_IDISHWND;
						g_pFrame->m_ToolTip.hwnd = g_pFrame->m_hMainWnd;
						g_pFrame->m_ToolTip.uId = (UINT_PTR) g_pFrame->m_hMainWnd;
						g_pFrame->m_ToolTip.hinst = g_pFrame->m_pm.GetInstance();
						CString str = (*iter)->GetStringByNoteText();
						//if(str.GetLength() > 30)
						//	str = str.Left(30);
						//Modify By Ray 2018-11-19
						str.Replace(_T("\n*&^"),_T("\r"));
						g_pFrame->m_ToolTip.lpszText = str.GetBuffer();
						//g_pFrame->m_ToolTip.rect = rt;
						if( g_pFrame->m_hwndTooltip == NULL ) {
							g_pFrame->m_hwndTooltip = ::CreateWindowEx(0, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, g_pFrame->m_hMainWnd, NULL, g_pFrame->m_pm.GetInstance(), NULL);
							::SendMessage(g_pFrame->m_hwndTooltip, TTM_ADDTOOL, 0, (LPARAM) &g_pFrame->m_ToolTip);
						}
						::SendMessage(g_pFrame->m_hwndTooltip,TTM_SETMAXTIPWIDTH,0, 300);
						::SendMessage(g_pFrame->m_hwndTooltip, TTM_SETTOOLINFO, 0, (LPARAM) &g_pFrame->m_ToolTip);
						::SendMessage(g_pFrame->m_hwndTooltip, TTM_TRACKACTIVATE, TRUE, (LPARAM) &g_pFrame->m_ToolTip);
						str.ReleaseBuffer();
						return -1;
					}
				}break;		
			default:
				break;
			}
			if(g_pFrame->m_bIsSeeNote)
			{
				////���////////
				theApp.m_EventLog.init();
				theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_STD_DETIAL);
				int nPage =  (*iter)->pageIndex;
				CString strPage;
				strPage.Format(L"%d",nPage);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,(*iter)->strClassId);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_STD_NAME,(*iter)->userName);
				if((*iter)->pdfNoteType==NoteFreedom||(*iter)->pdfNoteType==NoteLine)
				{
					theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
				}else
				{

					theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,(*iter)->coord);
				}
				int nType=0;

				nType =g_pFrame->GetLogNoteType((*iter)->pdfNoteType);
				CString strType;
				strType.Format(L"%d",nType);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,(*iter)->noteText);
				CString strLabeData=L"",strShareID=L"";
				strShareID.Format(L"%lld",(*iter)->ShareID);
			    theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_SERVER_SHAREID,strShareID);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,L"");
				CString strData=(*iter)->content;

				strData.Replace(_T("\\"),_T("\\\\"));
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,strData);
				theApp.m_EventLog.MakeJsonFormat();
				////////////////
			}
		}

		iter++;
		note_pos++;
	}
	return note_pos;
}
struct MY_POINT
{
	int x;
	int y;
};
void SplitString(const std::string& s,std::vector<MY_POINT>& int_list, const std::string& c)
{
	std::vector<std::string> v;
	std::string::size_type pos1, pos2;
	pos2 = s.find(c);
	pos1 = 0;
	while(std::string::npos != pos2)
	{
		v.push_back(s.substr(pos1, pos2-pos1));

		pos1 = pos2 + c.size();
		pos2 = s.find(c, pos1);
	}
	if(pos1 != s.length())
		v.push_back(s.substr(pos1));
	MY_POINT point;
	for(int i=0;i<v.size();i++)
	{
		MY_POINT point;
		std::string temp=v.at(i);
		if(i==0)
		{
			point.x=atoi(temp.c_str());
			
		}
		else
		{
			if(i%2!=1)
			{
				point.x=atoi(temp.c_str());
				
			}
			else
			{
				point.y=atoi(temp.c_str());
				int_list.push_back(point);
			}
		}
	}
}

long ptOnLine(double x,double y,int page)
{
	bool bBrakeFlag=FALSE;
	long ret=-1;
	int xx=(int)x;
	int yy=(int)y;
// 	xx=95;
// 	yy=83;
	int len=g_pFrame->m_pdfNoteInfoList_drawPdf.size();
	for(int i=0;i<len;i++)
	{

		CPDFNoteInfo* info= g_pFrame->m_pdfNoteInfoList_drawPdf.at(i);
		if(page!=(info->pageIndex))
			continue;
		std::string temp;

		temp=CT2A(info->coord.GetBuffer());
		std::vector<std::string> str_list;
		std::vector<MY_POINT> point_list;
		SplitString(temp,point_list,",");
		//SplitString(temp,str_list,";");
		//SplitString2Int(str_list,point_list);
//		CString strpoint=L"";

		for(int j=0;j<point_list.size();j++)
		{
			MY_POINT point=point_list.at(j);
			if((xx<=point.x+15 && xx>=point.x-15) && (yy>=point.y-15 && yy<=point.y+15))
			{
				ret=i/*info->id*/;
				bBrakeFlag =TRUE;
				if(g_pFrame->m_bEraseMove== TRUE)
				{
					//Add By Ray 2018-06-07
					//���ɻ��� ɾ��ʱ���бʼDZ���
					
					g_pFrame->m_bEraseMove= FALSE;
				}
				break;
			}

		}
		if(bBrakeFlag ==TRUE)
		{
			break;
		}
	}
	return ret;
}
int WINAPI  delete_note_callback(double x,double y,int page)
{
	std::vector<double> note_pt;
	note_pt.push_back(x);
	note_pt.push_back(y);
	//GetCurSelNote(note_pt, page);
	if(x==-100)
	{
		//���̧��
		g_pFrame->m_bEraseMove= TRUE;
		g_pFrame->m_bIsBackUpOnDelete=true;
		
	}
	g_pFrame->m_curSelNote =ptOnLine(x,y,page); //GetCurSelNote(note_pt, page);//
	if(g_pFrame->m_curSelNote!=-1)
	{
		//Add By Ray 2018-06-07
		//���ɻ��� ɾ��ʱ���бʼDZ���
		//g_pFrame->m_pdfNoteInfoListBK.assign(g_pFrame->m_pdfNoteInfoList.begin(), g_pFrame->m_pdfNoteInfoList.end());
		CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf.at(g_pFrame->m_curSelNote);
		if(info->pdfNoteType==NoteFreedom)
		{
			if(g_pFrame->m_isShowNotes)
			{
				g_pFrame->m_curSelNote=-1;
				if(g_pFrame->m_bIsBackUpOnDelete)
					g_pFrame->BackUpFreePen();
				g_pFrame->m_bIsBackUpOnDelete=false;
				g_pFrame->DeleteFreePen(info);
			}

		}

	}
	return 1;
}

int WINAPI  key_message_callback(bool isCtrl,bool isAtl,int key)
{
	//Alt =Shift
	g_pFrame->HotKey_Oeration(isCtrl,isAtl,key,1);
	return 1;
}

int WINAPI  draw_note_callback(HDC hdc, RECT *rcArea, int page)
{
	if(g_pFrame==NULL)
		return -1;

	g_pFrame->checkReloadNoteDB(0,0);
 	
	g_pFrame->flag=0;
	g_pFrame->DrawAllNote(hdc,rcArea,page);
	

	if(g_pFrame->m_currentSelectInfo && g_pFrame->m_currentSelectInfo->pageIndex==page)
	{
		std::vector<double> screen_tmp_pos_temp=g_pFrame->m_currentSelectInfo->coord_pt;
		int ret = PDF_Rect2Screen(g_pFrame->m_currentSelectInfo->coord_pt, screen_tmp_pos_temp, page);
		int i = 0;
		while (i < screen_tmp_pos_temp.size())
		{
			int y = screen_tmp_pos_temp[i+1]+screen_tmp_pos_temp[i+3];
			int lineWidth = 1;
			
			lineWidth = screen_tmp_pos_temp[i+3];
			y = screen_tmp_pos_temp[i+1];
			DrawNotes::DrawLine(hdc, TP_NOTES_TYPE::NOTES_LINE_MARK, lineWidth, Gdiplus::Color(0xFF000000), Gdiplus::Point(screen_tmp_pos_temp[i], y), Gdiplus::Point(screen_tmp_pos_temp[i]+screen_tmp_pos_temp[i+2], y));
			i += 4;
		}
	}


	return 0;
}
int WINAPI  new_note_callback(std::vector<double> &note_pt, std::wstring &str_sel_txt, int page)
{
	// ѡ���λ�ø�ʽΪ x  y  dx  dy
	g_note_pt.clear();
	g_note_pt =note_pt;
	g_sel_txt.Format(L"%s", str_sel_txt.c_str());

	if (-1==page)
	{
		page = PDF_GetCurPage();
		if( g_pFrame->m_hwndTooltip != NULL ) ::SendMessage(g_pFrame->m_hwndTooltip, TTM_TRACKACTIVATE, FALSE, (LPARAM) &g_pFrame->m_ToolTip);
		//g_pFrame->m_pMyPDFBook->RedrawLines();
		return 1;
	}
	else
	{
		if(L"##mouse is hover##"==g_sel_txt)
	{
		if(g_pFrame->m_isShowNotes)
		{
			if(ShowTooltips(note_pt, page) != -1)
			{
				if( g_pFrame->m_hwndTooltip != NULL ) ::SendMessage(g_pFrame->m_hwndTooltip, TTM_TRACKACTIVATE, FALSE, (LPARAM) &g_pFrame->m_ToolTip);;
			}
			//g_pFrame->m_pMyPDFBook->RedrawLines();
			return 0;
		}else
		{
			return 0;
		}

	}
	else if(L"##mouse is leave##"==g_sel_txt)
	{
		::SetFocus(g_pFrame->m_hMainWnd);
		if( g_pFrame->m_hwndTooltip != NULL ) ::SendMessage(g_pFrame->m_hwndTooltip, TTM_TRACKACTIVATE, FALSE, (LPARAM) &g_pFrame->m_ToolTip);
		return g_pFrame->m_curSelNote;
	}
	if (g_pFrame->m_bIsSeeNote && L"##double click on line##"==g_sel_txt)
	{
		
		int index = GetCurSelNote(note_pt, page);
		if(index>=0)
		{
			CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf.at(index);
			g_pFrame->OpenSeeNote(info);
			
		}
		return 1;
	}
	g_pFrame->m_curSelNote = -1;
	if(L"lbuttondown"==g_sel_txt)
	{
		if(g_pFrame->m_bIsSeeNote)
		{
			g_pFrame->m_curSelNote =-1;
			return -1;
		}
		g_pFrame->m_curSelNote = GetCurSelNote(note_pt, page);
		if(g_pFrame->m_curSelNote>=0)
		{
			g_pFrame->m_pMyPDFBook->SetMoveIcon(true);
;			CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf.at(g_pFrame->m_curSelNote);
			if(info->pdfNoteType==NotePdf || info->pdfNoteType==NotePpt || info->pdfNoteType==NoteExcel || info->pdfNoteType==NoteDoc || info->pdfNoteType==NoteImage || info->pdfNoteType==NoteVideo || info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteFile || info->pdfNoteType==NoteLink ||info->pdfNoteType==NoteTextBox)
			{
				//g_pFrame->SetPenAndColor(NOTES_IMAGE, g_pFrame->GetPenColor());
				g_pFrame->m_indexPos=g_pFrame->m_curSelNote;
			}
			else
				g_pFrame->m_indexPos=-1;
			g_pFrame->showNoteTool(NOTE_TOOL_TYPE::NOTE_NONE);
			return 0;
		}
		else
		{
			g_pFrame->showNoteTool(NOTE_TOOL_TYPE::NOTE_NONE);
			g_pFrame->m_indexPos=-1;
			g_pFrame->SetNeedReloadDB();
			g_pFrame->m_pMyPDFBook->RedrawLines();
			if(g_pFrame->m_currentSelectInfo)
			{
				g_pFrame->m_currentSelectInfo=NULL;
			}
			return 0;
		}
	}
	if(L"lbuttonup"==g_sel_txt)
	{
		g_pFrame->m_pMyPDFBook->SetMoveIcon(false);
		if(g_pFrame->m_bIsSeeNote)
		{
			g_pFrame->m_curSelNote =-1;
			return -1;
		}
		g_pFrame->m_curSelNote = GetCurSelNote(note_pt, page);
		if(g_pFrame->m_indexPos>=0 )
		{
			if(g_pFrame->m_note_type == NOTES_FREEDOM)
				return -1;
			CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf.at(g_pFrame->m_indexPos);
			
			std::vector<double> list_coord;
			info->coord;

			if((abs(note_pt.at(2)-info->coord_pt.at(0))>20)||(abs(note_pt.at(3)-info->coord_pt.at(1))>20) || info->pageIndex!=page)
			{
				double xx;
				double yy;
				PDF_GetPageSize(info->pageIndex,xx,yy);
				int x=note_pt.at(2);
				int y=note_pt.at(3);
				if(x<PIECES_SIZE_X/2) x=PIECES_SIZE_X/2;
				if(x>xx-PIECES_SIZE_X/2) x=xx-PIECES_SIZE_X/2;
				if(y<PIECES_SIZE_Y/2) y=PIECES_SIZE_Y/2;
				if(y>yy-PIECES_SIZE_Y/2) y=yy-PIECES_SIZE_Y/2;
				list_coord.push_back(x);
				list_coord.push_back(y);
				list_coord.push_back(30);
				list_coord.push_back(30);
				Point2StrCoord(list_coord, info->coord); //pNewPdfInfo->���꣬����ж��,��;�ָ�
				info->pageIndex=page;
				g_pFrame->UpdateDBAndPDFList(info,true,true);
				
				//g_pFrame->m_curSelNote=-1;
				

				g_pFrame->m_curSelNote = g_pFrame->m_indexPos=-1;
				g_pFrame->SetNeedReloadDB();
				g_pFrame->SetPenAndColor(NOTES_NONE, g_pFrame->GetPenColor());
				//g_pFrame->m_pMyPDFBook->RedrawLines();
			}	
		}
		//if(g_pFrame->m_currentSelectInfo)
		//{
		//	g_pFrame->m_currentSelectInfo=NULL;
		//}
		//g_pFrame->m_pMyPDFBook->RedrawLines();
		//g_pFrame->SetPen(NOTES_NONE);
		//g_pFrame->m_pMyPDFBook->RedrawLines();
		return 0;
	}
	if (L"##right click on line##"==g_sel_txt || L"##double click on line##"==g_sel_txt)
	{
		//  ##click on line##
		g_pFrame->m_curSelNote = GetCurSelNote(note_pt, page);
		if(g_pFrame->m_curSelNote==-1)
		{
			g_pFrame->showNoteTool(NOTE_TOOL_TYPE::NOTE_NONE);
		}
		
		if (L"##right click on line##"==g_sel_txt)
		{
			if(g_pFrame->m_bIsSeeNote)
			{
				g_pFrame->m_curSelNote =-1;
				return -1;
			}
			if(g_pFrame->m_curSelNote<0 || g_pFrame->m_currentSelectInfo)
			{
				if(g_pFrame->m_currentSelectInfo)//�༭���߱ʼ�
				{
					std::vector<double> screen_note_pos = g_pFrame->m_currentSelectInfo->coord_pt;
					RectPT2Point(screen_note_pos);
					int i = 0;
					while (i < g_pFrame->m_currentSelectInfo->coord_pt.size())
					{
						if ( note_pt[0]>=screen_note_pos[i]&&note_pt[0]<=screen_note_pos[i+2] &&
							note_pt[1]>=screen_note_pos[i+1]&&note_pt[1]<=screen_note_pos[i+3])
						{
							DuiLib::CPoint point(0,0);
							GetCursorPos(&point);
							CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
							pMenu->Init(NULL, _T("reader/menu/PDFContexMenu.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
							break;
						}

						i += 4;
					}	
				}
				else
				{
					CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
					DuiLib::CPoint point(0,0);
					GetCursorPos(&point);
					pMenu->Init(NULL, _T("reader/menu/PDFPageSetMenu.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);

					RECT rect1, rect2;
					GetWindowRect(g_pFrame->GetHWND(), &rect1);
					GetWindowRect(pMenu->GetHWND(), &rect2);

					if(rect1.bottom < rect2.bottom || rect1.right < rect2.right)
					{
						if(rect1.bottom < rect2.bottom)
						{
							rect2.top = rect2.top - (rect2.bottom - rect1.bottom);
							rect2.bottom = rect1.bottom;
						}
						if(rect1.right < rect2.right)
						{

							rect2.left = rect2.left - (rect2.right - rect1.right);
							rect2.right = rect1.right;
						}
						int width = rect2.right - rect2.left;
						int height = rect2.bottom - rect2.top;

						::SetWindowPos(pMenu->GetHWND(), HWND_TOPMOST, rect2.left, rect2.top, width, height, SWP_SHOWWINDOW);
					}
				}
			}
			else
			{
				CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf[g_pFrame->m_curSelNote];
				CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
				DuiLib::CPoint point(0,0);
				GetCursorPos(&point);
				if(info->pdfNoteType==NoteLine)//���߱ʼ��Ҽ��˵�
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_Line.xml"), point,&g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
				}
				else if(info->pdfNoteType==NoteTextBox)//�ı����Ҽ��˵�
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_NoteTextBox.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);

				}
				else if(info->pdfNoteType==NoteImage || info->pdfNoteType==NoteVideo || info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteFile|| info->pdfNoteType==NoteDoc|| info->pdfNoteType==NoteExcel|| info->pdfNoteType==NotePpt|| info->pdfNoteType==NotePdf)//�����ʼ�
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_NoteFile.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
				}
				else if(info->pdfNoteType==NoteLink)
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_NoteLink.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
				}
			}
		}
		else if (L"##double click on line##"==g_sel_txt)
		{
			//g_pFrame->OpenFileNoteByNoteId(g_pFrame->m_curSelNote);
			g_pFrame->m_curSelNote = GetCurSelNote(note_pt, page);
			if(g_pFrame->m_curSelNote>=0)
			{
				CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf.at(g_pFrame->m_curSelNote);
				if(info->noteOrigin==ORIGIN_SYSTEM)
				{
					if(info->pdfNoteType ==NoteExercise)
					{
						CString bookId=g_pFrame->m_pBookInfo->bookId;
						CString strLevelCode = g_pFrame->GetCurrentMuluLevelCode();
						if(g_pFrame->NetWorkAndTokenCheck())
						{
							CWebviewFrame* web = new CWebviewFrame(theApp.m_strUserConfig.strExercise_url,g_pFrame->m_current_page,strLevelCode,DO_EXERCISE_PAGE,g_pFrame->m_pBookInfo->bookId);
							web->Create(g_pFrame->GetHWND(), _T("WebviewFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
							web->CenterWindow();
							web->ShowWindow();
						}
						
					}else
					{
						if(info->resourcePath==L"")
						{
							g_pFrame->CustomMessageBox(L"����������",MSG_TYPE_NOTICE,FALSE);
						}else
						{
							CString bookId=g_pFrame->m_pBookInfo->bookId;
							CString path=theApp.m_strPublic_Path+bookId+info->resourcePath;
							path.Replace(_T("/"),_T("\\"));
							//path="D:\\YDJL\\Sourcecode\\SHgeniusPC\\ShanghaiObject\\debug\\source\\public\\7c02a4c33c2e44698ee3605d8990851e\\attachments\\123.mp3";
							g_pFrame->PlayMp3(path,info->noteText);
						}

					}


				}
				g_pFrame->ShowSelectNoteInfo(info);
				//
			}
			
		}
		else
			g_pFrame->m_currentSelectInfo=NULL;
		//g_pFrame->m_pMyPDFBook->RedrawLines();
		return 0;
	}
// 	if(g_pFrame->m_pMyPDFBook->m_bShow)
// 	{
// 		
// 		CGlobalUI::ShowMessage(g_pFrame->GetHWND(), _T("ֻ��ԭ��ģʽ�²��������бʼDz���!"),2,1);
// 		return 0;
// 	}

	if(g_pFrame->m_NoteShowType != 1 && g_pFrame->m_NoteShowType != 5 )
	{
		//CGlobalUI::ShowMessage(g_pFrame->GetHWND(), _T("�鵵�ʼ��²�֧�ֱʼǹ���!"));
		//return 0;
	}
	CPDFNoteInfo* pNewPdfInfo = new CPDFNoteInfo();

	
		switch (g_pFrame->m_note_type)
		{
		case TP_NOTES_TYPE::NOTES_LINE_STD:
			{
				pNewPdfInfo->pdfNoteType = PDFNoteType::NoteLine; //ע������
				pNewPdfInfo->lineType=LineType::FullLine;         //pNewPdfInfo->��������

				CString strMsg = g_pFrame->GetPenColorById(g_pFrame->GetPenColor());
				g_pFrame->WriteLog(OP_FULL_LINE, strMsg);
			}break;
		case TP_NOTES_TYPE::NOTES_LINE_WAVE:
			{
				pNewPdfInfo->pdfNoteType = PDFNoteType::NoteLine; //ע������
				pNewPdfInfo->lineType=LineType::WavyLine;         //pNewPdfInfo->��������

				CString strMsg = g_pFrame->GetPenColorById(g_pFrame->GetPenColor());
				g_pFrame->WriteLog(OP_WAVY_LINE, strMsg);
			}break;
		case TP_NOTES_TYPE::NOTES_LINE_DOT:
			{
				pNewPdfInfo->pdfNoteType = PDFNoteType::NoteLine; //ע������
				pNewPdfInfo->lineType=LineType::DottedLine;         //pNewPdfInfo->��������

				CString strMsg = g_pFrame->GetPenColorById(g_pFrame->GetPenColor());
				g_pFrame->WriteLog(OP_DOTTED_LINE, strMsg);
			}break;
		case TP_NOTES_TYPE::NOTES_NONE:
			{
				pNewPdfInfo->pdfNoteType = PDFNoteType::NoteNone; //ע������
			}break;

		case TP_NOTES_TYPE::NOTES_FREEDOM:
			{
				//Add Comment By Ray 2018-05-31
				//���ɻ��ʱʼ�
				pNewPdfInfo->pdfNoteType = PDFNoteType::NoteFreedom; //ע������
				//��ɫ��¼Log
				CString strMsg = g_pFrame->GetPenColorById(g_pFrame->GetPenColor());
				g_pFrame->WriteLog(OP_FREEDOM, strMsg);

			}break;


		case TP_NOTES_TYPE::NOTES_TEXTBOX:
			{
				pNewPdfInfo->pdfNoteType = PDFNoteType::NoteTextBox; //ע������
			}
			break;

		case TP_NOTES_TYPE::NOTES_ERASER:
			{
				g_isErasing = 1;
			}
			break;
		default:
			//return FALSE;
			break;
		}

		//Add By Ray 2018-06-07
		//���ɻ��� ����ʱ���бʼDZ���
		if(g_pFrame->m_note_type==TP_NOTES_TYPE::NOTES_FREEDOM)
		{
			g_pFrame->BackUpFreePen();
			if(g_note_pt.size()>4)
			{
				g_note_pt.erase(g_note_pt.end()-1);
				g_note_pt.erase(g_note_pt.end()-1);
			}
		}
		// ���ӱʼǵ�������Ϣ
		//Add Comment By Ray 2018-05-31
		//���ӱʼ�������Ϣ
		pNewPdfInfo->id=-1;
		pNewPdfInfo->bookId=g_pFrame->m_pBookInfo->bookId;           //pNewPdfInfo->��ID
		pNewPdfInfo->pdfId=0;            //pNewPdfInfo->ע��ID,����Ψһ

		pNewPdfInfo->content=g_sel_txt;          //pNewPdfInfo->�������»���ѡ������� �����ļ����� �����ӵ�ַ ����Ϣ,

		CTime tm=CTime::GetCurrentTime();
		CString strInfo=tm.Format("%Y-%m-%d %H:%M:%S");

		pNewPdfInfo->updateTime=strInfo;       //pNewPdfInfo->ʱ��
		pNewPdfInfo->noteCatalog=L"";      //pNewPdfInfo->����Ŀ¼
		pNewPdfInfo->pageIndex=page;        //pNewPdfInfo->ע������ҳ��
		pNewPdfInfo->contentStartPos=L"";  //pNewPdfInfo->ѡ��������ʼλ��
		//pNewPdfInfo->noteOrigin =(PDFNoteInfoOrigin)ORIGIN_USER;
		//CCatalogDao catalogDao;
		//int icatalogId = catalogDao.GetCatalogIdByPageIndex(pNewPdfInfo->bookId, pNewPdfInfo->pageIndex);
		//pNewPdfInfo->noteCatalog.Format(_T("%d"), icatalogId);
		pNewPdfInfo->catalogIndex=page-1;		//Ŀ¼ҳ��Ĭ��Ϊ�ʼ�ҳ��
		/*if(g_bScreenShow == 2)
		pNewPdfInfo->notePostilTextSize = 26;
		else if (g_bScreenShow == 1)
		pNewPdfInfo->notePostilTextSize = 26;
		else 
		pNewPdfInfo->notePostilTextSize = 18;

		pNewPdfInfo->notePostilTextColor =MDR_COLOR_RED;*/

		pNewPdfInfo->coord_pt = g_note_pt;
		std::vector<double> note_pt_tmp = g_note_pt;

		if (TP_NOTES_TYPE::NOTES_LINE_STD<=g_pFrame->m_note_type && TP_NOTES_TYPE::NOTES_TEXT>=g_pFrame->m_note_type)
		{
			RectPT2Point(note_pt_tmp);
			Point2StrCoord(note_pt_tmp, pNewPdfInfo->coord); //pNewPdfInfo->���꣬����ж��,��;�ָ�
		}
		else if (TP_NOTES_TYPE::NOTES_TEXTBOX == g_pFrame->m_note_type)
		{
			Point2StrCoord(note_pt_tmp, pNewPdfInfo->coord); //pNewPdfInfo->���꣬����ж��,��;�ָ�
		}
		else
		{
			//Add Comment By Ray 2018-05-31
			//����תΪString
			Point2Str(note_pt_tmp, pNewPdfInfo->coord); //pNewPdfInfo->���꣬����ж��,��;�ָ�
		}

		pNewPdfInfo->lineColor=g_pFrame->m_penColor;        //pNewPdfInfo->�ߵ���ɫ
		pNewPdfInfo->lineWidth=g_pFrame->m_iLineWidth;        // �߿�
		pNewPdfInfo->pageAngle=0;        // ҳ��Ƕ�
		//pNewPdfInfo->noteOrigin=PDFNoteInfoOrigin::ORIGIN_USER;       // �ʼ���Դ
		pNewPdfInfo->userName=theApp.m_UserInfo.strLoginName;         // �û�
		// ����
		g_pFrame->OnDrawLineFinish(pNewPdfInfo);
		//return 0;
	}
	return 0;
}


int AddNewNote2List(vector<CPDFNoteInfo*> &note_list, CPDFNoteInfo &info)
{
	if (note_list.size()==0)
	{
		note_list.push_back(&info);
		return 0;
	}

	vector<CPDFNoteInfo*>::iterator iter = note_list.begin();
	long note_pos = 0;
	while (iter != note_list.end()) 
	{
		if ((*iter)->pageIndex<info.pageIndex)
		{
			iter++;
			note_pos++;
			continue;
		}

		if ((*iter)->pageIndex>=info.pageIndex)
		{
			break;
		}
	}

	note_list.insert(iter,&info);

	return note_pos;
}

/************************************************************************/
/* ����ص��������������Ϊ���ֽڵģ���Ҫת��                                                                     */
/************************************************************************/
long CALLBACK OnDoEvent(long MSG_ID,long lParams,char* wParams, long DoNpHandle)
{
	//������ֽ��ַ��Ĵ�С�����ַ����㡣
	int len = MultiByteToWideChar(CP_ACP,0,wParams,lParams,NULL,0);
	//Ϊ���ֽ��ַ���������ռ䣬�����СΪ���ֽڼ���Ķ��ֽ��ַ���С
	TCHAR *buf = new TCHAR[len + 1];
	//���ֽڱ���ת���ɿ��ֽڱ���
	MultiByteToWideChar(CP_ACP,0,wParams,lParams,buf,len);
	buf[len] = '\0'; //�����ַ�����β��ע�ⲻ��len+1

	//��TCHAR����ת��ΪCString
	CString pWideChar;
	pWideChar.Append(buf);
	//ɾ��������
	delete []buf;
	static long lineID = -1;
	//	g_pFrame->m_cLog.WriteLog(_T("OnDoEvent ID is : %d"), MSG_ID);


	switch(MSG_ID){
	case 0: //��ǰҳ��/PDF��ҳ���л��¼�
		{
			int len = pWideChar.GetLength();
			int nPos = pWideChar.Find(_T("|"));
			CString CurPage  = pWideChar.Left(nPos);
			CString MaxPage  = pWideChar.Right(len - (nPos+1));

			//g_pFrame->m_pPageManageFrame->SetPageIndex(_ttoi(CurPage), _ttoi(MaxPage));

			int iPageIndex = _tstoi(CurPage);
			CString strMsg(CurPage);
			g_pFrame->WriteLog(OP_BOOK_CHANGE_PAGE, strMsg);

			break;
		}
	case 1://ע�ͻ�����ɻص�
		{
			/* 10|zjh|2014/07/03 11:22:41|4|1|51,128;244,125;|1|255,252,107,0|1|1. ��������ѧϰ��ϰ�� ||2,12||0*/
			/*ע������,�û�,ʱ��,ע������ҳ��,ע��ΨһID,����,ע������,��ɫ,�߿�,�������»���ѡ�������,�����ļ�·��,�������»���������ʼλ��,�����ӵ�ַ,��ǰҳ��Ƕ�*/
			/*ע������,�û�,ʱ��,        ҳ��,        ID,����,ע������,��ɫ,�߿�,�������»���ѡ�������,�����ļ�·��,�������»���������ʼλ��,��ǰҳ��Ƕ�*/
			if (pWideChar )
			{
				int i = 0;
				g_pFrame->p_newPdfInfo = new CPDFNoteInfo();
				while(pWideChar.Find(_T("|"))+1)
				{
					CString strdata  = pWideChar.Left(pWideChar.Find(_T("|")));
					//CStringA stra;
					CFunction function;
					pWideChar.Delete(0,strdata.GetLength()+1);
					if(strdata.GetLength()==0)
					{
						i++;
						continue;
					}

					//					g_pFrame->m_cLog.WriteLog(_T("Note Type is %d"), i);

					switch(i){
					case 0: //ע������
						g_pFrame->p_newPdfInfo->pdfNoteType=(PDFNoteType)_ttoi(strdata);
						break;
					case 1://�û�
						//g_pFrame->p_newPdfInfo->userName=strdata;
						g_pFrame->p_newPdfInfo->userName=theApp.m_UserInfo.strLoginName;
					case 2: // ʱ��
						{
							CTime tm=CTime::GetCurrentTime();
							CString str=tm.Format("%Y-%m-%d %H:%M");
							g_pFrame->p_newPdfInfo->updateTime= str;
						}
						break;
					case 3: //ע������ҳ��
						g_pFrame->p_newPdfInfo->pageIndex = _ttoi(strdata);
						long x, y;
						//g_pFrame->m_pMyPDFBook->m_pdf_view->GetPageSize(g_pFrame->p_newPdfInfo->pageIndex, (long)&x, (long)&y);
						g_pFrame->p_newPdfInfo->pageWidth = x;
						g_pFrame->p_newPdfInfo->pageHeight = y;
						break;
					case 4://ע��ΨһID
						g_pFrame->p_newPdfInfo->pdfId = _ttoi(strdata);
						break;
					case 5://����
						g_pFrame->p_newPdfInfo->coord=strdata;
						break;
					case 6://ע������
						g_pFrame->p_newPdfInfo->lineType =(LineType)_ttoi(strdata);
						break;
					case 7://��ɫ
						//g_pFrame->p_newPdfInfo->lineColor=strdata;
						break;
					case 8://,�߿�
						g_pFrame->p_newPdfInfo->lineWidth=_ttoi(strdata);
						break;
					case 9://,�������»���ѡ�������,
						g_pFrame->p_newPdfInfo->content=strdata;
						break;
					case 10://�����ļ�·��,
						//stra=strdata.GetBuffer(0);
						//strdata.ReleaseBuffer();
						/*p_newPdfInfo->noteText.noteText=function.UnicodeToUTF8(strdata);
						p_newPdfInfo->noteText.noteLength=strlen(p_newPdfInfo->noteText.noteText);*/
						g_pFrame->p_newPdfInfo->SetNoteTextByString(strdata);
						//stra.ReleaseBuffer();
						break;
					case 11://�������»���������ʼλ��,
						g_pFrame->p_newPdfInfo->contentStartPos=strdata;
						break;
						/*case 12://�����ӵ�ַ,
						p_newPdfInfo->noteText=strdata;
						break;*/
					case 12://��ǰҳ��Ƕ�
						g_pFrame->p_newPdfInfo->pageAngle=_ttoi(strdata);
						break;
					}
					i++;
				}
				if (g_pFrame->p_newPdfInfo->pdfNoteType != NoteTextBox)
				{
					g_pFrame->OnDrawLineFinish(g_pFrame->p_newPdfInfo);
				}
			}
		}
		break;
	case 2://ɾ��ע����ɻص�
		g_pFrame->OnDeleteNoteFinish(_ttoi(pWideChar));
		break;
	case 3://���PDF�ļ��ϵ�ע�ͻص�
		break;
	case 4://д��ע�ͻص�
		break;
	case 5://�ƶ������ı�ע��
		{
			if(g_isErasing){//������Ƥ��ģʽ
				if (wParams ){
					int id = _ttoi(pWideChar);
					//ɾ��PDF�ļ��еıʼ�
					if(id>0)
					{
						CPDFNoteInfo* p_Info=g_pFrame->GetPDFInfoByPdfId(id);
						PDFNoteType pdfNoteType=p_Info->pdfNoteType;
						//if((pdfNoteType==NoteLine || pdfNoteType==NoteFreedom) &&(p_Info->lineType!=DottedLine))
						if(pdfNoteType==NoteFreedom)
						{
							bool result=g_pFrame->m_pMyPDFBook->DeleteComment(id,0);//0Ϊɾ��ָ������ע�ͣ��������»�ֱ�ߣ��»������ߣ�Ǧ�ʣ�
							if(result)
							{
								g_pFrame->OnDeleteNoteFinish(id);
							}
						}
					}
				}
			}
		}
		break;
	case 6:
		break;
	case 7:
		if (wParams )
		{
			int id = _ttoi(pWideChar);
			if(id>0)
			{
				CPDFNoteInfo* pInfo=g_pFrame->GetPDFInfoByPdfId(id);
				if(pInfo!=NULL)
				{
					POINT pt;
					GetCursorPos(&pt);
					g_pFrame->m_tip.On(TRUE);
					if (pInfo->pdfNoteType == NoteLine)
					{
						CString str = pInfo->GetStringByNoteText();
//						g_pFrame->m_tip.Set(pt, pInfo->noteText, pInfo->noteText.GetLength());
					    pInfo->noteText.ReleaseBuffer();
					}
					else
						g_pFrame->m_tip.Set(pt,pInfo->content);
				}
			}
		}
		break;
	case 8: //�򿪸����¼�����Ҫ�Ѹ���·������ȥ
		if (wParams )
		{
			int id = _ttoi(pWideChar);
			if(id>0)
			{
				CString strSrc = theApp.m_ResourcePath;
				CString strFilePath = g_pFrame->GetFilePath(id);
				// 				if (strSrc.Right(1) == _T("\\"))
				// 				{
				// 					if (strFilePath.Right(1) == _T("\\"))
				// 						strSrc = strSrc.Left(strSrc.GetLength() - 1);
				// 				}
				//				CString path=strSrc + strFilePath;
				//				CString path = _T("C:\\Progress Check-4.mp3");
				g_pFrame->m_cLog.WriteLog(_T("Open Resource: %s"), strFilePath);
				//g_pFrame->m_pMyPDFBook->m_pdf_view->SetCmtValue(_T(""),_T(""),id,14,strFilePath,0);
				//g_pFrame->m_pMyPDFBook->m_pdf_view->InvalidateView(1);
			}
		}
		break;
	case 9:
		if (wParams )
		{
			/*ΨһID|��ǰע��ҳ��|��|ҳ��Ƕ� 1|1|227,133;|0*/
			int i=0;
			CPDFNoteInfo* p_Info=NULL;
			while(pWideChar.Find(_T("|"))+1)
			{
				CString strdata  = pWideChar.Left(pWideChar.Find(_T("|")));
				pWideChar.Delete(0,strdata.GetLength()+1);
				if(strdata.GetLength()==0)
				{
					i++;
					continue;
				}
				switch(i){
				case 0: //ע��ΨһID
					p_Info=g_pFrame->GetPDFInfoByPdfId(_ttoi(strdata));
					break;
				case 1: //ע������ҳ��
					if(p_Info!=NULL)
					{
						p_Info->pageIndex = _ttoi(strdata);
					}
					break;
				case 2://����
					if(p_Info!=NULL)
					{
						p_Info->coord=strdata;
					}

					break;
				case 3://��ǰҳ��Ƕ�
					if(p_Info!=NULL)
					{
						p_Info->pageAngle=_ttoi(strdata);
					}
					break;
				}
				i++;
			}
			if(p_Info!=NULL)
			{
				g_pFrame->m_noteDao->UpdateNoteInfo(*p_Info);
				
			}
		}
		break;
		/*�˴�Ϊ���ӱʼǴ������̣�
		* �¼�˳��Ϊ ѡ���ı������̧�� ����case10 ����ʱ�����»����ߺ󣬻ᴥ��case 1�¼�����case 1�����ӵ�list�У���case10 ��
		* ��ʾ�Ի���Ȼ��д�ʼǣ������и���
		*
		*/
	case 10:
		if (wParams)
		{
			long pdfId = _ttoi(pWideChar);
			//g_pFrame->m_pMyPDFBook->m_pdf_view->SelectAddUnderLine(2,_T(""));
			CPDFNoteInfo* p_Info=g_pFrame->GetPDFInfoByPdfId(pdfId);
			if(p_Info!=NULL)
			{
				//g_pFrame->ShowEditNoteFrame(p_Info,FALSE);
			}
		}
		break;
	case 11: //˫��ע��Tipͼ���¼�
		if (wParams)
		{
			int pdfId = _ttoi(pWideChar);
			g_pFrame->OnUpdateTextLine(pdfId);
		}
		break;
	case 13:
		{   // �ı����������
			int pos = pWideChar.Find(_T("|"));
			if (pos != -1)
			{
				int pdfid = _ttoi(pWideChar.Left(pos));
				CString strText = pWideChar.Right(pWideChar.GetLength() - pos -1);
				if (g_pFrame->p_newPdfInfo != NULL)
					g_pFrame->UpdateTextBoxAfterEditByPdfId(g_pFrame->p_newPdfInfo, pdfid, strText);
				else
					g_pFrame->UpdateTextBoxAfterEditByPdfId(NULL, pdfid, strText);
			}



			// 			else
			// 			{
			// 				int pos = pWideChar.Find(_T("|"));
			// 				if (pos != -1)
			// 				{
			// 					int pdfid = _ttoi(pWideChar.Left(pos));
			// 					CString strText = pWideChar.Right(pWideChar.GetLength() - pos -1);
			// 					g_pFrame->UpdateTextBoxAfterEditByPdfId(pdfid, strText);
			// 				}
			// 			}
		}
		break;
	}

	return 0;
}

namespace DuiLib
{
#pragma region ������ʼ��������

	CReaderFrame::CReaderFrame()
		: m_strCurNoteType("Menu_Note_All")
	{
		m_penColor            = MDR_COLOR_RED;
		m_nSelLineNote_Line =HighlightLine;
		m_nSelLineNote_Color=MDR_COLOR_BLUE;
		m_colorFrameVisible   = false;
		m_bFirstRun           = true;
		g_pFrame              = this;
		m_bAutoDelete         = true;//�Զ�ɾ���������
		m_pCloudNoteButton    = NULL;
		m_pCloudNoteList      = NULL;
		m_pDownloadCloudNotes = NULL;
		m_pPracticeButton     = NULL;
		m_strNoteId           = _T("");
		m_pBookInfo           = NULL;
		m_pTitleBookName      = NULL;
		m_iLineWidth          = 2;
		p_newPdfInfo          = NULL;
		m_pBookDao            = NULL;
		m_pBookDao            = new CBookDal();
		m_pReadToolLayout     = NULL;
		m_bShowtool           = FALSE;
		m_BookType            = None;
		m_pMyPDFBook          = NULL;
		m_pMyBook             = NULL;
		m_pBookLayout         = NULL;
		m_hMainWnd            = NULL;
		m_pPlayerWnd		  = NULL;
		m_pUploadNoteButton   = NULL;
		m_pResInBookButton	  = NULL;
		m_pResInSchoolButton  = NULL;
		m_pResInWebButton     = NULL;
		m_curSelFolderId	  = 0;
		m_pExercise			  = NULL;
		m_hwndTooltip		  = NULL;
		m_NoteShowType		  = 1;
		m_pLabelCloudPackageRefresh = NULL;
		m_Import = 2;
		m_strCloudNotePackageType = _T("Menu_CloudeNote_All");
		m_pNotesFilterStatus = 0;
		m_isshowcata=false;
		m_isShowNoteUi=false;
		m_isShowResourceUi=false;
		m_isShowXitiUi=false;
		isShowFreePen=false;
		isShowTextNote = false;
		isShowLineNoteTool=false;
		isShowAttachTool=false;
		isshowmark=false;
		iserase=false;
		m_isShowNotes=true;
		//Add By Ray 2018-06-07
		m_bEraseMove =TRUE;
        m_currentSelectInfo=NULL;
		m_nCurrentPage= 0;
		m_pLabelOper=NULL;
		m_isShowAllLabel=false;

		isDelete=false;
		isUpload=false;
		isDownload=false;
		isShare=false;
		m_bIsShowStudentSubmit=false;
		m_current_select_FolderList=NULL;
		m_attach_temp_note=NULL;
		flag=0;
		m_bCancel=false;
		m_bImport=false;
		m_bMove=false;

		m_bShareSearch=false;

		m_bShareTwoCancel=false;
		m_bShareTwoImport=false;
		m_share_note_operator=NULL;

		m_b10=false;
		m_b4=false;
		m_b2=false;
		m_b1=false;


		m_bMaxShow=FALSE;
		m_bIsSearch=false;
		m_strSearchKey=_T("");
		m_bIsSelect=false;

		m_bIsBackUpOnDelete=true;
		m_bIsFirstBackUp=false;

		m_IsNeedReloadDB=false;
		m_current_page=-1;

		m_pSeeNote=NULL;
		m_bIsSeeNote=false;

		m_bResourceSearch=false;

		m_bIsSetMuluIndex=true;
		m_indexPos=-1;


		m_freeLineFrame=NULL;
		m_pdfToolFrame =NULL;

		m_bIsReloadResource=true;
		m_nEndSearchPage=10000;
		m_nStartSearchPage = 0;
		m_bAddAndEdit=false;
		m_bIsNeedModifySelectAll=false;
		m_nPageTemp =0;
	}

	LRESULT CReaderFrame::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		m_cLog.WriteLog(_T("CReaderFrame OnCreate Start!"));
		LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
		styleValue &= ~WS_CAPTION;
		styleValue &= ~WS_BORDER & ~WS_THICKFRAME & ~WS_SIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
		::SetWindowLong(*this, GWL_STYLE, styleValue );
		m_pm.Init(m_hWnd);
		CDialogBuilder builder;
		CDialogBuilderCallbackEx cb(this, m_hWnd);

		/*�ڶ�ȡ��Դ֮ǰ��������Դ·��*/
		if(theApp.m_screen==0)
			CSkinBuilder::SetModuleName(_T("1366"));
		else if(theApp.m_screen==3)
			CSkinBuilder::SetModuleName(_T("2736"));
		else if(theApp.m_screen==2)
			CSkinBuilder::SetModuleName(_T("1600"));
		else
			CSkinBuilder::SetModuleName(_T("1920"));
		
		int cxScreen = GetSystemMetrics(SM_CXSCREEN);
		CControlUI* pRoot;
		
		pRoot = builder.Create(_T("reader\\ReaderFrame.xml"), (UINT)0, &cb, &m_pm);
		DuiLib::CDuiString resPath=DuiLib::CPaintManagerUI::GetResourcePath();
		ASSERT(pRoot && "Failed to parse XML");
		m_pm.AttachDialog(pRoot);
		m_pm.AddNotifier(this);

		RECT rt;
		SystemParametersInfo(SPI_GETWORKAREA,NULL, &rt,NULL);
		POINT pt;
		int width = GetSystemMetrics(SM_CXFULLSCREEN); 
		int height = rt.bottom;

		int iWidth;
		int iHeight;

		if(g_bScreenShow)
		{
			iWidth = 800;
			iHeight = 90;
		}
		else
		{
			iWidth = 400;
			iHeight = 45;
		}

		pt.y = height - iHeight;
		pt.x = width / 2;
		pt.x = pt.x - iWidth / 2;
		ClientToScreen(this->m_hWnd, &pt);

		/*m_pPageManageFrame = new CPageManageFrame(m_BookType, this->m_hWnd);
		m_pPageManageFrame->Create(m_hWnd, _T("PageManageFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		SetParent(m_pPageManageFrame->GetHWND(), this->m_hWnd);
		m_pPageManageFrame->SetWindowPos(HWND_TOP, pt.x, pt.y, iWidth, iHeight, SWP_SHOWWINDOW);
		m_pPageManageFrame->ShowWindow(m_bShowtool);*/


		m_tip.Create(CWnd::FromHandle(this->m_hWnd));
		m_tip.SetDelay(500);
		m_tip.SetOffset(0,20);

		Init();

		m_cLog.WriteLog(_T("CReaderFrame OnCreate End!"));
		//		StartDownloadNotesFromCloud();

		return 0;
	}

	void CReaderFrame::Init()
	{
		//::SetWindowText(this->GetHWND(),_T("ѧϰ����"));
		
		m_nRedrawTime =0;
		m_pRestoreBtn = NULL;
		m_pMaxBtn = NULL;
		m_bIsFirstShowLabel=true;

		//��ʼ�����ߵ���ɫ
		//m_penColor = 0x00fc6b00;
		//m_penColor = 0x000000;
		m_penColor = 0x00FF3B5B;
		SetPenColor(MDR_COLOR_RED);

		m_pMinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn")));
		m_pMaxBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("maxbtn")));
		m_pCloseBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn")));

		m_pBackButton= static_cast<CButtonUI*>(m_pm.FindControl(_T("backButton")));

		m_btn_prePage= static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_preImage")));
		m_btn_nextPage= static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_nextImage")));
	

		m_pShowMarkButton= static_cast<CButtonUI*>(m_pm.FindControl(_T("showMarkButton")));
		m_pHideMarkButton= static_cast<CButtonUI*>(m_pm.FindControl(_T("hideMarkButton")));

		m_pFullscreenButton= static_cast<COptionUI*>(m_pm.FindControl(_T("fullscreenButton")));
		
		
	
		m_pResToolButton=static_cast<COptionUI*>(m_pm.FindControl(_T("res_tool_button")));
		m_pLabelCloudPackageRefresh = static_cast<CLabelUI*>(m_pm.FindControl(_T("cloud_package_refresh_label")));

		//need
		m_pShowCalaButton= static_cast<COptionUI*>(m_pm.FindControl(_T("calalog_option")));
		m_pShowNoteButton= static_cast<COptionUI*>(m_pm.FindControl(_T("note_option")));
		m_pShowWorkButton= static_cast<CButtonUI*>(m_pm.FindControl(_T("work_button")));
		//if(m_pBookInfo->strExercise_URL.GetLength()==0)
		if(theApp.m_strUserConfig.nIs_exercise==1)
		{
			if(m_pBookInfo->nExercise==0)//ϰ�ⰴť��ʾ
			{
				m_pShowWorkButton->SetEnabled(false);


			}
		}else
		{
			m_pShowWorkButton->SetVisible(false);
		}

		m_pShowSourceButton= static_cast<COptionUI*>(m_pm.FindControl(_T("source_button")));
		if(theApp.m_strUserConfig.nIs_resource_list==1)
		{
			if(m_pBookInfo->nResource==0)//��Դ��ť��ʾ
			{
				m_pShowSourceButton->SetEnabled(false);
			}
		}else
		{
			m_pShowSourceButton->SetVisible(false);
		}

		
		
	
		//m_pShowFreePen=static_cast<COptionUI*>(m_pm.FindControl(_T("calalog_option")));

		
		m_ctrMulu=static_cast<CComboBoxUI*>(m_pm.FindControl(_T("ComboMulu")));
		m_ctrResourceMulu = static_cast<CComboUI*>(m_pm.FindControl(_T("ComboMulu_Resource")));
		m_ctrMulu->SetAttribute(_T("endellipsis"),_T("true"));
		m_ctrlClass=static_cast<CComboBoxUI*>(m_pm.FindControl(_T("ComboCLassSelect")));
		ComboShareSelect=static_cast<CComboBoxUI*>(m_pm.FindControl(_T("ComboShare")));
		m_pOptionSearchShare = static_cast<COptionUI*>(m_pm.FindControl(_T("notes_search_option_share")));

		m_show_double_page=static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_double_page")));
		m_show_single_page=static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_single_page")));

		m_pOptionLocalNoteUpload=static_cast<COptionUI*>(m_pm.FindControl(_T("local_upload_notes")));
		m_pOptionLocalNoteShare=static_cast<COptionUI*>(m_pm.FindControl(_T("local_notes_export")));
		m_pOptionLocalNoteDelete=static_cast<COptionUI*>(m_pm.FindControl(_T("local_notes_delete")));
		m_pOptionDownNote=static_cast<COptionUI*>(m_pm.FindControl(_T("cloud_down_notes")));
		//end need


		m_pResInBookButton=static_cast<COptionUI*>(m_pm.FindControl(_T("ResInBook")));
		m_pResInSchoolButton=static_cast<COptionUI*>(m_pm.FindControl(_T("ResInSchool")));
		m_pResInWebButton=static_cast<COptionUI*>(m_pm.FindControl(_T("ResInWeb")));
		m_pResShowButton=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("ResToolLayout")));
	    m_pLabelButton1 = static_cast<CLabelUI*>(m_pm.FindControl(_T("no_search_label")));

		notes_search_option = static_cast<COptionUI*>(m_pm.FindControl(_T("notes_search_option")));

		CLabelUI* title=static_cast<CLabelUI*>(m_pm.FindControl(_T("book_name")));
		title->SetText(m_pBookInfo->strShortName);

		
		

		if(m_pResInSchoolButton)
		{
			m_pResInSchoolButton->SetEnabled(false);
		}

		if(m_pResInWebButton)
		{
			m_pResInWebButton->SetEnabled(false);
		}

		
		
	

		

		m_pUploadNoteButton= static_cast<CButtonUI*>(m_pm.FindControl(_T("upload_notes")));

		m_pFolderAddButton = static_cast<CButtonUI*>(m_pm.FindControl(_T("notes_folder_add")));
		if(m_pFolderAddButton)
			m_pFolderAddButton->SetVisible(false);
		m_pNotesLabelSet = static_cast<CButtonUI*>(m_pm.FindControl(_T("notes_label_set")));
		m_pNotesFilter = static_cast<COptionUI*>(m_pm.FindControl(_T("notes_filter")));

		//m_pHideToolButton = static_cast<CButtonUI*>(m_pm.FindControl(_T("hide_tool_button")));

		m_pTagButtonGroup = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("tagButtonGroup")));

		m_pSidebarTabLayout=static_cast<CSliderTabLayoutUI*>(m_pm.FindControl(_T("sidebar_tablayout")));
		m_pSidebarTitle=static_cast<CTextUI*>(m_pm.FindControl(_T("sidebar_title")));
		m_pSidebarLayout=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("sidebar_layout")));
		
		m_pShareStudentFolderLayout=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("show_share_folder_student")));

		m_pTabLayoutWeb=static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("sidertablayout_web")));
		//m_pSidebarTitleBar=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("sidebar_titlebar")));

		m_pCatalogButton=static_cast<COptionUI*>(m_pm.FindControl(_T("catalog_button")));
		m_pNoteButton=static_cast<COptionUI*>(m_pm.FindControl(_T("note_button")));
		//m_pResButton=static_cast<COptionUI*>(m_pm.FindControl(_T("res_button")));
		m_pCloudNoteButton=static_cast<COptionUI*>(m_pm.FindControl(_T("cloud_button")));
		m_pPracticeButton=static_cast<COptionUI*>(m_pm.FindControl(_T("practice_button")));
		m_pResList=static_cast<CResListUI*>(m_pm.FindControl(_T("reslist")));
		//m_pResOriginCombo=static_cast<CComboBoxUI*>(m_pm.FindControl(_T("combo_resorigin")));

		m_pNoteList = static_cast<CNoteListUI*>(m_pm.FindControl(_T("notelist")));
		m_pNoteList->m_startPage=m_pBookInfo->startPage;
		m_pFolderList = static_cast<CNoteListUI*>(m_pm.FindControl(_T("share_folder")));
		m_pFolderList->SetCurrentType(NOTE_SHOW_TYPE::SHARE_NOTE_SHOW);
		m_pFolderList->m_startPage=m_pBookInfo->startPage;
		m_pNoteCatalogList = static_cast<CNoteListUI*>(m_pm.FindControl(_T("notecataloglist")));

		m_pShareFolderTreeUI=static_cast<CShareFolderTreeUI*>(m_pm.FindControl(_T("share_folder_tree")));
		
		CButtonUI* btn_diandu = static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_diandu")));
		//if(m_pBookInfo->strDiandu_URL.GetLength()==0)
		if(theApp.m_strUserConfig.nIs_point_reading==1)
		{
			if(m_pBookInfo->nDiandu==0)
			{
				btn_diandu->SetVisible(false);
			}
		}else
		{
			btn_diandu->SetVisible(false);
		}

			


		m_pRetFolderListButton = static_cast<CButtonUI*>(m_pm.FindControl(_T("return_folderlist")));
		m_pFolderName = static_cast<CLabelUI*>(m_pm.FindControl(_T("folder_name")));
		m_pNoteTypeLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("note_type_layout")));
		m_pResTypeLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("res_type_layout")));

		m_pLablesCombo=static_cast<CComboUI*>(m_pm.FindControl(_T("combo_labels")));
		m_pNoteTypeCombo=static_cast<CComboUI*>(m_pm.FindControl(_T("combo_notetypes")));
		m_pBookmarkList=static_cast<CBookmarkListUI*>(m_pm.FindControl(_T("bookmarkList")));
		m_pResMarkList=static_cast<CResMarkListUI*>(m_pm.FindControl(_T("ResMarkList")));
		m_pResChoiceAll=static_cast<COptionUI *>(m_pm.FindControl(_T("res_choice_all")));
		//m_pNotesChoiceAll=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
		m_pNoteTabLayout=static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("note_tablayout")));
		
		m_pExportEdit = static_cast<CRichEditUI*>(m_pm.FindControl(_T("richedit_export")));
		m_pCloudNoteList = static_cast<CCloudNoteListUI*>(m_pm.FindControl(_T("cloudnotelist")));
		//Modify By Ray 2018-07-03
	
		

		

		m_pMoreNoteBtn=static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_more_note")));
		

		

		

		CLabelUI *pLabelVersion = NULL;
		pLabelVersion = static_cast<CLabelUI*>(m_pm.FindControl(_T("titleversion")));
		//if(pLabelVersion!=NULL)
		//	pLabelVersion->SetText(theApp.m_strVersion);

		m_pXiaoBenView = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("browser_xiaobenView")));
		m_pTuiJianView = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("browser_tuijianView")));

		m_pXiaoBenBrowser = static_cast<CShuTuView*>(m_pm.FindControl(_T("browser_xiaobenWeb")));
		if(m_pXiaoBenBrowser){
			CShuTuBrowserEventHandler *pWebHandle = new CShuTuBrowserEventHandler(m_pXiaoBenBrowser);
			m_pXiaoBenBrowser->SetWebBrowserEventHandler(pWebHandle);
		}

		m_pTuiJianBrowser = static_cast<CShuTuView*>(m_pm.FindControl(_T("browser_tuijianWeb")));
		if(m_pTuiJianBrowser){
			CShuTuBrowserEventHandler *pWebHandle = new CShuTuBrowserEventHandler(m_pTuiJianBrowser);
			m_pTuiJianBrowser->SetWebBrowserEventHandler(pWebHandle);
		}

		

		m_pCloudNoteItemListLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("cloud_note_item_list")));
		m_pCloudNotePackageListLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("cloud_note_package_list_layout")));
		m_pCloudNoteItemList = static_cast<CNoteListUI*>(m_pm.FindControl(_T("cloudnoteitemlist")));
		m_pCloudChoiceAll = static_cast<COptionUI*>(m_pm.FindControl(_T("cloud_note_choice_all")));
		m_pCloudNotesChoiceAll = static_cast<COptionUI*>(m_pm.FindControl(_T("cloud_notes_choice")));
		m_pCloudImportButton = static_cast<CButtonUI*>(m_pm.FindControl(_T("cloud_notes_import")));
		m_pCloudImportReturn = static_cast<CButtonUI*>(m_pm.FindControl(_T("cloud_notes_return")));
		m_pTitleBookName = static_cast<CTextUI*>(m_pm.FindControl(_T("book_name_title")));

		search_keyword = static_cast<CEditUI*>(m_pm.FindControl(_T("search_keyword")));
		m_pSearch_layout=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_search_layout")));



	
		m_pReadToolLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("readtoolbar")));
		m_pSeeNoteFrameTitle = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("seenotetoolbar")));

		m_pPreStudentNote = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("pre_student_see_note")));
		m_pNextStudentNote = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("next_student_see_note")));

		m_pVShowNoData = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("no_data_show")));
		m_pVShowNoResource = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("no_resource_data_show")));

		pre_button= static_cast<CButtonUI*>(m_pm.FindControl(_T("button_pre_student")));
		next_button= static_cast<CButtonUI*>(m_pm.FindControl(_T("button_next_student")));


		m_pNoteOwn = static_cast<COptionUI*>(m_pm.FindControl(_T("note_own")));

	
	
		m_pCloudRefresh = static_cast<CButtonUI*>(m_pm.FindControl(_T("cloud_notes_refresh")));
		
		m_SidebarWidth=570/theApp.m_screen_ratio;

		m_pMyPDFBook                     = static_cast<MyPDFBook*>(m_pm.FindControl(_T("MyPDFReader")));

		m_pBookLayout                    = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("MyPDFBookReader_layout")));


		/*Ĭ�ϼ�ͷΪѡ��״̬*/
		TNotifyUI msg;
		ArrowButtonClick();

		//m_cLog.EnableWriteLog(TRUE);

		CRect rc(100, 100, 200, 200);
		m_tooltip.Create(CWnd::FromHandle(this->m_hWnd));
		m_tooltip.AddTool(CWnd::FromHandle(m_pMyPDFBook->GetHWND()), TTS_ALWAYSTIP, &rc, IDT_TIP);

		m_tooltip.SetToolRect(CWnd::FromHandle(m_pMyPDFBook->GetHWND()), IDT_TIP, &rc);

		//�趨���ֵ���ɫ
		m_tooltip.SetTipTextColor(RGB(0,0,255));

		//�趨��ʾ�����ڿؼ���ͣ����ʱ��
		m_tooltip.SetDelayTime(150);

		// �������
		if (PDF_SupportsGestures())
		{
			GESTURECONFIG gc = {0,GC_ALLGESTURES,0};
			PDF_SetGestureConfig(GetHWND(),0,1,&gc,sizeof(GESTURECONFIG));
		}
		m_waitflag=FALSE;
		m_pNoteList->SetContextMenuUsed(true);

		//��ʼ�����ɻ��ʵĴ���
		m_freeLineFrame= new CFreeLineFrame(m_hWnd);
		m_freeLineFrame->Create(m_hWnd, _T("PdfToolFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		m_freeLineFrame->CenterWindow();
		m_freeLineFrame->ShowWindow(false);

		m_pdfToolFrame= new CPdfToolFrame(m_hWnd);
		m_pdfToolFrame->Create(this->GetHWND(), _T("LineNoteEditFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		//m_pdfToolFrame->
		//m_pdfToolFrame->CenterWindow();
		RECT rc1,rc2;
		GetClientRect(m_hWnd,&rc1);
		GetClientRect(m_pdfToolFrame->GetHWND(),&rc2);
		m_pdfToolFrame->SetWindowPos(NULL,rc1.right/2,rc1.bottom-rc2.bottom,rc2.right,rc2.bottom,0);
		m_pdfToolFrame->ShowWindow(false);

		m_iLineWidth=4;

		SetPageOperatorView(false);
		

		//Add By Ray 2018-10-22 ����Wnd
		m_th.m_wnd=m_hWnd;
		//m_pNoteList->SetItemRSelected(true);
		//Wait Dlg
// 		m_pProgramWait=(CProgramWait*)AfxBeginThread(RUNTIME_CLASS(CProgramWait),THREAD_PRIORITY_BELOW_NORMAL,0,0,NULL);
// 		m_pProgramWait->SuspendThread();
// 		m_pProgramWait->m_bShow=FALSE;
// 		m_pProgramWait->SetFlag(TRUE);
// 		m_pProgramWait->ResumeThread();
	    //  
		//m_cwnd.Attach(m_hWnd);
	}

	void CReaderFrame::SetLabelForNewNotes()
	{
		int size = m_pLabelOper->m_LabelList.size();
		if(size>=20)
		{
			CustomMessageBox(STRING_READERFRAME_TAG_NUM_LIMIT,MSG_TYPE_NOTICE,FALSE);
			return;
		}
		CLabelSetFrame* pLabelSetFrame = new CLabelSetFrame(m_pLabelOper);
		pLabelSetFrame->Create(m_hWnd, _T("LabelSetFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		pLabelSetFrame->CenterWindow();
		if (IDOK == pLabelSetFrame->ShowModal())
		{
			if(m_pLabelOper)
			{
				SetLabelView();
			}
			
		}


	}



	LRESULT CReaderFrame::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		if (m_pMyPDFBook != NULL)
		{
			m_pMyPDFBook->Close();
		}
		m_th.m_curl->Stop();
		bHandled = FALSE;
		return 0;
	}

	LRESULT CReaderFrame::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		
		if (m_pMyPDFBook != NULL)
		{
			m_pMyPDFBook->Destroy();
			m_pMyPDFBook = NULL;
		}

		m_pMyBook = NULL;

		bHandled = FALSE;

		return 0;
	}

	CReaderFrame::~CReaderFrame(void)
	{
		if (m_pBookInfo != NULL)
		{
			delete m_pBookInfo;
			m_pBookInfo = NULL;
		}
		if(m_noteDao !=NULL)
		{
			delete m_noteDao;
			m_noteDao =NULL;
		}
		if (p_newPdfInfo != NULL)
		{
			delete p_newPdfInfo;
			p_newPdfInfo = NULL;
		}
		if(m_pLabelOper)
		{
			delete m_pLabelOper;
			m_pLabelOper=NULL;
		}
		if(m_share_note_operator)
		{
			delete m_share_note_operator;
			m_share_note_operator=NULL;
		}
		if(m_pSeeNote)
		{
			delete m_pSeeNote;
			m_pSeeNote=NULL;
		}
		if(m_freeLineFrame)
		{
			delete m_freeLineFrame;
			m_freeLineFrame=NULL;
		}
		if(m_pdfToolFrame)
		{
			delete m_pdfToolFrame;
			m_pdfToolFrame = NULL;
		}


		/*
		if (m_pDownloadCloudNotes != NULL)
		{
		delete m_pDownloadCloudNotes;
		m_pDownloadCloudNotes = NULL;
		}

		if (m_pPageManageFrame != NULL)
		{
		delete m_pPageManageFrame;
		m_pPageManageFrame = NULL;
		}

		
		*/
		//m_cwnd.Detach();
	}

	void CReaderFrame::OnPrepare() {
	}

	void CReaderFrame::CloseFrame(){
		if (NULL!=m_pMyPDFBook)
		{
			int pageIndex = m_pMyPDFBook->GetPageNum();
			m_pBookInfo->recentNo = pageIndex;
			m_pBookDao->UpdateBookRecentNo(m_pBookInfo->bookId, pageIndex);
			//m_pBookDao->UpdateBookInfoInDB(m_pBookInfo->bookId);

			if (m_pTitleBookName)
				m_pTitleBookName->SetText(_T(""));

			WriteLog(OP_BOOK_CLOSE);

			m_pMyPDFBook->Close();
		}

		DuiLib::CPaintManagerUI::SetResourcePath(m_LastResPath);
		this->Close(0);
	}
	float CReaderFrame::GetCurrentRadio()
	{
		int x,y,dx,dy;
		float visibleRadio=1;
		m_pMyPDFBook->GetPageInfo(m_pMyPDFBook->GetPageNum(),x,y,dx,dy,visibleRadio);
		return visibleRadio;
	}
	int CReaderFrame::OpenBook( LPCTSTR szBookFile )
	{
		

		if(m_pBookInfo==NULL || m_pMyPDFBook==NULL) return -1;

		m_strBookName = szBookFile;
		int pos = m_strBookName.ReverseFind('\\');
		if(pos!=-1)
			m_strBookName = m_strBookName.Right(m_strBookName.GetLength() - pos - 1);
		pos = m_strBookName.ReverseFind('.');
		if(pos!=-1)
			m_strBookName = m_strBookName.Left(pos);

		m_hMainWnd = AfxGetMainWnd()->m_hWnd;

		m_cLog.WriteLog(_T("Open Book : %s"), szBookFile);

		
		if (m_pBookLayout) m_pBookLayout->SetVisible(false);

		CString sFileName = szBookFile;
		if (m_pTitleBookName)
			m_pTitleBookName->SetText(m_pBookInfo->bookName);

		if (m_BookType == PDF_Book)
		{
			m_pMyBook = m_pMyPDFBook;
			m_pBookLayout->SetVisible(true);
			//m_pMyPDFBook->m_pdf_view->SetRCPath(theApp.GetCurDir()+_T("RC"));

			CString strImage;
			//strImage.Format(_T("%s%s\\simple\\reader\\%s"), theApp.GetCurDir(),DuiLib::CSkinBuilder::GetSkinPath().GetData(), _T("pdfview_bg.png"));
			//m_pMyPDFBook->m_pdf_view->SetBKImagePath(strImage);
			int nRet = -1;//m_pMyPDFBook->m_pdf_view->OpenEncPDF(szBookFile,_T(""),0);

			m_pMyPDFBook->SetupCallBack((long)new_note_callback, (long)draw_note_callback,(long)delete_note_callback,(long)key_message_callback);
			char p[50];
			m_pBookInfo->strSecurityKey.copy(p, m_pBookInfo->strSecurityKey.size(), 0);//����5���������Ƽ����ַ���0�������Ƶ�λ��  
			*(p+m_pBookInfo->strSecurityKey.size()) = '\0';//Ҫ�ֶ����Ͻ�����


			nRet = m_pMyPDFBook->Open(szBookFile,p);
			if (nRet!=0)
			{
				//ret = m_pMyPDFBook->m_pdf_view->OpenCtrlPDF(szBookFile, _T(""), 0);
				m_pMyPDFBook->m_bOpen = FALSE;
				string StrData;
				RemoteOpenBookErrLog(m_pBookInfo->bookId,nRet,StrData);
				m_cLog.WriteLog(_T("Open Book End 0 !"));
				return -1;
			}else
			{
				string StrData;
				RemoteClaimBook(m_pBookInfo->bookId,StrData);
			}
			m_pMyPDFBook->m_bOpen = TRUE;
			m_pMyPDFBook->SetViewMode(VIEW_MODE_DOUBLEPAGE);//Add By Ray 20180529 ��ʼΪ˫ҳģʽ
			m_pMyPDFBook->GetReaderType();
			//�����鼮Ŀ¼
			m_cata_list= m_pBookDao->GetBookCatalogData(m_pBookInfo->bookId);
			//Add By Ray 20190515 ��Ŀ¼����
			if(m_cata_list.size()==0)
			{
				m_pShowCalaButton->SetEnabled(false);
			}
			
			//Add By Ray 20180530 ��ȡ������BOOKID DIR
			/*��ȡ���бʼǺ���Դ��������*/
			m_noteDao =new CNoteDao(m_pBookInfo->bookId);
			//CNoteDao noteDao(m_pBookInfo->bookId);
			//Modify By Ray 20180605 ���ģʽ����VIEW_MODE_DOUBLEPAGE��VIEW_MODE_SINGLEPAGE 
			
			GetNoteByPage(m_pBookInfo->lastPage);
			//������ʼҳ����Ŀ¼�ʼ�

			//ϰ���ȡ
			std::string Result;
			CBookDal bookDal;
			if(RemoteGetPageExercise(m_pBookInfo->bookId,Result)==200)
			{
				ListExercise list_exercise;
				
				ParsePageExercise(m_pBookInfo->bookId,Result,list_exercise);
				bookDal.DeleteBookExerciseByBookId(m_pBookInfo->bookId);
				bookDal.UpdateBookExerciseData(m_pBookInfo->bookId,list_exercise);
			}

			//������Դ������NoteInfoList
			double dh=0,dw=0;
			PDF_GetPageSize(m_pMyPDFBook->GetPageNum(),dh,dw);
			m_minRadio = GetCurrentRadio();
			bookDal.GetBookPageResourceData(m_pBookInfo->startPage,m_pBookInfo->bookId,m_pdfNoteInfoList_drawPdf,VIEW_MODE_DOUBLEPAGE,dh,dw);
			////����ϰ�Ⲣ����NoteInfoListAdd By Ray 2018-08-28
			bookDal.GetBookPageExerciseData(m_pBookInfo->startPage,m_pBookInfo->bookId,m_pdfNoteInfoList_drawPdf,VIEW_MODE_DOUBLEPAGE,dh,dw);
			
			m_noteDao->GetNoteInfosByPageNo(m_pBookInfo->lastPage,m_pBookInfo->bookId,m_pdfNoteInfoList_drawPdf,VIEW_MODE_DOUBLEPAGE);
		    //�Ʊʼ�
			m_pcloudNote=new CCloudNote(m_pBookInfo->bookId,theApp.m_UserInfo.strUserId,&m_th,m_hWnd);

			BOOL result=m_pMyPDFBook->SetPDFNoteInfoList(m_pdfNoteInfoList_drawPdf);

			//ȡ��������Դ
			m_extrs = new CExtras(m_pBookInfo->bookId,theApp.m_UserInfo.strUserId,&m_th,GetHWND());
			//m_extrs->Reload();


			if(!result)
			{
				CustomMessageBox(_T("���ӱʼ��б�ʧ��"),MSG_TYPE_NOTICE,FALSE);
			}
			//Add By Ray 2018-06-28
			//��ǩ
			m_pLabelOper=new CLabelOperation(m_pBookInfo->bookId,theApp.m_UserInfo.strUserId);
			if(theApp.AnalysisConnect())
				m_pLabelOper->DownloadAndSaveLabel();
			m_noteDao->GetAllLabelInfo(m_labelInfos);
		

			//�����ʼ�
			m_pShareNote=new CShareNote(m_pBookInfo->bookId,theApp.m_UserInfo.strUserId,&m_th,m_hWnd);
			//GetShareNote();
			//�ļ���
			//Add By Ray 2018-07-20
			m_pFolderControl = new CloudFolderControl(m_pBookInfo->bookId);
			//std::vector<CUserClassInfo*> m_classes;

			/*��ȡϰ��ҳ����Ϣ*/
			CExercisePageDao pageDao;
			m_pdfExercisePageInfos = pageDao.GetExercisePagesByBookId(m_pBookInfo->bookId);

			/*��ȡ�ļ�����Ϣ*/
			m_folderDao.GetNoteFolderList(m_pdfNoteFolderList, m_pBookInfo->bookId);
			UpdateNoteFolders();

			/*�����Ʊʼ���Ϣ*/
			//CCloudNotePackageDao packageDao;
			//packageDao.UpdatePackageErrorStateToReady(m_pBookInfo->bookId);
			

		}
		
		m_cLog.WriteLog(_T("Open Book End!"));

		return 0;
	}

#pragma endregion

# pragma region ����¼�
	LRESULT CReaderFrame::OnMouseMove( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bHandled )
	{
		POINT point = {lParam,wParam}, pointScreen = {0, 0};
		RECT rtToolBar= {0, 0, 0, 0};

		DWORD dwPos = (DWORD)lParam;
		int x = LOWORD(dwPos);
		int y = HIWORD(dwPos);

		m_ptMouse.x = point.x;
		m_ptMouse.y = point.y;

		RECT rc = m_pMyBook->GetPos();

		SystemParametersInfo(SPI_GETWORKAREA,NULL, &rtToolBar,NULL);//��ȡ�������򣬲�����������
		GetCursorPos(&pointScreen);
		rtToolBar.bottom = 30;

		rc.top = rc.bottom - 50;
		rc.bottom = rc.bottom + 10;


		if(IsZoomed(this->GetHWND())){
			BOOL bShow = PtInRect(&rc, pointScreen);
			UpdateToolBarVisiblity(bShow);
		}


		return FALSE;
	}
#pragma endregion

#pragma region ����������

#pragma region ȫ���л�

	void MyFullscreen( HWND my_win, bool full_screen )
	{
		HWND   hDesk;
		RECT   rc;

		if (full_screen)
		{
			hDesk   =   ::GetDesktopWindow();
			::GetWindowRect(   hDesk,   &rc   );

			::SetWindowPos(my_win,   NULL,   0,   0,   rc.right,   rc.bottom,   SWP_SHOWWINDOW);
		}
		else
		{
			SystemParametersInfo(SPI_GETWORKAREA,NULL, &rc,NULL);//��ȡ�������򣬲�����������

			::SetWindowPos(my_win,   NULL,   0,   0,   rc.right,   rc.bottom,   SWP_SHOWWINDOW | SWP_NOZORDER);
		}
	}

	void CReaderFrame::UpdateToolBarVisiblity(BOOL bShow)
	{
		
	}
#pragma endregion



#pragma endregion

#pragma region ��ఴť����

	void CReaderFrame::ReadCatalogItem(CBookmarkListUI* pBookmarkList, LVTocItem * item,CBookmarkListUI::BookmarkNode* parent)
	{
		LVTocItem * parentItem = item;
		
		for(int i=1;i<m_cata_list.size();i++)
		{
			textbook_catalogInfo info=m_cata_list.at(i);
			pBookmarkList->AddItem(info);

			//CBookmarkListUI::BookmarkNode* thisNode = pBookmarkList->AddNode(info.catalogName, info.startPage, parent, NULL);

		}
	}

	void CReaderFrame::ReadResToolItem(CResMarkListUI* pBookmarkList, textbook_catalogInfo *item,CResMarkListUI::BookmarkNode* parent, std::vector<textbook_catalogInfo_noteInfo>& noteinfos)
	{
		textbook_catalogInfo *parentItem = item;
		if (NULL == parentItem)
		{
			parentItem = new textbook_catalogInfo();
			CEnhancedBookImporter* pImporter = new CEnhancedBookImporter();
			parentItem->catalogInfos = pImporter->TestBook(m_pBookInfo->bookId);

			//CNoteDao noteDao;
			int resNum = m_noteDao->SelectCountNumOriginNoteByBookId(m_pBookInfo->bookId);
			/*û����Դ����ʾ��ԴĿ¼*/
			if(resNum == 0)
				return;
		}
		/*���û�и��ڵ㣨�����Ǹ��ĵ����Ͳ�֧�֣������˳�*/
		if (NULL == parentItem){
			return;
		}

		std::vector<textbook_catalogInfo>::iterator iter;
		for(iter = parentItem->catalogInfos.begin(); iter != parentItem->catalogInfos.end(); iter++)
		{
			textbook_catalogInfo *childItem = &(*iter);

			if(childItem != NULL)
			{
				int index = 0;
				CResMarkListUI::BookmarkNode* thisNode = pBookmarkList->AddNode(childItem->catalogName, childItem->startPage, parent, NULL, index);
				if(thisNode!=NULL)
				{
					ReadResToolItem(pBookmarkList,childItem,thisNode, noteinfos);
				}
			}
		}
		std::vector<textbook_catalogInfo_noteInfo>::iterator iter1;
		for(iter1 = parentItem->noteInfos.begin(); iter1 != parentItem->noteInfos.end(); iter1++)
		{
			int index = 0;
			CResMarkListUI::BookmarkNode* thisNode = pBookmarkList->AddNode(iter1->content, iter1->pageNo, parent, NULL, index, 1, iter1->resAddr, iter1->pdfId);
			iter1->index = index;
			noteinfos.push_back(*iter1);
		}
	}

	void CReaderFrame::ReadCatalogListAndNoteList()
	{
		//m_pNotesChoiceAll->Selected(false);
		m_pLabelButton1->SetVisible(false);

		m_pdfCatalogInfos.clear();
		CCatalogDao catalogDao;
		catalogDao.GetCatalogListByParentId(m_pdfCatalogInfos, m_pBookInfo->bookId, 0, 0);
		m_pNoteCatalogList->RemoveAll();
	
		std::vector<textbook_catalogInfo_ex>::iterator iter;
		//int cnt = 0;
		for(iter = m_pdfCatalogInfos.begin(); iter != m_pdfCatalogInfos.end(); iter++)
		{
			m_pNoteCatalogList->AddCatalogItem((*iter), m_SidebarWidth);
			//++cnt;
		}
		//cnt = m_pdfCatalogInfos.size();
	}

#pragma  endregion

#pragma region ������ʾ���ƺ���

	

	void CReaderFrame::ShowSideBar(int index,CString text)
	{
		//		m_pReadToolLayout->SetVisible(true);
		//		m_pReadMangeLayout->SetVisible(true);
	
		m_pSidebarLayout->SetVisible(true);
		m_pSidebarLayout->SetFixedWidth(m_SidebarWidth);
		//m_pSidebarTitleBar->SetVisible(true);
		m_pNoteTypeLayout->SetVisible(true);
		m_pSidebarTabLayout->SelectItem(index);
		//m_pSidebarTitle->SetText(text);
		
		//m_pMyPDFBook->RedrawLines();
	}

	void CReaderFrame::InitNotesLables()
	{

	}
	void CReaderFrame::ShowShareNote(int width,BOOL isOperator/* =FALSE */)
	{
		if(m_bCancel || m_bImport || m_bMove)
			isOperator=TRUE;
		m_pNoteList->RemoveAll();
		if(m_pShareNote)
		{
			COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes_one")));
			COptionUI* myOptionMove=static_cast<COptionUI*>(m_pm.FindControl(_T("share_note_move")));
			COptionUI* share_back_note=static_cast<COptionUI*>(m_pm.FindControl(_T("share_back_note")));
			if(m_pShareNote->m_current_Firstfolder_list.size()==0)
			{
				if(!m_pOptionSearchShare->IsSelected())
					m_pOptionSearchShare->SetEnabled(false);
				import->SetEnabled(false);
				myOptionMove->SetEnabled(false);
				share_back_note->SetEnabled(false);
				m_pVShowNoData->SetVisible(true);
				m_pMoreNoteBtn->SetVisible(false);

			}
			else
			{
				m_pOptionSearchShare->SetEnabled(true);
				import->SetEnabled(true);
				myOptionMove->SetEnabled(true);
				share_back_note->SetEnabled(true);
				m_pVShowNoData->SetVisible(false);
				m_pMoreNoteBtn->SetVisible(true);
			}
			for (int i=0;i<m_pShareNote->m_current_Firstfolder_list.size();i++)
			{
				CShareFolder* folderInfo = m_pShareNote->m_current_Firstfolder_list.at(i);
				if(folderInfo->m_type==0)
				{
					if(folderInfo->m_note_list.size()>=1)
					{
						CPDFNoteInfo* info = folderInfo->m_note_list.at(0);
						if(ComboShareSelect->GetCurSel()==1 && GetUserType()==1)
							m_pNoteList->SetShareNameDiplay(TRUE);
						m_pNoteList->AddItem(*info,width,isOperator);
						m_pNoteList->SetShareNameDiplay(FALSE);
					}
				}
				else
				{
					m_pNoteList->AddFloder(folderInfo,width,i,true,isOperator);
				}
			}
		}
		CButtonUI* myBtnNew=static_cast<CButtonUI*>(m_pm.FindControl(_T("share_noyte_new_folder")));
		COptionUI* myOptionMove=static_cast<COptionUI*>(m_pm.FindControl(_T("share_note_move")));
		COptionUI* share_back_note=static_cast<COptionUI*>(m_pm.FindControl(_T("share_back_note")));
		if(ComboShareSelect->GetCurSel()==0)
		{
			myOptionMove->SetVisible(false);
			//myBtnNew->SetVisible(false);
			share_back_note->SetVisible(true);
			if(GetUserType()==2)
				myBtnNew->SetVisible(false);
		}
		else
		{
			if(GetUserType()==2)
			{
				myOptionMove->SetVisible(false);
				myBtnNew->SetVisible(false);
				m_ctrlClass->SetVisible(false);
			}
			else
			{
				if(theApp.m_target_info.target_list.size()<=1)
					m_ctrlClass->SetVisible(false);
				myOptionMove->SetVisible(true);
				myBtnNew->SetVisible(true);
				

			}
			share_back_note->SetVisible(false);
		}
		if(GetUserType()==1)
		{
			if(theApp.m_target_info.target_list.size()<=1)
				m_ctrlClass->SetVisible(false);
			else
				m_ctrlClass->SetVisible(true);
			m_ctrMulu->SetVisible(true);
		}
		else
		{
			m_ctrlClass->SetVisible(false);
			m_ctrMulu->SetVisible(false);
		}

		if(m_bShareSearch)
		{
			m_ctrlClass->SetVisible(false);
		}
	}
	void CReaderFrame::UpdateBookNotes(int width,BOOL isOperator)
	{
		if(isUpload || isDownload || isShare ||isDelete)
			isOperator=TRUE;
		//��ʾ�ʼ�
		if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW)
		{
			ShowAndHideMultyOption(NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW);
			//m_pdfNoteInfoList.clear();
			m_pNoteList->RemoveAll();
			
			if(m_pdfNoteInfoList.size()==0)
			{
				m_pVShowNoData->SetVisible(true);
			}
			else
				m_pVShowNoData->SetVisible(false);
			//int page=m_pMyPDFBook->GetPageNum();
			//noteDao.GetNoteInfosByPageNo(page-1,m_pBookInfo->bookId,m_pdfNoteInfoList,m_pMyPDFBook->GetViewMode());
			for(int i=0;i<m_pdfNoteInfoList.size();i++)
			{
				CPDFNoteInfo* info = m_pdfNoteInfoList.at(i);
				if (info->noteOrigin==ORIGIN_USER && info->isFather==1)
				{
					m_pNoteList->AddItem(*info,width,isOperator);
				}
				
			}
			if(m_pNoteCatalogList->IsVisible())
			{
				ReadCatalogListAndNoteList();
			}
		}
		else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
		{
			ShowAndHideMultyOption(NOTE_SHOW_TYPE::CLOUD_NOTE_SHOW);
 			if(m_pcloudNote)
 			{
 				m_pNoteList->RemoveAll();
				if(m_pcloudNote->GetCloudListSize()==0)
					m_pVShowNoData->SetVisible(true);
				else
					m_pVShowNoData->SetVisible(false);
 				for(int i=0;i<m_pcloudNote->GetCloudListSize();i++)
 				{
 					CPDFNoteInfo* info = m_pcloudNote->GetNoteInfoByIndex(i);
 					m_pNoteList->AddItem(*info,width,isOperator);
 				}
			}
			
		}
		else if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
		{
			ShowShareNote(m_SidebarWidth);
		}
	}

	void CReaderFrame::UpdateNoteFolders()
	{
		
	}

	void CReaderFrame::UpdateBookRes(int type)
	{
		
		m_pResList->RemoveAll();
		ExtrasType extrasList = m_extrs->GetCurrentListByType();
		if(extrasList.extrasList.size()==0)
		{
			m_pVShowNoResource->SetVisible(true);
		}
		else
		{
			m_pVShowNoResource->SetVisible(false);
			for (int i=0;i<extrasList.extrasList.size();i++)
			{
				CExtrasData& info = extrasList.extrasList.at(i);
				m_pResList->AddItem(info);
			}
		}
		
	}

	void CReaderFrame::UpdateCloudNotePackages(int noteFlag)
	{
		g_noteFlag = noteFlag;

		m_pCloudNotesChoiceAll->Selected(false);
		m_pCloudNoteItemListLayout->SetVisible(false);
		m_pCloudNotePackageListLayout->SetVisible(true);
		


		

		StartDownloadNotesFromCloud();

		return;
	}

	/*void CReaderFrame::UpdateCloudNotePackagesList()
	{
		m_pCloudNotesChoiceAll->Selected(false);
		m_CloudNotePackageList.clear();
		if (m_pCloudNoteList == NULL)
			return;

		m_pCloudNoteList->RemoveAll();
		m_NoteTypeMenuCheckInfo.clear();

		m_pCloudNoteItemListLayout->SetVisible(false);
		m_pCloudNotePackageListLayout->SetVisible(true);

		CCloudNotePackageDao packageDao;
		m_CloudNotePackageList = packageDao.GetAllNotePackageByBookId(g_noteFlag, m_pBookInfo->bookId);
		if (m_CloudNotePackageList.empty())
			return;

		std::vector<CCloudNotePackage>::iterator iter;
		for (iter = m_CloudNotePackageList.begin(); iter != m_CloudNotePackageList.end(); iter++)
		{
			m_pCloudNoteList->AddItem(*iter, m_SidebarWidth);
		}
	}*/

	void CReaderFrame::UpdateCloudNotePackagesList()
	{
		m_CloudNotePackageList.clear();
		if (m_pCloudNoteList == NULL)
			return;

		m_pCloudNoteList->RemoveAll();

		m_pCloudNoteItemListLayout->SetVisible(false);
		m_pCloudNotePackageListLayout->SetVisible(true);

		CCloudNotePackageDao packageDao;
		m_CloudNotePackageList = packageDao.GetAllNotePackageByBookId(g_noteFlag, m_pBookInfo->bookId);
		if (m_CloudNotePackageList.empty())
			return;

		std::vector<CCloudNotePackage>::iterator iter;
		for (iter = m_CloudNotePackageList.begin(); iter != m_CloudNotePackageList.end(); iter++)
		{
			//m_pCloudNoteList->AddItem(*iter, m_SidebarWidth);
		}

		if (m_pDownloadCloudNotes == NULL)
			m_pDownloadCloudNotes = new CDownloadCloudNote(this->m_hWnd);
		m_pDownloadCloudNotes->DownloadNotePackageByBookId(g_noteFlag, m_pBookInfo->bookId);
	}

	void CReaderFrame::UpdateOneCloudNoteStatus(int id)
	{
		CCloudNotePackageDao PackageDao;
		CCloudNotePackage notePackage = PackageDao.GetNotePackageById(id);
		if(notePackage.id != 0 && notePackage.iState == 1)
		{
			if (m_pDownloadCloudNotes == NULL)
				m_pDownloadCloudNotes = new CDownloadCloudNote(this->m_hWnd);
			m_pDownloadCloudNotes->ImportCloudNotePackage(notePackage.strFileName, notePackage.strNoteId);
		}

		if (m_pCloudNoteList)
			m_pCloudNoteList->RefreshItemState(id);
	}

	void CReaderFrame::RemoveNoteInfoFromListById(int id)
	{
		vector<CPDFNoteInfo*>::iterator iter;
		for(iter=m_pdfNoteInfoList.begin();iter!=m_pdfNoteInfoList.end();)
		{
			if((*iter)->id==id)
			{
				delete (*iter);
				*iter=NULL;
				m_pdfNoteInfoList.erase(iter);
				break;
			}
			else
			{
				iter++;
			}
		}
	}

	void CReaderFrame::RemoveLabelInfoFormlistById(int id)
	{
		vector<CLabelInfo*>::iterator iter;
		for(iter=m_labelInfos.begin();iter!=m_labelInfos.end();)
		{
			if((*iter)->id==id)
			{
				m_labelInfos.erase(iter);
				break;
			}
			else
			{
				iter++;
			}
		}
	}

	void CReaderFrame::RemoveNoteInfoFromListByPdfId(int pdfId)
	{
		vector<CPDFNoteInfo*>::iterator iter;
		for(iter=m_pdfNoteInfoList.begin();iter!=m_pdfNoteInfoList.end();)
		{
			if((*iter)->pdfId==pdfId)
			{
				CString strPath = (*iter)->GetStringByNoteText();
				CString strFileName = theApp.m_strUserPath + strPath;
				DeleteFile(strFileName);
				m_pdfNoteInfoList.erase(iter);
				break;
			}
			else
			{
				iter++;
			}
		}
	}
#pragma endregion

#pragma region ��ҳ���
	void CReaderFrame::DoReaderCommand( LVDocCmd cmd, int param)
	{
		if (NULL != m_pMyBook ){
			m_pMyBook->DoCommand(cmd, 1);
		}
	}

	void  CReaderFrame::ReaderPageUp(  )
	{
		DoReaderCommand(DCMD_PAGEUP,1);
		
	}

	void  CReaderFrame::ReaderPageDown(  )
	{
		DoReaderCommand(DCMD_PAGEDOWN,1);
	}

#pragma  endregion

#pragma region ����¼�
	void CReaderFrame::CloseApplication(int type)
	{
		if(type==0)
		{
			
			int ret = CustomMessageBox(_T("ȷ��Ҫ�˳���"),MSG_TYPE_YESNO);
			if(ret != IDOK)
			{
				return;
			}
			
		}
		else if(type==1)
		{
			//���Token��¼
			CUserDao dao;
			dao.DeleteUserToken();
			//////////////
			CustomMessageBox(STRING_MSG_LOGIN_TIMEOUT,MSG_TYPE_NOTICE,FALSE);
		}
		else if(type==2)
		{
			//���Token��¼
 			CUserDao dao;
 			dao.DeleteUserToken();
			//////////////
			CustomMessageBox(STRING_MSG_DATATIME_ERROR,MSG_TYPE_NOTICE,FALSE);
		}
		
		CBookDal book;
		int nPage =m_pMyBook->GetPageNum();
		book.SetLastPage(m_pBookInfo->bookId,theApp.m_UserInfo.strUserId,nPage);
		if (NULL!=m_pMyPDFBook)
		{
			int pageIndex = m_pMyPDFBook->GetPageNum();
			m_pBookInfo->recentNo = pageIndex;
			m_pBookDao->UpdateBookRecentNo(m_pBookInfo->bookId, pageIndex);
			
			m_pMyPDFBook->Close();
		}
		CMainFrame *pMain=(CMainFrame*) AfxGetApp()->m_pMainWnd;
// 		if(!theApp.m_bIsNeedReLogin)
// 		{
// 			
// 			pMain->m_pMainFrame->m_pWke->Close();
// 		}
		
		
		
		this->Close(0);


		if(g_hUploadLogThread != NULL)
		{
			SetEvent(g_clogManager.m_hThreadEvent);
			DWORD dw = WaitForSingleObject(g_hUploadLogThread, 10000);
			if (dw == WAIT_TIMEOUT)
				TerminateThread(g_hUploadLogThread, (DWORD)-1);
		}
		
		Sleep(1);
		if(type>0)
			theApp.AutoLogOut();
		PostQuitMessage(0);
	}
#pragma region

	CPDFNoteInfo* CReaderFrame::GetPDFInfoByPdfId(int pdfId)
	{
		vector<CPDFNoteInfo*>::iterator iter;
		for(iter=m_pdfNoteInfoList_drawPdf.begin();iter!=m_pdfNoteInfoList_drawPdf.end();iter++)
		{
			if((*iter)->id==pdfId && (*iter)->noteOrigin==ORIGIN_USER )
			{
				return *iter;
			}
		}
		CPDFNoteInfo * pNoteInfo = m_noteDao->GetNoteInfoById(pdfId);
		return pNoteInfo;
	}

	CString CReaderFrame::GetFilePath(long line_id)
	{
		CString path=_T("");

		CPDFNoteInfo *pCurrentLine = GetPDFInfoByPdfId(line_id);
		if (NULL != pCurrentLine)
		{
			if (pCurrentLine->noteOrigin == ORIGIN_SYSTEM)
				path = theApp.m_BookResPath;
			else
				path = theApp.m_ResourcePath;

			path += pCurrentLine->GetStringByNoteText();
			pCurrentLine=NULL;
		}
		return path;
	}

	//����ֵ��>0:����,�����ӵıʼǵ�id��0�����ӱ�ȡ����-1������
	int CReaderFrame::OnUpdateTextLine( int pdfId )
	{
		// ǰ����Ҫ�����ݿ��� ȡ
		CPDFNoteInfo *p_pdfNoteInfo = GetPDFInfoByPdfId(pdfId);
		if (NULL==p_pdfNoteInfo)
		{
			return -1;
		}
		//ShowEditNoteFrame(p_pdfNoteInfo);
		return 0;
	}

	//����ֵ��>0:����,�����ӵıʼǵ�id��0�����ӱ�ȡ����-1������
	int CReaderFrame::CopyFileToDest( CString& fileName,CString& newFile )
	{
		//�ļ������Լ��
		if (HDR_FileExist(newFile)){
			CString message = newFile +_T("�Ѿ����ڣ��Ƿ񸲸ǣ�");
			int ret = AfxMessageBox(message,MB_TOPMOST|MB_YESNO|MB_ICONEXCLAMATION);
			//�����ǣ����˳�
			if (IDYES != ret){
				return 0;
			}
		}

		//�����ļ������Ŀ���ļ����ڽ����ǡ�
		if (!::CopyFile(fileName, newFile, FALSE))
		{
			AfxMessageBox(_T("�����ļ�ʧ�ܡ�"),MB_TOPMOST|MB_OK|MB_ICONEXCLAMATION);
			return 0;
		}
		return 1;
	}


	AttachInfo CReaderFrame::InsertAttach(CPDFNoteInfo* pInfo, bool bDelete)
	{
		AttachInfo attachInfo;
		
		return attachInfo;
	}

	void CReaderFrame::DeleteNoteFromDBAndPDFList(CPDFNoteInfo* info)
	{
		vector<CPDFNoteInfo*>::iterator iter;
		for(iter=m_pdfNoteInfoList.begin();iter!=m_pdfNoteInfoList.end();iter++)
		{
			if((*iter)->pdfId == info->pdfId)
			{
				m_pdfNoteInfoList.erase(iter);
				break;
			}
		}
	}

	
	void CReaderFrame::MakeAttachNote(CPDFNoteInfo* info)
	{
		CString strFileType =info->content;
		CString strFilePath;
		CString strDetectPath =strFileType.Mid(0,1);
// 		if(strDetectPath=L""/*&&strDetectPath.Mid(0,1)==L"\\"*/)
// 		{
// 			//��ʾ·������ת��
// 			return;
//		}
		int pos = info->content.ReverseFind('.');
		if (pos > 0)
			strFileType = info->content.Right(strFileType.GetLength() - pos - 1);
		SYSTEMTIME tmSys;
		GetLocalTime(&tmSys);
		CTime tm3(tmSys);
		__int64 tmDst = __int64(tm3.GetTime())*1000 + tmSys.wMilliseconds;
		tmDst= tmDst+600000;
		CString strSignExp=L"",strSign=L"";
		strSignExp.Format(L"%lld",tmDst);
		CString strFileName =strSignExp;
		strFilePath.Format(L"%s%s\\%s\\%s.%s", theApp.m_strUser_Path,theApp.m_UserInfo.strUserId,m_pBookInfo->bookId,strFileName,strFileType);
		CString strSaveName;
		strSaveName.Format(L"\\source\\user\\%s\\%s\\%s.%s",theApp.m_UserInfo.strUserId,m_pBookInfo->bookId,strFileName,strFileType);
		//���������ϼв�����·��
		if(info->pdfNoteType ==NoteLink)
		{
			CopyFile(theApp.GetCurDir()+info->content,strFilePath,TRUE);
		}
		else
		{
			CopyFile(info->content,strFilePath,TRUE);
		}
		
		info->content =strSaveName;
		CString StrPoint;
		Point2Str(info->coord_pt,StrPoint);
		info->coord=StrPoint;
		info->isFather=TRUE;
	}

	void CReaderFrame::UpdateDBAndPDFList(CPDFNoteInfo* info,bool isShow,bool isMove)
	{
		SetNeedReloadDB();
		//�������޸ıʼ�
		CString strMsg = _T("");
		//CNoteDao Note(m_pBookInfo->bookId);
		CPDFNoteInfo* p_Info=g_pFrame->GetPDFInfoByPdfId(info->id);
		info->catalogIndex = info->pageIndex-1;
		if(p_Info!=NULL)
		{

			//�޸ıʼ�
			strMsg.Format(_T("�޸ıʼǣ�id=%d"), p_Info->id);
			WriteLog(OP_BOOK_NOTE_EDIT, strMsg);
			//Add By Ray
			//2019-05-23 ���޸ıʼǹ���
// 			if(info->pdfNoteType==NoteFile || info->pdfNoteType==NoteImage || info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteVideo||info->pdfNoteType ==NoteLink || info->pdfNoteType==NoteDoc || info->pdfNoteType==NotePpt || info->pdfNoteType==NoteExcel || info->pdfNoteType==NotePdf )//�����ʼ�
// 			{
// 				MakeAttachNote(info);
// 			}
			info->isCloud=FALSE;
			if(!isMove)
			{
				CTime tm=CTime::GetCurrentTime();
				CString str=tm.Format("%Y-%m-%d %H:%M:%S");
				info->updateTime=str;
			}
			else
			{
				CTime tm=CTime::GetCurrentTime();
				CString str=tm.Format("%Y-%m-%d %H:%M:%S");
				info->moveTime=str;
			}
			BOOL bUpdate = m_noteDao->UpdateNoteInfo(*info);
			if (!bUpdate)
			{
				int i = 0;
				i++;
			}
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_MODIFY_NOTE);
			int nPage =  m_pMyPDFBook->GetPageNum();
			CString strPage;
			strPage.Format(L"%d",nPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_WAY,L"1");
			CString strNoteLocalID;
			strNoteLocalID.Format(L"%d",info->id);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
			if(info->pdfNoteType==NoteFreedom||info->pdfNoteType==NoteLine)
			{
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
			}else
			{
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,info->coord);
			}
			int nType=0;

			nType =GetLogNoteType(info->pdfNoteType);
			CString strType;
			strType.Format(L"%d",nType);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,info->noteText);
			CString strLabeData=L"";
			for(int nNum=0;nNum<info->lableInfos.size();nNum++)
			{
				CLabelInfo label =info->lableInfos.at(nNum);
				strLabeData +=label.lableName;
				if(nNum!=info->lableInfos.size()-1)
				{
					strLabeData +=L"��";
				}
			}
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,strLabeData);
			CString strData=info->content;

			strData.Replace(_T("\\"),_T("\\\\"));
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,strData); 
			theApp.m_EventLog.MakeJsonFormat();
			////////////////

		}
		else
		{
			//Add By Ray 2018-07-06
			//�����ʼ�	

			double width;
			double heihgt;
			PDF_GetPageSize(info->pageIndex,width,heihgt);
			info->pageWidth=(int)width;
			info->pageHeight=(int)heihgt;
			info->noteOrigin=ORIGIN_USER;
			info->ServerID =-1;
			info->bookId=m_pBookInfo->bookId;
			if(info->pdfNoteType==NoteFile || info->pdfNoteType==NoteImage || info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteVideo||info->pdfNoteType ==NoteLink || info->pdfNoteType==NoteDoc || info->pdfNoteType==NotePpt || info->pdfNoteType==NoteExcel || info->pdfNoteType==NotePdf )//�����ʼ�
			{
				MakeAttachNote(info);
			}
			else if(info->pdfNoteType==NoteTextBox)//�ı��ʼ�
			{
				CString StrPoint;
				Point2Str(info->coord_pt,StrPoint);
				info->coord=StrPoint;
				info->isFather=TRUE;
			}
			//Add By Ray 2018-06-01��Ҫ�޸�
			//CNoteDao NoteDao(m_pBookInfo->bookId);
			
			long id=m_noteDao->AddNoteInfo(*info);
			info->id=id;
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_CREATE_NOTE);
			int nPage =  m_pMyPDFBook->GetPageNum();
			CString strPage;
			strPage.Format(L"%d",nPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_MODIFY_WAY,L"1");
			CString strNoteLocalID;
			strNoteLocalID.Format(L"%d",id);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
			
			if(info->pdfNoteType==NoteFreedom||info->pdfNoteType==NoteLine)
			{
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
			}else
			{

				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,info->coord);
			}
			int nType=0;

			nType =GetLogNoteType(info->pdfNoteType);
			CString strType;
			strType.Format(L"%d",nType);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,info->noteText);
			CString strLabelTag=L"";
			for(int nNum=0;nNum<m_pLabelOper->m_LabelList.size();nNum++)
			{
				
				CLabelInfo &LabelInfo = *m_pLabelOper->m_LabelList.at(nNum);
				if(LabelInfo.bUse ==TRUE)
				{
					//��������Ӧ��
					strLabelTag+=LabelInfo.lableName;
					if(nNum!=m_pLabelOper->m_LabelList.size()-1)
					{
						strLabelTag+=L",";
					}
				}
			}
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,strLabelTag);
			CString strData=info->content;

			strData.Replace(_T("\\"),_T("\\\\"));
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,strData); 
			theApp.m_EventLog.MakeJsonFormat();
			////////////////
			strMsg.Format(_T("���ӱʼǣ�id=%d"), id);
			WriteLog(OP_BOOK_ADD_NOTE, strMsg);
			
		
		}
		if(!isMove)
			m_pLabelOper->SaveLabelToNote(info->id);
		if(isShow)
		{
			if(m_pSidebarTabLayout->GetCurSel()==2)
			{
				GetNoteByCataIndex(m_current_mulu_index);
			}
			else if(m_pSidebarTabLayout->GetCurSel()==1)
			{
				UpdateBookRes();
			}
		}
		g_pFrame->ShowMarkButtonClick(TRUE);
		m_nRedrawTime =3;
		SetTimer(m_hWnd,1,1000,NULL);
		m_pMyPDFBook->RedrawLines();
	}

	void CReaderFrame::UpdateTextBoxAfterEditByPdfId(CPDFNoteInfo* info, int pdfId, CString strText)
	{
		CPDFNoteInfo* pInfo = GetPDFInfoByPdfId(pdfId);
		if (pInfo == NULL)
		{
			info->noteOrigin = ORIGIN_USER;
			info->content = strText;
			info->bookId = m_pBookInfo->bookId;
			info->lableInfos = m_labelInfos;
			long id=m_noteDao->AddNoteInfo(*info);
			info->id=id;
			//g_pFrame->m_pdfNoteInfoList.push_back(info);
			AddNewNote2List(g_pFrame->m_pdfNoteInfoList, *info);
		}
		else
		{
			vector<CPDFNoteInfo*>::iterator iter = m_pdfNoteInfoList.begin();
			for (; iter != m_pdfNoteInfoList.end(); ++iter)
			{
				if ((*iter)->pdfId == pdfId)
				{
					(*iter)->content = strText;
					BOOL bUpdate = m_noteDao->UpdateNoteInfo(**iter);
					break;
				}
			}
		}

		//		UpdateDBAndPDFList(pNoteInfo, true);
		if(m_pSidebarTabLayout->GetCurSel()==2)
			UpdateBookNotes(m_SidebarWidth);
		else if(m_pSidebarTabLayout->GetCurSel()==1)
			UpdateBookRes();
	}


	//����ֵ��>0:����,�����ӵıʼǵ�id��0�����ӱ�ȡ����-1������
	int CReaderFrame::OnDrawLineFinish(CPDFNoteInfo* info){
		if (NULL==info)
		{
			return 0;
		}
		//SetNeedReloadDB();
		// add success
		info->bookId = m_pBookInfo->bookId;
		info->noteOrigin=ORIGIN_USER;
		switch (info->pdfNoteType)
		{
		case NoteLine:
			info->lineWidth=2;
			UpdateDBAndPDFList(info,true);
			break;
		case NoteFile:
		case NoteImage:
		case NoteVideo:
		case NoteAudio:
			{
				CString fileName=info->GetStringByNoteText();
				CFileStatus fs;
				if (CFile::GetStatus(fileName, fs))
				{
					if (fs.m_size > 30 * 1024 * 1024)
					{
						m_pMyPDFBook->DeleteComment(info->pdfId,1);

						/*ɾ���б�*/
						RemoveNoteInfoFromListById(info->id);

						m_noteDao->DeleteNoteInfo(info->id);
						CustomMessageBox(_T("���ӵ���Դ�ļ������������(30M),������ѡ��!"),MSG_TYPE_NOTICE,FALSE);
					}
					else
					{
						AttachInfo attach = InsertAttach(info);
						if (attach.Success)
						{
							UpdateDBAndPDFList(info,true);
						}
					}
				}
			}
			break;
		case NoteFreedom:
			info->content=_T("���ɻ���");
			UpdateDBAndPDFList(info,true);
			break;
		case NoteTextBox:
			UpdateDBAndPDFList(info, true);
			break;
		case NoteNone:
			m_currentSelectInfo=info;
		default:
			break;
		}
	}

	//����ֵ��1:������0��ɾ����ȡ����-1������
	int CReaderFrame::OnDeleteNoteFinish(int pdfId){
		if (pdfId==-1)
		{
			//ɾ������ע�ͣ�Ŀǰ����Ҫ�������
		}else
		{
			// 			int ret = AfxMessageBox(_T("�Ƿ�Ҫɾ���ñʼǣ�"), MB_YESNO);
			// 			if (ret != IDYES)
			// 			{
			// 				return 0;
			// 			}
			m_tip.Hide();
			RemoveNoteInfoFromListByPdfId(pdfId);
			m_noteDao->DeleteNoteInfoBypdfId(m_pBookInfo->bookId,pdfId);

			if(m_pSidebarTabLayout->GetCurSel()==2)
			{
				UpdateBookNotes(m_SidebarWidth);
			}
			else if(m_pSidebarTabLayout->GetCurSel()==1)
			{
				UpdateBookRes();
			}
			m_tip.Display();
		}
		return 1;
	}

	int CReaderFrame::OnNoteClicked(long note_id){
		/*g_cur_note = note_id;
		CNoteLine *pCurrentLine = NULL;

		for(int i=0;i<m_noteLineList.GetCount(); i++)
		{
		CNoteLine *pNote = m_noteLineList.GetLine(i);
		if (pNote->m_recordId==g_cur_note)
		{
		pCurrentLine = pNote;
		break;
		}
		}

		if (NULL==pCurrentLine)
		{
		return 0;
		}

		if (pCurrentLine->m_noteType==NOTES_TEXT)
		{
		CEditNoteFrame *editNoteFrame = new CEditNoteFrame(pCurrentLine, &m_labelInfos);
		editNoteFrame->Create(m_hWnd, _T("EditNoteFrame1"), UI_WNDSTYLE_DIALOG, WS_EX_TOPMOST, 0,0,0, 0, NULL);
		editNoteFrame->CenterWindow();
		if (IDOK!=editNoteFrame->ShowModal())
		{
		return 0;
		}
		/*TODO:��ҪSAVE��*/
		//}
		/*else if (NOTES_IMAGE == pCurrentLine->m_noteType
		||  NOTES_AUDIO== pCurrentLine->m_noteType
		|| NOTES_VIDEO == pCurrentLine->m_noteType
		|| NOTES_URL == pCurrentLine->m_noteType
		|| NOTES_FILE == pCurrentLine->m_noteType)
		{
		CString fileName;
		fileName.Format(_T("%s"), pCurrentLine->m_bookText.c_str());
		HDR_WindowShellOpen(this->GetHWND(),fileName,NULL,NULL);
		}

		return 0;

		/*
		if (g_cur_note==-1)
		{
		UpdateLabel(NULL);
		return 0;
		}

		for(int i=0;i<m_noteLineList.GetCount(); i++)
		{
		CNoteLine *pNote = m_noteLineList.GetLine(i);
		if (pNote->m_recordId==g_cur_note)
		{
		UpdateLabel( &(pNote->m_pLableList) );
		break;
		}
		}*/

		return 0;
	}

#pragma region ��Ϣ����

	/************************************************************************
	* ���ɽ��������еĵ���¼�b
	************************************************************************/
	void  CReaderFrame::ClickEvent( TNotifyUI &msg )
	{
		CDuiString name = msg.pSender->GetName();
		CString sName = name.GetData();
		CString btn_name=sName.Mid(0,15);
		if(btn_name==_T("one_lable_click"))
		{
			CString strId=sName.Mid(btn_name.GetLength(),sName.GetLength()-btn_name.GetLength());
			int id=_wtoi(strId.GetBuffer());
			strId.ReleaseBuffer();
			if(m_pLabelOper)
			{
				m_pLabelOper->ModifyLabelStatus(id);
				SetLabelView();
			}
			return;
		}
		if( msg.pSender == m_pCloseBtn ) {
			WriteLog(OP_QUIT);
			CloseApplication();
			return;
		}else if( msg.pSender == m_pMinBtn ) {
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, NULL);
			AfxGetMainWnd()->PostMessageW(WM_SYSCOMMAND,SC_MINIMIZE,NULL);
			return;
		}
		else if( msg.pSender == m_pMaxBtn ) {
			View_Size_Max();
			return;
		}
		else if( msg.pSender == m_pBackButton ) {
			WriteLog(OP_BACK);
			BackButtonClick(msg);
			return;
		}
		else if (msg.pSender->GetName() == _T("tool_huabi"))
		{
			m_curSelNote=-1;
			ShowFreeLineFrame();
			m_pMyPDFBook->RedrawLines();
			return;
		}
		else if (msg.pSender->GetName() == _T("tool_wenbenkuang"))//�ı��ʼ�
		{
			
			m_curSelNote=-1;
			OpenTextNoteFrame(NULL);
			return;
		}
		else if(msg.pSender->GetName()==_T("tool_fujian"))
		{
			m_curSelNote=-1;
			OpenAttachFileNoteFrame(NULL);
			return;
		}
		else if( msg.pSender == m_pShowMarkButton ) {
			
			ShowMarkButtonClick(); return;
		}
		else if( msg.pSender == m_pHideMarkButton ) {

			ShowMarkButtonClick(); return;
		}
		else if( msg.pSender->GetName() == _T("pdf_zoom_in")) {//�Ŵ�PDF

			DoReaderCommand(DCMD_ZOOM_IN); 
			return;
		}
		else if( msg.pSender->GetName() == _T("pdf_zoom_out")) {//��СPDF
			float radio = GetCurrentRadio();
			if(m_minRadio-radio>0.05)
				DoReaderCommand(DCMD_ZOOM_OUT);
			return;
		}
else if( msg.pSender == m_pFullscreenButton ) {
			WriteLog(OP_FULL_SCREEN);
			FullScreenButtonClick(msg); return;
		}else if( msg.pSender == m_show_double_page ) {
			changeShowMode(); return;
		}
		else if( msg.pSender == m_show_single_page ) {
			changeShowMode(); return;
		}
		else if( msg.pSender == m_pShowCalaButton ) {
			
			showReadTool(READ_TOOL_SHOW::CATALOGUE);
			return;
		}else if( msg.pSender == m_pShowNoteButton ) {
			showReadTool(READ_TOOL_SHOW::NOTELIST);
			return;
		}
		else if( msg.pSender == m_pShowWorkButton ) {

				//ShowBrowser(2,m_pBookInfo->strExercise_URL);
				//Modify By Ray 2019-05-22
			    //ϰ��302��ת
			   //Add By Ray 2019-06-11 ��ȡ��ӦĿ¼
				
				if(NetWorkAndTokenCheck())
				{
					CWebviewFrame* web = new CWebviewFrame(theApp.m_strUserConfig.strExercise_url,0,L"",DO_EXERCISE,m_pBookInfo->bookId);
					web->Create(this->GetHWND(), _T("WebviewFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
					web->CenterWindow();
					web->ShowWindow();
				}
			
			return;
		}else if( msg.pSender == m_pShowSourceButton ) {
			
				showReadTool(READ_TOOL_SHOW::RESOURCELIST);
				return;
			
			
		}
		else if (msg.pSender == m_pResToolButton)
		{
			WriteLog(OP_NOTE_SWTICH);
			ShowNoteTools(1);
			return;
		}
		else if (msg.pSender == m_pResInBookButton)
		{
			ShowResLayouts(1);
			return;
		}
		else if (msg.pSender == m_pResInSchoolButton)
		{
			ShowResLayouts(2);
			return;
		}
		else if (msg.pSender == m_pResInWebButton)
		{
			ShowResLayouts(3);
			return;
		}
		else if( msg.pSender == m_pCatalogButton ) {
			WriteLog(OP_SHOW_CATALOG);
			ShowSideBar(0,_T("Ŀ¼"));
			
			if(m_pBookmarkList!=NULL)
			{
				m_pBookmarkList->RemoveAll();
				ReadCatalogItem(m_pBookmarkList,NULL,NULL);
			}
			ShowNotesListTools(1);
		}else if( msg.pSender == m_pNoteButton ) {
			WriteLog(OP_NOTE_LIST);
			ShowSideBar(2,_T("�ʼ�"));
			m_curSelFolderId = 0;

			

			//if(m_pNoteList->IsVisible())
			m_pNoteOwn->Selected(true);
			//m_pdfNoteInfoList.clear();
			ClearPdfNoteList();
			ClearPdfNoteList_left();

			ShowNotesListTools(1);
			//m_noteDao.GetNoteInfosByBookId(m_pBookInfo->bookId,m_pdfNoteInfoList);
			UpdateBookNotes(m_SidebarWidth);
		}else if( msg.pSender == m_pResButton ) {
			WriteLog(OP_RESOURCE_LIST);
			ShowSideBar(1,_T("��Դ"));
			UpdateBookRes();
		}
		
		else if (msg.pSender == m_pCloudNoteButton){
			WriteLog(OP_CLOUD_NOTE_LIST);
			WriteLog(OP_CLOUD_NOTE_OWN);
			ShowSideBar(3, _T("�Ʊʼ�"));
		
			UpdateCloudNotePackages(1);
		}else if (name == _T("cloud_note_share")){
			WriteLog(OP_CLOUD_NOTE_SHARE);
			UpdateCloudNotePackages(0);
			m_pCloudState=1;
		}else if (name == _T("note_own")){
			Enable(false);
			BackAllMultyOption();//��ԭ��������
			m_pMoreNoteBtn->SetVisible(false);
			ShowNotesListTools(1);
			m_pNoteList->RemoveAll();
			m_pNoteList->SetCurrentType(NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW);
			UpdateBookNotes(m_SidebarWidth);
			GetNoteByCataIndex(m_current_mulu_index);
			m_bIsSetMuluIndex=false;
			m_ctrMulu->SelectItem(m_current_mulu_index);
			m_bIsSetMuluIndex=true;
			m_pMyPDFBook->RedrawLines();
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTELIST_CHG);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_CHG_MODEL,L"1"); 
			theApp.m_EventLog.MakeJsonFormat();
			Enable(true);
			CHorizontalLayoutUI* separator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("separator_share")));
			separator_share->SetVisible(false);
			////////////////
		}else if (name == _T("note_list")){//�ҵ��Ʊʼ�
			Enable(false);
			ShareNoteShowTool(0);
			BackAllMultyOption();//��ԭ��������
			m_pNoteList->RemoveAll();
			GetCloudNote();
			if(m_th.m_isNeedReLogin)
			{
				CloseApplication(1);
			}
			m_pMoreNoteBtn->SetVisible(false);
			ShowNotesListTools(2);
			m_pNoteList->SetCurrentType(NOTE_SHOW_TYPE::CLOUD_NOTE_SHOW);
			UpdateBookNotes(m_SidebarWidth);
			m_pMyPDFBook->RedrawLines();
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTELIST_CHG);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_CHG_MODEL,L"1"); 
			theApp.m_EventLog.MakeJsonFormat();
			Enable(true);
			CHorizontalLayoutUI* separator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("separator_share")));
			separator_share->SetVisible(false);
			////////////////
		}
		else if (name == _T("note_folder")){//�����ʼ�
			Enable(false);
			CHorizontalLayoutUI* h_search_layout_share = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_search_layout_share")));
			h_search_layout_share->SetVisible(false);
			if(m_pOptionSearchShare->IsSelected())
				m_pOptionSearchShare->Selected(false);
			BackAllMultyOption();//��ԭ��������
			m_shareNoteSearch=L"";
			ClearShareNoteOperator();
			AddClassInfo2ComboCtrl();
			//m_ctrMulu->SelectItem(0);
			//GetShareNote();
			m_pNoteList->SetCurrentType(NOTE_SHOW_TYPE::SHARE_NOTE_SHOW);
			
			m_pMoreNoteBtn->SetVisible(true);
			ShowNotesListTools(3);
			ShowShareNote(m_SidebarWidth);
			
			m_pMyPDFBook->RedrawLines();
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTELIST_CHG);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_CHG_MODEL,L"1"); 
			theApp.m_EventLog.MakeJsonFormat();
			////////////////
			Enable(true);
			CHorizontalLayoutUI* separator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("separator_share")));
			separator_share->SetVisible(true);
		}
		else if (name == _T("gobackReader")){
			CloseBrowser();
			m_pMyPDFBook->RedrawLines();
		}
		else if (name == _T("btn_diandu")){
			//Modify By Ray 2019-05-22
			//���302��ת
			if(NetWorkAndTokenCheck())
			{
				CString strLevelCode = g_pFrame->GetCurrentMuluLevelCode();
				CWebviewFrame* web = new CWebviewFrame(theApp.m_strUserConfig.strPoint_reading_url,m_pMyPDFBook->GetPageNum(),strLevelCode,DO_DIANDU,m_pBookInfo->bookId);
				web->Create(this->GetHWND(), _T("WebviewFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
				web->CenterWindow();
				web->ShowWindow();
			}

			//ShowBrowser(1);	

			return;

		}
		else if(name==_T("notes_sort"))//���ñʼDZ�ǩ
		{
			
		}
		else if(name==_T("ok_submit_student_name"))
		{
			
			if(!theApp.AnalysisConnect())
			{
				CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
				return;
			}
			m_freeLineFrame->ShowWindow(false);
			isShowFreePen=false;
			SetPenAndColor(NOTES_NONE, GetPenColor());
			m_nPageTemp =m_current_page;
			m_bisShowNoteTemp =m_isShowNotes;
			BackAllMultyOption(0);
			OpenSeeNoteFrame(msg.pSender->GetTag());
			

		}
		else if(name==_T("SeeNotePrePage"))
		{
			
			m_pSeeNote->GetPrePageInfo();
			ShowNoteInfo();

		}
		else if(name==_T("SeeNoteNextPage"))
		{
			
			m_pSeeNote->GetNextPageInfo();
			ShowNoteInfo();
		}
		else if(name==_T("button_pre_student"))
		{
			
			m_pSeeNote->GetPreInfo();
			ShowNoteInfo();
		}
		else if(name==_T("button_next_student"))
		{
		
			m_pSeeNote->GetNextInfo();
			ShowNoteInfo();
		}
		else if(name==_T("closeSeeNote"))
		{

			GoToPage(m_nPageTemp);
			CloseSeeNoteFrame();
		}
		else if(name==_T("btn_preImage"))
		{
			GotoPrePage();
		}
		else if(name==_T("btn_nextImage"))
		{
			GotoNextPage();
		}
		else if(name==_T("notes_delete"))
		{
			//WriteLog(OP_NOTE_DELETE);

			if(m_pNoteList==NULL) return;

			if(m_pNoteList->IsVisible())
			{
				vector<CPDFNoteInfo*> selectedInfos;
				m_pNoteList->GetSelectItems(m_pdfNoteInfoList,selectedInfos);
				DelSelectedNote(selectedInfos);
			}

			

			if(m_pNoteCatalogList->IsVisible())
			{
				vector<CPDFNoteInfo*> selectedInfos;
				m_pNoteCatalogList->GetSelectItems(m_pdfNoteInfoList,selectedInfos);
				DelSelectedNote(selectedInfos);
			}

		}else if(name==_T("edit_note"))
		{
			WriteLog(OP_NOTE_EDIT);
			if(msg.pSender->GetTag()!=NULL)
			{
				CPDFNoteInfo* pInfo=(CPDFNoteInfo*)msg.pSender->GetTag();
				if(pInfo!=NULL)
				{
					//ShowEditNoteFrame(pInfo, FALSE);
				}
			}
		}else if(name==_T("return_folderlist"))
		{
			//m_pNotesChoiceAll->Selected(false);
			CLabelUI* pLabelButton1 = static_cast<CLabelUI*>(m_pm.FindControl(_T("no_search_label")));
			pLabelButton1->SetVisible(false);
			ShowNotesListTools(4);
		}else if(msg.pSender==m_pResChoiceAll)
		{
			WriteLog(OP_RES_SELECT_ALL);

			m_pResList->SelectAllItems(!m_pResChoiceAll->IsSelected());
// 		}else if(msg.pSender==m_pNotesChoiceAll)
// 		{
// 			WriteLog(OP_NOTE_SELECT_ALL);
// 
// 			if(m_pNoteList->IsVisible())
// 				m_pNoteList->SelectAllItems(!m_pNotesChoiceAll->IsSelected());
// 
// 			if(m_pNoteFolderList->IsVisible())
// 				m_pNoteFolderList->SelectAllItems(!m_pNotesChoiceAll->IsSelected());
// 
// 			if(m_pNoteCatalogList->IsVisible())
// 				m_pNoteCatalogList->SelectAllItems(!m_pNotesChoiceAll->IsSelected());
// 		}
		}
		//else if (name == _T("note_choice")) 
		//{
		//	//m_pNotesChoiceAll->Selected(m_pNoteList->isAllItemsSelected());
		//	m_pCloudNotesChoiceAll->Selected(m_pCloudNoteList->isAllItemsSelected());

		//	m_pCloudChoiceAll->Selected(m_pCloudNoteItemList->isAllItemsSelected());
		//}

// 		else if(msg.pSender == m_pHideToolButton)
// 		{
// 			if(m_pCatalogButton->IsSelected() || m_pNoteButton->IsSelected() || m_pCloudNoteButton->IsSelected())
// 			{
// 				m_pSidebarLayout->SetVisible(!m_pSidebarLayout->IsVisible());
// 				g_pFrame->m_pMyPDFBook->RedrawLines();
// 			}
// 		}
		else if (name == _T("notes_search"))
		{
			WriteLog(OP_NOTE_SEARCH);

			
			m_pMyPDFBook->RedrawLines();
		}
		else if (name == _T("note_search_start"))
		{
		
			CEditUI* pSearchEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("note_search_edit")));
			if (pSearchEdit != NULL)
			{
				CString strText = pSearchEdit->GetText();
				SearchNotesKeyWords(strText);
				WriteLog(OP_NOTE_SEARCH, strText);
			}
			CString strText= pSearchEdit->GetText();
			if(strText=="")
				CustomMessageBox(_T("��������Ҫ�����Ĺؼ��֣�"),MSG_TYPE_NOTICE,FALSE);
			
		}
		else if (name == _T("notes_filter") || name == _T("clear_saixuan_button"))
		{
			FilterNote();
			if(name == _T("clear_saixuan_button"))
				m_pNotesFilter->Selected(false);
			
			
		}
		else if(name==_T("clear_search_button"))
		{
			search_keyword->SetText(_T(""));
			search_keyword->SetFocus();
		}
		else if(name==_T("clear_search_button_share"))
		{
			CEditUI* key = static_cast<CEditUI*>(m_pm.FindControl(_T("search_keyword_share")));
			key->SetText(_T(""));
			key->SetFocus();
		}
		else if(name==_T("do_search_button"))
		{
			//���رʼ�����
			CString key=search_keyword->GetText();

// 			key.TrimLeft();
// 			key.TrimRight();
			if(key.GetLength()==0)
			{
				CustomMessageBox(L"��������������",MSG_TYPE_NOTICE,FALSE);
				return;
			}

			m_strSearchKey=key;
			if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
			{
				//CNoteDao NoteDao(m_pBookInfo->bookId);
				m_pdfNoteInfoList=m_noteDao->ContentAndTextSelect(key,FALSE);
				UpdateBookNotes(m_SidebarWidth);
				m_pMyPDFBook->RedrawLines();
			}
			else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
			{
				m_pcloudNote->NoteSearch(key);
				UpdateBookNotes(m_SidebarWidth);
			}
			////���////////
			int nOrgPageNum=0;
			nOrgPageNum =m_pMyBook->GetPageNum();
			theApp.m_EventLog.init();
			CString strOrgPageNum,strType;
			strOrgPageNum.Format(L"%d",nOrgPageNum);
			int nType =0;
			if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
			{
				nType =1;
			}else
			{
				nType =2;
			}
			strType.Format(L"%d",nType);
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_SEARCH_NOTE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SEARCH_WAY,L"1");
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SEARCH_KEYWORD,key);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SEARCH_MODE,strType);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strOrgPageNum);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}

		else if(name==_T("do_search_button_share"))//�����ʼ�����
		{
			CEditUI* key = static_cast<CEditUI*>(m_pm.FindControl(_T("search_keyword_share")));
			//���رʼ�����
			CString keyword=key->GetText();
// 			keyword.TrimLeft();
// 			keyword.TrimRight();
			if(keyword.GetLength()==0)
			{
				CustomMessageBox(L"��������������",MSG_TYPE_NOTICE,FALSE);
				return;
			}
			////���////////
			int nOrgPageNum=0;
			nOrgPageNum =m_pMyBook->GetPageNum();
			theApp.m_EventLog.init();
			CString strOrgPageNum;
			strOrgPageNum.Format(L"%d",nOrgPageNum);
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_SEARCH_NOTE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SEARCH_WAY,L"1");
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SEARCH_KEYWORD,keyword);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SEARCH_MODE,L"3");
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strOrgPageNum);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
			m_shareNoteSearch=keyword;
			GetShareNote();
			ShowShareNote(m_SidebarWidth);
			m_ctrlClass->SetVisible(false);
		}

		else if(name==_T("notes_search_option"))
		{
			m_strSearchKey=_T("");
			NoteSearch();
			m_pMyPDFBook->RedrawLines();
		}

		else if(name==_T("share_note_refresh"))//�����ʼ�ˢ��
		{
			m_pNoteList->RemoveAll();
			GetShareNote();
			ShowShareNote(m_SidebarWidth);
		}
		else if(name==_T("resource_search_option"))//��Դ����
		{
			ResourceSearch();
		}
		else if(name==_T("do_resource_search_button"))//��Դ����
		{
			
			CEditUI* key = static_cast<CEditUI*>(m_pm.FindControl(_T("resource_search_keyword")));
			CString text = key->GetText();

// 			text.TrimLeft();
// 			text.TrimRight();
			if(text.GetLength()==0)
			{
				CustomMessageBox(L"��������������",MSG_TYPE_NOTICE,FALSE);
				return;
			}
			////���////////
			int nOrgPageNum=0;
			nOrgPageNum =m_pMyBook->GetPageNum();
			theApp.m_EventLog.init();
			CString strOrgPageNum;
			strOrgPageNum.Format(L"%d",nOrgPageNum);
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_RESOURCE_SEARCH);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_SEARCH_TYPE_WAY,L"1");//1 or 2 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK__RESOURCE_SEARCH_KEYWORD,text); 
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strOrgPageNum);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////

			m_extrs->m_extras_list.clear();
			if(!theApp.AnalysisConnect())
			{
				CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			}
			else
			{
				m_extrs->SearchResource(text);
			}
			
			
			AddResTypeElement();
			UpdateBookRes(0);
		}
		else if(name==_T("notes_folder_add"))
		{
			//SetNoteFolderName();
		}
		else if (name == _T("notes_export"))
		{
			
		}
		else if(name==_T("labelset_close"))
		{
			WriteLog(OP_LABELSET_CLOSE);
			m_pNoteTabLayout->SelectItem(0);
			//			InitLablesCombo();
			//m_pMyPDFBook->m_pdf_view->InvalidateView(1);
		}else if(name==_T("labelset_add"))
		{
// 			WriteLog(OP_LABELSET_ADD);
// 
// 			CDuiLabelAdd* p_Add=new CDuiLabelAdd();
// 			if( p_Add == NULL ) return ;
// 			RECT rect=m_pNoteTabLayout->GetPos();
// 			p_Add->Create(this->m_hWnd, _T(""), UI_WNDSTYLE_FRAME, 0L, 0, 0, rect.right-rect.left-20, 300);
// 
// 			::SetWindowPos(p_Add->GetHWND(),NULL,rect.left,(rect.bottom-rect.top)/2,-1, -1, SWP_NOSIZE);
// 			//p_Add->OnPrepare();
// 			if(p_Add->ShowModal()==IDOK)
// 			{
// 				CLabelInfo* p_newInfo=m_noteDao.GetLabelInfoById(p_Add->m_LabelId);
// 				if(p_newInfo!=NULL)
// 				{
// 					m_labelInfos.push_back(p_newInfo);
// 					ShowLabelInfos();
// 				}
// 			}
		}else if(name==_T("label_edit"))
		{
			WriteLog(OP_LABEL_EDIT);

			CVerticalLayoutUI* m_pLables=static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("layout_labels")));
			CStdPtrArray* p_Array=m_pm.FindSubControlsByClass(m_pLables,_T("HorizontalLayoutUI"));
			if(p_Array!=NULL)
			{
				for(int i=0;i<p_Array->GetSize();i++)
				{
					CHorizontalLayoutUI * p_Layout=(CHorizontalLayoutUI*)(p_Array->GetAt(i));
					if(p_Layout!=NULL)
					{
						CButtonUI* p_Button=static_cast<CButtonUI*>(m_pm.FindSubControlByName(p_Layout,_T("label_delete")));
						if(p_Button!=NULL)
						{
							p_Button->SetVisible(true);
						}
					}
				}
			}
		}else if(msg.pSender->GetName()==_T("label_delete"))
		{
// 			WriteLog(OP_LABEL_DELETE);
// 
// 			CLabelInfo* pInfo=(CLabelInfo *)(msg.pSender->GetTag());
// 			if(pInfo!=NULL)
// 			{
// 				int ret = CGlobalUI::ShowMessage(this->m_hWnd, _T("�Ƿ�ɾ���ñ�ǩ��"));
// 				if (ret != IDOK)
// 					return;
// 
// 				if(m_noteDao.LabelInfoIsUse(pInfo->id)==0)
// 				{
// 					m_noteDao.UpdateLabelToNoUse(pInfo->id);
// 					RemoveLabelInfoFormlistById(pInfo->id);
// 					ShowLabelInfos();
// 				}
// 				else
// 				{
// 					CGlobalUI::ShowMessage(this->m_hWnd, _T("�ñ�ǩ�Ѿ���ʹ�ã��޷�ɾ����"));
// 					//	MessageBox(GetHWND(),_T("�ñ�ǩ�Ѿ���ʹ�ã��޷�ɾ����"),_T("ϵͳ��ʾ"),MB_OK);
// 				}
// 			}
		}
		else if (name == _T("note_view_button"))
		{
			WriteLog(OP_CLOUD_NOTE_VIEW);
			CCloudNotePackage* pNotePackage = (CCloudNotePackage *)(msg.pSender->GetTag());
			if (pNotePackage != NULL)
			{
				CCloudNotePackageDao PackageDao;
				CCloudNotePackage notePackage = PackageDao.GetNotePackageById(pNotePackage->id);
				int cloudNoteNum = notePackage.iCloudNoteNum;
				int clickState = notePackage.iclickState;
				if(cloudNoteNum==0 && clickState==1)
				{
					/*PackageDao.UpdateStateByNoteId(pNotePackage->strNoteId,2,0);
					PackageDao.UpdateImportedclickStateByNoteId(pNotePackage->strNoteId,0);
					msg.pSender->SetEnabled(false);

					if (m_pDownloadCloudNotes == NULL)
						m_pDownloadCloudNotes = new CDownloadCloudNote(this->m_hWnd);
					m_pDownloadCloudNotes->DownloadPackageListByBookId(m_pBookInfo->bookId);
					return;*/


					CCloudNotePackageDao PackageDao;
					PackageDao.UpdateStateByNoteId(pNotePackage->strNoteId,0,0);
					UpdateCloudNotePackagesList();
					return;
				}

				if(clickState==0)
				{
					CCloudNotePackageDao PackageDao;
					PackageDao.UpdateImportedclickStateByNoteId(pNotePackage->strNoteId,1);
				}

				m_strNoteId = pNotePackage->strNoteId;
				CString strTitle = _T("�Ʊʼ�-") + pNotePackage->strUserName;
				ShowSideBar(3, strTitle);
				UpdateCloudBookNotes(pNotePackage);
			}
		}
		else if (name == _T("cloud_note_delete"))
		{
			
			int iRet = CustomMessageBox(_T("�Ƿ�ɾ�����Ʊʼǣ�"),MSG_TYPE_YESNO);
			if (iRet != IDOK)
				return;


			CCloudNotePackage* pNotePackage = (CCloudNotePackage *)(msg.pSender->GetTag());
			if (pNotePackage != NULL)
			{
				WriteLog(OP_CLOUD_NOTE_PACKAGE_DELETE, pNotePackage->strUserName);
				DeleteCloudNotePackageInListByid(pNotePackage->id);
			}
		}
		else if (msg.pSender == m_pCloudImportButton)
		{
			WriteLog(OP_CLOUD_NOTE_IMPORT);

			ImportCloudNotesIntoLocal();
		}
		else if (msg.pSender == m_pCloudImportReturn)
		{
			WriteLog(OP_CLOUD_NOTE_RETURN);
			ShowSideBar(3, _T("�Ʊʼ�"));
			UpdateCloudNotePackagesList();
		}
		else if (name == _T("cloud_notes_delete"))
		{
			WriteLog(OP_CLOUD_NOTE_DELETE);
			DeleteCloudNotesSelected();
		}
		else if (name == _T("cloud_package_delete"))
		{
			DeleteCloudPackagesSelected();
		}
	/*	else if (name == _T("cloud_package_download"))
		{
			DownloadCloudPackageList();
		}*/
		else if (name == _T("cloud_package_import"))
		{
			ImportCloudPackageIntoLocal();
		}
		else if (msg.pSender == m_pCloudChoiceAll)
		{
			WriteLog(OP_CLOUD_NOTE_CHOOSE_ALL);
			m_pCloudNoteItemList->SelectAllItems(!m_pCloudChoiceAll->IsSelected());
		}
		else if(msg.pSender == m_pCloudNotesChoiceAll)
		{
			m_pCloudNoteList->SelectAllItems(!m_pCloudNotesChoiceAll->IsSelected());
		}
		
		else if (msg.pSender->GetName() == _T("cloud_note_import"))
		{
			
		}
		else if (msg.pSender->GetName() == _T("cloud_note_class"))
		{
			
		}
		else if(msg.pSender->GetName()==_T("multi_select_operator_close"))
		{
			
			if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW || m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
			{
				if(m_pNotesFilter->IsSelected())
				{
					//int aa=m_pcloudNote->GetCloudListSize();
					BackAllMultyOption(0);
					//int aa1=m_pcloudNote->GetCloudListSize();
					m_pNotesFilter->Selected(true);
					m_bIsSelect=true;
					
				}
				if(m_bIsSearch)
				{
					BackAllMultyOption(0);
					//int aa1=m_pcloudNote->GetCloudListSize();
					notes_search_option->Selected(true);
					m_bIsSearch=true;
					m_pNotesFilter->SetEnabled(false);
				}
				else
				{
					BackAllMultyOption(0);
				}
				UpdateBookNotes(m_SidebarWidth);
			}
			else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::SHARE_NOTE_SHOW)
			{
				ClearShareNoteOperator();
				ShowShareNote(m_SidebarWidth);
			}
		}

		else if(msg.pSender->GetName()==_T("btn_more_note"))
		{
			if(!m_pShareNote->m_bMorePage)
				CustomMessageBox(_T("û�и���ʼ��ˣ�"),MSG_TYPE_NOTICE,FALSE);
			else
			{
				GetShareNote(FALSE);
				ShowShareNote(m_SidebarWidth);
			}

		}
		
		else if (msg.pSender->GetName() == _T("multi_select_operator"))//��������
		{
			

			vector<CPDFNoteInfo*>  infos;
			vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
			m_pNoteList->GetSelectItems(infos,selectNoteInfos);
			if(selectNoteInfos.size()==0)
			{
				CustomMessageBox(_T("��ѡ����Ҫ�����ıʼǣ�"),MSG_TYPE_NOTICE,FALSE);
				return;
			}
			if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW)
			{	

				if(isShare)
				{
					if(!theApp.AnalysisConnect())
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
						return ;
					}
					if(!CheckHasTarget())
					{
						return ;
					}
					ShareLocal2Share(selectNoteInfos);
					m_pLabelOper->DownloadAndSaveLabel();
					
				}
				else if(isDelete)
				{
					
					int ret = CustomMessageBox(STRING_MSG_DELETE_DOUBLE_CHECK,MSG_TYPE_YESNO);
					if(ret == IDOK)
					{
						//�رղ�����
						if(m_pPlayerWnd != NULL)
						{
							for (int i=0;i<selectNoteInfos.size();i++)
							{
								CPDFNoteInfo* info = selectNoteInfos.at(i);
								if(info->pdfNoteType==NoteAudio)
								{
									if(theApp.GetCurDir()+info->content == m_pPlayerWnd->m_strPath)
									{
										CustomMessageBox(L"ɾ��ʧ��,���ȹر���Ƶ���Ŵ���",MSG_TYPE_NOTICE,FALSE);
										return;
									}
								}
							}
						}
						if(!DeleteLocalNote(selectNoteInfos))
						{
							//ShowMultiOperator(0);
							CustomMessageBox(STRING_READERFRAME_DELETE_FAIL,MSG_TYPE_NOTICE,FALSE);
						}
						else
						{
							ShowMultiOperator(0);
							UpdateBookNotes(m_SidebarWidth);
							
							CustomMessageBox(STRING_READERFRAME_DELETE_SUCCESS,MSG_TYPE_NOTICE,TRUE);
							
							
						}
						
					}else
					{
						ShowMultiOperator(0);
						UpdateBookNotes(m_SidebarWidth);
					}
				}
				else if(isUpload)
				{
					if(!theApp.AnalysisConnect())
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
						return ;
					}
					int ret = CustomMessageBox(_T("ȷ��Ҫ��ѡ��ıʼ��ϴ����Ʊʼ���"),MSG_TYPE_YESNO);
					if(ret == IDOK)
					{
						if(!theApp.AnalysisConnect())
						{
							CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
							return;
						}
						
						if(UploadLocal2CloudNote(selectNoteInfos))
						{
							
							ShowMultiOperator(0);
							CustomMessageBox(m_pcloudNote->m_strActionRes,MSG_TYPE_NOTICE,TRUE);
						}else
						{
							
							ShowMultiOperator(0);
							if(m_th.m_curl->m_curlCode == CURLE_RECV_ERROR)
								CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
							//CustomMessageBox(L"�ϴ�ʧ��",MSG_TYPE_NOTICE,FALSE);
						}
						
						ShowMultiOperator(0);
						GetNoteByCataIndex(m_current_mulu_index);
						UpdateBookNotes(m_SidebarWidth);
					}else
					{
						ShowMultiOperator(0);
						UpdateBookNotes(m_SidebarWidth);
					}
				}
				
			}
			else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::CLOUD_NOTE_SHOW)
			{

				if(isShare)
				{

					if(!CheckHasTarget())
					{
						return ;
					}
					if(theApp.m_UserInfo.iUserType==2)//ѧ��
					{
						if(!theApp.AnalysisConnect())
						{
							CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
							return ;
						}
						ShareCloud2Share(selectNoteInfos);
						m_pLabelOper->DownloadAndSaveLabel();
					}
					else 
					{
						CShareTeacherNoteFrame* pShareTeacherNoteFrame = new CShareTeacherNoteFrame(m_pShareNote,m_pBookInfo->strGrade);
						pShareTeacherNoteFrame->Create(m_hWnd, _T("ShareTeacherNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
						pShareTeacherNoteFrame->CenterWindow();
						if(!theApp.AnalysisConnect())
						{
							CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
							return;
						}
						if (IDOK == pShareTeacherNoteFrame->ShowModal())
						{
							//Add Comment and Modify By Ray 2018-09-14
							//��ʦ���������ʼǸ��༶
							int aa=pShareTeacherNoteFrame->m_select_classinfo.size();//ѡ�еİ༶index
							int bb=selectNoteInfos.size();
							//�������ţB�������ʼǷ������������Ʊʼǵ�
							if(pShareTeacherNoteFrame->m_share_desc.GetLength()<=0)
							{
								CPDFNoteInfo* noteinfo=selectNoteInfos.at(0);
								int nNum =selectNoteInfos.size();
								CString strDescribe;
								if(noteinfo->pdfNoteType==NoteLine)
									strDescribe=_T("���߱ʼ�");
								else if(noteinfo->pdfNoteType==NoteTextBox)
									strDescribe=_T("�ı���ʼ�");
								else if(noteinfo->pdfNoteType==NoteFreedom)
									strDescribe=_T("���ɻ���");
								else if(noteinfo->pdfNoteType==NoteAudio)
								    strDescribe=_T("��Ƶ");
								else if(noteinfo->pdfNoteType==NoteVideo)
									strDescribe=_T("��Ƶ");
								else if(noteinfo->pdfNoteType==NoteImage)
									strDescribe=_T("ͼƬ");
								else if(noteinfo->pdfNoteType==NoteLink)
									strDescribe=_T("��������Դ�ʼ�");
								else if(noteinfo->pdfNoteType==NoteFile)
									strDescribe=_T("�������ͱʼ�");
								pShareTeacherNoteFrame->m_share_desc.Format(L"%s��%d���ʼ�",strDescribe,nNum);

							}
							
							if(m_pShareNote->CloudShareToClass(selectNoteInfos,pShareTeacherNoteFrame->m_select_classinfo,pShareTeacherNoteFrame->m_share_desc))
							{
								
								ShowMultiOperator(0);
								GetNoteByCataIndex(m_current_mulu_index);
								UpdateBookNotes(m_SidebarWidth);
								CustomMessageBox(STRING_MSG_SHARE_OK,MSG_TYPE_NOTICE,TRUE);
							}else
							{
								
								CustomMessageBox(STRING_MSG_SHARE_ERR,MSG_TYPE_NOTICE,FALSE);
							}

						}
						else
						{
							ShowMultiOperator(0);
							UpdateBookNotes(m_SidebarWidth);
						}
						if(pShareTeacherNoteFrame) 
						{
							delete pShareTeacherNoteFrame;
							pShareTeacherNoteFrame=NULL;
						}
					}

				}
				else if(isDelete)
				{
					if(!theApp.AnalysisConnect())
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
						return;
					}
					int ret = CustomMessageBox(_T("ȷ��Ҫɾ��ѡ����Ʊʼ���"),MSG_TYPE_YESNO);
					if(ret == IDOK)
					{
						int res = DeleteCloudNote(selectNoteInfos);
						if(res==1)
						{
							m_pLabelOper->DownloadAndSaveLabel();
							BackAllMultyOption(0);
							UpdateBookNotes(m_SidebarWidth);
							CustomMessageBox(STRING_READERFRAME_DELETE_SUCCESS,MSG_TYPE_NOTICE,TRUE);
							if(m_pNotesFilter->IsSelected())
							{
								m_pNotesFilter->Selected(false);
								notes_search_option->SetEnabled(true);
								m_bIsSelect=false;
								m_ctrMulu->SetVisible(true);
								CHorizontalLayoutUI* mulu_hide = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("mulu_hide")));
								mulu_hide->SetVisible(false);
							}
							
						}							
						else
						{
							CustomMessageBox(STRING_READERFRAME_DELETE_FAIL,MSG_TYPE_NOTICE,FALSE);
						}
					}else
					{
						BackAllMultyOption(0);
						UpdateBookNotes(m_SidebarWidth);
					}
					
				}
				else if(isDownload)
				{
					
// 					int ret =CustomMessageBox(_T("�Ʊʼǵ��뱾�أ�"),MSG_TYPE_YESNO);
// 					if(ret == IDOK)
// 					{
						int nRet =ImportNoteToLocal(selectNoteInfos,NOTE_CLOUD);
						if(nRet==1)
						{
							ShowMultiOperator(0);
							UpdateBookNotes(m_SidebarWidth);
							CustomMessageBox(STRING_READERFRAME_IMPORT_SUCCESS,MSG_TYPE_NOTICE,TRUE);
						}else if(nRet==99)
						{
							CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
						}
						else
						{
							
							CustomMessageBox(STRING_READERFRAME_IMPORT_FAIL,MSG_TYPE_NOTICE,FALSE);
						}
						
//					}
//					else
// 					{
// 						ShowMultiOperator(0);
// 						UpdateBookNotes(m_SidebarWidth);
// 					}
				}
				
			}
			else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::SHARE_NOTE_SHOW)
			{
				std::vector<int> select_index;
				m_pNoteList->GetSelectItems(select_index);
				if(m_bCancel)
				{

					RecallShareNotes(select_index);
					
				}
				if(m_bImport)
				{
					m_pShareNote->GetMultiSelFolderNotes(select_index);
					int nRet =ImportNoteToLocal(m_pShareNote->m_temp_Second_note_list,NOTE_SHARE);
					if(nRet==1)
					{
						ShowMultiOperator(0);
						UpdateBookNotes(m_SidebarWidth);
						CustomMessageBox(STRING_READERFRAME_IMPORT_SUCCESS,MSG_TYPE_NOTICE,TRUE);
					}else if(nRet==99)
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
					}
					else
					{
						
						CustomMessageBox(STRING_READERFRAME_IMPORT_FAIL,MSG_TYPE_NOTICE,FALSE);
					}
				}
				if(m_bMove)
				{
					std::vector<CPDFNoteInfo*> list;
					m_pNoteList->GetSelectItems(m_pdfNoteInfoList,list);
					ShowShareMoveFrame(list);

				}
				ShareNoteShowTool(0);
				ShowShareNote(m_SidebarWidth);
				
			}
		}
		else if (msg.pSender->GetName() == _T("share_multi_select_operator_cancel_two"))//�����ʼǶ������ڹر�
		{
			ClearShareNoteTwoOperator();
}
		else if (msg.pSender->GetName() == _T("share_multi_select_operator_two"))//�����ʼǶ���������������
		{
			vector<CPDFNoteInfo*> list;
			m_pFolderList->GetSelectItems(m_pdfNoteInfoList,list);
			vector<int> index_list;
			m_pFolderList->GetSelectItems(index_list);
			if(list.size()==0)
			{
				CustomMessageBox(L"ѡ��ʼ�Ϊ��,������ѡ��",MSG_TYPE_NOTICE,FALSE);
				return;
			}
			if(GetUserType()==2)
			{

				
				if(m_bShareTwoImport)//�������
				{	
					
					int nRet =ImportNoteToLocal(list,NOTE_SHARE);
					if(nRet ==1)
					{
						ShowMultiOperator(0);
						UpdateBookNotes(m_SidebarWidth);
						CustomMessageBox(STRING_READERFRAME_IMPORT_SUCCESS,MSG_TYPE_NOTICE,TRUE);
					}else if(nRet ==99)
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
					}else
					{
						
						CustomMessageBox(STRING_READERFRAME_IMPORT_FAIL,MSG_TYPE_NOTICE,FALSE);
					}
				}
				if(m_bShareTwoCancel)//��������
				{
					//AfxMessageBox(_T("�����ڳ���"));
					RecallShareNotes(index_list);
				}
			}
			else
			{
				if(ComboShareSelect->GetCurSel()==0)//�ҹ�����
				{

 					
					if(m_bShareTwoImport)//�������
					{	
						//m_pShareNote->GetMultiSelFolderNotes(index_list);
						int nRet =ImportNoteToLocal(list,NOTE_SHARE);
						if(nRet==1)
						{
							ShowMultiOperator(0);
							UpdateBookNotes(m_SidebarWidth);
							CustomMessageBox(STRING_READERFRAME_IMPORT_SUCCESS,MSG_TYPE_NOTICE,TRUE);
						}else if(nRet ==99)
						{
							CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
						}else
						{
							
							CustomMessageBox(STRING_READERFRAME_IMPORT_FAIL,MSG_TYPE_NOTICE,FALSE);
						}
					}
					if(m_bShareTwoCancel)//��������
					{
						RecallShareNotes(index_list);
					}
				}
				else//�������ҵ�
				{

					int nRet =ImportNoteToLocal(list,NOTE_SHARE);
					if(nRet ==1)
					{
						ShowMultiOperator(0);
						ShowShareNoteTwo();
						CustomMessageBox(STRING_READERFRAME_IMPORT_SUCCESS,MSG_TYPE_NOTICE,TRUE);
					}else if(nRet ==99)
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
					}else
					{
						
						CustomMessageBox(STRING_READERFRAME_IMPORT_FAIL,MSG_TYPE_NOTICE,FALSE);
					}
				}
			}
			ClearShareNoteTwoOperator();
		}
		else if (msg.pSender->GetName() == _T("date_choose_button"))
		{
			WriteLog(OP_NOTE_FILTER_DATE);

			RECT rc = msg.pSender->GetPos();
			POINT pt;
			pt.x = rc.left;
			pt.y = rc.bottom;
			::ClientToScreen(this->GetHWND(), &pt);
			
			std::vector<SYSTEMTIME> vectTime;
			for (int i = 10; i < 20; i++)
			{
				SYSTEMTIME sysTime;
				sysTime.wYear = 2015;
				sysTime.wMonth = 6;
				sysTime.wDay = i;
				vectTime.push_back(sysTime);
			}

		}
		else if (msg.pSender->GetName() == _T("cloud_note_date"))
		{
			RECT rc = msg.pSender->GetPos();
			POINT pt;
			pt.x = rc.left;
			pt.y = rc.bottom;
			::ClientToScreen(this->GetHWND(), &pt);


		}
		else if (msg.pSender->GetName() == _T("add_pizhu_button"))
		{
			int id = msg.pSender->GetTag();
			CPDFNoteInfo* pNoteInfo = m_noteDao->GetNoteInfoById(id);
			if (pNoteInfo != NULL)
			{
				CString strMsg;
				strMsg.Format(_T("%d"), pNoteInfo->id);
				WriteLog(OP_NOTE_ADD_LABEL, strMsg);
				//ShowEditNoteFrame(pNoteInfo);
			}
		}
		else if (msg.pSender->GetName() == _T("rename_button"))
		{
			int id = msg.pSender->GetTag();
			CPDFNoteInfo* pNoteInfo = m_noteDao->GetNoteInfoById(id);
			if (pNoteInfo != NULL)
			{
				AttachInfo attach = InsertAttach(pNoteInfo, true);
				if (attach.Success)
				{
					UpdateDBAndPDFList(pNoteInfo,true);
					m_pMyPDFBook->RedrawLines();
				}
			}
		}
		else if (msg.pSender->GetName() == _T("catalog_choice"))
		{
			textbook_catalogInfo_ex* pInfo = (textbook_catalogInfo_ex*)msg.pSender->GetTag();
			COptionUI *pOptionUI = (COptionUI*)msg.pSender;
			m_pNoteCatalogList->SelectCatalogAllItems(pInfo, !pOptionUI->IsSelected());
		}
		else if (msg.pSender->GetName() == _T("catalog_arrow"))
		{
			textbook_catalogInfo_ex* pInfo = (textbook_catalogInfo_ex*)msg.pSender->GetTag();
			COptionUI *pOptionUI = (COptionUI*)msg.pSender;
			m_pNoteCatalogList->ShowCatalogAllItems(pInfo, pOptionUI->IsSelected());
		}
		else if(msg.pSender->GetName() == _T("folder_rename"))
		{
			
		}
		
		
		else if (name == _T("add_label_to_note"))//���ӱ�ǩ���ʼ�
		{
			if(m_isShowAllLabel)
				m_isShowAllLabel=false;
			else
				m_isShowAllLabel=true;
			SetLabelView();
		}
		else if (name == _T("btn_add_label"))//���ӱ�ǩ
		{
			WriteLog(OP_LABEL_SET);
			SetLabelForNewNotes();
		}
	
		else if (name == _T("note_clip_borad"))
		{
			WriteLog(OP_NOTE_CLIPBORAD);

			m_pMyPDFBook->CoypCurPageToClipboard();
			CustomMessageBox(_T("�ɹ����Ƶ�������!"),MSG_TYPE_NOTICE,TRUE);
		}
		else if (name == _T("tool_exercise"))
		{
			int page = m_pMyBook->GetPageNum();
			GoToExercisePage(page);
		}
		else if(name == _T("cloud_notes_refresh"))//�Ʊʼ�ˢ��
		{
			if(m_pNotesFilter->IsSelected())
			{
				FilterNote();
			}
			BackAllMultyOption();//��ԭ��������
			m_pNoteList->RemoveAll();
			GetCloudNote();
			if(m_th.m_isNeedReLogin)
			{
				CloseApplication(1);
			}
			UpdateBookNotes(m_SidebarWidth);
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTELIST_CHG);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_CHG_MODEL,L"1"); 
			theApp.m_EventLog.MakeJsonFormat();
			Enable(true);
			CHorizontalLayoutUI* separator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("separator_share")));
			separator_share->SetVisible(false);
			////////////////
		}
		else if (name == _T("notes_label_set"))//��ǩ����ҳ��
		{
			if(!theApp.AnalysisConnect())
			{
				CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
				return;
			}
			if(m_pLabelOper)
			{

				BackAllMultyOption();
				UpdateBookNotes(m_SidebarWidth);

				//Add By Ray 2019-06-10 ��ǩ���»�ȡ
				m_pLabelOper->DownloadAndSaveLabel();
				m_noteDao->GetAllLabelInfo(m_labelInfos);


				m_pLabelOper->ModifyUseCount();
				CLabelManageFrame* pLabelManageFrame = new CLabelManageFrame(m_pLabelOper);
				pLabelManageFrame->Create(m_hWnd, _T("LabelManageFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
				pLabelManageFrame->CenterWindow();
				if (IDOK == pLabelManageFrame->ShowModal())
				{
					//m_pMyPDFBook->RedrawLines();
				}
				GetNoteByCataIndex(m_current_mulu_index);
				////���////////
				theApp.m_EventLog.init();
				theApp.m_EventLog.SetLogEvent(EVENT_BOOK_TAG_MANAGER_ON_OFF);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_TAG_MANAGER_OPEN_CLOSE,L"1");
				theApp.m_EventLog.MakeJsonFormat();
				/////////////
			}
		}
		else if(name==_T("share_noyte_new_folder"))//�����ļ���
		{
			if(theApp.AnalysisConnect())
				CreateFolder();
			else
				CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);

		}
		else if (name == _T("show_hide_share_student"))//��ʾ����ѧ���ύ�����
		{
			ShowStudentSubmit();
		}
		else if (name == _T("local_upload_notes"))
		{
			ShowMultiOperator(1);	
			
		}else if(name == _T("local_notes_export"))
		{
			ShowMultiOperator(2);
		}else if(name == _T("local_notes_delete"))
		{
			ShowMultiOperator(3);
		}else if(name == _T("cloud_down_notes"))
		{
			ShowMultiOperator(4);
		}
		else if(name == _T("Share_folder_goBack"))//�����ʼ� ���˰�ť
		{
			ShareFolderGoBack();
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_FOLDER_OPEN_CLOSE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FOLDER_OPEN_CLOSE,L"0");
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,L"");
			theApp.m_EventLog.MakeJsonFormat();
			////////////////
		}

		/*else if(name == _T("share_down_notes"))//�����ʼ�(�������ҵģ�
		{
			CHorizontalLayoutUI* h_bottom_operator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
			CButtonUI* share_multi_select_operator=static_cast<CButtonUI*>(m_pm.FindControl(_T("share_multi_select_operator")));
			CButtonUI* share_multi_select_operator_cancel=static_cast<CButtonUI*>(m_pm.FindControl(_T("share_multi_select_operator_cancel")));
			if(h_bottom_operator_share && share_multi_select_operator && share_multi_select_operator_cancel)
			{
				h_bottom_operator_share->SetVisible(true);
				share_multi_select_operator->SetText(_T("���뱾��"));
			}

			ShowShareStudentFolder(true);
			m_pMyPDFBook->RedrawLines();
		}*/
		else if(name == _T("share_back_note"))//�ҹ����ij���
		{
			ShareNoteShowTool(2);
		}
		else if(name == _T("share_down_notes_one"))//����������
		{
			ShareNoteShowTool(1);
		}
		else if(name == _T("notes_search_option_share"))//�����ʼǵ�����
		{
			CHorizontalLayoutUI* h_search_layout_share = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_search_layout_share")));
			if(m_pOptionSearchShare->IsSelected())
			{
				m_shareNoteSearch=_T("");
				h_search_layout_share->SetVisible(false);
				if(ComboShareSelect->GetCurSel()==1 && GetUserType()==1 && theApp.m_target_info.target_list.size()>=2)
					m_ctrlClass->SetVisible(true);
				else
					m_ctrlClass->SetVisible(false);
				GetShareNote();
				m_bShareSearch=false;
				ShowShareNote(m_SidebarWidth);
				
			}
			else
			{
				h_search_layout_share->SetVisible(true);
				m_ctrlClass->SetVisible(false);
				m_bShareSearch=true;
				CEditUI* key_word_edit = static_cast<CEditUI*>(m_pm.FindControl(_T("search_keyword_share")));
				key_word_edit->SetText(_T(""));
			}
		}
		else if(name == _T("share_note_move"))//�������ҵ��ƶ�
		{
			ShareNoteShowTool(3);
		}
		else if(name == _T("share_down_notes"))//���������� 2��
		{
			ShowShareNoteTwoTool(1);
		}
		else if(name == _T("share_notes_back"))//�����ij��� 2��
		{
			ShowShareNoteTwoTool(2);
		}
		else if(name == _T("share_note_refresh_two"))//�ļ����ڵ�ˢ��
		{
			
			if(theApp.AnalysisConnect())
			{
				CHorizontalLayoutUI* h_submit=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_submit")));
				int nType=0;
				if(h_submit->IsVisible())
				{
					nType=1;
				}
				m_pShareNote->GetFolderListById(nType,m_pShareNote->m_Struct_FolderInfo.id);
				ShowShareNoteTwo(false);
			}
			else
			{
				CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			}
		}
	}

	/************************************************************************
	* ���ɽ��������е��¼�֪ͨ
	************************************************************************/
	void CReaderFrame::Notify(TNotifyUI& msg)
	{
		if (msg.sType==_T("selectchanged"))
		{
			if(msg.pSender->GetName() == _T("note_choice"))
			{
				//m_pNoteList->SelectItem(m_pNoteList->m_current_select_index,false);
				if(m_pNoteList->m_bIsFresh)
					MultySelect();
				m_pNoteList->m_bIsFresh=true;

			}
			else if( msg.pSender->GetName() == _T("note_choice_all") ) {
				if(!m_bIsNeedModifySelectAll)
				{
					COptionUI* all_choice = static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
					bool bb=all_choice->IsSelected();
					if(bb)
					{
						CLabelUI* multi_select_note_num = static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num")));
						CString str;
						str.Format(_T("��ѡ��%d���ʼ�"),m_pNoteList->GetCount());
						multi_select_note_num->SetText(str);

					}
					m_pNoteList->SelectAllItems(bb);
				}

			}
			else if(msg.pSender->GetName() == _T("source_type"))
			{
				if(m_extrs)
				{

					m_extrs->m_current_index = msg.pSender->GetTag();
					////���////////
					int nOrgPageNum=0;
					nOrgPageNum =m_pMyBook->GetPageNum();
					theApp.m_EventLog.init();
					CString strOrgPageNum;
					strOrgPageNum.Format(L"%d",nOrgPageNum);
					theApp.m_EventLog.SetLogEvent(EVENT_BOOK_RESOURCE_TITLE_CHG);
					theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_TITLE_TYPE_WAY,L"1");
					theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_TITLE_CHG,m_extrs->GetCurrentTypeName()); 
					theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strOrgPageNum);
					theApp.m_EventLog.MakeJsonFormat();
					////////////////
					UpdateBookRes();
				}
				
			}
			else if(msg.pSender->GetName()==_T("note_choice_all_two"))
			{
				if(!m_bIsNeedModifySelectAll)
				{
					COptionUI* note_choice_all_two = static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all_two")));
					m_pFolderList->SelectAllItems(note_choice_all_two->IsSelected());	
				}
				
			}
		}
		if( msg.sType == _T("windowinit") ) {
			OnPrepare();
		}
	
		if(msg.sType == _T("dropdown"))
		{
			if(msg.pSender->GetName()==_T("ComboMulu"))
				m_ctrMulu->SetFocus();
		}
		if( msg.sType == _T("setfocus") ) 
		{
			if(msg.pSender->GetName()==_T("MyPDFReader"))
			{
				m_pMyPDFBook->RedrawLines();
				//m_pMyPDFBook->SetFocus();
				//::SetFocus(m_hWnd);
			}
			else if(msg.pSender->GetName()==_T("edit_text_note"))
			{
				//AfxMessageBox(_T("ll"));
			}

		}
		if( msg.sType == _T("killfocus") ) 
		{
			if(msg.pSender->GetName()==_T("MyPDFReader"))
			{
				m_pMyPDFBook->RedrawLines();
			}
		}
// 		if (msg.sType == DUI_MSGTYPE_LINK)
// 		{
// 			CTextUI* pText=(CTextUI*)msg.pSender;
// 
// 			CDuiString* str = pText->GetLinkContent(msg.ptMouse);
// 			ShellExecute(NULL, L"open", str->GetData(), NULL, NULL, SW_SHOWNORMAL);
// 		}

else if( msg.sType == _T("click") ) {
			ClickEvent(msg);
			return;
		}
		else if (msg.sType == DUI_MSGTYPE_LINK)
		{
			CTextUI* pText=(CTextUI*)msg.pSender;

			CDuiString* str = pText->GetLinkContent(msg.ptMouse);
			ShellExecute(NULL, L"open", str->GetData(), NULL, NULL, SW_SHOWNORMAL);
		}
		else if( msg.sType == _T("rbtndown") ) {
			if(m_pSidebarTabLayout->GetCurSel()==1)
			{
				int index=m_pResList->GetItemIndex(msg.pSender);
				if(index>=0)
				{
					CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
					DuiLib::CPoint point(0,0);
					GetCursorPos(&point);
					pMenu->Init(NULL, _T("reader\\Menu_Resource_List.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
				}
			}
			else if(m_pSidebarTabLayout->GetCurSel()==2)
			{
				CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
				CHorizontalLayoutUI* h_bottom_operator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
				if(h_operator->IsVisible() || h_bottom_operator_share->IsVisible())
					return;
				if(m_pShareStudentFolderLayout->IsVisible())
				{
					int index=m_pFolderList->GetItemIndex(msg.pSender);
					ShowNoteListMenu(NULL);
				}
				else
				{
					int index=m_pNoteList->GetItemIndex(msg.pSender);
					if(index>=0)
					{
						CPDFNoteInfo* info = GetPdfInfoByIndexExtentFreePen(index);
						ShowNoteListMenu(info);
					}
				}
				
			}
			
		}
		else if( msg.sType == _T("itemclick") ) {
			m_pMyPDFBook->RedrawLines();
			if(m_pSidebarTabLayout->GetCurSel()==0)
			{
				if(m_pBookmarkList->GetItemIndex(msg.pSender) != -1 )
				{
					if( _tcscmp(msg.pSender->GetClass(), _T("ListLabelElementUI")) == 0 ) {
						//textbook_catalogInfo* node = (textbook_catalogInfo*)msg.pSender->GetTag();
						int page = msg.pSender->GetTag();
						if(page>0)
						{
							m_pMyBook->GotoPageNum(page);
							m_pMyPDFBook->RedrawLines();
						}				
					}
				}
			}
			else if(m_pSidebarTabLayout->GetCurSel()==2)
			{
				CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
				CHorizontalLayoutUI* h_bottom_operator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
				if(h_operator->IsVisible() || h_bottom_operator_share->IsVisible())
				{
					if(h_bottom_operator_share->IsVisible())
						m_pFolderList->SelectItem(msg.pSender->GetTag(),true);
					else
					{

						m_pNoteList->SelectItem(msg.pSender->GetTag(),true);
					}

					return;
				}
				if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
				{
					
					m_pNoteList->SelectItem(msg.pSender->GetTag(),false);
					return;
				}
				if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
				{

					if( m_pNoteList->GetItemIndex(msg.pSender) != -1 && m_pNoteList->IsVisible())
					{
						if( _tcscmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0 ) {
							CPDFNoteInfo* pNoteInfo = (CPDFNoteInfo*)msg.pSender->GetTag();
							if(pNoteInfo!=NULL)
							{
								if(pNoteInfo->pageIndex>0)
								{
									m_curSelNote=-1;
									//m_pMyPDFBook->GotoPageNum(pNoteInfo->pageIndex);
									if(!isUpload && !isShare && !isDelete)
									{
										GoToPage(pNoteInfo->pageIndex);
										m_current_mulu_index=getCurrentMuluIndexByPage(pNoteInfo->pageIndex);
										m_bIsSetMuluIndex=false;
										m_ctrMulu->SelectItem(m_current_mulu_index);
										m_bIsSetMuluIndex=true;
										////���////////
										int nOrgPageNum=0;
										nOrgPageNum =m_pMyBook->GetPageNum();
										theApp.m_EventLog.init();
										CString strPage,strOrgPageNum;
										strPage.Format(L"%d",pNoteInfo->pageIndex);
										strOrgPageNum.Format(L"%d",nOrgPageNum);
										theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGE_CHANGE);
										theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_CHG_TYPE_WAY,L"3");//1 or 2 or 3
										theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_PAGE_FROM,strOrgPageNum); 
										theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
										theApp.m_EventLog.MakeJsonFormat();
										/////////////
										
										
									}
									GetNoteByCataIndex(m_current_mulu_index);



								}
							}

						}
					}
				}
				if (m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
				{
					COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes")));
					if (ComboShareSelect->GetCurSel()==1 && m_pShareStudentFolderLayout->IsVisible() && !import->IsSelected())
					{
						int index = msg.pSender->GetTag();
						SpreadFolder(index);
						CString sn =L"",strId=L"";
						if(m_pShareNote->m_current_Secondfolder_list.size()>0 && m_pShareNote->m_current_Secondfolder_list.size()>index)
						{
							CShareFolder* list =m_pShareNote->m_current_Secondfolder_list.at(index);
							sn =list->m_name;
							for(int n=0;n<list->m_note_list.size();n++)
							{
								CPDFNoteInfo* data=list->m_note_list.at(n);
								CString strserverId;
								strserverId.Format(L"%lld",data->ServerID);
								strId+=strserverId;
								if(n!=(list->m_note_list.size()-1))
								{
									strId+=L",";
								}
							}
							
						}
						
						////���////////
						theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_STD_NOTE);
						theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,L"");
						theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_STD_NAME,sn);
						theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_SERVERID,strId);
						theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_STD_VIEWWAY,L"1");
						theApp.m_EventLog.MakeJsonFormat();
						/////////////
					}
				}
				

				if(m_pNoteCatalogList->GetItemIndex(msg.pSender) != -1 && m_pNoteCatalogList->IsVisible())
				{
					if (_tcscmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0)
					{
						int pgNum = 0;
						if (_tcscmp(msg.pSender->GetName(), _T("Catalog")) == 0)
						{
							textbook_catalogInfo_ex* pCatalogInfo = (textbook_catalogInfo_ex*)msg.pSender->GetTag();
							if (pCatalogInfo != NULL)
							{
								if ((pgNum = pCatalogInfo->startPage) > 0)
								{
									m_pMyBook->GotoPageNum(pCatalogInfo->startPage);
									////���////////
									int nOrgPageNum=0;
									nOrgPageNum =m_pMyBook->GetPageNum();
									theApp.m_EventLog.init();
									CString strPage,strOrgPageNum;
									strPage.Format(L"%d",pgNum);
									strOrgPageNum.Format(L"%d",nOrgPageNum);
									theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGE_CHANGE);
									theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_CHG_TYPE_WAY,L"2");//1 or 2 or 3
									theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_PAGE_FROM,strOrgPageNum); 
									theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
									theApp.m_EventLog.MakeJsonFormat();
									/////////////
								}
							}
						}
						else
						{
							CPDFNoteInfo* pNoteInfo = (CPDFNoteInfo*)msg.pSender->GetTag();
							if (pNoteInfo != NULL)
							{
								if ((pgNum = pNoteInfo->pageIndex) > 0)
								{
									m_pMyBook->GotoPageNum(pNoteInfo->pageIndex);
								}
							}
						}

						

						if (pgNum >= 0) {
							m_pMyPDFBook->RedrawLines();
							
							//m_pdfNoteInfoList.clear();
							//m_noteDao.GetNoteInfosByPageNo(pgNum, m_pBookInfo->bookId, m_pdfNoteInfoList);
							//UpdateBookNotes(m_SidebarWidth);
						}
						//UpdatePageTextShow();
					}
				}
			}
			else if(m_pSidebarTabLayout->GetCurSel()==1)
			{
				if( m_pResList->GetItemIndex(msg.pSender) != -1 )
				{
					if( _tcscmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0 ) {
						CPDFNoteInfo* pResInfo = (CPDFNoteInfo*)msg.pSender->GetTag();
						if(pResInfo!=NULL)
						{
							if(pResInfo->pageIndex>0)
							{
								//m_pMyPDFBook->m_pdf_view->UserNoteSelect(pResInfo->pdfId,NULL);
							}
						}
						
					}
				}
			}
			else if (m_pSidebarTabLayout->GetCurSel() == 3)
			{
				if (m_pCloudNoteList->GetItemIndex(msg.pSender) != -1)
				{
					if( _tcscmp(msg.pSender->GetClass(), _T("ListContainerElementUI")) == 0 )
					{
						CCloudNotePackage* packageInfo = (CCloudNotePackage*)msg.pSender->GetTag();
						if (packageInfo != NULL)
						{
							int i = 0;
							i++;
						}
					}
				}
			}

			if( m_pResMarkList->GetItemIndex(msg.pSender) != -1 )
			{
				if( _tcscmp(msg.pSender->GetClass(), _T("ListLabelElementUI")) == 0 ) {
					CResMarkListUI::BookmarkNode* node = (CResMarkListUI::BookmarkNode*)msg.pSender->GetTag();
					m_pResMarkList->GetExpanderSizeX(node);
					m_pResMarkList->ExpandNode(node, !node->data()._expand);
					if (0 != node->data()._pageNo){
						m_pMyBook->GotoPageNum(node->data()._pageNo);
					}

					if (0 != node->data()._flag)
					{
						if( m_pPlayerWnd != NULL )
						{
							m_pPlayerWnd->ShowWindow();

							CString strSrc = theApp.m_BookResPath;
							CString strRes;

							if (strSrc.Right(1) == _T("\\"))
							{
								strSrc = strSrc.Left(strSrc.GetLength() - 1);
							}

							SetCurrentDirectory(strSrc);
							//strRes = strSrc + node->data()._resAddr;
							strRes = node->data()._resAddr;

							if (strRes.Left(1) == _T("\\"))
							{
								strRes = strRes.Right(strRes.GetLength() - 1);
							}

							m_pPlayerWnd->SetLabelName(node->data()._text.GetData());
							m_pPlayerWnd->m_pdfId = node->data()._pdfId;
							
							m_pPlayerWnd->Play(strRes);
						}
					}
				}
			}
			else
			{
				return;
			}
		}else if(msg.sType==_T("itemselect"))
		{
			CDuiString name=msg.pSender->GetName();
			if(name==_T("combo_labels"))
			{
				UpdateBookNotes(m_SidebarWidth);
			}else if(name==_T("combo_notetypes"))
			{
				UpdateBookNotes(m_SidebarWidth);
			}else if(name==_T("combo_restype"))
			{
				UpdateBookRes();
			}else if(name==_T("combo_resorigin"))
			{
				UpdateBookRes();
			}
			else if(name==_T("ComboMulu"))
			{
				if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
				{
					if(m_bIsSetMuluIndex)
					{
						m_current_mulu_index=m_ctrMulu->GetCurSel();
						GoToPage(m_cata_list.at(m_current_mulu_index).startPage);
						GetNoteByCataIndex(m_current_mulu_index);
						m_pMyPDFBook->RedrawLines();
					}
					else
						m_bIsSetMuluIndex=true;
				}
				else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
				{
					m_current_mulu_index=m_ctrMulu->GetCurSel();
					
					if(m_current_mulu_index>=0 && m_current_mulu_index<m_cata_list.size())
					{
						textbook_catalogInfo& info = m_cata_list.at(m_current_mulu_index);
						m_pcloudNote->SearchCloudNoteByPage(info.startPage,info.endPage);
						UpdateBookNotes(m_SidebarWidth);
						GoToPage(m_cata_list.at(m_current_mulu_index).startPage);
						GetNoteByCataIndex(m_current_mulu_index);
						m_pMyPDFBook->RedrawLines();
					}
				}

			}
			else if(name==_T("ComboMulu_Resource"))
			{
				int index = m_ctrResourceMulu->GetCurSel();
				if(index>=0)
				{
					m_current_mulu_index = index;
					textbook_catalogInfo& info = m_cata_list.at(index);	
					GoToPage(info.startPage);
				}
				if(!theApp.AnalysisConnect())
				{

					CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
				
				}else
				{
					PostMessage(WM_GETEXTRAS,0,0);
				}
				
				
			}
			else if(name==_T("ComboShare"))
			{
				ComboShareSelect->SetEnabled(false);
				GetShareNote();
				if(ComboShareSelect->GetCurSel()==1)
				{
					//AddClassInfo2ComboCtrl();
					m_ctrlClass->SetVisible(true);
				}
				else
					m_ctrlClass->SetVisible(false);

				//m_bCancel=m_bImport=m_bMove=false;
				ClearShareNoteOperator();
				ShowShareNote(m_SidebarWidth);
				ComboShareSelect->SetEnabled(true);
			}
			else if(name==_T("ComboCLassSelect"))
			{
				GetShareNote();
				ShowShareNote(m_SidebarWidth);

			}
		}
		else if(_tcsicmp(msg.sType, _T("dbclick")) == 0)//��������ʼ��ļ���
		{
			CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
			if(h_operator->IsVisible())//����
				return;
			int index=(int)msg.wParam;
			if(index<0) return;
			if(!m_isShowNoteUi)
				return;
			if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW)
			{	
				CPDFNoteInfo* info = GetPdfInfoByIndexExtentFreePen(index);
				if(info)
				{
					
					//m_curSelNote=Setindex;
					//GoToPage(info->pageIndex);
					//ShowSelectNoteInfo(info);
					DataGetByPage(info->pageIndex-1);
					SetCurSel(index);
					m_pMyPDFBook->RedrawLines();
				}
				
			}
			else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::SHARE_NOTE_SHOW)
			{
				if(theApp.AnalysisConnect())
				{
					int index = m_pNoteList->m_current_select_index;
					m_pShareNote->m_index=index;
					if(index>=0 && index<m_pShareNote->m_current_Firstfolder_list.size())
					{
						CShareFolder* folderInfo = m_pShareNote->m_current_Firstfolder_list.at(index);
						if(folderInfo->m_id<=0)
							return;
						else
						{
							//��������ļ���id�����ļ�����Ϣ
							if(folderInfo->m_endtime.GetLength()==0 || GetUserType()==2)
								m_pShareNote->GetFolderListById(0,folderInfo->m_id);
							else
								m_pShareNote->GetFolderListById(1,folderInfo->m_id);
							ShowShareNoteTwo(false);
							////���////////
							theApp.m_EventLog.init();
							theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_FOLDER_OPEN_CLOSE);
							theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FOLDER_OPEN_CLOSE,L"1");
							theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,folderInfo->m_name);
							theApp.m_EventLog.MakeJsonFormat();
							////////////////
						}
					}
				}
				else
				{
					CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
				}
			}
			

		}
		else if(msg.sType==_T("link"))
		{
			CListContainerElementUI* pListElement=(CListContainerElementUI*)msg.pSender->GetTag();
			if(pListElement==NULL) return;
			CPDFNoteInfo* pInfo=(CPDFNoteInfo*)(pListElement->GetTag());
			if(pInfo!=NULL)
			{
				CString strSrc = _T("");
				CString noteText=pInfo->GetStringByNoteText();

				if (pInfo->noteOrigin == ORIGIN_SYSTEM)
					strSrc = theApp.m_BookResPath;
				else
					strSrc = theApp.m_ResourcePath;

				if (strSrc.Right(1) == _T("\\"))
				{
					if (strSrc.Right(1) == _T("\\"))
					{
						if (noteText.Right(1) == _T("\\"))
							strSrc = strSrc.Left(strSrc.GetLength() - 1);
					}
				}
				m_cLog.WriteLog(_T("Open Resources Left: strSrc = %s"), strSrc);
				m_cLog.WriteLog(_T("Open Resources Left: notetext= %s"), noteText);
				if(1)
				{
					//CString str_doc = _T("\"")+strSrc+noteText+_T("\"");
					WriteLog(OP_OPEN_FILE);
					CString str_doc = strSrc+noteText;
					CString office_path = GetOfficePath(str_doc);

					CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);

					HINSTANCE result = (HINSTANCE)ERROR_FILE_NOT_FOUND;

					str_doc = _T("\"")+strSrc+noteText+_T("\"");
					if (_T("")==office_path)
					{
						CString str_temp = str_doc;
						str_temp.MakeLower();
						if(str_temp.Find(_T(".mp3")) != -1)
						{
							SetCurrentDirectory(strSrc);
							CString strResPath = noteText;

							if( g_pFrame->m_pPlayerWnd == NULL)
							{
								g_pFrame->m_pPlayerWnd = new CPlayerWnd();

								g_pFrame->m_pPlayerWnd->Create(NULL, _T("DuiLib Demo from mbstudio.cn / meineson"), UI_WNDSTYLE_DIALOG, 0L, 0, 0, 0, 0);
								SetParent(g_pFrame->m_pPlayerWnd->GetHWND(), g_pFrame->GetHWND());
								RECT rect;
								GetWindowRect(g_pFrame->GetHWND(), &rect);

								if(g_bScreenShow)
									::SetWindowPos(g_pFrame->m_pPlayerWnd->GetHWND(), NULL, rect.right-600, rect.bottom-105, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
								else
									::SetWindowPos(g_pFrame->m_pPlayerWnd->GetHWND(), NULL, rect.right-300, rect.bottom-42, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

								g_pFrame->m_pPlayerWnd->ShowWindow();
								g_pFrame->m_pPlayerWnd->SetLabelName(_T(""));
							
								g_pFrame->m_pPlayerWnd->bRead = false;
								g_pFrame->m_pPlayerWnd->Play(strResPath);
								result = (HINSTANCE)32;
							}
							else
							{
								g_pFrame->m_pPlayerWnd->ShowWindow();
								g_pFrame->m_pPlayerWnd->SetLabelName(_T(""));
								
								g_pFrame->m_pPlayerWnd->bRead = false;
								g_pFrame->m_pPlayerWnd->Play(strResPath);
								result = (HINSTANCE)32;
							}
						}
						else
						{
							result = ShellExecute(NULL,_T("open"),str_doc,NULL,NULL,SW_SHOWNORMAL);

							if(!((int)result > 32))
							{
								int pos = noteText.ReverseFind('.');
								if(pos != -1)
									noteText = noteText.Right(noteText.GetLength() - pos);

								noteText.MakeLower();

								if(noteText == _T(".jpg") || noteText == _T(".jpeg") || noteText == _T(".gif") || noteText == _T(".bmp") || noteText == _T(".png"))
								{
									result = ShellExecute(NULL,_T("edit"),str_doc,NULL,NULL,SW_SHOWNORMAL);
								}
							}
						}
					} 
					else
					{
						result = ShellExecute(NULL,_T("open"),office_path,str_doc,NULL,SW_SHOWNORMAL);
					}

					if(((int)result)==ERROR_FILE_NOT_FOUND)
					{
						CustomMessageBox(_T("��Դ�ļ������ڣ�"),MSG_TYPE_NOTICE,FALSE);
					}
					else if(((int)result)<32)
					{
						CustomMessageBox(_T("�Ҳ����򿪸���Դ�ij���"),MSG_TYPE_NOTICE,FALSE);
					}
				}
			}
		}
	}

	LRESULT CReaderFrame::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		bHandled = false;
		return 0;
	}


	BOOL CReaderFrame::HandleGesturePan(GESTUREINFO &gi, CListUI* pInList)
	{
		CListUI* pList = NULL;

		pList = pInList;
		/*if (m_pBookmarkList->IsVisible())
		{
		pList = m_pBookmarkList;
		} 
		else if (m_pNoteList->IsVisible())
		{
		pList = m_pNoteList;
		}
		else if (m_pCloudNoteList->IsVisible())
		{
		pList = m_pCloudNoteList;
		}
		else if (m_pResList->IsVisible())
		{
		pList = m_pResList;
		}*/
		
		if( NULL==pList ) return FALSE;

		// Flicking left or right changes the page,
		// panning moves the document in the scroll window
		if (gi.dwFlags == GF_BEGIN) {
			g_touchState.panStarted = true;
			g_touchState.panPos = gi.ptsLocation;

			g_touchState.panScrollOrig = pList->GetScrollPos();
		}
		else if (g_touchState.panStarted) {
			int deltaX = g_touchState.panPos.x - gi.ptsLocation.x;
			int deltaY = g_touchState.panPos.y - gi.ptsLocation.y;
			g_touchState.panPos = gi.ptsLocation;

			//if ((gi.dwFlags & GF_INERTIA)) {

			// ����
			pList->Scroll(0,deltaY);
			pList->Invalidate();
			UpdateWindow(GetHWND());
			//}
		}
		else if (gi.dwFlags == GF_END)
		{
			g_touchState.panStarted = false;
		}

		return TRUE;
	}


	LRESULT CReaderFrame::DecodeGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
		// Create a structure to populate and retrieve the extra message info.
		CListUI* pList = NULL;

		if (m_pBookmarkList->IsVisible())
		{
			pList = m_pBookmarkList;
		} 
		else if (m_pNoteList->IsVisible())
		{
			pList = m_pNoteList;
		}
		else if (m_pCloudNoteList->IsVisible())
		{
			pList = m_pCloudNoteList;
		}
		else if (m_pResList->IsVisible())
		{
			pList = m_pResList;
		}
		else if (m_pResMarkList->IsVisible())
		{
			pList = m_pResList;
		}

		if( NULL==pList ) return FALSE;

		GESTUREINFO gi;  

		ZeroMemory(&gi, sizeof(GESTUREINFO));

		gi.cbSize = sizeof(GESTUREINFO);

		BOOL bResult  = PDF_GetGestureInfo((HGESTUREINFO)lParam, &gi);
		BOOL bHandled = FALSE;

		POINT pt; pt.x = gi.ptsLocation.x; pt.y = gi.ptsLocation.y;
		::ScreenToClient(*this, &pt);

		RECT rectBox = pList->GetPos();
		if (!PtInRect(&rectBox,pt))
		{
			if(m_pResMarkList != pList && m_pResMarkList->IsVisible())
			{
				RECT rectBox2 = m_pResMarkList->GetPos();
				if(PtInRect(&rectBox2,pt))
					pList = m_pResMarkList;
				else
					return FALSE;
			}
			else
				return FALSE;
		}

		CScrollBarUI* pScroll = pList->GetVerticalScrollBar();
		if (NULL!=pScroll)
		{
			RECT rt_scroll = pScroll->GetPos();

			if (PtInRect(&rt_scroll,pt))
			{
				return FALSE;
			}

		}


		if (bResult){
			// now interpret the gesture
			switch (gi.dwID){
			case GID_ZOOM:
				// Code for zooming goes here     
				//bHandled = TRUE;
				break;
			case GID_PAN:
				// Code for panning goes here
				bHandled = HandleGesturePan(gi, pList);
				break;
			case GID_ROTATE:
				// Code for rotation goes here
				//bHandled = TRUE;
				break;
			case GID_TWOFINGERTAP:
				// Code for two-finger tap goes here
				//bHandled = TRUE;
				break;
			case GID_PRESSANDTAP:
				// Code for roll over goes here
				//bHandled = TRUE;
				break;
			default:
				// A gesture was not recognized
				break;
			}
		}else{
			DWORD dwErr = GetLastError();
			if (dwErr > 0){
				//MessageBoxW(hWnd, L"Error!", L"Could not retrieve a GESTUREINFO structure.", MB_OK);
			}
		}

		return bHandled;

	}

	LRESULT CReaderFrame::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
	{
		CLabelUI* pViewReader = NULL;
		LRESULT lRes = 0;
		BOOL bHandled = TRUE;
		GESTURECONFIG gc = {0,GC_ALLGESTURES,0};
		BOOL bResult = TRUE;

		switch( uMsg ) {
/*		case WM_OPER_OK: */
// 			{m_pLabelSetFrame->Close();
// 			theApp.WaitOperation(0);
// 			break;}
		//Add By Ray 2018-10-22 
		/*case WM_THREAD_NOTEFILE_DOWNLOAD_OK:
			{
				AfxMessageBox(L"download-ok");
				CNoteDao noteDao(m_pBookInfo->bookId);
				//�ҵ���ɵıʼDz�д���������
				int nIndex=(int)(wParam);
				CPDFNoteInfo temp=m_DownloadNoteFileTemp.at(nIndex);
				temp.content =m_DownloadNoteFile_List.m_SavePath.c_str();//�����޸�Ϊ���
				//Copy������Ŀ¼�£�����Content
				SetAttachFile(&temp);
				int nMaxId=noteDao.AddNoteInfo(temp);
				AfxMessageBox(L"update data-ok");
				//Note.id =nMaxId;
				//}
				break;
			}*/
		case WM_CREATE:        lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
		case WM_CLOSE:         lRes = OnClose(uMsg, wParam, lParam, bHandled); break;
		case WM_DESTROY:       lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
		case WM_NCACTIVATE:    lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
			// 		case WM_NCCALCSIZE:    lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
			// 		case WM_NCPAINT:       lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
			//case WM_NCHITTEST:     lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
		case WM_TIMER: lRes = OnTimer(uMsg, wParam, lParam, bHandled); break;
		case WM_MOUSEMOVE:
			{
				lRes = OnMouseMove(uMsg, wParam, lParam, bHandled);
				bHandled=FALSE;
			}break;
		case WM_GETEXTRAS://Add By Ray 2019-07-12
			{
				GetExtras();
				UpdateBookRes();
				break;
			}
		case WM_PDF_PRE_PAGE:
			{
				//ReaderPageUp();
				GotoPrePage();
			
			}break;
		case WM_PDF_NEXT_PAGE:
			{
				//ReaderPageDown();
				GotoNextPage();
			}break;
		case WM_FREEPEN_FRAME_CLOSE:
			{
				m_freeLineFrame->ShowWindow(false);
				isShowFreePen=false;
				SetPenAndColor(NOTES_NONE, GetPenColor());
			}break;
		case WM_SELECT_PEN_COLOR:
			{
				SetPenColor(wParam);
			}break;
		case WM_SELECT_PEN_WIDTH:
			{
				m_iLineWidth = wParam;
				UpdateLineMode();
				
			}break;
		case WM_FREEPEN_FRAME_CLEAR:
			{
				EraseModeUse();
			}break;
		case WM_FREEPEN_FRAME_BACK:
			{
				if(m_isShowNotes)
				{
					BackOpertaion();
				}
			}break;
		case WM_FREEPEN_FRAME_CLEAR_ALL:
			{

				if(m_isShowNotes)
				{
					if(CustomMessageBox(L"�Ƿ������ǰҳ�������ɻ��ʣ�",MSG_TYPE_YESNO)==IDOK)
					{
						//CNoteDao NoteDao(m_pBookInfo->bookId);
						BackUpFreePen();
						if (m_pdf_show_model==4)//˫ҳ
						{
							m_noteDao->DeleteFreePenNoteByPage(m_current_page-1);
							m_noteDao->DeleteFreePenNoteByPage(m_current_page);
						}
						else
							m_noteDao->DeleteFreePenNoteByPage(m_current_page-1);
						GetNoteByCataIndex(m_current_mulu_index);
						SetNeedReloadDB();
						m_pMyPDFBook->RedrawLines();
					}
				}
				
			}break;
		case WM_GESTURE:
			if (PDF_SupportsGestures())
			{
				bResult = DecodeGesture(GetHWND(),uMsg,wParam,lParam);
			}
			else
			{
				bResult = FALSE;
			}

			break;
		case WM_SIZE:      lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
			//case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break;
			//case WM_TIMER: lRes = OnTimer(uMsg, wParam, lParam, bHandled); break;
			//case WM_SYSCOMMAND:    lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break;
		case  WM_NCLBUTTONDBLCLK:
			if(HTCAPTION==wParam)
			{
				return 0;
			}
		case WM_MENUCLICK:
			{
				CDuiString *strMenuName = (CDuiString*)wParam;

				bool bChecked = (bool)lParam;
				CString strMenuItem = (CString)(*strMenuName);
	
				if (*strMenuName == _T("Menu_Postil_Edit"))
					UpdatePostilNoteInfo(lParam);
				else if (*strMenuName == _T("Menu_Fit_Height_Tool"))
					DoReaderCommand(DCMD_EDIT_FIT_PAGE);
				else if (*strMenuName == _T("Menu_Show_Hide_Note"))
					ShowMarkButtonClick();
				else if (*strMenuName == _T("Menu_Double_Single_Page_Tool"))
					changeShowMode();
				else if (*strMenuName == _T("Menu_Zoomin_Tool"))
					DoReaderCommand(DCMD_ZOOM_IN);
				else if (*strMenuName == _T("Menu_Zoomout_Tool"))
				{
					float radio = GetCurrentRadio();
					if(m_minRadio-radio>0.05)
						DoReaderCommand(DCMD_ZOOM_OUT);
				}


				//�ʼ��б� �Ҽ� ���ز˵�
				else if (*strMenuName == _T("local_note_open"))//�༭   ����
				{
					int index=m_pNoteList->m_current_select_index;
					if(index>=0 && index<m_pdfNoteInfoList.size())
					{
						
						CPDFNoteInfo* info = GetPdfInfoByIndexExtentFreePen(index);
						//m_curSelNote=set;
						if(info->pdfNoteType==NoteFreedom)
						{
							CustomMessageBox(L"���ɻ��ʲ�֧�ֱ༭",MSG_TYPE_NOTICE,FALSE);
							return 0;
						}
						
						GoToPage(info->pageIndex);
						SetCurSel(index);
						ShowSelectNoteInfo(info);
						m_pMyPDFBook->RedrawLines();

					}
				}
				else if (*strMenuName == _T("local_note_open_source"))//����Դ   ����
				{
					//Modify By Ray 2019-05-22
					//��Դ302��ת
					if(NetWorkAndTokenCheck())
					{
						int index=m_pNoteList->m_current_select_index;
						if(index>=0 && index<m_pdfNoteInfoList.size())
						{

							CPDFNoteInfo* info = GetPdfInfoByIndexExtentFreePen(index);
							CWebviewFrame* web = new CWebviewFrame(info->LinkURL,m_pMyPDFBook->GetPageNum(),L"",DO_RESOURCE,m_pBookInfo->bookId);
							web->Create(this->GetHWND(), _T("WebviewFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
							web->CenterWindow();
							web->ShowWindow();

						}

					}
					
				}
				else if (*strMenuName == _T("local_note_delete"))//ɾ��    ����
				{
					DeleteSelNoteInList(FALSE,2);
				}

				else if (*strMenuName == _T("local_note_to_cloud"))//���رʼ��ϴ��Ʊʼ�
				{
					if(!theApp.AnalysisConnect())
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
						return 0;
					}
					UpNoteToCloud();
					GetNoteByCataIndex(m_current_mulu_index);
					UpdateBookNotes(m_SidebarWidth);
				}
				else if (*strMenuName == _T("local_note_to_share"))//���رʼǷ���(�Ҽ�)
				{
					ShatrNoteInList();
					

				}

				else if (*strMenuName == _T("local_note_open_file"))//���رʼǴ򿪸���
				{
					vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
					int index=m_pNoteList->m_current_select_index;
					if(index>=0 && index<m_pdfNoteInfoList.size())
					{
						CPDFNoteInfo* info = GetPdfInfoByIndexExtentFreePen(index);
						openAppendFile(info,index);
					}
				}
				//��Դ�Ҽ��б�

				else if (strMenuItem.Find(_T("Menu_Open_Resource")) != -1)//����Դ
				{
					if(NetWorkAndTokenCheck())
					{
						int index=m_pResList->m_current_index;
						if(index>=0)
						{
							CHorizontalLayoutUI* res_type_layout=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("res_type_layout")));
							if(res_type_layout)
							{
								int size = res_type_layout->GetCount();
								if(size>0)
								{
									
									CExtrasData info=m_extrs->GetSelectExtrasData(index);
									
									////���////////
									CString strId=L"";
									int nPos =info.strHtmlUrl.ReverseFind('=');
									strId =info.strHtmlUrl.Mid(nPos+1,info.strHtmlUrl.GetLength());
									int nOrgPageNum=0;
									nOrgPageNum =m_pMyBook->GetPageNum();
									theApp.m_EventLog.init();
									CString strOrgPageNum;
									strOrgPageNum.Format(L"%d",nOrgPageNum);
									theApp.m_EventLog.SetLogEvent(EVENT_BOOK_RESOURCE_VIEW);
									theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_VIEW_NAME,info.strTitle);
									theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_VIEW_ID,strId); 
									theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strOrgPageNum);
									theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_URL,info.strHtmlUrl);
									theApp.m_EventLog.MakeJsonFormat();
									////////////////
									//Modify By Ray 2019-05-22
									//��Դ302��ת
									//ShowBrowser(3,info.strHtmlUrl);
									CWebviewFrame* web = new CWebviewFrame(info.strHtmlUrl,m_pMyPDFBook->GetPageNum(),L"",DO_RESOURCE,m_pBookInfo->bookId);
									web->Create(this->GetHWND(), _T("WebviewFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
									web->CenterWindow();
									web->ShowWindow();
								}
							}
						}

					}


				}
				else if (strMenuItem.Find(_T("Menu_Add_Resource_2_Page")) != -1)//������Դ��PDF
				{
					AddResource2Page();
				}

				
				//�Ʊʼ��Ҽ��˵�
				else if (strMenuItem.Find(_T("cloud_notes_download")) != -1)//���뱾��
				{
					NoteImport();
				}
				else if (*strMenuName == _T("cloud_notes_share"))//�ƱʼǷ���
				{
					ShatrNoteInList(TRUE);

				}
				else if (*strMenuName == _T("cloud_notes_delete"))//ɾ���Ʊʼ�
				{
					DeleteSelNoteInList(TRUE);
					
				}
				
				else if (*strMenuName == _T("menu_share_folder_to_local_to_me_teacher"))//�������뱾��  �������ҵ�   ��ʦ
				{
					
					int index=m_pNoteList->m_current_select_index;
					m_pShareNote->GetSingleSelFolderNotes(index);
					if(index>=0)
					{
						
						ShareNoteImport2Local(m_pShareNote->m_temp_Second_note_list);


					}
				}
				else if (*strMenuName == _T("menu_share_folder_to_local_to_me_student"))//�������뱾��  �������ҵ�   ѧ��
				{
					
					int index=m_pNoteList->m_current_select_index;
					m_pShareNote->GetSingleSelFolderNotes(index);
					if(index>=0)
					{

						ShareNoteImport2Local(m_pShareNote->m_temp_Second_note_list);


					}
				}
				else if (*strMenuName == _T("menu_share_folder_to_local_to_me_student_two"))//�������뱾��  �������ҵ�   ѧ�� ����
				{
					int index = m_pFolderList->m_current_select_index;
					vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
					m_pShareNote->GetTrueNoteInfo(selectNoteInfos,index);

					ShareNoteImport2Local(selectNoteInfos);


					
					
				}
				else if (*strMenuName == _T("menu_share_folder_to_local"))//�������뱾��  �ҹ�����
				{
					
					int index=m_pNoteList->m_current_select_index;
					m_pShareNote->GetSingleSelFolderNotes(index);
					if(index<0)
						CustomMessageBox(L"ѡ��ʼ�Ϊ��,������ѡ��",MSG_TYPE_NOTICE,FALSE);
					else
					{
						
						ShareNoteImport2Local(m_pShareNote->m_temp_Second_note_list);

					}

				}
				else if(*strMenuName ==_T("menu_share_folder_open"))
				{
					if(theApp.AnalysisConnect())
					{
						int index = m_pNoteList->m_current_select_index;
						m_pShareNote->m_index=index;
						if(index>=0 && index<m_pShareNote->m_current_Firstfolder_list.size())
						{
							CShareFolder* folderInfo = m_pShareNote->m_current_Firstfolder_list.at(index);
							if(folderInfo->m_id>0)
							{
								//��������ļ���id�����ļ�����Ϣ
								if(folderInfo->m_endtime.GetLength()==0 || GetUserType()==2)
									m_pShareNote->GetFolderListById(0,folderInfo->m_id);
								else
									m_pShareNote->GetFolderListById(1,folderInfo->m_id);
								ShowShareNoteTwo(false);
								////���////////
								theApp.m_EventLog.init();
								theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_FOLDER_OPEN_CLOSE);
								theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FOLDER_OPEN_CLOSE,L"1");
								theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,folderInfo->m_name);
								theApp.m_EventLog.MakeJsonFormat();
								////////////////
							}
						}
					}
					else
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
					}
				}
				else if (*strMenuName == _T("menu_share_student_to_local_two"))//�������뱾��  �ҹ����� ����ҳ��   
				{
					vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
					m_pFolderList->GetSelectItems(m_pdfNoteInfoList,selectNoteInfos);
					//����Ŀ¼����ʼ�����
					ShareNoteImport2Local(selectNoteInfos);

					//int size = m_pShareNote->m_current_Second_note_list.size();

				
				}
				else if (*strMenuName == _T("menu_share_teacher_cancel_two"))//��ʦ �����ʼ� �ҹ����� ����  �����ʼ� 
				{
					vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
					m_pFolderList->GetSelectItems(m_pdfNoteInfoList,selectNoteInfos);
					//����Ŀ¼����ʼ�����
				  RecallShareNote();


				}
				else if (*strMenuName == _T("menu_share_folder_modify_name"))//�޸��ļ�������  
				{
					if(m_pNoteList->m_current_select_index>=0)
					{
						CShareFolder* info = m_pShareNote->m_current_Firstfolder_list.at(m_pNoteList->m_current_select_index);
						ModifyFolder(info);
					}

				}
				else if (*strMenuName == _T("menu_open_share_folder"))//�鿴���� 
				{
					if(theApp.AnalysisConnect())
					{
						int index = m_pNoteList->m_current_select_index;
						m_pShareNote->m_index=index;
						if(index>=0 && index<m_pShareNote->m_current_Firstfolder_list.size())
						{
							CShareFolder* folderInfo = m_pShareNote->m_current_Firstfolder_list.at(index);
							if(folderInfo->m_id>0)
							{
								//��������ļ���id�����ļ�����Ϣ
								if(folderInfo->m_endtime.GetLength()==0 || GetUserType()==2)
									m_pShareNote->GetFolderListById(0,folderInfo->m_id);
								else
									m_pShareNote->GetFolderListById(1,folderInfo->m_id);
								ShowShareNoteTwo(false);
								////���////////
								theApp.m_EventLog.init();
								theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_FOLDER_OPEN_CLOSE);
								theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FOLDER_OPEN_CLOSE,L"1");
								theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,folderInfo->m_name);
								theApp.m_EventLog.MakeJsonFormat();
								////////////////
							}
						}
					}
					else
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
					}
				}
				else if (*strMenuName == _T("menu_share_student_to_cancel_two"))//��������  �ҹ�����   �����ʼ�
				{
					RecallShareNote();
				}

				else if (*strMenuName == _T("menu_share_from_me_open_folder"))//���ļ���  �ҹ�����
				{
					vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
					if(m_share_note_operator)
					{
						delete m_share_note_operator;
						m_share_note_operator=NULL;
					}
					m_share_note_operator=new CShareNoteOperator;
					m_share_note_operator->m_type=0;
					m_share_note_operator->m_select_index=m_pNoteList->m_current_select_index;
					ShowShareNoteTwo(false);
				}

				else if (*strMenuName == _T("menu_move_folder_to_local_to_me_teacher"))//�������ҵ�  �ƶ�
				{
					vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
					int index=m_pNoteList->m_current_select_index;
					
					if(index>=0)
					{
						//GetSelectShareNotes(index,selectNoteInfos);
						selectNoteInfos =m_pShareNote->m_current_Firstfolder_list.at(index)->m_note_list;
						ShowShareMoveFrame(selectNoteInfos);
					}
					//int index=m_pFolderList->m_current_select_index;
				}
				else if (*strMenuName == _T("menu_share_folder_cancel"))//���ع����ʼ�  �ҹ�����
				{

					RecallShareNote();
				}

				//pdf�Ķ����Ҽ��˵���Ϣ

				else if (*strMenuName == _T("Menu_Open_Note_Attach"))//�򿪸���
				{
					OpenFileNoteByNoteId(m_curSelNote);
				}
				else if (*strMenuName == _T("Menu_Edit_Note"))//�༭�ʼǣ����߱ʼ�֮�⣩
				{
					if(m_curSelNote>=0)
					{
						CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
						ShowSelectNoteInfo(info);
						m_pMyPDFBook->RedrawLines();
					}	
				}
				else if (*strMenuName == _T("Menu_Edit_See"))//�鿴�ʼǣ����߱ʼ�֮�⣩
				{
					if(m_curSelNote>=0)
					{
						CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
						ShowSelectNoteInfo(info,1);
						m_pMyPDFBook->RedrawLines();
					}	
				}
				else if (*strMenuName == _T("Menu_saveAs_Attach_Note"))//�����ʼ�����Ϊ
				{
					if(m_curSelNote>=0)
					{
						CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
						SaveAttachFile2Local(info->content);
					}
				}
				else if (*strMenuName == _T("Menu_Open_Note_Link"))//��Դ�ʼǴ�
				{
					if(NetWorkAndTokenCheck())
					{
						if(m_curSelNote>=0)
						{
							CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);

							////���////////
							CString strId=L"";
							int nPos =info->LinkURL.ReverseFind('=');
							strId =info->LinkURL.Mid(nPos+1,info->LinkURL.GetLength());
							int nOrgPageNum=0;
							nOrgPageNum =m_pMyBook->GetPageNum();
							theApp.m_EventLog.init();
							CString strOrgPageNum;
							strOrgPageNum.Format(L"%d",nOrgPageNum);
							theApp.m_EventLog.SetLogEvent(EVENT_BOOK_RESOURCE_VIEW);
							theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_VIEW_NAME,_T(""));
							theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_VIEW_ID,strId); 
							theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strOrgPageNum);
							theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_RESOURCE_URL,info->LinkURL);
							theApp.m_EventLog.MakeJsonFormat();
							////////////////
							//Modify By Ray 2019-05-22
							//��Դ302��ת
							//ShowBrowser(3,info.strHtmlUrl);
							CWebviewFrame* web = new CWebviewFrame(info->LinkURL,m_pMyPDFBook->GetPageNum(),L"",DO_RESOURCE,m_pBookInfo->bookId);
							web->Create(this->GetHWND(), _T("WebviewFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
							web->CenterWindow();
							web->ShowWindow();
						}

					}
				}
				else if (*strMenuName == _T("Menu_move_note_2_page"))//����ҳ���ƶ�
				{
					if(m_curSelNote>=0)
					{
						CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
						if(info->pageIndex%2==0)
							info->pageIndex=info->pageIndex-1;
						else
							info->pageIndex=info->pageIndex+1;
						UpdateDBAndPDFList(info,true);
						SetNeedReloadDB();
						m_curSelNote=-1;
						m_pMyPDFBook->RedrawLines();

					}	
				}


				else if (*strMenuName == _T("Menu_Add_Line_Note"))//���ӻ��߱ʼ�
				{
					AddToLineNote(LineType(m_nSelLineNote_Line),m_nSelLineNote_Color);
				}	
				else if(*strMenuName == _T("Menu_Edit_Line_Note"))//�༭���߱ʼ�
				{
					RightClickEditLineNote();
				}
				else if(*strMenuName == _T("Menu_Add_And_Edit_Line_Note"))//���Ӳ��ұ༭���߱ʼ�
				{
					m_bAddAndEdit=true;
					AddToLineNote(LineType(m_nSelLineNote_Line),m_nSelLineNote_Color);
					m_bAddAndEdit=false;
					
				}
				else if (*strMenuName == _T("Menu_Copy_Text_Tool"))//��������
				{
					//CopyTextToClipBoard(lParam);
					//m_pMyPDFBook->CopyContext();
					if(m_curSelNote>=0)
					{
						CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
						CopyToClipboard(info->content.GetBuffer(info->content.GetLength()),info->content.GetLength());
					}else
					{
						CopyToClipboard(m_currentSelectInfo->content.GetBuffer(m_currentSelectInfo->content.GetLength()),m_currentSelectInfo->content.GetLength());
					}

				}
				else if (*strMenuName == _T("Menu_Delete_Note"))//ɾ���ʼ�
				{     
					int iRet =CustomMessageBox(STRING_MSG_DELETE_DOUBLE_CHECK,MSG_TYPE_YESNO,0);
					if(iRet ==IDOK)
					{
						DeleteSelNote();
					}

				}
				delete strMenuName;
			}
			break;
		case MY_WM_READER_TOOLBAR:
			UpdateToolBarVisiblity(wParam);
			break;
		case MY_WM_FIT_WIDTH:

			//WaitTimeMs(50);

			if (m_pMyPDFBook)
			{
				m_pMyPDFBook->FitWidth();
			}

			break;

		case WM_KEYDOWN:
			{
				/* lRes = OnKeyDown(uMsg, wParam, lParam, bHandled);*/
				BOOL bCtrl=FALSE;
				BOOL bShift=FALSE;
				if(GetKeyState(VK_CONTROL)<0)
				{
					bCtrl=TRUE;
				}
				if(GetKeyState(VK_SHIFT)<0)
				{
					bShift=TRUE;
				}
				
				if(wParam!=17)
					HotKey_Oeration(bCtrl,bShift,wParam,2);
			}
			break;

		case WM_UPDATE_NOTES_IN_CLOUD:
			{
				UpdateCloudNotePackagesList();

				if(m_pLabelCloudPackageRefresh->IsVisible())
				{
					m_pLabelCloudPackageRefresh->SetText(_T("ˢ�³ɹ���"));
					
		
				}
				//m_pLabelCloudPackageRefresh->SetVisible(FALSE);
				m_NoteTypeMenuCheckInfo.clear();
				
			}
			break;

		case WM_UPDATE_ONE_NOTE_STATE:
			{
				UpdateOneCloudNoteStatus((int)wParam);
			}
			break;

		case WM_CLOUD_PACKAGE_DELETE:
			{
				if (m_pDownloadCloudNotes != NULL)
				{
					if(m_pDownloadCloudNotes->m_isDelete == 1)
						m_pDownloadCloudNotes->DeletePackageListByNoteId(m_pBookInfo->bookId);
				}
			}
			break;

	/*	case WM_CLOUD_PACKAGE_DWONLOAD:
			{
				if (m_pDownloadCloudNotes != NULL)
				{
					if(m_pDownloadCloudNotes->m_isDowload == 1)
						m_pDownloadCloudNotes->DownloadPackageListByBookId(m_pBookInfo->bookId);
				}
			}
			break;*/

		case WM_PAINT:
			{
				int i = 0;
				i++;
				bHandled = FALSE;
				//				m_pMyPDFBook->m_pdf_view->InvalidateView(1);
			}
			break;

		
		case WM_PDFVIEW_GOTO_PAGE:
			{
				int iPage = (int)wParam;
				GoToPageByStart(iPage);

			}
			break;
		case WM_SEARCH_START:
			{
				BSTR b = (BSTR)wParam;
				CString strText(b);
				SysFreeString(b);
				WriteLog(OP_SEARCH, strText);
				m_pMyPDFBook->SearchStr(strText, 0, 1);
			}
			break;
		case WM_SEARCH_PRE:
			{
				BSTR b = (BSTR)wParam;
				CString strText(b);
				SysFreeString(b);
				//m_pMyPDFBook->SearchPrev();
				m_pMyPDFBook->SearchStr(strText, 0, 0);
			}
			break;
		case WM_SEARCH_NEXT:
			{
				BSTR b = (BSTR)wParam;
				CString strText(b);
				SysFreeString(b);
				//m_pMyPDFBook->SearchNext();
				m_pMyPDFBook->SearchStr(strText, 1, 0);
			}
			break;
		case WM_READ_PAGE_PRE:
			{
				PrevPageButtonClick();
			}
			break;
		case WM_READ_PAGE_NEXT:
			{
				NextPageButtonClick();
			}
			break;
		case WM_READ_PAGE_DOUBLE:
			{
				DoublePageButtonClick();
			}
			break;
		case WM_READ_PAGE_SINGLE:
			{
				SinglePageButtonClick();
			}
			break;
		case WM_READ_PAGE_FIXED:
			{
				int iShow = (int)wParam;
				if (iShow == 1)
					m_bShowtool = FALSE;
				else 
					m_bShowtool = TRUE;
			}
			break;
		
		default:
			bHandled = FALSE;
		}

		if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) );
		return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
	}

	LRESULT CReaderFrame::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		RECT rcWnd;
		//::GetWindowRect(GetHWND(), &rcWnd);

		/*if (rcWnd.right-rcWnd.left>10)
		{
		if (m_pMyPDFBook)
		{
		m_pMyPDFBook->FitWidth();
		}
		}*/
		AfxGetMainWnd()->GetClientRect(&rcWnd);
		MoveWindow(this->GetHWND(),rcWnd.left,rcWnd.top,rcWnd.right-rcWnd.left,rcWnd.bottom-rcWnd.top,FALSE);
		return 0;
		//bHandled = FALSE;
		//return -1;
	}
	void CReaderFrame::ClearPdfNoteList()
	{
		for (int i=m_pdfNoteInfoList_drawPdf.size()-1;i>=0;i--)
		{
			CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(i);
			if(info)
			{
				delete info;
				info=NULL;
			}
		}
		m_pdfNoteInfoList_drawPdf.clear();
	}
	void CReaderFrame::ClearBkFreeLinePdfNoteList()
	{
		for (int i=m_pdfNoteInfoListBK.size()-1;i>=0;i--)
		{
			CPDFNoteInfo* info = m_pdfNoteInfoListBK.at(i);
			if(info)
			{
				delete info;
				info=NULL;
			}
		}
		m_pdfNoteInfoListBK.clear();
	}
	LRESULT CReaderFrame::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		MONITORINFO oMonitor = {};
		oMonitor.cbSize = sizeof(oMonitor);
		::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
		CDuiRect rcWork = oMonitor.rcWork;
		LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam;
		lpMMI->ptMaxPosition.x = rcWork.left;
		lpMMI->ptMaxPosition.y = rcWork.top;
		lpMMI->ptMaxSize.x = rcWork.right - rcWork.left;
		lpMMI->ptMaxSize.y = rcWork.bottom - rcWork.top;

		bHandled = FALSE;
		return -1;
	}

	/*LRESULT  CReaderFrame::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
	// ��ʱ�����յ�WM_NCDESTROY���յ�wParamΪSC_CLOSE��WM_SYSCOMMAND
	/*if( wParam == SC_CLOSE ) {
	::PostQuitMessage(0L);
	bHandled = TRUE;
	return 0;
	}
	//BOOL bZoomed = ::IsZoomed(*this);
	LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);

	/*
	if( ::IsZoomed(*this) != bZoomed ) {
	if( !bZoomed ) {
	CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
	if( pControl ) pControl->SetVisible(false);
	pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
	if( pControl ) pControl->SetVisible(true);
	}
	else {
	CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
	if( pControl ) pControl->SetVisible(true);
	pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
	if( pControl ) pControl->SetVisible(false);
	}
	}

	return lRes;
	}*/

	LRESULT CReaderFrame::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		if( ::IsIconic(*this) ){
			bHandled = FALSE;
		}
		return (wParam == 0) ? TRUE : FALSE;
	}

	LRESULT CReaderFrame::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
		::ScreenToClient(*this, &pt);

		RECT rcClient;
		::GetClientRect(*this, &rcClient);

		if( !::IsZoomed(*this) ) {
			RECT rcSizeBox = m_pm.GetSizeBox();
			if( pt.y < rcClient.top + rcSizeBox.top ) {
				if( pt.x < rcClient.left + rcSizeBox.left ) return HTTOPLEFT;
				if( pt.x > rcClient.right - rcSizeBox.right ) return HTTOPRIGHT;
				return HTTOP;
			}
			else if( pt.y > rcClient.bottom - rcSizeBox.bottom ) {
				if( pt.x < rcClient.left + rcSizeBox.left ) return HTBOTTOMLEFT;
				if( pt.x > rcClient.right - rcSizeBox.right ) return HTBOTTOMRIGHT;
				return HTBOTTOM;
			}
			if( pt.x < rcClient.left + rcSizeBox.left ) return HTLEFT;
			if( pt.x > rcClient.right - rcSizeBox.right ) return HTRIGHT;
		}

		RECT rcCaption = m_pm.GetCaptionRect();
		if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
			&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) {
				CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
				if( pControl && _tcscmp(pControl->GetClass(), _T("ButtonUI")) != 0 &&
					_tcscmp(pControl->GetClass(), _T("OptionUI")) != 0 &&
					_tcscmp(pControl->GetClass(), _T("TextUI")) != 0 )
					return HTCAPTION;
		}

		return HTCLIENT;
	}
#pragma endregion

	int CReaderFrame::SetBookFileName( CBookInfo *bookInfo,LPCTSTR  szBookFile)
	{
		CString sFileName(szBookFile);
		CString sExt = PathFindExtension(sFileName);
		//		AfxMessageBox(sExt);

		if (sExt.CompareNoCase(_T(".pdf")) == 0)
			m_BookType = PDF_Book;
		else if(sExt.CompareNoCase(_T(".epub")) == 0)
			m_BookType = EPUB_Book;
		else
			m_BookType = None;

		if (m_pBookInfo == NULL)
			m_pBookInfo = new CBookInfo();
		*m_pBookInfo = *bookInfo;
		return 0;
	}

	bool multiToUnicode( CString   multiText, CString& unicodeText)
	{
		char * ps = (char *)multiText.GetBuffer();
		int size = ::MultiByteToWideChar(CP_ACP,
			0,
			//multiText.c_str(),
			ps,
			-1,
			NULL,
			0);
		if (0 == size)
		{
			multiText.ReleaseBuffer();
			return false;
		}

		wchar_t* wszBuffer = new wchar_t[size + 1];
		::ZeroMemory(wszBuffer, (size + 1) * sizeof(wchar_t));

		if (0 == ::MultiByteToWideChar(CP_ACP,
			0,
			//multiText.c_str(),
			ps,
			-1,
			wszBuffer,
			size + 1))
		{
			delete[] wszBuffer;
			multiText.ReleaseBuffer();
			return false;
		}

		unicodeText = wszBuffer;
		delete[] wszBuffer;
		multiText.ReleaseBuffer();
		return true;
	}



	void CReaderFrame::SetPen( TP_NOTES_TYPE note_type )
	{
		m_note_type = note_type;
		UpdateLineMode();
	}

	void CReaderFrame::SetPenColor( DWORD clrPen )
	{
		m_penColor = clrPen;
		UpdateLineMode();
		WriteLog(OP_CHANGECOLOR);

	}

	

	
	void CReaderFrame::SetPenAndColor(TP_NOTES_TYPE note_type,DWORD penColor){
		m_note_type = note_type;
		m_penColor = penColor;
		UpdateLineMode();
	}

	void CReaderFrame::UpdateLineMode(){
		if (NULL != m_pMyPDFBook ){
			/*
			CString logMessage;
			logMessage.Format(_T("%s:%d %s:%d"),_T("NoteType: "),(int)m_note_type,_T(" Line Color: "),m_clrLine);
			CAppLogger::Debug(_T("CReaderFrame::UpdateLineMode"),logMessage);
			*/
			m_pMyPDFBook->SetLineMode(m_note_type, m_penColor, m_iLineWidth, this);
		}
	}

	void CReaderFrame::OnFinalMessage(HWND hWnd){
		if (m_bAutoDelete){
			delete this;
		}
	}

#pragma region ����������
	void  CReaderFrame::BackButtonClick( TNotifyUI &msg ) {
		CloseFrame();
		CWnd* pWnd = AfxGetMainWnd();
		//		pWnd->ShowWindow(SW_HIDE);
		CBookDal book;
		book.SetLastPage(m_pBookInfo->bookId,theApp.m_UserInfo.strUserId,m_pMyPDFBook->GetPageNum());
		CMainFrame *pMain=(CMainFrame*) AfxGetApp()->m_pMainWnd;
		if(pMain!=NULL)
		{
			CMyReaderDUIMFCDoc* pMainDoc=pMain->GetDocument();
			if(pMainDoc!=NULL)
			{
				pMainDoc->UpdateBookInfos();
				pMainDoc->m_pBookDal->ReloadCloudNoteNum(&pMainDoc->m_oldbooklist);
				pMain->m_pMainFrame->UpdateBooks();
				
				
				
			}
		}
		
		////���////////
		theApp.m_EventLog.init();
		CString strPage=L"";
		strPage.Format(L"%d",m_current_page);
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_OPEN_CLOSE);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_OPEN_CLOSE,L"0");
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
		theApp.m_EventLog.MakeJsonFormat();
		/////////////
		theApp.m_ClassInfo.clear();
		pWnd->ShowWindow(SW_SHOW);
		
	}

	void  CReaderFrame::ArrowButtonClick() {
		SetPen(NOTES_NONE);
		//m_pMyPDFBook->m_pdf_view->SetSelectMode(0);
	}


	


	void  CReaderFrame::ZoomoutButtonClick( TNotifyUI &msg )  {
		float radio = GetCurrentRadio();
		if(m_minRadio-radio>0.05)
			DoReaderCommand(DCMD_ZOOM_OUT);
		ArrowButtonClick();
		//		m_pZoomOutButton->SetBkColor(0xFF0094E2);
	}
	void  CReaderFrame::ZoominButtonClick( TNotifyUI &msg )  {
		DoReaderCommand(DCMD_ZOOM_IN);
		ArrowButtonClick();
		//		m_pZoomInButton->SetBkColor(0xFF0094E2);
	}



	void  CReaderFrame::GotoCenterButtonClick( TNotifyUI &msg )  {
		CloseFrame();
		//::Post(AfxGetMainWnd()->GetActiveWindow()->GetSafeHwnd(),WM_MAIN_FORM_SHOW_CENTER,0,0);
		AfxGetMainWnd()->ShowWindow(SW_SHOWMAXIMIZED);
		AfxGetMainWnd()->PostMessageW(WM_MAIN_FORM_SHOW_CENTER,0,0);
	}

void  CReaderFrame::ShowMarkButtonClick(BOOL bSet)  {
	if(bSet)
	{
		m_isShowNotes =FALSE;
	}
		if (m_isShowNotes)
		{
			//��ʾ���л���
			m_pMyPDFBook->ShowAllComment(false);
			m_pMyPDFBook->RedrawLines();
			m_isShowNotes=false;
			m_pShowMarkButton->SetVisible(false);
			m_pHideMarkButton->SetVisible(true);
			////���////////
			theApp.m_EventLog.init();
			CString strPage;
			strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_HIDE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_NOTE_HIDE_TYPE_WAY,L"1");//1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_NOTE_HIDE_CHG,L"0"); //0=show 1=hide
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
			//ArrowButtonClick();
		}
		else
		{
			//���������
			m_pMyPDFBook->ShowAllComment(true);
			m_pMyPDFBook->RedrawLines();
			m_isShowNotes=true;
			m_pShowMarkButton->SetVisible(true);
			m_pHideMarkButton->SetVisible(false);
			////���////////
			theApp.m_EventLog.init();
			CString strPage;
			strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_HIDE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_NOTE_HIDE_TYPE_WAY,L"1");//1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_NOTE_HIDE_CHG,L"1"); //0=show 1=hide
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
	}

	void  CReaderFrame::FullScreenButtonClick( TNotifyUI &msg )  {
		CHorizontalLayoutUI *captionBar = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("captionBar")));
		if (NULL == captionBar){
			return;
		}

		// 		CHorizontalLayoutUI *toolBar = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("toolBar")));
		// 		if (NULL == toolBar){
		// 			return;
		// 		}

		BOOL bSelected = m_pFullscreenButton->IsSelected();
		captionBar->SetVisible(m_pFullscreenButton->IsSelected());
		// 		toolBar->SetVisible(m_pFullscreenButton->IsSelected());
		// 		m_pFullscreenButton->SetBkColor(0xFF0094E2);
		MyFullscreen(GetHWND(), !m_pFullscreenButton->IsSelected());

	
		ArrowButtonClick();
	}

	void CReaderFrame::DoublePageButtonClick()
	{
		m_pMyPDFBook->SetViewMode(4);
	}

	void CReaderFrame::SinglePageButtonClick()
	{
		m_pMyPDFBook->SetViewMode(2);
	}

	

	void  CReaderFrame::PrevPageButtonClick()  {
		WriteLog(OP_PAGE_PREVIOUS);
		OnNoteClicked(-1);
		int nPage = m_pMyBook->GetPageNum();
		if (nPage <= 1){
			CustomMessageBox(_T("�Ѿ��ǵ�һҳ��"),MSG_TYPE_NOTICE,FALSE);
			return ;
		}
		
		ReaderPageUp();
	}

	void  CReaderFrame::NextPageButtonClick()  {
		OnNoteClicked(-1);
		WriteLog(OP_PAGE_NEXT);
		int nPageCount = m_pMyBook->GetPageCount();
		int nPage = m_pMyBook->GetPageNum();
		int page = m_pBookInfo->startPage;

		if ((nPage-page) >= (nPageCount-page)){
			CustomMessageBox(_T("�Ѿ������һҳ��"),MSG_TYPE_NOTICE,FALSE);
			
			return ;
		}

		ReaderPageDown();
	}

	

	void CReaderFrame::TextboxButtonClick(TNotifyUI &msg)
	{
		SetPen(NOTES_TEXTBOX);
	}

	void CReaderFrame::ShowResLayouts(int type)
	{
		if(type == 1)
		{
			m_pResInBookButton->SetTextColor(0xFF47C1E9);
			m_pResInSchoolButton->SetTextColor(0xFF000000);
			m_pResInWebButton->SetTextColor(0xFF000000);
			m_pResMarkList->SetVisible(true);
			m_pXiaoBenView->SetVisible(false);
			m_pTuiJianView->SetVisible(false);
		}
		else if(type == 2)
		{
			m_pResInBookButton->SetTextColor(0xFF000000);
			m_pResInSchoolButton->SetTextColor(0xFF47C1E9);
			m_pResInWebButton->SetTextColor(0xFF000000);
			m_pResMarkList->SetVisible(false);
			m_pXiaoBenView->SetVisible(true);
			m_pTuiJianView->SetVisible(false);
			m_pXiaoBenBrowser->OnXiaoben(theApp.m_UserInfo.strLoginName,theApp.m_UserInfo.strPassword,m_strBookName,m_pMyPDFBook->str_UnitName, m_pMyPDFBook->str_LesonName);
		}
		else if(type == 3)
		{
			m_pResInBookButton->SetTextColor(0xFF000000);
			m_pResInSchoolButton->SetTextColor(0xFF000000);
			m_pResInWebButton->SetTextColor(0xFF47C1E9);
			m_pResMarkList->SetVisible(false);
			m_pXiaoBenView->SetVisible(false);
			m_pTuiJianView->SetVisible(true);
			m_pTuiJianBrowser->OnTuijian(theApp.m_UserInfo.strLoginName,theApp.m_UserInfo.strPassword,m_strBookName,m_pMyPDFBook->str_UnitName, m_pMyPDFBook->str_LesonName);
		}
	}

	void CReaderFrame::ShowNoteTools(int type)
	{
		
	}



	void CReaderFrame::ExportOneNoteFile()
	{
		
	}


	BOOL CReaderFrame::IsOfficeInstalled()
	{
		BOOL bInstall = FALSE;
		CoInitialize(NULL);
		CLSID clsid;
		HRESULT hr = ::CLSIDFromProgID(_T("Word.Application"), &clsid);
		if (SUCCEEDED(hr))
		{
			IDispatch* app = NULL;
			hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&app);
			if (FALSE(hr))
				bInstall = FALSE;
			else
			{
				app->Release();
				bInstall = TRUE;
			}
		}

		CoUninitialize();

		return bInstall;

		CRegKey   key,key1;
		DWORD   dwIndex=0,lpcbname=100,ret=0;
		TCHAR   T_name[100];
		FILETIME   lpftlast;
		int   i=0;

		int iret = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
		int ierr = GetLastError();
		if   (iret ==ERROR_SUCCESS)
		{
			for(i=0;ret==ERROR_SUCCESS;i++,dwIndex++)
			{
				ZeroMemory(T_name,100);
				lpcbname=100;

				ret=RegEnumKeyEx(key,dwIndex,T_name,&lpcbname,NULL,NULL,NULL,&lpftlast);
				if (ret==ERROR_SUCCESS)
					if (key1.Open(key,T_name)==ERROR_SUCCESS)
					{
						ZeroMemory(T_name,100);
						lpcbname=100;
						if (key1.QueryValue(T_name, L"DisplayName",&lpcbname)==ERROR_SUCCESS)
						{
							CString strName = T_name;
							CString strOffice = _T("Microsoft Office");

							if (strName.MakeLower().Find(strOffice.MakeLower()) != -1)
							{
								key1.Close();
								key.Close();
								return TRUE;
							}
						}
						key1.Close();
					}
			}

			key.Close();
		}

		return FALSE;
	}


	BOOL CReaderFrame::ExportRes(CString fileName)
	{
		return TRUE;
	}

	BOOL CReaderFrame::ImportRes(CString fileName)
	{
		return FALSE;
	}

	BOOL CReaderFrame::PreTranslateMessage(MSG* pMsg)
	{
		if(m_tooltip.m_hWnd!=NULL)
			m_tooltip.RelayEvent(pMsg);

		if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
		{
			if (pMsg->wParam == VK_UP || VK_DOWN || VK_LEFT || VK_RIGHT)
			{
				return FALSE;
			}
		}
		return TRUE;
	}

	wchar_t* CReaderFrame::Ansi2Unicode(const char* szAnsi)
	{
		if (szAnsi == NULL)
			return NULL;

		int wcsLen = ::MultiByteToWideChar(CP_ACP, NULL, szAnsi, strlen(szAnsi), NULL, 0);
		wchar_t* wszString = new wchar_t[wcsLen+1];
		if (wszString != NULL)
		{
			::MultiByteToWideChar(CP_ACP, NULL, szAnsi, strlen(szAnsi), wszString, wcsLen);
			wszString[wcsLen] = L'/0';
		}

		return wszString;
	}

	char* CReaderFrame::Unicode2Ansi(const wchar_t* wszString)
	{
		if (wszString == NULL)
			return NULL;

		int ansiLen = ::WideCharToMultiByte(CP_ACP, NULL, wszString, wcslen(wszString), NULL, 0, NULL, NULL);
		char* szAnsi = new char[ansiLen + 1];
		if (szAnsi != NULL)
		{
			::WideCharToMultiByte(CP_ACP, NULL, wszString, wcslen(wszString), szAnsi, ansiLen, NULL, NULL);
			szAnsi[ansiLen] = '/0';
		}

		return szAnsi;
	}

	void CReaderFrame::GoToPage(int nPage)
	{
		try
		{
			int nPageCount = m_pMyBook->GetPageCount();
			int page = m_pBookInfo->startPage;
			if(nPage==page)
				if(nPage==1)
					m_pdfToolFrame->SetPreButtonEnable(false);
			else
				m_pdfToolFrame->SetPreButtonEnable(true);
			if(nPage==page==nPageCount)
				m_pdfToolFrame->SetNextButtonEnable(false);
			else
				m_pdfToolFrame->SetNextButtonEnable(true);
			if (nPageCount > 1)
			{
				if(nPage<= 0)
				{
					m_current_page=1;
					CString message;
					CustomMessageBox(_T("�Ѿ��ǿα���һҳ"),MSG_TYPE_NOTICE,FALSE);
					return ;
				}
				if(nPage >= nPageCount)
				{
					CustomMessageBox(_T("�Ѿ��ǿα����һҳ"),MSG_TYPE_NOTICE,FALSE);
					return ;
				}
				
				m_pMyBook->GotoPageNum(nPage);
			}
		}
		catch (...)
		{
			return;
		}
		//m_pMyPDFBook->SetFocus();
		m_curSelNote =-1;
		m_pMyPDFBook->RedrawLines();
	}

	void CReaderFrame::GoToPageByStart(int nPage)
	{
		//if (nPage <=0)
		//{
			nPage+=1;
			GoToPage(nPage);
		//}
	}

	void CReaderFrame::UpdateNotesInCloud(CString strBookId)
	{
		m_CloudNotePackageList = m_pDownloadCloudNotes->GetNotePackageList();
	}

	void CReaderFrame::DelSelectedNote(BOOL bMsg)
	{
		if (m_curSelNote>=0 && m_pdfNoteInfoList.size()>0)
		{
			if(m_pdfNoteInfoList[m_curSelNote]->noteOrigin != 2)
			{
				CustomMessageBox(_T("�̲���Դ,���ܽ���ɾ������!"),MSG_TYPE_NOTICE,FALSE);
				return;
			}
			if(m_pdfNoteInfoList[m_curSelNote]->pdfNoteType !=NoteFreedom)
			{
				//ֻ������ɻ���
				return;
			}
			vector<CPDFNoteInfo*> selectedInfos;
			selectedInfos.push_back(m_pdfNoteInfoList[m_curSelNote]);
			DelSelectedNote(selectedInfos,bMsg);
		}
	}

	void CReaderFrame::DelSelectedNote( vector<CPDFNoteInfo*> &selectedInfos,BOOL bMsg)
	{
        //���ɻ���
		m_curSelNote = -1;
		if(selectedInfos.size()>0)
		{
			if(bMsg)//Modify By Ray 2018-06-01
			{
				
				int iRet =CustomMessageBox(STRING_MSG_DELETE_DOUBLE_CHECK,MSG_TYPE_YESNO);
				if (iRet != IDOK)
				return;

			}
			vector<CPDFNoteInfo*>::iterator iter;
			CString noteIds;
			CString temp;
			for(iter=selectedInfos.begin();iter!=selectedInfos.end();iter++)
			{
				temp.Format(_T("%ld,"),(*iter)->id);
				long pdfId=(*iter)->pdfId;

					if((*iter)->pdfNoteType == NoteFreedom)
						WriteLog(OP_DELETE_FREEDOM);
					else if((*iter)->pdfNoteType == NoteLine)
					{
						if((*iter)->lineType == FullLine)
							WriteLog(OP_DELETE_FULL_LINE);
						else if((*iter)->lineType == WavyLine)
							WriteLog(OP_DELETE_WAVY_LINE);
						else if((*iter)->lineType == DottedLine)
							WriteLog(OP_DELETE_DOTTED_LINE);
						else
							WriteLog(OP_DELETE_LINE);
					}
					else
						WriteLog(OP_NOTE_DELETE);



					/*ɾ���б�*/
					RemoveNoteInfoFromListById((*iter)->id);
					temp.Format(_T("%ld,"),(*iter)->id);
					noteIds.Append(temp);

			}
			/*ɾ�����ݿ�*/
			if(noteIds.GetLength()>=2)
			{
				CString ntIds = noteIds.Left(noteIds.GetLength() - 1);
				std::vector<int> folderIds;
				int folderCnt = m_noteDao->getFolderByNoteIds(ntIds, folderIds);
				//m_noteDao.DeleteNoteInfos(ntIds);
				//Modify By Ray 2018-06-05
				//ɾ��FreePenNote ���޸�
				//CNoteDao NoteDao(m_pBookInfo->bookId);
				long id=m_noteDao->DeleteNoteInfos(ntIds);
				
				//��鲢ɾ��NoteInfo
				iter=selectedInfos.begin();
				if((*iter)->pdfNoteType== NoteFreedom)
				{
					m_noteDao->CheckAndDeleteNoneRecord((*iter)->fid);
				}
				//m_noteDao.DeleteNoteInfos(noteIds.Left(noteIds.GetLength()-1)); no use
				m_pResChoiceAll->Selected(false);
				//CGlobalUI::ShowMessage(this->m_hWnd, _T("ɾ���ɹ�!"));
			}

		}
		else
		{
			
			CustomMessageBox(_T("��ѡ����Ҫɾ���ıʼ�"),MSG_TYPE_NOTICE,FALSE);
			//	AfxMessageBox(_T("��ѡ����Ҫɾ���ıʼ�"));
		}

		m_pMyBook->RedrawLines();
	}

	void CReaderFrame::StartDownloadNotesFromCloud()
	{
		if (m_pDownloadCloudNotes == NULL)
		{
			m_pDownloadCloudNotes = new CDownloadCloudNote(this->m_hWnd);
		}
		try
		{
			m_pDownloadCloudNotes->GetNotePackageInfoByBookId(g_noteFlag, m_pBookInfo->bookId);
		}
		catch (CException* e)
		{
			m_cLog.WriteLog(Danger_log, _T("StartDownloadNotesFromCloud Error"));
		}

		m_cLog.WriteLog(_T("StartDownloadNotesFromCloud End!"));
	}



	LRESULT CReaderFrame::OnUpdateNotePackageList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		return 0;
	}




	void CReaderFrame::UpdateCloudBookNotes(CCloudNotePackage* pPackage)
	{
		m_pCloudChoiceAll->Selected(false);
		m_pCloudNoteInfos.clear();
		m_pCloudNoteItemListLayout->SetVisible(true);
		m_pCloudNotePackageListLayout->SetVisible(false);
		if (m_pDownloadCloudNotes == NULL)
			m_pDownloadCloudNotes = new CDownloadCloudNote(this->m_hWnd);
		m_strNoteId = pPackage->strNoteId;
		m_pCloudNoteItemList->RemoveAll();

		/*{
			BOOL bImport = m_pDownloadCloudNotes->ImportCloudNotePackage(pPackage->strFileName, pPackage->strNoteId);
			if (!bImport)
				return;
		}*/
		UpdateCloudNoteList();
	}

	void CReaderFrame::ImportCloudPackageIntoLocal()
	{
		vector<CCloudNotePackage*> selectNotePackages;
		m_pCloudNoteList->GetSelectItems(selectNotePackages);
		if (selectNotePackages.size() == 0)
		{
			CGlobalUI::ShowMessage(this->m_hWnd, _T("��ѡ��Ҫ������Ʊʼǣ�"));
			return;
		}

		vector<CCloudNotePackage*>::iterator tmpIter;
		for (tmpIter = selectNotePackages.begin(); tmpIter != selectNotePackages.end(); tmpIter++)
		{
			CCloudNotePackageDao PackageDao;
			CCloudNotePackage notePackage = PackageDao.GetNotePackageById((*tmpIter)->id);
			if(notePackage.iState != 1)
			{
				CGlobalUI::ShowMessage(this->m_hWnd, _T("δ���ص��ƱʼDz�֧�ֵ��룬�������ظ��Ʊʼǣ�"));
				return;
			}
		}

		int ret = CGlobalUI::ShowMessage(this->m_hWnd, _T("ȷ��Ҫ������ѡ����Ʊʼ���"));
		if (ret != IDOK)
			return;

		vector<CPDFNoteInfo*> pCloudNoteInfos;
		CCloudNoteDao cloudNoteDao;
		CCloudNotePackageDao packageDao;
		vector<CCloudNotePackage*>::iterator packageIter;
		for (packageIter = selectNotePackages.begin(); packageIter != selectNotePackages.end(); packageIter++)
		{
			CString strPackageId = _T("");
			if ((*packageIter)->strNoteId.GetLength() >= 8)
				strPackageId = (*packageIter)->strNoteId.Right(8);
			else
				strPackageId = (*packageIter)->strNoteId;

			long packageid = _ttol(strPackageId);
			vector<CPDFNoteInfo*> tmpInfo = cloudNoteDao.GetNoteInfosByPackageId(packageid);
			pCloudNoteInfos.insert(pCloudNoteInfos.end(), tmpInfo.begin(), tmpInfo.end());
		}

		int i = 0, j = 0;
		int count = pCloudNoteInfos.size();
		//CNoteDao noteDao;
		vector<CPDFNoteInfo*>::iterator noteIter;
		for (noteIter = pCloudNoteInfos.begin(); noteIter != pCloudNoteInfos.end(); noteIter++)
		{
			CPDFNoteInfo* pNoteInfo = new CPDFNoteInfo;
			*pNoteInfo = **noteIter;
			CCloudNoteInfo* pCloudNote = cloudNoteDao.GetNoteInfoById(pNoteInfo->id);

			//�޸�Ϊ�Ʊʼǵ��뱾�غ�,����ɾ�����Կɵ���
			//if (pCloudNote->import == 0 && noteDao.CheckRepeatRow(**iter) == 0)
			if (m_noteDao->CheckRepeatRow(**noteIter) == 0)
			{
				i++;
				int pdfId = m_noteDao->GetMaxPdfId(pNoteInfo->bookId);
				pNoteInfo->pdfId = pdfId + 1;
				long noteId = m_noteDao->AddNoteInfo(*pNoteInfo);

				CString strNoteDownladDir = theApp.m_strUserPath + _T("resources\\Download_Note\\") + pNoteInfo->bookId;
				CString strSrcFile = strNoteDownladDir + _T("\\") + NOTE_CLOUD_FLODER + _T("\\") + pNoteInfo->content;
				CString strSourceFileDir = theApp.m_strUserPath + _T("resources\\books\\MyResources\\");
				::CreateDirectory(strSourceFileDir, NULL);
				strSourceFileDir += + pNoteInfo->bookId;
				::CreateDirectory(strSourceFileDir, NULL);
				CString strDstFile = strSourceFileDir + _T("\\") + pNoteInfo->content;
				::MoveFile(strSrcFile, strDstFile);

				CPDFNoteInfo* info=m_noteDao->GetNoteInfoById(noteId);
				AddNewNote2List(g_pFrame->m_pdfNoteInfoList, *info);

				cloudNoteDao.UpdateImportStateById(pNoteInfo->id, 1);

				CString tmpNoteId;
				tmpNoteId.Format(_T("%d"),pCloudNote->packageId);
				packageDao.UpdateImportedStateByNoteId(tmpNoteId,1);
			}
			else
				j++;
		}

		CString strInfo;
		if(i == 0)
			CGlobalUI::ShowMessage(this->m_hWnd, _T("�ʼ��Ѵ��ڣ�"));
		else
		{
			strInfo.Format(_T("�㹲����%d���ʼǣ��ɹ�����%d��!"), count, i);
			CGlobalUI::ShowMessage(this->m_hWnd, strInfo);
		}
	}

	void CReaderFrame::ImportCloudNotesIntoLocal()
	{
		vector<CPDFNoteInfo*> selectedInfos;
		m_pCloudNoteItemList->GetSelectItems(m_pCloudNoteInfos, selectedInfos);
		if (selectedInfos.size() == 0)
		{
			CGlobalUI::ShowMessage(this->m_hWnd, _T("��ѡ��Ҫ���뵽���ص��Ʊʼǣ�"));
			return;
		}

		int ret = CGlobalUI::ShowMessage(this->m_hWnd, _T("ȷ��Ҫ������ѡ����Ʊʼ���"));
		if (ret != IDOK)
			return;

		int i = 0, j = 0;
		int count = selectedInfos.size();

		//CNoteDao noteDao;
		CCloudNoteDao cloudNoteDao;
		CCloudNotePackageDao packageDao;
		vector<CPDFNoteInfo*>::iterator iter;
		for (iter = selectedInfos.begin(); iter != selectedInfos.end(); iter++)
		{
			CPDFNoteInfo* pNoteInfo = new CPDFNoteInfo;
			*pNoteInfo = **iter;
			CCloudNoteInfo* pCloudNote = cloudNoteDao.GetNoteInfoById(pNoteInfo->id);

			//�޸�Ϊ�Ʊʼǵ��뱾�غ�,����ɾ�����Կɵ���
			//if (pCloudNote->import == 0 && noteDao.CheckRepeatRow(**iter) == 0)
			if (m_noteDao->CheckRepeatRow(**iter) == 0)
			{
				i++;
				int pdfId = m_noteDao->GetMaxPdfId(pNoteInfo->bookId);
				pNoteInfo->pdfId = pdfId + 1;
				long noteId = m_noteDao->AddNoteInfo(*pNoteInfo);

				CString strNoteDownladDir = theApp.m_strUserPath + _T("resources\\Download_Note\\") + pNoteInfo->bookId;
				CString strSrcFile = strNoteDownladDir + _T("\\") + NOTE_CLOUD_FLODER + _T("\\") + pNoteInfo->content;
				CString strSourceFileDir = theApp.m_strUserPath + _T("resources\\books\\MyResources\\");
				::CreateDirectory(strSourceFileDir, NULL);
				strSourceFileDir += + pNoteInfo->bookId;
				::CreateDirectory(strSourceFileDir, NULL);
				CString strDstFile = strSourceFileDir + _T("\\") + pNoteInfo->content;
				::MoveFile(strSrcFile, strDstFile);

				CPDFNoteInfo* info=m_noteDao->GetNoteInfoById(noteId);
				AddNewNote2List(g_pFrame->m_pdfNoteInfoList, *info);

				cloudNoteDao.UpdateImportStateById(pNoteInfo->id, 1);

				CString tmpNoteId;
				tmpNoteId.Format(_T("%d"),pCloudNote->packageId);
				packageDao.UpdateImportedStateByNoteId(tmpNoteId,1);
			}
			else
				j++;
		}

		CString strInfo;
		if(i == 0)
			CGlobalUI::ShowMessage(this->m_hWnd, _T("�ʼ��Ѵ��ڣ�"));
		else
			{
				strInfo.Format(_T("�㹲����%d���ʼǣ��ɹ�����%d��!"), count, i);
				CGlobalUI::ShowMessage(this->m_hWnd, strInfo);
			}

		m_pMyPDFBook->SetPDFNoteInfoList(m_pdfNoteInfoList);

		// 		m_pdfNoteInfoList.clear();
		// 		m_noteDao.GetNoteInfosByBookId(m_pBookInfo->bookId, m_pdfNoteInfoList);
	}

	void CReaderFrame::DeleteCloudNotePackageInListByid(int id)
	{
		CCloudNotePackageDao packageDao;
		packageDao.UpdateDownloadStateById(id, -2);
		UpdateCloudNotePackagesList();
	}

	void CReaderFrame::DeleteCloudNotesSelected()
	{
		vector<CPDFNoteInfo*> selectedInfos;
		m_pCloudNoteItemList->GetSelectItems(m_pCloudNoteInfos, selectedInfos);
		if (selectedInfos.size() == 0)
		{
			CustomMessageBox(_T("��ѡ��Ҫɾ�����Ʊʼǣ�"),MSG_TYPE_NOTICE,FALSE);
			return;
		}
		
		int ret = CustomMessageBox(_T("�Ƿ�ɾ����ѡ��ıʼǣ�"),MSG_TYPE_YESNO);
		if (ret != IDOK)
			return;

		WriteLog(OP_CLOUD_NOTE_DELETE);

		CCloudNoteDao cloudNoteDao;
		vector<CPDFNoteInfo *>::iterator iter;
		for (iter = selectedInfos.begin(); iter != selectedInfos.end(); iter++)
		{
			cloudNoteDao.DeleteNoteInfoById((*iter)->id);
		}

		UpdateCloudNoteList();
	}
/*
	void CReaderFrame::DownloadCloudPackageList()
	{
		vector<CCloudNotePackage*> selectNotePackages;
		m_pCloudNoteList->GetSelectItems(selectNotePackages);
		if (selectNotePackages.size() == 0)
		{
			CGlobalUI::ShowMessage(this->m_hWnd, _T("��ѡ��Ҫ���ص��Ʊʼǣ�"));
			return;
		}

		int ret = CGlobalUI::ShowMessage(this->m_hWnd, _T("ȷ��Ҫ������ѡ����Ʊʼ���"));
		if (ret != IDOK)
			return;

		BOOL isDownload = false;
		CCloudNotePackageDao packageDao;
		vector<CCloudNotePackage*>::iterator iter;
		for (iter = selectNotePackages.begin(); iter != selectNotePackages.end(); iter++)
		{
			bool isUpdate = packageDao.GetUnDownloadPackageByBookIdAndNoteId((*iter)->strBookId, (*iter)->strNoteId);
			if(isUpdate)
			{
				packageDao.UpdateDownloadStateByNoteId((*iter)->strBookId, (*iter)->strNoteId, 2);
				isDownload = true;
			}
		}

		if(!isDownload)
		{
			CGlobalUI::ShowMessage(this->m_hWnd, _T("��ѡ��δ���ص��Ʊʼǣ�"));
			return;
		}
		else
			UpdateCloudNotePackagesList();

		if (m_pDownloadCloudNotes == NULL)
			m_pDownloadCloudNotes = new CDownloadCloudNote(this->m_hWnd);
		m_pDownloadCloudNotes->DownloadPackageListByBookId(m_pBookInfo->bookId);
	}
*/
	void CReaderFrame::DeleteCloudPackagesSelected()
	{
		vector<CCloudNotePackage*> selectNotePackages;
		m_pCloudNoteList->GetSelectItems(selectNotePackages);
		if (selectNotePackages.size() == 0)
		{
			
			CustomMessageBox(_T("��ѡ��Ҫɾ�����Ʊʼǣ�"),MSG_TYPE_NOTICE,FALSE);
			return;
		}
					
		int ret =CustomMessageBox(_T("�Ƿ�ɾ����ѡ����Ʊʼǣ�"),MSG_TYPE_YESNO);
		if (ret != IDOK)
			return;

		WriteLog(OP_CLOUD_NOTE_DELETE);

		CCloudNotePackageDao packageDao;
		vector<CCloudNotePackage*>::iterator iter;
		for (iter = selectNotePackages.begin(); iter != selectNotePackages.end(); iter++)
		{
			if((*iter)->iShareType == 0)
			{
				packageDao.UpdateDownloadStateById((*iter)->id, 0);
			}
			else
			{
				packageDao.UpdateSourceBySourceId((*iter)->id, 1);
			}
		}

		UpdateCloudNotePackagesList();

		if (m_pDownloadCloudNotes == NULL)
			m_pDownloadCloudNotes = new CDownloadCloudNote(this->m_hWnd);
		m_pDownloadCloudNotes->DeletePackageListByNoteId(m_pBookInfo->bookId);
	}

	void CReaderFrame::UpdateCloudNoteList()
	{
		m_pCloudNoteItemList->RemoveAll();

		CCloudNoteDao cloudNotedao;
		//			int iPackageId = cloudNotedao.GetMaxPackageId();
		CString strPackageId = _T("");
		if (m_strNoteId.GetLength() >= 8)
			strPackageId = m_strNoteId.Right(8);
		else
			strPackageId = m_strNoteId;
		long packageid = _ttol(strPackageId);
		m_pCloudNoteInfos = cloudNotedao.GetNoteInfosByPackageId(packageid);

		if (m_pCloudNoteItemList)
		{
			int page = m_pBookInfo->startPage;
			m_pCloudNoteItemList->GetStartPage(page);
		}

		//sort(m_pCloudNoteInfos.begin(), m_pCloudNoteInfos.end(), CPDFNoteInfo::ComparPdfInfoByPageIndex);
		sort(m_pCloudNoteInfos.begin(), m_pCloudNoteInfos.end(), CPDFNoteInfo::ComparPdfInfoByUpdateTime);

		vector<CPDFNoteInfo*>::iterator iter;
		for(iter=m_pCloudNoteInfos.begin();iter!=m_pCloudNoteInfos.end();iter++)
		{
			//m_pCloudNoteItemList->AddItem(**iter,m_SidebarWidth, true);
		}
	}


	void CReaderFrame::OpenLineNote(CPDFNoteInfo* info,int type)
	{
		if(info->pdfNoteType==NoteLine)
		{
			HideOrShowPdfToolFrame(false);
			CLineNoteEditFrame* LineNote = new CLineNoteEditFrame(info,m_pLabelOper,type);
			LineNote->Create(m_hWnd, _T("LineNoteEditFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
			LineNote->CenterWindow();
			if(LineNote->ShowModal()==IDOK)
			{

				info->isCloud=FALSE;
				
				//Move By Ray 2018-10-03
				//CNoteDao NoteDao(m_pBookInfo->bookId);
				m_pLabelOper->SaveLabelToNote(info->id);
				CTime tm=CTime::GetCurrentTime();
				CString str=tm.Format("%Y-%m-%d %H:%M:%S");
				info->updateTime=str;
				m_noteDao->UpdateLineNote(info);
				m_nSelLineNote_Line=info->lineType;
				m_nSelLineNote_Color=info->lineColor;
				////���////////
				theApp.m_EventLog.init();
				theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_MODIFY_NOTE);
				int nPage =  m_pMyPDFBook->GetPageNum();
				CString strPage;
				strPage.Format(L"%d",nPage);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_WAY,L"1");
				CString strNoteLocalID;
				strNoteLocalID.Format(L"%d",info->id);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
				if(info->pdfNoteType==NoteFreedom||info->pdfNoteType==NoteLine)
				{
					theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
				}else
				{
					theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,info->coord);
				}
				int nType=0;

				nType =GetLogNoteType(info->pdfNoteType);
				CString strType;
				strType.Format(L"%d",nType);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,info->noteText);
				CString strLabeData=L"";
				for(int nNum=0;nNum<info->lableInfos.size();nNum++)
				{
					CLabelInfo label =info->lableInfos.at(nNum);
					strLabeData +=label.lableName;
					if(nNum!=info->lableInfos.size()-1)
					{
						strLabeData +=L"��";
					}
				}
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,strLabeData);
				theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,info->content); 
				theApp.m_EventLog.MakeJsonFormat();
				////////////////
			}
			else 
			{
				SetNeedReloadDB();
				GetNoteByCataIndex(m_current_mulu_index);
				m_pMyPDFBook->RedrawLines();
			}
			HideOrShowPdfToolFrame(true);
			if(LineNote)
			{
				delete LineNote;
				LineNote=NULL;
			}
			if(m_pLabelOper)
				m_pLabelOper->ClearStatus();
			SetNeedReloadDB();
			GetNoteByCataIndex(m_current_mulu_index);
			m_pMyPDFBook->RedrawLines();
			m_curSelNote=-1;
		}
	}
	

	

	

	void CReaderFrame::SearchNotesKeyWords(CString strKeyword)
	{
		WriteLog(OP_NOTE_SEARCH, strKeyword);

		if(m_pNoteList->IsVisible())
		{
			m_pNoteList->RemoveAll();
			
			
			CLabelUI* pLabelButton1 = static_cast<CLabelUI*>(m_pm.FindControl(_T("no_search_label")));
			vector<CPDFNoteInfo*>::iterator iter;
			
			int a=0;
			if(strKeyword=="")
			{
				a=1;
				pLabelButton1->SetVisible(false);
			}
			for (iter = m_pdfNoteInfoList.begin(); iter != m_pdfNoteInfoList.end(); iter++)
			{
				/*CPDFNoteInfo* pNoteInfo = *iter;
				BOOL bContain = m_noteDao.NoteIsContainKeyword(pNoteInfo->id, strKeyword);
				
				if (bContain)
				{
					a = 1;
					m_pNoteList->AddItem(**iter, m_SidebarWidth);
				}*/
			}
			if(a==0)
			{
				pLabelButton1->SetVisible(true);
			}
			
			else
				pLabelButton1->SetVisible(false);

		}
	}



	void CReaderFrame::WriteLog(CA_OPERATION op, CString strMsg)
	{
		HWND hWnd = AfxGetMainWnd()->m_hWnd;
		::PostMessage(hWnd, WM_WRITE_LOG, (WPARAM)(strMsg.AllocSysString()), (LPARAM)op);
	}






	void CReaderFrame::UpdateTextBoxNotePos(CPDFNoteInfo *p_info, std::vector<double> &page_note_pos)
	{
		if(Point2StrCoord(page_note_pos, p_info->coord) == -1)
			Point2Str(page_note_pos, p_info->coord);
		UpdateDBAndPDFList(p_info, true);
	}


	CString CReaderFrame::GetPenColorById(DWORD colorId)
	{
		CString colorName = _T("��ɫ");

		switch(colorId)
		{
		case MDR_COLOR_BLACK:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_YELLOW:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_RED:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_GRAY:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_GREEN:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_VIOLET:
			colorName = _T("�ۺ�ɫ");
			break;
		case MDR_COLOR_LAVENDER:
			colorName = _T("����ɫ");
			break;
		case MDR_COLOR_PURPLE:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_SKYBLUE:
			colorName = _T("����ɫ");
			break;
		case MDR_COLOR_BLUE:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_WHITE:
			colorName = _T("��ɫ");
			break;
		case MDR_COLOR_ORANGE:
			colorName = _T("��ɫ");
			break;
		}

		return colorName;
	}

	void CReaderFrame::ShowTextBoxNoteMenu(int m_noteId)
	{
		vector<CPDFNoteInfo*>::iterator iter = m_pdfNoteInfoList.begin();
		long note_pos = 0;
		while (iter != m_pdfNoteInfoList.end())
		{
			if((*iter)->id == m_noteId)
			{
				this->m_curSelNote = note_pos;
				break;
			}

			note_pos++;
			iter++;
		}

		/*CMenuWnd* pMenu = new CMenuWnd(this->m_hWnd);
		DuiLib::CPoint point(0,0);
		GetCursorPos(&point);
		pMenu->Init(NULL, _T("PDFContexMenu .xml"), point, &this->m_pm, &this->m_NoteTypeMenuCheckInfo);*/
	}


	void CReaderFrame::UpdatePostilNoteInfo(int m_noteId)
	{
		vector<CPDFNoteInfo*>::iterator iter = m_pdfNoteInfoList.begin();
		while (iter != m_pdfNoteInfoList.end())
		{
			if((*iter)->id == m_noteId)
			{
				CPDFNoteInfo* pNoteInfo = m_noteDao->GetNoteInfoById(m_noteId);
				if (pNoteInfo != NULL)
				{
					if(pNoteInfo->noteOrigin != 2)
					{
						CustomMessageBox(_T("�̲���Դ,����������ע!"),MSG_TYPE_NOTICE,FALSE);
						
						return;
					}
					//ShowEditNoteFrame(pNoteInfo);
				}
				break;
			}
			iter++;
		}
	}


	void CReaderFrame::DelSelectedFolder(vector<note_folder_info*> &selectedFolders)
	{
		if(selectedFolders.size()>0)
		{
			
		int	iRet =CustomMessageBox(_T("ȷ��Ҫɾ��ѡ���������ɾ���󲻿ɻָ�!"),MSG_TYPE_YESNO);
			if (iRet != IDOK)
				return;

			bool ret = false;
			vector<note_folder_info*>::iterator iter;
			for(iter=selectedFolders.begin();iter!=selectedFolders.end();iter++)
			{
				ret = m_folderDao.DeletFolderById((*iter)->folderId);
				m_noteDao->DeleteNoteByFolderId((*iter)->folderId);
			}

			/*ɾ�����ݿ�*/
			if(ret)
			CustomMessageBox(STRING_READERFRAME_DELETE_SUCCESS,MSG_TYPE_NOTICE,TRUE);

			m_pdfNoteFolderList.clear();
			m_folderDao.GetNoteFolderList(m_pdfNoteFolderList, m_pBookInfo->bookId);
			UpdateNoteFolders();
		}else
		{
			CustomMessageBox(_T("��ѡ����Ҫɾ��������"),MSG_TYPE_NOTICE,FALSE);
			
		}
	}
	void CReaderFrame::BackAllMultyOption(int type)
	{
		m_pVShowNoData->SetVisible(false);
		if(type==1)
		{
			//bool bb=notes_search_option->IsSelected();
			//if(notes_search_option->IsSelected())
			//notes_search_option->Selected(false);
			m_pNotesFilter->Selected(false);
			m_ctrMulu->SetVisible(true);
			m_pSearch_layout->SetVisible(false);
			m_bIsSearch=false;
			m_bIsSelect=false;
			m_ctrMulu->SetVisible(true);
			CHorizontalLayoutUI* label = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("mulu_hide")));
			label->SetVisible(false);
			
		}
		if(notes_search_option->IsSelected())
		{
			notes_search_option->Selected(false);
			m_bIsSearch=false;
		}


		COptionUI* local_upload_notes = static_cast<COptionUI*>(m_pm.FindControl(_T("local_upload_notes")));
		COptionUI* cloud_down_notes = static_cast<COptionUI*>(m_pm.FindControl(_T("cloud_down_notes")));
		COptionUI* local_notes_export = static_cast<COptionUI*>(m_pm.FindControl(_T("local_notes_export")));
		COptionUI* local_notes_delete = static_cast<COptionUI*>(m_pm.FindControl(_T("local_notes_delete")));

		local_upload_notes->Selected(false);
		cloud_down_notes->Selected(false);
		local_notes_export->Selected(false);
		local_notes_delete->Selected(false);

		m_pNotesFilter->SetEnabled(true);
		notes_search_option->SetEnabled(true);

		isUpload=isDelete=isShare=isDownload=false;

		CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
		h_operator->SetVisible(false);
		COptionUI* note_choice_all=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
		note_choice_all->Selected(false);

		CLabelUI * select_num=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num")));
		select_num->SetText(_T("��ѡ��0���ʼ�"));
		CEditUI * resource_search_keyword=static_cast<CEditUI*>(m_pm.FindControl(_T("resource_search_keyword")));
		resource_search_keyword->SetVisible(false);
		CButtonUI* searchButton = static_cast<CButtonUI*>(m_pm.FindControl(_T("do_resource_search_button")));
		searchButton->SetVisible(false);
		COptionUI* resource_search_option = static_cast<COptionUI*>(m_pm.FindControl(_T("resource_search_option")));
		resource_search_option->Selected(false);
		m_bResourceSearch=false;
		
		

	



	}
	void CReaderFrame::ShowNotesListTools(int type)
	{

		CHorizontalLayoutUI* h_local_cloud_note_list = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_local_cloud_note_list")));
		CHorizontalLayoutUI* h_share_note_tool = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_share_note_tool")));
		m_NoteShowType = type;

		if(type == 1)
		{
			h_local_cloud_note_list->SetVisible(true);
			h_share_note_tool->SetVisible(false);
			m_pNoteList->SetVisible(true);
			m_pNotesLabelSet->SetVisible(true);
			m_pNotesFilter->SetVisible(true);
			m_pNoteCatalogList->SetVisible(false);	
			m_pOptionDownNote->SetVisible(false);
			m_pOptionLocalNoteUpload->SetVisible(true);
			m_pCloudRefresh->SetVisible(false);
			
		}
		else if(type == 2)
		{
 			h_local_cloud_note_list->SetVisible(true);
			h_share_note_tool->SetVisible(false);
			m_pNoteList->SetVisible(true);	
			m_pNotesLabelSet->SetVisible(false);
			m_pNotesFilter->SetVisible(true);
			m_pNoteCatalogList->SetVisible(false);
			
			m_pOptionDownNote->SetVisible(true);
			m_pOptionLocalNoteUpload->SetVisible(false);

			m_pCloudRefresh->SetVisible(true);
			
		}
		else if(type == 3)
		{
			h_local_cloud_note_list->SetVisible(false);
			h_share_note_tool->SetVisible(true);
			if(theApp.m_UserInfo.iUserType==1)
			{
				CComboUI* m_ctrClass=static_cast<CComboUI*>(m_pm.FindControl(_T("ComboCLassSelect")));
				if(m_ctrClass)
					m_ctrClass->SetVisible(false);
		
			}
		}
	}

	void CReaderFrame::OpenFileNoteByNoteId(int noteId)
	{
		CPDFNoteInfo* pInfo = NULL;
		if(noteId>=0 && noteId<m_pdfNoteInfoList_drawPdf.size())
			pInfo=m_pdfNoteInfoList_drawPdf.at(noteId);

		if(pInfo != NULL)
		{
			//CString filePath=theApp.m_strPublic_Path+pInfo->bookId+_T("//")+pInfo->resourcePath;
			openAppendFile(pInfo,m_curSelNote,1);
		}

	}

	

	void CReaderFrame::GoToExercisePage(int page)
	{
		
	}


void CReaderFrame::CopyTextToClipBoard(int noteId)
{

	HWND hWnd = NULL;
	CString m_strResult;
	CPDFNoteInfo* pInfo = NULL;
	vector<CPDFNoteInfo*>::iterator iter;
	for (iter = m_pdfNoteInfoList.begin(); iter != m_pdfNoteInfoList.end(); iter++)
	{
		if ((*iter)->id == noteId)
		{
			pInfo = *iter;
			break;
		}
	}
	if (pInfo->pdfNoteType == NoteLine || pInfo->pdfNoteType ==NoteNone)
		m_strResult = pInfo->content;
	int nLen = m_strResult.GetLength();


	//{
	//	::OpenClipboard(m_hWnd);// �򿪼��а� ��ֹ���� ���̵ڼ��а���� 
	//	EmptyClipboard();//��ռ��а� ���ҽ�Ȩ�޸��ӵ� �򿪼��а�Ĵ��� 
	//	HANDLE h = GlobalAlloc(GMEM_FIXED, (nLen + 100) * sizeof(WCHAR)); //��ȫ�ֶѷ����ڴ沢�ҷ��ؾ�� 
	//	WCHAR *p = (WCHAR*)GlobalLock(h); //����ָ���ڴ����,�����ڴ�ָ������һ���ֽڵ�ָ��,�����ڴ�������������
	//	memcpy(p, m_strResult.GetBuffer(), (nLen+100) * sizeof(WCHAR));
	//	//strcpy(p, (char*)m_strResult.GetBuffer());  //���ַ���������ȫ�ֶ�
	//	SetClipboardData(CF_UNICODETEXT, h);
	//	//SetClipboardData(CF_TEXT, h);  //��ָ���ڴ������������õ����а�
	//	GlobalUnlock(h);//�����ڴ���� ���Ҽ�����������
	//	CloseClipboard();  //�رռ��а� �ڵ���Open֮�� ������
	//}
	//return;

	HANDLE hText = ::GlobalAlloc(GMEM_MOVEABLE, (nLen + 100) * sizeof(WCHAR));
	if (hText == NULL) 
		return;
	LPWSTR lpText = (LPWSTR)::GlobalLock(hText);
	if (NULL == lpText) 
	{
		::CloseHandle(hText);
		return;
	}
	memcpy(lpText, m_strResult, (nLen+100) * sizeof(WCHAR));
	lpText[nLen] = NULL;
	::GlobalUnlock(hText);

	if (!OpenClipboard(hWnd))
		return;
	//OpenClipboard(hWnd);
	EmptyClipboard();
	//SetClipboardData(CF_UNICODETEXT, hText);
	if (SetClipboardData(CF_UNICODETEXT, hText) == 0)
	{
		GlobalFree(hText);
		hText = NULL;
	}
	CloseClipboard();

}

void CReaderFrame::BackOpertaion()
{
	RestoreFreePen();
}
void CReaderFrame::showNoteTool(NOTE_TOOL_TYPE type)
{
	
}

void CReaderFrame::DataGetByPage(int nPageNo)
{
	
	//CNoteDao noteDao(m_pBookInfo->bookId);
	//m_pdfNoteInfoList.clear();
	double dWidth=0;
	double dHeight=0;
	PDF_GetPageSize(nPageNo,dWidth,dHeight);
	ClearPdfNoteList();
	
	CBookDal bookDal;
	bookDal.GetBookPageResourceData(nPageNo,m_pBookInfo->bookId,m_pdfNoteInfoList_drawPdf,m_pMyPDFBook->GetViewMode(),dHeight,dWidth);
	//Add By Ray
	bookDal.GetBookPageExerciseData(nPageNo,m_pBookInfo->bookId,m_pdfNoteInfoList_drawPdf,m_pMyPDFBook->GetViewMode(),dHeight,dWidth);

	m_noteDao->GetNoteInfosByPageNo(nPageNo,m_pBookInfo->bookId,m_pdfNoteInfoList_drawPdf,m_pMyPDFBook->GetViewMode());
	//Sort
	//sort(m_pdfNoteInfoList_drawPdf.begin(),m_pdfNoteInfoList_drawPdf.end(),CPDFNoteInfo::ComparPdfInfoByFid);

}
void CReaderFrame::PlayMp3(CString filePath,CString desc)
{
	HINSTANCE result = (HINSTANCE)ERROR_FILE_NOT_FOUND;
	if(m_pPlayerWnd == NULL)
	{
		m_pPlayerWnd = new CPlayerWnd();

		m_pPlayerWnd->Create(NULL, _T("DuiLib Demo from mbstudio.cn / meineson"), UI_WNDSTYLE_DIALOG, 0L, 0, 0, 0, 0);
		SetParent(m_pPlayerWnd->GetHWND(), GetHWND());
		RECT rect;
		GetWindowRect(GetHWND(), &rect);
		m_pPlayerWnd->ShowWindow();
		if(g_bScreenShow)
			::SetWindowPos(m_pPlayerWnd->GetHWND(), NULL, 100, rect.bottom-250, 280, 224, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
		else
			::SetWindowPos(m_pPlayerWnd->GetHWND(), HWND_TOPMOST, 100, rect.bottom-250, 280, 224, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

		
		if(desc.GetLength()>0)
			m_pPlayerWnd->SetLabelName(desc);
		else
			m_pPlayerWnd->SetLabelName(_T("���ޱ�ע"));
		
		m_pPlayerWnd->bRead = false;
		m_pPlayerWnd->Play(filePath);

		result = (HINSTANCE)32;
		

	}
	else
	{
		m_pPlayerWnd->InitWindow();
		m_pPlayerWnd->ShowWindow();
		if(desc.GetLength()>0)
			m_pPlayerWnd->SetLabelName(desc);
		else
			m_pPlayerWnd->SetLabelName(_T("���ޱ�ע"));
		
		m_pPlayerWnd->bRead = false;
		m_pPlayerWnd->Play(filePath);
		result = (HINSTANCE)32;
	}
}
void CReaderFrame::PlayMp4(CString filePath)
{

}
void CReaderFrame::openOfficeFile(CString filePath)
{
	HINSTANCE result = (HINSTANCE)ERROR_FILE_NOT_FOUND;
	CString office_path /*= GetOfficePath(filePath)*/;

	if(office_path.GetLength()==0)
	{
		HINSTANCE HRet =ShellExecute(NULL,_T("open"),filePath,NULL,NULL, SW_SHOWNORMAL);
		if((int)HRet ==SE_ERR_NOASSOC)
		{
			CustomMessageBox(L"��֧�ֵ��ļ���ʽ",MSG_TYPE_NOTICE,FALSE);
		}
		DWORD d = GetLastError();
	}
	else
	{
		CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
		result = ShellExecute(NULL,_T("open"),office_path,filePath,NULL,SW_SHOWNORMAL);
	}
	
}
void CReaderFrame::openImage(CString filePath,CString text)
{
	CViewImageFrame * pImageFrame = new CViewImageFrame(filePath,text);
	pImageFrame->Create(m_hWnd, _T("pImageFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
	pImageFrame->CenterWindow();
	pImageFrame->ShowModal();
}

void CReaderFrame::OpenTextNoteFrame(CPDFNoteInfo* info,int type)
{
	m_freeLineFrame->ShowWindow(false);
	SetPenAndColor(NOTES_NONE, GetPenColor());
	if(m_freeLineFrame->erase_select->IsSelected())
	{
		m_freeLineFrame->erase_select->Selected(false);
		EraseModeUse();
	}
	CTextNoteFrame* TextNote = new CTextNoteFrame(info,m_pLabelOper,type);
	TextNote->Create(this->GetHWND(), _T("TextNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
	TextNote->CenterWindow();
	if(TextNote->ShowModal()==IDOK)
	{
		if(TextNote->m_model==1)
		{
			int x=0;
			int y=0;
			TextNote->m_info->pageIndex=m_current_page;
			getFileNoteRc(x,y,TextNote->m_info->pageIndex);
			TextNote->m_info->coord_pt.push_back(x);
			TextNote->m_info->coord_pt.push_back(y);
			TextNote->m_info->coord_pt.push_back(10);
			TextNote->m_info->coord_pt.push_back(10);	
		}
		
		UpdateDBAndPDFList(TextNote->m_info,true);
		//m_pLabelOper->SaveLabelToNote(TextNote->m_info->id);
		//SetNeedReloadDB();
		GetNoteByCataIndex(m_current_mulu_index);
		CustomMessageBox(L"����ɹ������϶��ı���ť������λ��",MSG_TYPE_NOTICE,TRUE);
		
	}
	else 
	{
		SetNeedReloadDB();
		GetNoteByCataIndex(m_current_mulu_index);
		m_pMyPDFBook->RedrawLines();
	}
	if(TextNote)
	{
		delete TextNote;
		TextNote=NULL;
	}
	if(m_pLabelOper)
		m_pLabelOper->ClearStatus();
	m_curSelNote=-1;
	
}

void CReaderFrame::OpenAttachFileNoteFrame(CPDFNoteInfo* info,int type)
{
	m_freeLineFrame->ShowWindow(false);
	isShowFreePen=false;
	SetPenAndColor(NOTES_NONE, GetPenColor());
	if(m_freeLineFrame->erase_select->IsSelected())
	{
		m_freeLineFrame->erase_select->Selected(false);
		EraseModeUse();
	}
	CAttachFileNoteFrame* AttachNote = new CAttachFileNoteFrame(info,m_pLabelOper,type);
	AttachNote->Create(this->GetHWND(), _T("AttachFileNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
	AttachNote->CenterWindow();
	if(AttachNote->ShowModal()==IDOK)
	{
		if(AttachNote->m_model==1)
		{
			int x=0;
			int y=0;
			AttachNote->m_info->pageIndex=m_current_page;
			getFileNoteRc(x,y,AttachNote->m_info->pageIndex);
			AttachNote->m_info->coord_pt.push_back(x);
			AttachNote->m_info->coord_pt.push_back(y);
			AttachNote->m_info->coord_pt.push_back(10);
			AttachNote->m_info->coord_pt.push_back(10);

			


		}

		UpdateDBAndPDFList(AttachNote->m_info,true);
		//m_pLabelOper->SaveLabelToNote(AttachNote->m_info->id);
		//SetNeedReloadDB();
		GetNoteByCataIndex(m_current_mulu_index);
		CustomMessageBox(L"����ɹ������϶������ʼ�������λ��",MSG_TYPE_NOTICE,TRUE);

	}
	else 
	{
		SetNeedReloadDB();
		GetNoteByCataIndex(m_current_mulu_index);
		m_pMyPDFBook->RedrawLines();
	}
	if(AttachNote)
	{
		delete AttachNote;
		AttachNote=NULL;
	}
	if(m_pLabelOper)
		m_pLabelOper->ClearStatus();
	m_curSelNote=-1;
	m_pMyPDFBook->RedrawLines();
}
bool CReaderFrame::checkReloadNoteDB(int page1,int model1)
{
	/*if (m_bIsSearch || m_bIsSelect)
	{
		g_pFrame->UpdateBookNotes(571);
		return false;
	}*/
	if(m_bIsSeeNote)
		return false;
	int model = m_pMyPDFBook->GetViewMode();
	int page = m_pMyPDFBook->GetPageNum();
	if(model!=m_pdf_show_model || m_current_page!=page)
	{
		DataGetByPage(page-1);
		//GetNoteByPage(page);
		//UpdateBookNotes(571);
		
		m_pdf_show_model=model;
		m_current_page=page;
	}
	else
	{
		if(m_IsNeedReloadDB)
		{
			DataGetByPage(page-1);
			//GetNoteByPage(page);
			UpdateBookNotes(m_SidebarWidth);
			m_IsNeedReloadDB=false;
		}
	}
// 	bool bRet=false;
// 	if(model!=m_pdf_show_model)
// 	{
// 		m_current_page_no.clear();
// 		m_pdf_show_model=model;
// 		m_current_page_no.push_back(page);
// 		bRet=true;
// 	}
// 	else
// 	{
// 
// 	}
	/*bool bRet=true;
	if(m_current_page_no.size()==0)
	{
		m_current_page_no.push_back(page);
		bRet=false;
		return bRet;
	}
	if(m_pdf_show_model==model)
	{
		int len=0;
		for(int i=0;i<m_current_page_no.size();i++)
		{
			int temp=m_current_page_no.at(i);
			if(page==temp)
			{
				bRet=false;
				break;
			}
			else
				len++;
		}
		if (model==4)
		{
			if(len==m_current_page_no.size()==2)
			{
				m_current_page_no.clear();
				m_current_page_no.push_back(page);
			}
			if(len==m_current_page_no.size()==1)
			{
				m_current_page_no.push_back(page);
			}
		}
		else
		{
			if(len==m_current_page_no.size()==1)
			{
				m_current_page_no.clear();
				m_current_page_no.push_back(page);
			}
		}
	}
	else
	{
		m_current_page_no.clear();
		m_current_page_no.push_back(page);
		m_pdf_show_model=model;
	}*/
	return true;
}
void AutoPositionSet(int nPage,int nPageSize,int& x,int& y,std::vector<CPDFNoteInfo*> note)
{
	//PitchNum =Row ����+1
	double ra=(double)nPageSize/double(PAGE_BIAOZHUN_WIDTH);
	double bianju = ra*PIECES_BIANJU;
	int nStartPosX =0,nStartPosY=0;
	double nPitchX =((double)nPageSize -bianju*2)/(double)PIECES_NUM;//ÿ������Ŀ���
	//����չ��
	BOOL bExist[PIECES_NUM][PIECES_NUM];
	//��������
	CPoint PosData[PIECES_NUM][PIECES_NUM];
	ZeroMemory(&bExist,sizeof(bExist));
	ZeroMemory(&PosData,sizeof(PosData));
	for(int nRow=0;nRow<PIECES_NUM;nRow++)
	{
		for(int nCol=0; nCol<PIECES_NUM;nCol++)
		{
			PosData[nRow][nCol].x =bianju+(double)nCol*(double)nPitchX+(double)nPitchX/(double)2;
			PosData[nRow][nCol].y =(double)nRow*(double)nPitchX+(double)nPitchX/2;
			for(int nNum=0;nNum<note.size();nNum++)
			{
				CPDFNoteInfo* noteinfo =note.at(nNum);
				
				if((noteinfo->pdfNoteType==NoteDoc|| noteinfo->pdfNoteType==NoteExcel|| noteinfo->pdfNoteType==NotePpt|| noteinfo->pdfNoteType==NotePdf || noteinfo->pdfNoteType==NoteFile || noteinfo->pdfNoteType==NoteImage ||noteinfo->pdfNoteType==NoteAudio || noteinfo->pdfNoteType==NoteVideo || noteinfo->pdfNoteType==NoteTextBox ||noteinfo->pdfNoteType==NoteLink)&&(noteinfo->pageIndex ==nPage)&&(noteinfo->noteOrigin!=ORIGIN_SYSTEM))
				{
					CRect rcPiece;
					CRect rcItem;
					rcItem.SetRect(noteinfo->coord_pt.at(0)-noteinfo->coord_pt.at(2)*0.5,noteinfo->coord_pt.at(1)-noteinfo->coord_pt.at(3)*0.5,noteinfo->coord_pt.at(0)+noteinfo->coord_pt.at(2)*0.5,noteinfo->coord_pt.at(1)+noteinfo->coord_pt.at(3)*0.5);
					rcPiece.SetRect(PosData[nRow][nCol].x-((double)nPitchX/(double)2),PosData[nRow][nCol].y-((double)nPitchX/(double)2),PosData[nRow][nCol].x+((double)nPitchX/(double)2),PosData[nRow][nCol].y+((double)nPitchX/(double)2));
					if(rcPiece.IntersectRect(rcItem,rcPiece))
					{
						bExist[nRow][nCol]=TRUE;
					}
				}
				
				
			}
		}
	}
	//��������Ƿ񸲸�
	BOOL bGetPos=FALSE;
	for(int nRow=0;nRow<PIECES_NUM;nRow++)
	{
		for(int nCol=0; nCol<PIECES_NUM;nCol++)
		{
			if(!bExist[nRow][nCol])
			{
				x =PosData[nRow][nCol].x;
				y =PosData[nRow][nCol].y;
				bGetPos =TRUE;
				break;
			}
		}
		if(bGetPos)
		{
			break;
		}
	}



}
void CReaderFrame::getFileNoteRc(int& x,int& y,int nPage)
{

	int Cx=0,Cy=0;
	double width;
	double heihgt;
	PDF_GetPageSize(nPage,width,heihgt);
	int count=0;

	for(int i=0;i<m_pdfNoteInfoList_drawPdf.size();i++)
	{
		CPDFNoteInfo* info=m_pdfNoteInfoList_drawPdf.at(i);
		if((info->pdfNoteType==NotePdf ||info->pdfNoteType==NotePpt ||info->pdfNoteType==NoteExcel ||info->pdfNoteType==NoteDoc ||info->pdfNoteType==NoteFile || info->pdfNoteType==NoteImage ||info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteVideo || info->pdfNoteType==NoteTextBox ||info->pdfNoteType==NoteLink)&&(info->pageIndex ==nPage))
			count++;

	}
	AutoPositionSet(nPage,(int)width,Cx,Cy,m_pdfNoteInfoList_drawPdf);
	x =Cx;
	y=Cy;
}
void CReaderFrame::AddLabel2H(CLabelInfo* info,CHorizontalLayoutUI* h_list)
{
	if(info)
	{
		CButtonUI* label=new CButtonUI;
		label->SetAttribute(_T("text"),info->lableName);
		label->SetAttribute(_T("autocalcwidth"),_T("true"));
		label->SetAttribute(_T("borderround"),_T("5,5"));
		label->SetAttribute(_T("font"),_T("0"));
		label->SetFixedWidth(90/theApp.m_screen_ratio);
		label->SetFixedHeight(30/theApp.m_screen_ratio);
		if(info->bUse)
		{
			label->SetAttribute(_T("textcolor"),_T("#FFFFFFFF"));
			label->SetAttribute(_T("bkcolor1"),_T("#FF48ACFB"));
			label->SetAttribute(_T("tooltip"),_T("����Ƴ�"));
		}
		else
		{
			label->SetAttribute(_T("textcolor"),_T("#FF8996A6"));
			label->SetAttribute(_T("bkcolor1"),_T("#FFFFFFFF"));
			label->SetAttribute(_T("bordersize"),_T("1"));
			label->SetAttribute(_T("bordercolor"),_T("#FF8996A6"));
			label->SetAttribute(_T("tooltip"),_T("�������"));
			
		}
		if(info->id==-1)
		{
			label->SetAttribute(_T("name"),_T("add_label_to_note"));
		}
		else
		{
			CString name;
			name.Format(_T("one_lable_click%d"),info->id);
			label->SetAttribute(_T("name"),name);
		}
		
		label->SetAttribute(_T("padding"),_T("10,0,0,0"));
		
		label->SetAttribute(_T("align"),_T("center"));
		
		h_list->Add(label);
	}
}
void CReaderFrame::AddLabel2Note(CVerticalLayoutUI* list,std::vector<int> list_index)
{
	
		int row=list_index.size()/LABEL_ROW_NUM;

		for(int i=0;i<=row;i++)
		{
			CHorizontalLayoutUI* h_list=new CHorizontalLayoutUI;
			h_list->SetAttribute(_T("padding"),_T("10,5,0,0"));
			h_list->SetFixedHeight(30/theApp.m_screen_ratio);
			//h_list->SetFixedWidth(300/theApp.m_screen_ratio);
			int max=i*LABEL_ROW_NUM+3;
			if(max>list_index.size())
				max=list_index.size();
			for(int j=LABEL_ROW_NUM*i;j<max;j++)
			{
				int temp=list_index.at(j);
				CLabelInfo* info=m_pLabelOper->m_LabelList.at(temp);
				AddLabel2H(info,h_list);
			}
			if(h_list->GetCount()>=0 && h_list->GetCount()<3 && list_index.size()!=3)
			{
				CLabelInfo* info=new CLabelInfo;
				info->lableName=_T("���ӱ�ǩ");
				info->id=-1;
				AddLabel2H(info,h_list);
				list->Add(h_list);
			}
			else
				if(h_list->GetCount()>0)
					list->Add(h_list);
// 			if(h_list->GetCount()!=3 && list_index.size()<=5)
// 			{
// 				CHorizontalLayoutUI* h_list1=new CHorizontalLayoutUI;
// 				h_list1->SetAttribute(_T("padding"),_T("10,5,0,0"));
// 				h_list1->SetAttribute(_T("height"),_T("44"));
// 				CLabelInfo* info=new CLabelInfo;
// 				info->lableName=_T("���ӱ�ǩ");
// 				info->id=-1;
// 				AddLabel2H(info,h_list1);
// 				list->Add(h_list1);
// 			}
		}
		if(list_index.size()%LABEL_ROW_NUM==0 && list_index.size()<=5 && list_index.size()!=0)
		{
			CHorizontalLayoutUI* h_list1=new CHorizontalLayoutUI;
			h_list1->SetAttribute(_T("padding"),_T("10,5,0,0"));
			h_list1->SetFixedHeight(30/theApp.m_screen_ratio);
			CLabelInfo* info=new CLabelInfo;
			info->lableName=_T("���ӱ�ǩ");
			info->id=-1;
			AddLabel2H(info,h_list1);
			list->Add(h_list1);
		}
}
void CReaderFrame::AddLabelNoUse2Note(CVerticalLayoutUI* list,std::vector<int> list_index)
{
	if(list_index.size()>0)
	{
		int row=list_index.size()/LABEL_ROW_NUM;

		for(int i=0;i<=row;i++)
		{
			CHorizontalLayoutUI* h_list=new CHorizontalLayoutUI;
			h_list->SetAttribute(_T("padding"),_T("10,10,0,0"));
			h_list->SetAttribute(_T("tooltip"),_T("�������"));
			h_list->SetFixedHeight(30/theApp.m_screen_ratio);
			
			int max=i*LABEL_ROW_NUM+3;
			if(max>list_index.size())
				max=list_index.size();
			for(int j=LABEL_ROW_NUM*i;j<max;j++)
			{
				int temp=list_index.at(j);
				CLabelInfo* info=m_pLabelOper->m_LabelList.at(temp);
				AddLabel2H(info,h_list);
			}
			if(h_list->GetCount()>0)
				list->Add(h_list);
		}
	}
	
}
void CReaderFrame::SetLabelView()
{
	CVerticalLayoutUI* list=static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("label_list")));
	list->RemoveAll();
	if(list && m_pLabelOper)
	{
		//m_pLabelOper->LoadNoteLabels(-1);
		int size = m_pLabelOper->m_LabelList.size();
		std::vector<int> nouse_index_list;
		std::vector<int> use_index_list;

		for(int i=0;i<size;i++)
		{
			if((use_index_list.size()+nouse_index_list.size())>=20)
				break;
			CLabelInfo* info=m_pLabelOper->m_LabelList.at(i);
			if(info->bUse)
				use_index_list.push_back(i);
			else
			{
				nouse_index_list.push_back(i);
			}
		}

		AddLabel2Note(list,use_index_list);
		if(m_isShowAllLabel)
			AddLabelNoUse2Note(list,nouse_index_list);

	}
}
void CReaderFrame::showNotePage()
{
	
	//getCurrentMuluIndexByPage(m_pMyPDFBook->GetPageNum());
	m_ctrMulu->RemoveAll();
	for(int i=0;i<m_cata_list.size();i++)
	{
		textbook_catalogInfo info=m_cata_list.at(i);
		CListLabelElementUI* item=new CListLabelElementUI;
		item->SetAttribute(_T("text"),info.catalogName);
		item->SetFixedHeight(40/theApp.m_screen_ratio);
		item->SetAttribute(_T("textpadding"),_T("2,0,0,0"));
		item->SetAttribute(_T("endellipsis"),_T("true"));
		/*if(info.nAttachment>0)
		{
				if(theApp.m_screen==0 || theApp.m_screen==2)
				item->SetBkImage(_T("file='reader\\readerimages\\resources.png' dest='5,9,16,20'"));
			else if(theApp.m_screen==3)
				item->SetBkImage(_T("file='reader\\readerimages\\resources_icon.png' dest='5,16,25,41'"));
			else
				item->SetBkImage(_T("file='reader\\readerimages\\resources_icon.png' dest='5,12,20,27'"));
		}*/
		m_ctrMulu->Add(item);
	}
	m_current_mulu_index=getCurrentMuluIndexByPage(m_current_page);
	m_ctrMulu->SelectItem(m_current_mulu_index);
}
void CReaderFrame::GotoPageByMuluIndex()
{
	int page=GetCurrentPageByMuluIndex();
	if(page>=0)
	{
		GoToPage(page);
		m_pMyPDFBook->RedrawLines();
	}
}
int CReaderFrame::getCurrentMuluIndexByPage(int page)
{
	//page-=1;
	int iRet=0;
	int nTemp=0;
	for(int i=1;i<m_cata_list.size();i++)
	{
		textbook_catalogInfo info=m_cata_list.at(i);
		
		if(page>=info.startPage && page<=info.endPage)
		{
			//m_current_mulu_index=i;
			if(info.parentId==1)
			{
				nTemp =i;
				continue;
			}
			iRet=i;
			break;
		}
	}
	if(iRet==0)
	{
		iRet=nTemp;
	}
	return iRet;
}
int CReaderFrame::GetCurrentPageByMuluIndex()
{
	int page=-1;
	if(m_current_mulu_index>=0 && m_current_mulu_index<m_cata_list.size())
	{
		textbook_catalogInfo info=m_cata_list.at(m_current_mulu_index);
		page=info.startPage;

	}
	return page;
}
void CReaderFrame::showReadTool(int index)
{
	BackAllMultyOption();
	ClearShareNoteOperator();
	ClearShareNoteTwoOperator();
	m_pShareStudentFolderLayout->SetVisible(false);
	ShareFolderGoBack();
	if(index==READ_TOOL_SHOW::CATALOGUE)
	{
		if(m_isshowcata)
		{
			m_pSidebarLayout->SetVisible(false);
			m_isshowcata=false;
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_MENULIST_OPEN_CLOSE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_MENU_LIST_TYPE,L"1");//1-8
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_MENU_LIST_TYPE_WAY,L"1"); //1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_MENU_LIST_OPEN_CLOSE,L"0");//0=close 1=open 
			theApp.m_EventLog.MakeJsonFormat();
			SetPageOperatorView(false);
			/////////////
		}
		else
		{
			SetPageOperatorView(true);
			m_pShowNoteButton->Selected(false);
			m_pShowSourceButton->Selected(false);

			
			WriteLog(OP_SHOW_MARK);
			ShowSideBar(0,_T("Ŀ¼"));
			if(m_pBookmarkList!=NULL)
			{
				m_pBookmarkList->RemoveAll();
				ReadCatalogItem(m_pBookmarkList,NULL,NULL);
			}
			m_isshowcata=true;
			m_isShowNoteUi=false;
			m_isShowResourceUi=false;
			m_isShowXitiUi=false;
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_MENULIST_OPEN_CLOSE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_MENU_LIST_TYPE,L"1");//1-8
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_MENU_LIST_TYPE_WAY,L"1"); //1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_MENU_LIST_OPEN_CLOSE,L"1");//0=close 1=open 
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
	}
	else if(index==READ_TOOL_SHOW::NOTELIST)
	{
		if(m_isShowNoteUi)
		{
			SetPageOperatorView(false);
			m_pSidebarLayout->SetVisible(false);
			m_pShowNoteButton->Selected(true);
			//m_pShowNoteButton->SetAttribute(L"selected",L"false");
			m_isShowNoteUi=false;
			////���////////
			theApp.m_EventLog.init();
			CString strPage;
			strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTELIST_OPEN_CLOSE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_TYPE_WAY,L"3");//1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_OPEN_CLOSE,L"0"); //0=close 1=open 
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
		else
		{
			ShowMarkButtonClick(TRUE);
			SetPageOperatorView(true);
			m_pShowCalaButton->Selected(false);
			m_pShowSourceButton->Selected(false);
			//m_pShowWorkButton->Selected(false);
			WriteLog(OP_NOTE_LIST);
			ShowSideBar(2,_T("�ʼ�"));
			UpdateBookNotes(m_SidebarWidth);
			showNotePage();
			m_isshowcata=false;
			m_isShowNoteUi=true;
			m_isShowResourceUi=false;
			m_isShowXitiUi=false;
			////���////////
			theApp.m_EventLog.init();
			CString strPage;
			strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTELIST_OPEN_CLOSE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_TYPE_WAY,L"3");//1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_OPEN_CLOSE,L"1"); //0=close 1=open 
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
	}
	else if(index==READ_TOOL_SHOW::RESOURCELIST)
	{
		m_pResList->RemoveAll();
		m_pResTypeLayout->RemoveAll();
		if(m_isShowResourceUi)
		{
			SetPageOperatorView(false);
			m_pSidebarLayout->SetVisible(false);
			m_isShowResourceUi=false;
			////���////////
			theApp.m_EventLog.init();
			CString strPage;
			strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_RESOURCELIST_OPEN_CLOSE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_RESOURCE_LIST_TYPE_WAY,L"1");//1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_RESOURCE_LIST_OPEN_CLOSE,L"0"); //0=close 1=open 
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
		else
		{

			CComboUI* mulu = static_cast<CComboUI*>(m_pm.FindControl(_T("ComboMulu_Resource")));
			mulu->SetVisible(true);
			SetPageOperatorView(true);
			m_pShowCalaButton->Selected(false);
			m_pShowNoteButton->Selected(false);
			//m_pShowSourceButton->Selected(true);
			//m_pShowWorkButton->Selected(false);
			WriteLog(OP_RESOURCE_LIST);
			ShowSideBar(1,_T("��Դ"));
			
// 			else
// 				GetExtras();
			
			m_isshowcata=false;
			m_isShowNoteUi=false;
			m_isShowResourceUi=true;
			m_isShowXitiUi=false;
			m_bIsReloadResource=false;
			ShowResourceMuLu();
			UpdateBookRes();
			m_bIsReloadResource=true;
			////���////////
			theApp.m_EventLog.init();
			CString strPage;
			strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_RESOURCELIST_OPEN_CLOSE);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_RESOURCE_LIST_TYPE_WAY,L"1");//1 or 3
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_RESOURCE_LIST_OPEN_CLOSE,L"1"); //0=close 1=open 
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
	}
	else if(index==READ_TOOL_SHOW::EXERCISES)
	{
		if(m_isShowXitiUi)
		{
			m_pSidebarLayout->SetVisible(false);
			//m_pShowWorkButton->SetAttribute(L"selected",L"false");
			m_isShowXitiUi=false;
		}
		else
		{
			m_isshowcata=false;
			m_isShowNoteUi=false;
			m_isShowResourceUi=false;
			m_isShowXitiUi=true;
		}
	}
	g_pFrame->m_pMyPDFBook->RedrawLines();
}
void CReaderFrame::changeShowMode()
{
	if(m_pMyPDFBook->GetViewMode()==2)//��ҳ
	{
		m_pMyPDFBook->SetViewMode(4);
		m_show_double_page->SetVisible(true);
		m_show_single_page->SetVisible(false);

		theApp.m_EventLog.init();
		CString strPage;
		strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGEVIEW_MODE_CHG);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG_TYPE_WAY,L"1");//1 or 3
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG,L"0"); //0=single 1=double 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
		theApp.m_EventLog.MakeJsonFormat();

	}
	else
	{
		m_pMyPDFBook->SetViewMode(2);
		m_show_double_page->SetVisible(false);
		m_show_single_page->SetVisible(true);
		// 		////���////////
		theApp.m_EventLog.init();
		CString strPage;
		strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGEVIEW_MODE_CHG);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG_TYPE_WAY,L"1");//1 or 3
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG,L"1"); //0=single 1=double 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
		theApp.m_EventLog.MakeJsonFormat();
	}
// 	if(m_bChangeShowMode->IsSelected())
// 	{
// 		m_pMyPDFBook->SetViewMode(2);
// 		////���////////
// 		theApp.m_EventLog.init();
// 		CString strPage;
// 		strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
// 		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGEVIEW_MODE_CHG);
// 		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG_TYPE_WAY,L"1");//1 or 3
// 		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG,L"1"); //0=single 1=double 
// 		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
// 		theApp.m_EventLog.MakeJsonFormat();
// 		/////////////
// 	}
// 	else
// 	{
// 		m_pMyPDFBook->SetViewMode(4);
// 		////���////////
// 		theApp.m_EventLog.init();
// 		CString strPage;
// 		strPage.Format(L"%d",m_pMyPDFBook->GetPageNum());
// 		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGEVIEW_MODE_CHG);
// 		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG_TYPE_WAY,L"1");//1 or 3
// 		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_PAGEVIEW_MODE_CHG,L"0"); //0=single 1=double 
// 		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
// 		theApp.m_EventLog.MakeJsonFormat();
// 		/////////////
// 	}
}
void CReaderFrame::ShowNoteListMenu(CPDFNoteInfo* info)
{
	CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
	DuiLib::CPoint point(0,0);
	GetCursorPos(&point);
	if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW)
	{
		if(info->pdfNoteType==NoteLine || info->pdfNoteType==NoteTextBox)
			pMenu->Init(NULL, _T("reader\\menu\\Menu_List_Note_Local_Normal.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
		else if(info->pdfNoteType==NoteFreedom )
			pMenu->Init(NULL, _T("reader\\menu\\Menu_List_Note_Local_Normal_FreePenLine.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
			
		else if(info->pdfNoteType==NoteLink)
			pMenu->Init(NULL, _T("reader\\menu\\Menu_List_Note_Local_NoteLink.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
		else 
			pMenu->Init(NULL, _T("reader\\menu\\Menu_List_Note_Local_Attach.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
	}
	else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::CLOUD_NOTE_SHOW)
	{
		pMenu->Init(NULL, _T("reader\\menu\\Menu_List_Note_Cloud.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
	}	
	else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::SHARE_NOTE_SHOW)
	{
		
		if(ComboShareSelect)
		{
			if(ComboShareSelect->GetCurSel()==0)
			{
				if(GetUserType()==2)
				{
					if(m_pShareStudentFolderLayout->IsVisible())
					{
						pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_from_me_two.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
					}
					else
					{
						int index = m_pNoteList->m_current_select_index;
						if(index>=0)
						{
							CShareFolder* info = m_pShareNote->m_current_Firstfolder_list.at(index);
							if(info->m_id<0)
								pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_from_me_student_note.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
							else
								pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_from_me_student_folder.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
						}
					}
						
				}
				else
				{
					if(m_pShareStudentFolderLayout->IsVisible())
						pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_from_me_two_teacher.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
					else
						pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_from_me.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
				}


			}
			else
			{
				if(GetUserType()==2)
				{
					if(m_pShareStudentFolderLayout->IsVisible())//����ҳ��
					{
						pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_to_me_two_student.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
					}
					else
						pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_to_me.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
					
				}
				else if(GetUserType()==1)
				{
					if(m_pShareStudentFolderLayout->IsVisible())//����ҳ��
					{
						pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_to_me_two_teacher.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
					}
					else
					{
						int index = m_pNoteList->m_current_select_index;
						if(index>=0)
						{
							CShareFolder* info = m_pShareNote->m_current_Firstfolder_list.at(index);
							if(info->m_id<0)
								pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_to_me_dantiao_teacher.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
							else
								pMenu->Init(NULL, _T("reader\\menu\\Menu_Note_Share_to_me_folder_teacher.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);

						}
					}
				}
				

				/*CShareFolderList* info=m_pShareNote->m_share_to_me_list.at(index);
				if(info->m_id<=0)//�����ʼ�
				{
					pMenu->Init(NULL, _T("reader\\ShareToMeMenu.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
				}
				else
				{
					pMenu->Init(NULL, _T("reader\\ShareToMeNoteMenu.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
				}*/
			}

		}
	}
}
void CReaderFrame::openAppendFile(CPDFNoteInfo* info,int nIndex,int nType)
{
	if(info)
	{
		CString path=theApp.GetCurDir()+info->content;
		path.Replace(_T("/"),_T("\\"));
		int nPos=0;
		CString strFilePath=info->content;
		nPos=strFilePath.ReverseFind('.');
		CString strType =strFilePath.Mid(nPos+1,strFilePath.GetLength());
		nPos =strFilePath.ReverseFind('\\');
		CString strFielName =strFilePath.Mid(nPos+1,strFilePath.GetLength());
		if(info->pdfNoteType==NoteAudio)
		{
			PlayMp3(path,info->noteText);
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_AUDIO);
			int nPage =  info->pageIndex;
			CString strPage;
			strPage.Format(L"%d",nPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_TYPE,strType);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_NAME,strFielName);
			CString strNoteLocalID;
			strNoteLocalID.Format(L"%d",info->id);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
		else if(info->pdfNoteType==NoteVideo)
		{
			ShellExecute(NULL, L"open", path, NULL, NULL, SW_SHOWNORMAL);
// 			CWnd cwnd;
// 			
// 			cwnd.Attach(m_hWnd);
// 			if(nType ==1)
// 			{
// 				CDlgWmplayer player(&cwnd,m_pdfNoteInfoList_drawPdf,nIndex);
// 				player.DoModal();
// 				cwnd.Detach();
// 			}else
// 			{
// 				CDlgWmplayer player(&cwnd,m_pdfNoteInfoList,nIndex);
// 				player.DoModal();
// 				cwnd.Detach();
// 			}
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_VIDEO);
			int nPage =  info->pageIndex;
			CString strPage;
			strPage.Format(L"%d",nPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_TYPE,strType);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_NAME,strFielName);
			CString strNoteLocalID;
			strNoteLocalID.Format(L"%d",info->id);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
		else if(info->pdfNoteType==NoteImage)
		{
			if(nType ==1)
			{
				CViewImageFrame * pImageFrame = new CViewImageFrame(m_pdfNoteInfoList_drawPdf,nIndex);
				pImageFrame->Create(m_hWnd, _T("pImageFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
				pImageFrame->CenterWindow();
				pImageFrame->ShowModal();
			}
			else
			{
				CViewImageFrame * pImageFrame = new CViewImageFrame(m_pdfNoteInfoList,nIndex);
				pImageFrame->Create(m_hWnd, _T("pImageFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
				pImageFrame->CenterWindow();
				pImageFrame->ShowModal();
			}
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_PIC);
			int nPage =  info->pageIndex;
			CString strPage;
			strPage.Format(L"%d",nPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_TYPE,strType);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_NAME,strFielName);
			CString strNoteLocalID;
			strNoteLocalID.Format(L"%d",info->id);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
		else
		{
			openOfficeFile(path);
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_DOC);
			int nPage =  info->pageIndex;
			CString strPage;
			strPage.Format(L"%d",nPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_TYPE,strType);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILE_NAME,strFielName);
			CString strNoteLocalID;
			strNoteLocalID.Format(L"%d",info->id);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
			theApp.m_EventLog.MakeJsonFormat();
			/////////////
		}
	}
}
RECT ChangeFileShowCoord(int x,int y)
{
	RECT rc;
	rc.left=x-PIECES_SIZE_X/2;
	rc.top=y-PIECES_SIZE_Y/2;
	rc.bottom=y+PIECES_SIZE_Y/2;
	rc.right=x+PIECES_SIZE_X/2;
	if(rc.top <0)
	{
		rc.top=0;
		rc.bottom =PIECES_SIZE_Y;
	}
	return rc;
}
void CReaderFrame::DrawAllNote(HDC hdc, RECT *rcArea, int page)
{

	if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
	{
		//getCurrentMuluIndexByPage(page);
		//m_ctrMulu->SelectItem(m_current_mulu_index);
	}
	
	for (int n=m_pdfNoteInfoList_drawPdf.size()-1;n>=0;n--)
	{
		CPDFNoteInfo* info=m_pdfNoteInfoList_drawPdf.at(n);
		if(info->pageIndex!=page)
		{
			continue;
		}
		if(info->noteOrigin==PDFNoteInfoOrigin::ORIGIN_SYSTEM)//ϵͳ�Դ���Դ�ʼ�
		{
			if(info->coord_pt.size()>0)
			{
				CString img;
				RECT temp1=ChangeFileShowCoord(info->coord_pt.at(0),info->coord_pt.at(1));
				std::vector<double> temp_point_list_src;
				std::vector<double> temp_point_list_det;
				temp_point_list_src.push_back(temp1.left);
				temp_point_list_src.push_back(temp1.top);
				temp_point_list_src.push_back(temp1.right-temp1.left);
				temp_point_list_src.push_back(temp1.bottom-temp1.top);
				temp_point_list_det=temp_point_list_src;

				PDF_Rect2Screen(temp_point_list_src, temp_point_list_det, info->pageIndex);
				RECT temp;
				temp.left=temp_point_list_det.at(0);
				temp.top=temp_point_list_det.at(1);
				temp.right=temp_point_list_det.at(2)+temp.left;
				temp.bottom=temp_point_list_det.at(3)+temp.top;
				if(info->pdfNoteType==NoteExercise)
				{
					img=info->resourcePath;
				}else
				{
					img=theApp.GetCurDir()+_T("RES//file_icon//music.png");
				}

				DrawNotes::DrawImg(hdc, img, temp);
			}
			
			
		}
		else if(info->noteOrigin==PDFNoteInfoOrigin::ORIGIN_USER)//�û��Խ��ʼ�
		{
			if(!m_isShowNotes)
				continue;;
			if(info->coord_pt.size()==0)
			{
				StrCoord2Point(info->coord, info->coord_pt);

				//if (info->pdfNoteType==NoteLine || info->pdfNoteType==NoteTextBox)
				//{
				//	Point2RectPT(info->coord_pt);
				//}

			}
			std::vector<double> screen_note_pos = info->coord_pt;
			switch (info->pdfNoteType)
			{
				case NoteLine://     =	10,  //	  �»��ߣ�
					{
						if(info->lineType==HighlightLine)
						{
							int ret = PDF_Rect2Screen(info->coord_pt, screen_note_pos, page);
							int i=0;
							while (i < screen_note_pos.size())
							{
								int y = screen_note_pos[i+1]+screen_note_pos[i+3];
								int lineWidth = screen_note_pos[i+3];
								y = screen_note_pos[i+1];
								DrawNotes::DrawLine(hdc, TP_NOTES_TYPE::NOTES_LINE_MARK, lineWidth, Gdiplus::Color(0xFF000000 + info->lineColor), Gdiplus::Point(screen_note_pos[i], y), Gdiplus::Point(screen_note_pos[i]+screen_note_pos[i+2], y));

								if (m_curSelNote!=-1&&
									m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&
									m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id
									)
								{
									// ��ѡ�п�
									DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(screen_note_pos[i], screen_note_pos[i+1]), Gdiplus::Point(screen_note_pos[i]+screen_note_pos[i+2], screen_note_pos[i+1]+screen_note_pos[i+3]));
								}
								i += 4;
							}
						}
						else
						{
							int ret = PDF_Rect2Screen(info->coord_pt, screen_note_pos, page);
							TP_NOTES_TYPE note_line_type = TP_NOTES_TYPE::NOTES_NONE;

							if(info->lineType==FullLine)
							{
								note_line_type = TP_NOTES_TYPE::NOTES_LINE_STD;
							}
							else if(info->lineType==WavyLine)
							{
								note_line_type =  TP_NOTES_TYPE::NOTES_LINE_WAVE;
							}
							else if(info->lineType==DottedLine)
							{
								note_line_type = TP_NOTES_TYPE::NOTES_LINE_DOT;
							}
							else
							{
								return;
							}

							int i = 0;
							while (i < screen_note_pos.size())
							{
								int y = screen_note_pos[i+1]+screen_note_pos[i+3];
								int lineWidth = info->lineWidth;
								DrawNotes::DrawLine(hdc, note_line_type, lineWidth, Gdiplus::Color(0xFF000000 + info->lineColor), Gdiplus::Point(screen_note_pos[i], y), Gdiplus::Point(screen_note_pos[i]+screen_note_pos[i+2], y));

								if (m_curSelNote!=-1&&m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id)
								{
									// ��ѡ�п�
									DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(screen_note_pos[i], screen_note_pos[i+1]), Gdiplus::Point(screen_note_pos[i]+screen_note_pos[i+2], screen_note_pos[i+1]+screen_note_pos[i+3]));
								}

								i += 4;
							}
						}
						
					}
					break;
				case NoteImage:
					{
						if(info->coord_pt.size()>0)
						{

							CString img=theApp.GetCurDir()+_T("RES//file_icon//pic.png");
							RECT temp1=ChangeFileShowCoord(info->coord_pt.at(0),info->coord_pt.at(1));
							std::vector<double> temp_point_list_src;
							std::vector<double> temp_point_list_det;
							temp_point_list_src.push_back(temp1.left);
							temp_point_list_src.push_back(temp1.top);
							temp_point_list_src.push_back(temp1.right-temp1.left);
							temp_point_list_src.push_back(temp1.bottom-temp1.top);
							temp_point_list_det=temp_point_list_src;

							PDF_Rect2Screen(temp_point_list_src, temp_point_list_det, info->pageIndex);
							RECT temp;
							temp.left=temp_point_list_det.at(0);
							temp.top=temp_point_list_det.at(1);
							temp.right=temp_point_list_det.at(2)+temp.left;
							temp.bottom=temp_point_list_det.at(3)+temp.top;
							SetShowNoteIcon(info,img);
							DrawNotes::DrawImg(hdc, img, temp);
							if (m_curSelNote!=-1&&
								m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&
								m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id
								)
							{
								// ��ѡ�п�
								DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(temp.left-1, temp.top-1), Gdiplus::Point(temp.right+1, temp.bottom+1));
							}
						}
						
					}
					break;
				case NoteLink:
					{
						CString img=theApp.GetCurDir()+_T("RES//file_icon//ziyuan.png");
						RECT temp1=ChangeFileShowCoord(info->coord_pt.at(0),info->coord_pt.at(1));
						std::vector<double> temp_point_list_src;
						std::vector<double> temp_point_list_det;
						temp_point_list_src.push_back(temp1.left);
						temp_point_list_src.push_back(temp1.top);
						temp_point_list_src.push_back(temp1.right-temp1.left);
						temp_point_list_src.push_back(temp1.bottom-temp1.top);
						temp_point_list_det=temp_point_list_src;

						PDF_Rect2Screen(temp_point_list_src, temp_point_list_det, info->pageIndex);
						RECT temp;
						temp.left=temp_point_list_det.at(0);
						temp.top=temp_point_list_det.at(1);
						temp.right=temp_point_list_det.at(2)+temp.left;
						temp.bottom=temp_point_list_det.at(3)+temp.top;
						SetShowNoteIcon(info,img);
						DrawNotes::DrawImg(hdc, img, temp);
						if (m_curSelNote!=-1&&
							m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&
							m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id
							)
						{
							// ��ѡ�п�
							DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(temp.left-1, temp.top-1), Gdiplus::Point(temp.right+1, temp.bottom+1));
						}
					}
					break;
				case NoteTextBox:
					{
						if(info->coord_pt.size()>0)
						{
							CString img=theApp.GetCurDir()+_T("RES//file_icon//text.png");
							RECT temp1=ChangeFileShowCoord(info->coord_pt.at(0),info->coord_pt.at(1));
							std::vector<double> temp_point_list_src;
							std::vector<double> temp_point_list_det;
							temp_point_list_src.push_back(temp1.left);
							temp_point_list_src.push_back(temp1.top);
							temp_point_list_src.push_back(temp1.right-temp1.left);
							temp_point_list_src.push_back(temp1.bottom-temp1.top);
							temp_point_list_det=temp_point_list_src;

							PDF_Rect2Screen(temp_point_list_src, temp_point_list_det, info->pageIndex);
							RECT temp;
							temp.left=temp_point_list_det.at(0);
							temp.top=temp_point_list_det.at(1);
							temp.right=temp_point_list_det.at(2)+temp.left;
							temp.bottom=temp_point_list_det.at(3)+temp.top;
							SetShowNoteIcon(info,img);
							DrawNotes::DrawImg(hdc, img, temp);
							if (m_curSelNote!=-1&&
								m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&
								m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id
								)
							{
								// ��ѡ�п�
								DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(temp.left-1, temp.top-1), Gdiplus::Point(temp.right+1, temp.bottom+1));
							}
						}
						
					}
					break;
				case NoteVideo:
					{
						if(info->coord_pt.size()>0)
						{
							CString img=theApp.GetCurDir()+_T("RES//file_icon//video.png");
							RECT temp1=ChangeFileShowCoord(info->coord_pt.at(0),info->coord_pt.at(1));
							std::vector<double> temp_point_list_src;
							std::vector<double> temp_point_list_det;
							temp_point_list_src.push_back(temp1.left);
							temp_point_list_src.push_back(temp1.top);
							temp_point_list_src.push_back(temp1.right-temp1.left);
							temp_point_list_src.push_back(temp1.bottom-temp1.top);
							temp_point_list_det=temp_point_list_src;

							PDF_Rect2Screen(temp_point_list_src, temp_point_list_det, info->pageIndex);
							RECT temp;
							temp.left=temp_point_list_det.at(0);
							temp.top=temp_point_list_det.at(1);
							temp.right=temp_point_list_det.at(2)+temp.left;
							temp.bottom=temp_point_list_det.at(3)+temp.top;
							SetShowNoteIcon(info,img);
							DrawNotes::DrawImg(hdc, img, temp);
							if (m_curSelNote!=-1&&
								m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&
								m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id
								)
							{
								// ��ѡ�п�
								DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(temp.left-1, temp.top-1), Gdiplus::Point(temp.right+1, temp.bottom+1));
							}
						}
						
					}
					break;
				case NoteAudio:
					{
						if(info->coord_pt.size()>0)
						{
							CString img=theApp.GetCurDir()+_T("RES//file_icon//voice.png");
							RECT temp1=ChangeFileShowCoord(info->coord_pt.at(0),info->coord_pt.at(1));
							std::vector<double> temp_point_list_src;
							std::vector<double> temp_point_list_det;
							temp_point_list_src.push_back(temp1.left);
							temp_point_list_src.push_back(temp1.top);
							temp_point_list_src.push_back(temp1.right-temp1.left);
							temp_point_list_src.push_back(temp1.bottom-temp1.top);
							temp_point_list_det=temp_point_list_src;

							PDF_Rect2Screen(temp_point_list_src, temp_point_list_det, info->pageIndex);
							RECT temp;
							temp.left=temp_point_list_det.at(0);
							temp.top=temp_point_list_det.at(1);
							temp.right=temp_point_list_det.at(2)+temp.left;
							temp.bottom=temp_point_list_det.at(3)+temp.top;
							SetShowNoteIcon(info,img);
							DrawNotes::DrawImg(hdc, img, temp);
							if (m_curSelNote!=-1&&
								m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&
								m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id
								)
							{
								// ��ѡ�п�
								DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(temp.left-1, temp.top-1), Gdiplus::Point(temp.right+1, temp.bottom+1));
							}
						}
						
					}
					break;
				case NoteFile:
				case NoteDoc:
				case NoteExcel:
				case NotePpt:
				case NotePdf:
					{
						if(info->coord_pt.size()>0)
						{
							CString img=GetFileIconPath(info);
							RECT temp1=ChangeFileShowCoord(info->coord_pt.at(0),info->coord_pt.at(1));
							std::vector<double> temp_point_list_src;
							std::vector<double> temp_point_list_det;
							temp_point_list_src.push_back(temp1.left);
							temp_point_list_src.push_back(temp1.top);
							temp_point_list_src.push_back(temp1.right-temp1.left);
							temp_point_list_src.push_back(temp1.bottom-temp1.top);
							temp_point_list_det=temp_point_list_src;

							PDF_Rect2Screen(temp_point_list_src, temp_point_list_det, info->pageIndex);
							RECT temp;
							temp.left=temp_point_list_det.at(0);
							temp.top=temp_point_list_det.at(1);
							temp.right=temp_point_list_det.at(2)+temp.left;
							temp.bottom=temp_point_list_det.at(3)+temp.top;
							SetShowNoteIcon(info,img);
							DrawNotes::DrawImg(hdc, img, temp);
							if (m_curSelNote!=-1&&
								m_curSelNote<m_pdfNoteInfoList_drawPdf.size() &&
								m_pdfNoteInfoList_drawPdf[m_curSelNote]->id==info->id
								)
							{
								// ��ѡ�п�
								DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(temp.left-1, temp.top-1), Gdiplus::Point(temp.right+1, temp.bottom+1));
							}
						}
						
					}
					break;
				case NoteFreedom://       ���ɻ���
					{

						if (info->isFather==TRUE || info->coord_pt.size()<8)  break;
						int ret = PDF_PT2Screen(info->coord_pt, screen_note_pos, page);

						DrawNotes::DrawLineFree(hdc, info->lineWidth, Gdiplus::Color(0xFF000000 + info->lineColor), screen_note_pos);

						/*if (m_curSelNote!=-1&&m_curSelNote<m_pdfNoteInfoList.size() &&m_pdfNoteInfoList[m_curSelNote]->id==info->id && m_pdfNoteInfoList[m_curSelNote]->fid<0)
						{
						RectF max_rt = GetMaxRect(screen_note_pos);
						DrawNotes::DrawRect(hdc, 3, Color(255,0,0), Gdiplus::DashStyle::DashStyleDash, Gdiplus::Point(max_rt.GetLeft(),max_rt.GetTop()), Gdiplus::Point(max_rt.GetRight(),max_rt.GetBottom()));
						}*/
						
					}
					break;
				default:
					break;
		}
	}	
}
}
bool CReaderFrame::MultiOperatorNote(std::vector<CPDFNoteInfo*> list)
{
	bool bRet=false;
	if(list.size()<=0)
		CustomMessageBox( _T("��ѡ����Ҫ�����ıʼ�"),MSG_TYPE_NOTICE,FALSE);
	else
	{
		if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW)//���رʼ�
		{

		}
		else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::CLOUD_NOTE_SHOW)//�������ص�����
		{

		}
	}
	return bRet;
}
bool CReaderFrame::IsAccordSearchCondition(CPDFNoteInfo* info)
{
	bool bRet=true;
	bool bCatalog=false;
	bool bData=false;
	bool bType=false;
	bool bLineType=false;
	bool Label=false;
	if(info)
	{ 
		if(m_search_condition.m_startPage>=0 && m_search_condition.m_endPage>=0)
		{
			if(info->pageIndex>=m_search_condition.m_startPage && info->pageIndex<=m_search_condition.m_endPage)
			{
				bCatalog=true;
			}
			else
				bCatalog=false;
		}
		else
		{
			bCatalog=true;
		}

		if(m_search_condition.m_startPage>=0 && m_search_condition.m_endPage>=0)
		{
			if(info->pageIndex>=m_search_condition.m_startPage && info->pageIndex<=m_search_condition.m_endPage)
			{
				bCatalog=true;
			}
			else
				bCatalog=false;
		}
		else
		{
			bCatalog=true;
		}


	}
	return bRet;
}
void CReaderFrame::ShowShareFolderTreeView(int type)
{
	if(m_pShareNote)
	{
		if(type==1)//�ҹ�����
		{
			int a=0;
		}
		else
		{
			for (int i=0;i<m_pShareNote->m_share_to_me_list.size();i++)
			{
				CShareFolderList* listInfo=m_pShareNote->m_share_to_me_list.at(i);
				if(listInfo->m_id>=0)//�ļ���
				{
					CTreeNodeUI* node=new CTreeNodeUI;
					node->SetItemText(listInfo->m_name);
					node->SetAttribute(_T("font"),_T("0"));
					node->SetItemTextColor(0xFFCDCDCD);
					//node->SetItemHotTextColor(0xFFC8C6CB);
					//node->SetSelItemTextColor(0xFFC8C6CB);
					node->SetAttribute(_T("folderattr"), _T("width=\"0\" float=\"true\" "));
					node->SetAttribute(_T("itemattr"), _T("padding=\"16,0,0,0\" align=\"left\" "));
					for(int j=0;j<listInfo->m_folder_list.size();j++)
					{
						CShareFolder* info=listInfo->m_folder_list.at(j);
						CTreeNodeUI* nodeFolder=new CTreeNodeUI;
						nodeFolder->SetItemText(info->m_name);
						nodeFolder->SetItemTextColor(0xFFCDCDCD);
						for(int k=0;k<info->m_note_list.size();k++)
						{
							CTreeNodeUI* noteNote=new CTreeNodeUI;
							noteNote->SetItemTextColor(0xFFCDCDCD);
							//noteNote->SetItemHotTextColor(0xFFC8C6CB);
							//noteNote->SetSelItemTextColor(0xFFC8C6CB);
							noteNote->SetAttribute(_T("folderattr"), _T("width=\"0\" float=\"true\" "));
							noteNote->SetAttribute(_T("itemattr"), _T("padding=\"16,0,0,0\" align=\"left\" "));
							noteNote->SetItemText(_T("�ʼ�"));
							nodeFolder->Add(noteNote);
						}
						node->Add(nodeFolder);
					}
					m_pShareFolderTreeUI->Add(node);
				}
			}
		}
	}
}

void CReaderFrame::ShowStudentSubmit()
{
	CHorizontalLayoutUI* h_share_folder_list= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_share_folder_list")));

	CHorizontalLayoutUI* submit_ok= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_ok")));
	CHorizontalLayoutUI* submit_no= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_no")));
	CButtonUI* pButton=static_cast<CButtonUI*>(m_pm.FindControl(_T("show_hide_share_student")));
	if(pButton)
	{
		if(m_bIsShowStudentSubmit)
		{
			m_bIsShowStudentSubmit=false;
			if(submit_ok && submit_no)
			{
				submit_ok->SetVisible(false);
				submit_no->SetVisible(false);
			}
			pButton->SetText(_T("�鿴�ύ���"));
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_SHOW_HIDE_STD_SUBMIT);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_STD_SUBMIT_ON_OFF,L"0");
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,L"");
			theApp.m_EventLog.MakeJsonFormat();
			////////////////
			/*h_share_folder_list->SetFixedHeight(660/theApp.m_screen_ratio);
			if(theApp.m_screen==3)
				h_share_folder_list->SetFixedHeight(850);
			else if(theApp.m_screen==1)
				h_share_folder_list->SetFixedHeight(570);*/
			SetShareTwoListSize();
		}
		else
		{
			m_bIsShowStudentSubmit=true;
			pButton->SetText(_T("�����ύ���"));
			if(submit_ok && submit_no)
			{
				submit_ok->SetVisible(true);
				submit_no->SetVisible(true);
				ShowStudentList();
				
				
			}
			////���////////
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_SHOW_HIDE_STD_SUBMIT);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_STD_SUBMIT_ON_OFF,L"1");
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,L"");
			theApp.m_EventLog.MakeJsonFormat();
			////////////////
			/*h_share_folder_list->SetFixedHeight(240/theApp.m_screen_ratio);
			if(theApp.m_screen==3)
				h_share_folder_list->SetFixedHeight(430);
			else if(theApp.m_screen==1)
				h_share_folder_list->SetFixedHeight(200);*/
			SetShareTwoListSize();

		}
	}
}
void CReaderFrame::ShowSelectNoteInfo(CPDFNoteInfo* info,int type)
{
	if(info==NULL)
		return;
	HideOrShowPdfToolFrame(false);
	isShowFreePen=false;
	isShowLineNoteTool=false;
	isShowTextNote=false;
	isShowAttachTool=false;
	TNotifyUI msg;
	////���////////
	theApp.m_EventLog.init();
	theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_NOTE);
	int nPage =  info->pageIndex;
	CString strPage;
	strPage.Format(L"%d",nPage);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_WAY,L"1");
	CString strNoteLocalID;
	strNoteLocalID.Format(L"%d",info->id);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
	if(info->pdfNoteType==NoteFreedom||info->pdfNoteType==NoteLine)
	{
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
	}else
	{
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,info->coord);
	}
	int nType=0;

	nType =GetLogNoteType(info->pdfNoteType);
	CString strType;
	strType.Format(L"%d",nType);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,info->noteText);
	CString strLabeData=L"";
	for(int nNum=0;nNum<info->lableInfos.size();nNum++)
	{
		CLabelInfo label =info->lableInfos.at(nNum);
		strLabeData +=label.lableName;
		if(nNum!=info->lableInfos.size()-1)
		{
			strLabeData +=L"��";
		}
	}
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,strLabeData);
	CString strData=info->content;

	strData.Replace(_T("\\"),_T("\\\\"));
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,strData); 
	theApp.m_EventLog.MakeJsonFormat();
	////////////////
	if(info->pdfNoteType==NoteLine)
	{
		OpenLineNote(info,type);
	}
	else if(info->pdfNoteType==NoteTextBox)
	{
		
		OpenTextNoteFrame(info,type);
	}
	else if(info->pdfNoteType==NoteImage || info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteVideo || info->pdfNoteType==NoteFile || info->pdfNoteType==NoteDoc|| info->pdfNoteType==NoteExcel|| info->pdfNoteType==NotePpt|| info->pdfNoteType==NotePdf)
	{
		
		OpenAttachFileNoteFrame(info,type);
	}
	HideOrShowPdfToolFrame(true);
}
void CReaderFrame::ShowStudentList()
{
	CHorizontalLayoutUI* submit_ok_h= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_ok")));
	CHorizontalLayoutUI* submit_no_h= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_no")));
	CVerticalLayoutUI* submit_ok=static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("v_share_student_submit_ok")));
	CVerticalLayoutUI* submit_no=static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("v_share_student_submit_no")));
	submit_no->RemoveAll();
	submit_ok->RemoveAll();
	std::vector<CShareFolder*> m_ok_list;
	std::vector<CShareFolder*> m_no_list;
	for (int i=0;i<m_pShareNote->m_current_Secondfolder_list.size();i++)
	{
		CShareFolder* info = m_pShareNote->m_current_Secondfolder_list.at(i);
		if(info->m_note_list.size()==0)
			m_no_list.push_back(info);
		else
			m_ok_list.push_back(info);
	}
	int ok_row=m_ok_list.size()/5;
	int ok_col = m_ok_list.size()%5;
	if(ok_col>0)
		ok_row+=1;
	ok_row++;
	if(ok_row>10)
		ok_row=10;
	int ok_height=ok_row*40/theApp.m_screen_ratio;
	submit_ok_h->SetFixedHeight(ok_height);


	CLabelUI* ok_label=new CLabelUI;
	CString okStr;
	okStr.Format(_T("�Ѿ��ύѧ�� %d��(���ѧ�������ɲ鿴���ύ�ʼ�)"),m_ok_list.size());
	ok_label->SetText(okStr);
	ok_label->SetAttribute(_T("font"),_T("0"));
	ok_label->SetAttribute(_T("textcolor"),_T("#FF47C1E9"));
	submit_ok->Add(ok_label);


	int no_row=m_no_list.size()/5;
	int no_col = m_no_list.size()%5;
	if(no_col>0)
		no_row+=1;
	no_row++;
	if(no_row>10)
		no_row=10;
	submit_no_h->SetFixedHeight(no_row*40/theApp.m_screen_ratio);
	CLabelUI* no_label=new CLabelUI;
	CString noStr;
	noStr.Format(_T("δ�ύѧ�� %d��"),m_no_list.size());
	no_label->SetText(noStr);
	no_label->SetAttribute(_T("font"),_T("0"));
	no_label->SetAttribute(_T("textcolor"),_T("#FFFF0000"));
	submit_no->Add(no_label);


	int row=m_ok_list.size()/STUDENT_ROW_NUM;
	int temp_index=0;
	for (int i=0;i<=row;i++)
	{
		CHorizontalLayoutUI* one_line=new CHorizontalLayoutUI;
		one_line->SetFixedHeight(40/theApp.m_screen_ratio);
		//one_line->SetAttribute(_T("height"),_T("40"));
		for(int j=i*STUDENT_ROW_NUM;j<i*STUDENT_ROW_NUM+STUDENT_ROW_NUM;j++)
		{
			if(j>=m_ok_list.size())
			{
				if(one_line->GetCount()>0)
					submit_ok->Add(one_line);
				break;
			}
			CShareFolder* folderInfo=m_ok_list.at(j);
			CButtonUI* one_student=new CButtonUI;
			if(theApp.m_screen_ratio>=0.9)
			{
				one_student->SetFixedHeight(30);
				one_student->SetFixedWidth(75);
			}
			else
			{
				one_student->SetFixedHeight(30/theApp.m_screen_ratio);
				one_student->SetFixedWidth(75/theApp.m_screen_ratio);
			}
			
			//one_student->SetAttribute(_T("width"),_T("70"));
			//one_student->SetAttribute(_T("height"),_T("30"));
			one_student->SetAttribute(_T("font"),_T("0"));
			one_student->SetAttribute(_T("textcolor"),_T("#FF47ACFB"));
			one_student->SetAttribute(_T("padding"),_T("10,0,0,0"));
			one_student->SetAttribute(_T("text"),folderInfo->m_name);
			one_student->SetName(_T("ok_submit_student_name"));
			one_student->SetAttribute(_T("endellipsis"),_T("true"));
			one_student->SetTag(temp_index);
			temp_index++;
			one_line->Add(one_student);
		}
		if(one_line->GetCount()==STUDENT_ROW_NUM)
			submit_ok->Add(one_line);
	}
	row=m_no_list.size()/STUDENT_ROW_NUM;
	for (int i=0;i<=row;i++)
	{
		CHorizontalLayoutUI* one_line=new CHorizontalLayoutUI;
		one_line->SetFixedHeight(40/theApp.m_screen_ratio);
		for(int j=i*STUDENT_ROW_NUM;j<i*STUDENT_ROW_NUM+STUDENT_ROW_NUM;j++)
		{
			if(j>=m_no_list.size())
			{
				if(one_line->GetCount()>0)
					submit_no->Add(one_line);
				break;
			}
			CShareFolder* folderInfo=m_no_list.at(j);
			CButtonUI* one_student=new CButtonUI;
			if(theApp.m_screen_ratio>=0.9)
			{
				one_student->SetFixedHeight(30);
				one_student->SetFixedWidth(75);
			}
			else
			{
				one_student->SetFixedHeight(30/theApp.m_screen_ratio);
				one_student->SetFixedWidth(75/theApp.m_screen_ratio);
			}
			one_student->SetAttribute(_T("font"),_T("0"));
			one_student->SetAttribute(_T("textcolor"),_T("#FF8B97A6"));
			one_student->SetAttribute(_T("padding"),_T("10,0,0,0"));
			one_student->SetAttribute(_T("endellipsis"),_T("true"));
			one_student->SetAttribute(_T("text"),folderInfo->m_name);
			one_line->Add(one_student);
		}
		if(one_line->GetCount()==STUDENT_ROW_NUM)
			submit_no->Add(one_line);
	}

}
bool CReaderFrame::ShareNoteCancel(std::vector<CPDFNoteInfo*> note_list)
{
	//���ﴦ����ţB�ij�������
	return m_pShareNote->RecallShareNotes(note_list);
	
}
bool CReaderFrame::ShareNoteImport2Local(std::vector<CPDFNoteInfo*> note_list)
{
	//���ﴦ����ţB�Ĺ����ʼǵ���Ĵ���
	BOOL bRet =FALSE;
	if(!theApp.AnalysisConnect())
	{
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		return bRet;
	}
	int  nRet =ImportNoteToLocal(note_list,NOTE_SHARE);
	if(nRet==1)
	{
		CustomMessageBox(STRING_READERFRAME_IMPORT_SUCCESS,MSG_TYPE_NOTICE,TRUE);
		bRet =TRUE;
	}
	else if(nRet==99)
	{
		bRet =FALSE;
	}else
	{
		CustomMessageBox(STRING_READERFRAME_IMPORT_FAIL,MSG_TYPE_NOTICE,FALSE);
		bRet =TRUE;
	}
							
	return bRet;
}
bool CReaderFrame::ShareNoteMove2Folder(std::vector<CPDFNoteInfo*> note_list,long long id)
{

	//���ﴦ����ţB�Ĺ����ʼ��ƶ����ļ��еĴ���
	BOOL bRet =m_pShareNote->MoveShareNoteMuti(note_list,id);
	return bRet;
	

	
}
void CReaderFrame::ShowShareNoteTwoTool(int type)
{
	CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
	CButtonUI* buttom_submit=static_cast<CButtonUI*>(m_pm.FindControl(_T("share_multi_select_operator_two")));
	COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes")));
	COptionUI* quxiao=static_cast<COptionUI*>(m_pm.FindControl(_T("share_notes_back")));

	CLabelUI* text_two=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num_two")));
	text_two->SetText(_T("��ѡ��0���ʼ�"));

	if(import && quxiao )
	{
		
		if(type==1)//����
		{
			quxiao->Selected(false);
			m_bShareTwoCancel=false;
			if(m_bShareTwoImport)
			{
				m_bShareTwoImport=false;
				m_bShareTwoCancel=false;
				ShowShareNoteTwo(false);
				h_operator->SetVisible(false);
				
			}
			else
			{
				h_operator->SetVisible(true);
				buttom_submit->SetText(_T("���뱾��"));
				m_bShareTwoImport=true;
				m_bShareTwoCancel=false;
				ShowShareNoteTwo(true);
			}
		}
		else if(type==2)
		{
			import->Selected(false);
			m_bShareTwoImport=false;
			if(m_bShareTwoCancel)
			{
				m_bShareTwoImport=false;
				m_bShareTwoCancel=false;
				ShowShareNoteTwo(false);
				h_operator->SetVisible(false);
			}
			else
			{
				h_operator->SetVisible(true);
				buttom_submit->SetText(_T("����"));
				m_bShareTwoCancel=true;
				m_bShareTwoImport=false;
				ShowShareNoteTwo(true);
			}
		}
		else
		{
			import->Selected(false);
			quxiao->Selected(false);
			m_bShareTwoImport=false;
			m_bShareTwoCancel=false;
			ShowShareNoteTwo(false);
			h_operator->SetVisible(false);
		}
	}
}
void CReaderFrame::ShowShareNoteTwo(bool bOperator)
{
	CLabelUI* folderName=static_cast<CLabelUI*>(m_pm.FindControl(_T("Share_folder_name")));
	folderName->SetText(m_pShareNote->m_Struct_FolderInfo.strCapttion);
	m_pSidebarTabLayout->SetVisible(false);
	m_pShareStudentFolderLayout->SetVisible(true);
	COptionUI* quxiao=static_cast<COptionUI*>(m_pm.FindControl(_T("share_notes_back")));
	COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes")));
	int type_share = ComboShareSelect->GetCurSel();
	if(type_share==0)//�ҹ�����
	{
		if(theApp.m_UserInfo.iUserType==1)//��ʦ
		{
			import->SetVisible(true);
			quxiao->SetVisible(true);
		}
		else if(theApp.m_UserInfo.iUserType==2)//ѧ��
		{
			import->SetVisible(true);
			quxiao->SetVisible(false);
		}
		
	}
	else if(type_share==1)//�������ҵ�
	{
		if(theApp.m_UserInfo.iUserType==1)//��ʦ
		{
			import->SetVisible(true);
			quxiao->SetVisible(false);
		}
		else if(theApp.m_UserInfo.iUserType==2)//ѧ��
		{
			import->SetVisible(true);
			quxiao->SetVisible(false);
		}
		import->SetVisible(false);
	}


	//quxiao->SetVisible(false);


	CHorizontalLayoutUI* h_submit=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_submit")));

	
	if(GetUserType()==2)
	{
		import->SetVisible(true);
		if(m_pShareNote->m_current_Second_note_list.size()==0)
		{
			import->SetEnabled(false);
			quxiao->SetEnabled(false);
		}
		else
		{
			import->SetEnabled(true);
			quxiao->SetEnabled(true);
		}
	}
	else
	{
		if(m_pShareNote->m_current_Secondfolder_list.size()==0 && m_pShareNote->m_current_Second_note_list.size()==0)
		{
			import->SetEnabled(false);
			quxiao->SetEnabled(false);
		}
		else
		{
			import->SetEnabled(true);
			quxiao->SetEnabled(true);
		}
	}

	
	m_pFolderList->RemoveAll();
	if(m_pShareNote->m_Struct_FolderInfo.strEndTime.GetLength()==0 || GetUserType()==2)//��ͨ�ļ���
	{
		h_submit->SetVisible(false);
		for (int i=0;i<m_pShareNote->m_current_Second_note_list.size();i++)
		{
			CPDFNoteInfo* info = m_pShareNote->m_current_Second_note_list.at(i);
			m_pFolderList->AddItem(*info,m_SidebarWidth,bOperator);

		}
	}
	else
	{
		CLabelUI* label_folder_desc=static_cast<CLabelUI*>(m_pm.FindControl(_T("share_student_submit_desc")));
		CString folder_desc;
		folder_desc.Format(_T("���ύ:%d/%d��"),m_pShareNote->m_Struct_FolderInfo.nShareStdCount,m_pShareNote->m_Struct_FolderInfo.nReqStdCount);
		label_folder_desc->SetText(folder_desc);

		CLabelUI* label_folder_enddingtime=static_cast<CLabelUI*>(m_pm.FindControl(_T("share_endding_time")));
		label_folder_enddingtime->SetText(_T("����ʱ��:")+m_pShareNote->m_Struct_FolderInfo.strEndTime);

		h_submit->SetVisible(true);
		bool isShowImport=false;
		for (int i=0;i<m_pShareNote->m_current_Secondfolder_list.size();i++)
		{
			CShareFolder* info = m_pShareNote->m_current_Secondfolder_list.at(i);
//			if(bOperator)
//				info->m_isSpread=bOperator;
			if(info->m_note_list.size()>0)
			{
				m_pFolderList->AddFloder(info,m_SidebarWidth,i,false,bOperator);
				if(info->m_isSpread)
				{
					isShowImport=true;
					for (int j=0;j<info->m_note_list.size();j++)
					{
						CPDFNoteInfo* note = info->m_note_list.at(j);
						m_pFolderList->AddItem(*note,m_SidebarWidth,bOperator);
					}
				}
			}
		}
		/*COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes")));
		if(!isShowImport)
		{
			
			import->SetEnabled(false);
		}
		else
			import->SetEnabled(true);*/


	}
	/*CHorizontalLayoutUI* submit_ok= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_ok")));
	CHorizontalLayoutUI* submit_no= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_no")));
	CHorizontalLayoutUI* h_share_folder_list= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_share_folder_list")));
	int allHeight = submit_ok->GetHeight()+submit_no->GetHeight();
	if(submit_ok->IsVisible())
	{
		h_share_folder_list->SetFixedHeight(700/theApp.m_screen_ratio-allHeight);
		if(theApp.m_screen==3)
			h_share_folder_list->SetFixedHeight(1200-allHeight);
	}
	else
	{
		h_share_folder_list->SetFixedHeight(700/theApp.m_screen_ratio);
		if(theApp.m_screen==3)
			h_share_folder_list->SetFixedHeight(1200-allHeight);
	}*/
	if(h_submit->IsVisible())
		SetShareTwoListSize();
	
	
}
void CReaderFrame::SetLineSize(int type)
{
	CButtonUI* Line10=static_cast<CButtonUI*>(m_pm.FindControl(_T("option_lineW_10")));
	CButtonUI* Line4=static_cast<CButtonUI*>(m_pm.FindControl(_T("option_lineW_4")));
	CButtonUI* Line2=static_cast<CButtonUI*>(m_pm.FindControl(_T("option_lineW_2")));
	CButtonUI* Line1=static_cast<CButtonUI*>(m_pm.FindControl(_T("option_lineW_1")));
	if(type==1 && !m_b10)
	{
		Line4->SetAttribute(L"bordercolor",L"");
		Line4->SetAttribute(L"bordersize",L"0");

		Line2->SetAttribute(L"bordercolor",L"");
		Line2->SetAttribute(L"bordersize",L"0");

		Line1->SetAttribute(L"bordercolor",L"");
		Line1->SetAttribute(L"bordersize",L"0");

		Line10->SetAttribute(L"bordercolor",L"#FFCDCDCD");
		Line10->SetAttribute(L"bordersize",L"1");
		m_b1=m_b4=m_b2=false;
		m_b10=true;
	}
	else if(type==2 && !m_b4)
	{
		Line10->SetAttribute(L"bordercolor",L"");
		Line10->SetAttribute(L"bordersize",L"0");

		Line2->SetAttribute(L"bordercolor",L"");
		Line2->SetAttribute(L"bordersize",L"0");

		Line1->SetAttribute(L"bordercolor",L"");
		Line1->SetAttribute(L"bordersize",L"0");

		Line4->SetAttribute(L"bordercolor",L"#FFCDCDCD");
		Line4->SetAttribute(L"bordersize",L"1");
		m_b1=m_b10=m_b2=false;
		m_b4=true;
	}
	else if(type==3 && !m_b2)
	{
		Line4->SetAttribute(L"bordercolor",L"");
		Line4->SetAttribute(L"bordersize",L"0");

		Line10->SetAttribute(L"bordercolor",L"");
		Line10->SetAttribute(L"bordersize",L"0");

		Line1->SetAttribute(L"bordercolor",L"");
		Line1->SetAttribute(L"bordersize",L"0");

		Line2->SetAttribute(L"bordercolor",L"#FFCDCDCD");
		Line2->SetAttribute(L"bordersize",L"1");
		m_b1=m_b4=m_b10=false;
		m_b2=true;
	}
	else if(type==4 && !m_b1)
	{
		Line4->SetAttribute(L"bordercolor",L"");
		Line4->SetAttribute(L"bordersize",L"0");

		Line10->SetAttribute(L"bordercolor",L"");
		Line10->SetAttribute(L"bordersize",L"0");

		Line2->SetAttribute(L"bordercolor",L"");
		Line2->SetAttribute(L"bordersize",L"0");

		Line1->SetAttribute(L"bordercolor",L"#FFCDCDCD");
		Line1->SetAttribute(L"bordersize",L"1");
		m_b10=m_b4=m_b2=false;
		m_b1=true;
	}
}

void CReaderFrame::ShareNoteShowTool(int type)
{
	CHorizontalLayoutUI* temp=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
	COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes_one")));
	COptionUI* move=static_cast<COptionUI*>(m_pm.FindControl(_T("share_note_move")));
	COptionUI* quxiao=static_cast<COptionUI*>(m_pm.FindControl(_T("share_back_note")));

	COptionUI* note_choice_all=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
	CLabelUI* lable_all_select=static_cast<CLabelUI*>(m_pm.FindControl(_T("lable_all_select")));

	note_choice_all->Selected(false);
	if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
	{
		note_choice_all->SetVisible(false);
		lable_all_select->SetVisible(false);
	}
	else
	{
		note_choice_all->SetVisible(true);
		lable_all_select->SetVisible(true);
	}

	if(temp && import && move && quxiao)
	{
		if(type==1)//����
		{
			m_bMove=false;
			m_bCancel=false;
			quxiao->Selected(false);
			move->Selected(false);
			if(m_bImport)
			{
				temp->SetVisible(false);
				m_bImport=false;
				ShowShareNote(m_SidebarWidth);
				m_pMyPDFBook->RedrawLines();
			}
			else
			{
				temp->SetVisible(true);
				CButtonUI* multi_select_operator_share=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
				multi_select_operator_share->SetText(_T("���뱾��"));
				m_bImport=true;
				ShowShareNote(m_SidebarWidth,TRUE);
				m_pMyPDFBook->RedrawLines();
			}
		}
		else if(type==2)
		{
			m_bMove=false;
			m_bImport=false;
			import->Selected(false);
			move->Selected(false);
			if(m_bCancel)
			{
				temp->SetVisible(false);
				m_bCancel=false;
				ShowShareNote(m_SidebarWidth);
				m_pMyPDFBook->RedrawLines();
			}
			else
			{
				temp->SetVisible(true);
				CButtonUI* multi_select_operator_share=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
				multi_select_operator_share->SetText(_T("����"));
				m_bCancel=true;
				ShowShareNote(m_SidebarWidth,TRUE);
				m_pMyPDFBook->RedrawLines();
			}
		}
		else if(type==3)
		{
			m_bCancel=false;
			m_bImport=false;
			import->Selected(false);
			quxiao->Selected(false);
			if(m_bMove)
			{
				temp->SetVisible(false);
				m_bMove=false;
				ShowShareNote(m_SidebarWidth);
				m_pMyPDFBook->RedrawLines();
			}
			else
			{
				temp->SetVisible(true);
				CButtonUI* multi_select_operator_share=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
				multi_select_operator_share->SetText(_T("�ƶ�"));
				m_bMove=true;
				ShowShareNote(m_SidebarWidth,TRUE);
				m_pMyPDFBook->RedrawLines();
			}
		}
		else
		{
			m_bCancel=false;
			m_bImport=false;
			import->Selected(false);
			quxiao->Selected(false);
			temp->SetVisible(false);
			ShowShareNote(m_SidebarWidth);
		}
	}
	if(temp->IsVisible())
	{
		m_pMoreNoteBtn->SetVisible(false);
		CLabelUI * select_num=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num")));
		select_num->SetText(_T("��ѡ��0���ʼ�"));
	}
	else
	{
		if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
			m_pMoreNoteBtn->SetVisible(true);
	}
}
void CReaderFrame::ShowShareMoveFrame(std::vector<CPDFNoteInfo*> select_note_list)
{
	if(!theApp.AnalysisConnect())
	{
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		ClearShareNoteOperator();
		ShowShareNote(m_SidebarWidth);
		return ;
	}
	if(!CheckHasTarget())
	{
		return ;
	}
	CPDFNoteInfo* note =select_note_list.at(0);
	CString NoteClassId=note->strClassId;
	m_pShareNote->GetMoveNoteFolderList(NoteClassId);
	CShareNoteMoveFrame* pShareNoteMoveFrame = new CShareNoteMoveFrame(m_pShareNote);
	pShareNoteMoveFrame->Create(m_hWnd, _T("ShareTeacherNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
	pShareNoteMoveFrame->CenterWindow();
	if (IDOK == pShareNoteMoveFrame->ShowModal())
	{
		if(ShareNoteMove2Folder(select_note_list,pShareNoteMoveFrame->m_folder_id))
		{
			GetShareNote();
			ShowShareNote(m_SidebarWidth);
			CustomMessageBox(L"�ʼ��ƶ��ɹ�",MSG_TYPE_NOTICE,TRUE);
		}else
		{
			CustomMessageBox(L"�ʼ��ƶ�ʧ��:���������ʼ���ѧ���༶����",MSG_TYPE_NOTICE,FALSE);
		}
			
		ShowShareNote(m_SidebarWidth);
		ClearShareNoteOperator();

	}else
	{
		ClearShareNoteOperator();
		ShowShareNote(m_SidebarWidth);

	}
	if(pShareNoteMoveFrame) 
	{
		delete pShareNoteMoveFrame;
		pShareNoteMoveFrame=NULL;
	}
}
void CReaderFrame::ShowBrowser(int type,CString strUrl)
{
	
}
void CReaderFrame::CloseBrowser()
{
	//m_pMyPDFBook->SetVisible(true);
	
}
void CReaderFrame::ShowMultiOperator(int type)//���Ʊ��ض�ѡ������ť�Ļ���
{
	CHorizontalLayoutUI* temp=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
	COptionUI* note_choice_all=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
	CLabelUI* lable_all_select=static_cast<CLabelUI*>(m_pm.FindControl(_T("lable_all_select")));

	note_choice_all->Selected(false);
	if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
	{
		note_choice_all->SetVisible(false);
		lable_all_select->SetVisible(false);
	}
	else
	{
		note_choice_all->SetVisible(true);
		lable_all_select->SetVisible(true);
	}
	if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW)//���رʼ�
	{
		if(type==1)
		{

			if(isUpload)
			{
				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth);
				if(temp)
					temp->SetVisible(false);
			}
			else
			{
				m_pOptionLocalNoteShare->Selected(false);
				m_pOptionLocalNoteDelete->Selected(false);
				isUpload=true;
				isDelete=false;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth,TRUE);
				if(temp)
				{
					temp->SetVisible(true);
					CButtonUI* button=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
					if(button)
						button->SetText(_T("�ϴ��Ʊʼ�"));
				}
			}
		}
		else if(type==2)
		{
			if(isShare)
			{
				
				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth);
				if(temp)
					temp->SetVisible(false);
			}
			else
			{
				m_pOptionLocalNoteUpload->Selected(false);
				m_pOptionLocalNoteDelete->Selected(false);
				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=true;
				UpdateBookNotes(m_SidebarWidth,TRUE);
				if(temp)
				{
					temp->SetVisible(true);
					CButtonUI* button=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
					if(button)
					{
						if(theApp.m_UserInfo.iUserType==2)
							button->SetText(_T("��������ʦ"));
						else
							button->SetText(_T("�����ʼ�"));
					}
				}
			}
		}
		else if(type==3)
		{
			if(isDelete)
			{
				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth);
				if(temp)
					temp->SetVisible(false);
			}
			else
			{
				m_pOptionLocalNoteUpload->Selected(false);
				m_pOptionLocalNoteShare->Selected(false);
				isUpload=false;
				isDelete=true;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth,TRUE);
				if(temp)
				{
					temp->SetVisible(true);
					CButtonUI* button=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
					if(button)
						button->SetText(_T("ɾ��"));
				}
			}
		}
		else
		{
			if(isDelete)
				m_pOptionLocalNoteDelete->Selected(false);
			if(isUpload)
				m_pOptionLocalNoteUpload->Selected(false);
			if(isShare)
				m_pOptionLocalNoteShare->Selected(false);

			isUpload=false;
			isDelete=false;
			isDownload=false;
			isShare=false;
			UpdateBookNotes(m_SidebarWidth,FALSE);
			if(temp)
				temp->SetVisible(false);
		}
		
	}
	else if(m_pNoteList->GetCurrentType()==NOTE_SHOW_TYPE::CLOUD_NOTE_SHOW)//
	{
		if(type==4)//���뱾��
		{
			if(isDownload)
			{
				//m_pOptionDownNote->Selected(false);
				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth);
				if(temp)
					temp->SetVisible(false);
			}
			else
			{
				//m_pOptionDownNote->Selected(true);
				m_pOptionLocalNoteShare->Selected(false);
				m_pOptionLocalNoteDelete->Selected(false);
				isUpload=false;
				isDelete=false;
				isDownload=true;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth,TRUE);
				if(temp)
				{
					temp->SetVisible(true);
					CButtonUI* button=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
					if(button)
						button->SetText(_T("���뱾��"));
				}
			}
		}
		else if(type==2)//����
		{
			if(isShare)
			{
				//m_pOptionLocalNoteShare->Selected(false);

				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth);
				if(temp)
					temp->SetVisible(false);
			}
			else
			{
				m_pOptionDownNote->Selected(false);
				//m_pOptionLocalNoteShare->Selected(true);
				m_pOptionLocalNoteDelete->Selected(false);
				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=true;
				UpdateBookNotes(m_SidebarWidth,TRUE);
				if(temp)
				{
					temp->SetVisible(true);
					CButtonUI* button=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
					if(button)
					{
						if(theApp.m_UserInfo.iUserType==2)
							button->SetText(_T("��������ʦ"));
						else
							button->SetText(_T("�����ʼ�"));
					}
				}
			}
		}
		else if(type==3)
		{
			if(isDelete)
			{
				//m_pOptionLocalNoteDelete->Selected(false);
				isUpload=false;
				isDelete=false;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth);
				if(temp)
					temp->SetVisible(false);
			}
			else
			{
				m_pOptionDownNote->Selected(false);
				m_pOptionLocalNoteShare->Selected(false);
				//m_pOptionLocalNoteDelete->Selected(true);
				isUpload=false;
				isDelete=true;
				isDownload=false;
				isShare=false;
				UpdateBookNotes(m_SidebarWidth,TRUE);
				if(temp)
				{
					temp->SetVisible(true);
					CButtonUI* button=static_cast<CButtonUI*>(m_pm.FindControl(_T("multi_select_operator")));
					if(button)
						button->SetText(_T("ɾ��"));
				}
			}
		}
		else
		{
			
			if(isDownload)
				m_pOptionDownNote->Selected(false);
			if(isDelete)
				m_pOptionLocalNoteDelete->Selected(false);
			if(isShare)
				m_pOptionLocalNoteShare->Selected(false);
			isUpload=false;
			isDelete=false;
			isDownload=false;
			isShare=false;
			if(temp)
				temp->SetVisible(false);
		}
	}
	if(temp->IsVisible())
	{
		CLabelUI * select_num=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num")));
		select_num->SetText(_T("��ѡ��0���ʼ�"));
	}
}
void CReaderFrame::BackUpFreePen(int type)
{

	ClearBkFreeLinePdfNoteList();
	for (int i=0;i<m_pdfNoteInfoList_drawPdf.size();i++)
	{
		CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(i);
		if(info->pdfNoteType==NoteFreedom && info->fid>0)
		{
			CPDFNoteInfo* temp =new CPDFNoteInfo;
			*(temp)=*(info);
			m_pdfNoteInfoListBK.push_back(temp);
		}
	}
	if(m_pdfNoteInfoListBK.size()==0)
		m_bIsFirstBackUp=true;
	else
		m_bIsFirstBackUp=false;
}
void CReaderFrame::RestoreFreePen()
{
	//CNoteDao NoteDao(m_pBookInfo->bookId);
	if(m_pdfNoteInfoListBK.size()==0)
	{
		if (m_bIsFirstBackUp)
		{
			if(m_pdf_show_model==4)
			{
				m_noteDao->DeleteFreePenNoteByPage(m_current_page-1);
				m_noteDao->DeleteFreePenNoteByPage(m_current_page);
			}
			else
				m_noteDao->DeleteFreePenNoteByPage(m_current_page-1);
			
			m_bIsFirstBackUp=false;
		}
		else
		{
			CustomMessageBox(_T("��ǰû�п��Գ��صIJ���"),MSG_TYPE_NOTICE,FALSE);
		}
		
	}
	else
	{
		
		if(m_pdf_show_model==4)
		{
			m_noteDao->DeleteFreePenNoteByPage(m_current_page-1);
			m_noteDao->DeleteFreePenNoteByPage(m_current_page);
		}
		else
			m_noteDao->DeleteFreePenNoteByPage(m_current_page-1);
		for (int i=0;i<m_pdfNoteInfoListBK.size();i++)
		{
			CPDFNoteInfo* info =m_pdfNoteInfoListBK.at(i);
			m_noteDao->AddNoteInfo(*info);
		}
	}
	ClearBkFreeLinePdfNoteList();
	SetNeedReloadDB();
	GetNoteByCataIndex(m_current_mulu_index);
	m_pMyPDFBook->RedrawLines();
}
void CReaderFrame::DeleteFreePen(CPDFNoteInfo* info)
{
	if(info)
	{
		//CNoteDao NoteDao(m_pBookInfo->bookId);
		long id=m_noteDao->DeleteNoteInfos(info);
		SetNeedReloadDB();
		GetNoteByCataIndex(m_current_mulu_index);
		m_pMyPDFBook->RedrawLines();
	}
}

int CReaderFrame::ImportNoteToLocal(vector<CPDFNoteInfo *>CloudNotes,int nType)
{
	//�����ʡ����ʱʼǣ��ơ�������������д�뱾�����ݿ�
	CFunction fun;
	if(!theApp.AnalysisConnect())
	{
		return 99;
	}

	
	int nRet=0;
	int nMaxId=0;
	int nIndex=90;
	BOOL bMissLabel=FALSE;
	//CNoteDao noteDao(m_pBookInfo->bookId);
	std::vector<CPDFNoteInfo*> NoteCopy;
	for(int n=0;n<CloudNotes.size();n++)
	{
		CPDFNoteInfo *Notes =new CPDFNoteInfo;
		*Notes =*CloudNotes.at(n);
		//strcpy(Notes ,CloudNotes.at(0));
		//memcpy(Notes,CloudNotes.at(n),sizeof(CPDFNoteInfo));
		NoteCopy.push_back(Notes);
	}
	
	//Notes = CloudNotes.at(0);
	//Notes.assign(*CloudNotes.begin(),*CloudNotes.end());
	m_th.AddDownLoadFileToQueue(NoteCopy);
	if(m_th.m_DownloadNoteFile_List.size()>0)
	{
		//���������̣߳��������ȿ�
		if(StartDownNote()==0)
		{
			m_th.MakeNoteData();
		}
		else
			return -1;
	}
	if(m_th.m_isNeedReLogin)
	{
		CloseApplication(1);
		while (1)
		{

		}
	}
    //Notetemp.assign(*CloudNotes.begin(),*CloudNotes.end());
 	for(int nNum=0;nNum<NoteCopy.size();nNum++)
 	{
		//��ȡ����
		CPDFNoteInfo Note;
		Note=*NoteCopy.at(nNum);
		//�����ݽ��п�������Ӱ�촫����ԭʼ����
 		if(Note.pdfNoteType==NoteFreedom)
 		{
// 			CStringA strTemp;
// 			if(nType ==NOTE_SHARE)
// 			{
// 				strTemp =GetFreepenCoord(nType,Note.ShareID);
// 			}else
// 			{
// 				strTemp =GetFreepenCoord(nType,Note.ServerID);
// 			}

 			int res=m_pShareNote->GetFreePenCoord(&Note,fun.UnicodeToAscii(Note.coord));
// 			strTemp.ReleaseBuffer();
 			if(res<0)
 				continue;
 		}
        if(-1==CoordChange(&Note))
		{
			continue;
		}


		if(nType == NOTE_SHARE)
		{
			Note.noteOrigin=ORIGIN_USER;
		}
		if(nType != NOTE_SHARE)
		{
			if(m_noteDao->NoteExist(Note.ServerID))
			{
				//ɾ���ʼ�
				//noteDao.DeleteNoteInfo();
				int nId =m_noteDao->GetIdByServerId(Note.ServerID);
				if(Note.pdfNoteType!=NoteFreedom)
				{
					m_noteDao->DeleteNoteInfo(nId);
				}else
				{
					//��ɾ��FreePenNote
					m_noteDao->DeleteFreePenByFid(nId);
					//����Noteɾ��
					m_noteDao->CheckAndDeleteNoneRecord(nId);
				}
				//Add By Ray 2018-09-30
				//ɾ����ǩ
				m_noteDao->CleanNoteLabel(nId);
			
			}
		}else
		{

				if(Note.pdfNoteType==NoteFreedom)
				{
					//��ɾ��FreePenNote
					m_noteDao->DeleteFreePenNoteByPage(Note.pageIndex-1);
				}

		}

		CTime tm=CTime::GetCurrentTime();
		CString strInfo=tm.Format("%Y-%m-%d %H:%M:%S");
		Note.updateTime =strInfo;
		//�������رʼ�
		if(Note.pdfNoteType==NoteFreedom)
		{
			nRet =m_noteDao->ImportFreePenNote(&Note);
		}else
		{
			
			//���Ǹ����ʼǣ����ص�����������·��д��Content
			if(Note.pdfNoteType==NoteFile || Note.pdfNoteType==NoteImage || Note.pdfNoteType==NoteAudio || Note.pdfNoteType==NoteVideo||Note.pdfNoteType==NoteLink|| Note.pdfNoteType==NoteDoc|| Note.pdfNoteType==NoteExcel|| Note.pdfNoteType==NotePpt|| Note.pdfNoteType==NotePdf)//�����ʼ�
			{
// 				//���ظ�����ָ��λ��
// 				//2018-10-22 Ray �޸�Ϊ���߳�����,���֪ͨ������
// 				m_DownloadNoteFileTemp.clear();
// 				Note.id=nIndex;//index
// 				m_DownloadNoteFileTemp.push_back(Note);
// 				nIndex++;
// 				AddNoteFileDownloadQueue(Note.content,Note.id);//���ƱʼǼ������ʼ�IDԭ�򣬽���������ID
// 				m_th.StartDownload();
// // 			    CString strFilePath =theApp.DownLoadFile(Note.content);
// // 	             �������滻���ص�����			
// // 				if(strFilePath.GetLength()!=0)
// // 				{
// // 					Note.content =strFilePath;
// // 				}
// // 				//Copy������Ŀ¼�£�����Content
				SetAttachFile(&Note);
				int nMaxId=m_noteDao->AddNoteInfo(Note);
				//Add By Ray 2019-05-21
				Note.id =nMaxId;
			}else//add By Ray 2018-10-22 δ���سɹ�������
			{
			 
			 nMaxId=m_noteDao->AddNoteInfo(Note);
			 Note.id =nMaxId;
			}
		}
		nRet =TRUE;
		//�������ʼǣ�����ʼǵı�ǩ��������ı�ǩ+����>20 �򲻵���
		int nExist=0;
		int nAdd=0;
		if(nType == NOTE_SHARE)
		{
			
			for(int nNum=0;nNum<Note.lableInfos.size();nNum++)
			{
				CLabelInfo* Label;
				Label =Note.lableInfos.at(nNum);
				BOOL bExist=m_noteDao->GetLabelExist(Label->lableName);
				if(bExist>0)
				{
					nExist++;//�����������еı�ǩ��
				}
			}
		}
		//�ƱʼDZ�ǩ����
		for(int nNum=0;nNum<Note.lableInfos.size();nNum++)
		{
			CLabelInfo* Label;
			Label =Note.lableInfos.at(nNum);

			//
			int nLabelId=-1;
			if(nType == NOTE_SHARE)
			{
				if(m_pLabelOper->m_LabelList.size()+(Note.lableInfos.size()-nExist)<=20)
				{
					int nUse=m_noteDao->GetLabelExist(Label->lableName);
					if(nUse>0)
					{
						//��ǩ�����д�LABEL,ȡ��ID�����ӳ���

						nRet =m_noteDao->GetLabelIDbyName(nLabelId,Label->lableName);
						nRet =m_noteDao->AddNoteLabel(nLabelId,Note.id);

					}else
					{
						//�޴�LABEL�����ݿ��ñ�ǩ��������
						if(m_pLabelOper->m_LabelList.size()+(Note.lableInfos.size()-nExist)<=20)
						{
							//AddLabel
							if(m_pLabelOper->AddLabel(Label->lableName))
							{
								//������ӳ��
								if(m_noteDao->GetLabelIDbyName(nLabelId,Label->lableName))
								{
									nRet =m_noteDao->AddNoteLabel(nLabelId,Note.id);
								}
								nExist++;
							}

						}else
						{
							bMissLabel=TRUE;
							break;;
						}
					}
				}else
				{
					bMissLabel=TRUE;
					
					break;;
				}

			}else
			{
				m_noteDao->GetLabelIDbyName(Label->id,Label->lableName);
				m_noteDao->AddNoteLabel(Label->id,Note.id);
			}
			
		}
		
	if(nType == NOTE_CLOUD)
	{
		////���////////
		theApp.m_EventLog.init();
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_IMPORT_CLOUDNOTE);
		int nPage =  m_pMyPDFBook->GetPageNum();
		CString strPage;
		strPage.Format(L"%d",nPage);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_WAY,L"1");
		CString strNoteLocalID;
		strNoteLocalID.Format(L"%d",Note.id);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
		if(Note.pdfNoteType==NoteFreedom||Note.pdfNoteType==NoteLine)
		{
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
		}else
		{
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,Note.coord);
		}
		int nType=0;

		nType =GetLogNoteType(Note.pdfNoteType);
		CString strType=L"",strServerID=L"";
		strType.Format(L"%d",nType);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,Note.noteText);
		CString strLabeData=L"";
		for(int nNum=0;nNum<Note.lableInfos.size();nNum++)
		{
			CLabelInfo label =Note.lableInfos.at(nNum);
			strLabeData +=label.lableName;
			if(nNum!=Note.lableInfos.size()-1)
			{
				strLabeData +=L"��";
			}
		}
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,strLabeData);
		CString strData=Note.content;

		strData.Replace(_T("\\"),_T("\\\\"));
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,strData); 
		strServerID.Format(L"%lld",Note.ServerID);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CLOUD_SERVERID,strServerID);
		theApp.m_EventLog.MakeJsonFormat();
		////////////////
	}else
	{
		////���////////
		CString strServerID=L"";
		theApp.m_EventLog.init();
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_IMPORT_SHARENOTE);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_IMPORT_SHARENOTE_WAY,L"1");
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_USERNAME,Note.userName);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,L"");
		strServerID.Format(L"%lld",Note.ShareID);//ShareID
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_SHAREID,strServerID);
		theApp.m_EventLog.MakeJsonFormat();
		////////////////
		////////////////
	}

		
	}
	if(bMissLabel)
	{
		
		CustomMessageBox(STRING_MSG_IMPORT_TAG_ERR,MSG_TYPE_NOTICE,FALSE);
	}
	for(int n=0;n<NoteCopy.size();n++)
	{
		
		CPDFNoteInfo* temp =NoteCopy.at(n);
		delete temp;
		temp=NULL;
		//strcpy(Notes ,CloudNotes.at(0));
		//memcpy(Notes,CloudNotes.at(n),sizeof(CPDFNoteInfo));
	}


	NoteCopy.clear();
	SetNeedReloadDB();
	m_pMyPDFBook->RedrawLines();

	return nRet;
}
int  CReaderFrame::DeleteLocalNote(vector<CPDFNoteInfo*> list)
{
	
	int iRet=-1;
	//ɾ�����رʼ�
	//CNoteDao noteDao(m_pBookInfo->bookId);

	for(int nNum=0;nNum<list.size();nNum++)
	{
		CPDFNoteInfo* Note =list.at(nNum);
		iRet=m_noteDao->DeleteNoteInfos(Note);
		////���////////
		theApp.m_EventLog.init();
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_REMOVE_NOTE);
		int nPage =  m_pMyPDFBook->GetPageNum();
		CString strPage;
		strPage.Format(L"%d",nPage);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_REMOVE_WAY,L"1");
		CString strNoteLocalID;
		strNoteLocalID.Format(L"%d",Note->id);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
		if(Note->pdfNoteType==NoteFreedom||Note->pdfNoteType==NoteLine)
		{
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
		}else
		{
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,Note->coord);
		}
		int nType=0;

		nType =GetLogNoteType(Note->pdfNoteType);
		CString strType;
		strType.Format(L"%d",nType);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,Note->noteText);
		CString strLabeData=L"";
		for(int nNum=0;nNum<Note->lableInfos.size();nNum++)
		{
			CLabelInfo label =Note->lableInfos.at(nNum);
			strLabeData +=label.lableName;
			if(nNum!=Note->lableInfos.size()-1)
			{
				strLabeData +=L"��";
			}
		}
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,strLabeData);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,Note->content); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_REMOVE_MODE,L"2");
		theApp.m_EventLog.MakeJsonFormat();
		////////////////
	}
	m_curSelNote =-1;
	SetNeedReloadDB();
	
	GetNoteByCataIndex(m_current_mulu_index);
	m_pMyPDFBook->RedrawLines();
	return iRet;
}
int CReaderFrame::UploadLocal2CloudNote(vector<CPDFNoteInfo*> list)
{
	m_freeLineFrame->ShowWindow(false);
	isShowFreePen=false;
	SetPenAndColor(NOTES_NONE, GetPenColor());
	if(m_freeLineFrame->erase_select->IsSelected())
	{
		m_freeLineFrame->erase_select->Selected(false);
		EraseModeUse();
	}
	int iRet=-1;
	//���Ӵ������رʼ��ϴ��Ʊʼǵķ���

	iRet =m_pcloudNote->AddCloudNote(list);
	if(m_th.m_isNeedReLogin)
	{
		CloseApplication(1);
		while(1)
		{

		}
	}
	m_pLabelOper->DownloadAndSaveLabel();
	return iRet;
}

void CReaderFrame::ShowPdfRightMenu(std::vector<double> &note_pt,int page)
{
	if(m_curSelNote>=0)
	{
		if(m_curSelNote<m_pdfNoteInfoList.size())
		{
			DuiLib::CPoint point(0,0);
			GetCursorPos(&point);
			CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
			CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
			if(info->pdfNoteType==NoteLine)//���߱ʼ��Ҽ��˵�
			{
				pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_Line.xml"), point, &m_pm, &m_NoteTypeMenuCheckInfo);
			}
			else if(info->pdfNoteType==NoteTextBox)//�ı����Ҽ��˵�
			{
				if (m_pMyPDFBook->GetViewMode()==4)
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_NoteTextBox.xml"), point, &m_pm, &m_NoteTypeMenuCheckInfo);
				}
				else
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_NoteTextBox_Spage.xml"), point, &m_pm, &m_NoteTypeMenuCheckInfo);
				}
				
			}
			else if(info->pdfNoteType==NoteImage || info->pdfNoteType==NoteVideo || info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteFile|| info->pdfNoteType==NoteDoc|| info->pdfNoteType==NoteExcel|| info->pdfNoteType==NotePpt|| info->pdfNoteType==NotePdf)//�����ʼ�
			{
				if (m_pMyPDFBook->GetViewMode()==4)
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_NoteFile.xml"), point, &m_pm, &m_NoteTypeMenuCheckInfo);
				}
				else
				{
					pMenu->Init(NULL, _T("reader/menu/Menu_ReaderNote_NoteTextBox_Spage.xml"), point, &m_pm, &m_NoteTypeMenuCheckInfo);
				}
				
			}
			else
			{
				return;
			}
		}
	}
	else
	{
		if(m_currentSelectInfo)//�½����߱ʼ�
		{
			std::vector<double> screen_note_pos =m_currentSelectInfo->coord_pt;
			RectPT2Point(screen_note_pos);
			int i = 0;
			while (i <m_currentSelectInfo->coord_pt.size())
			{
				if ( note_pt[0]>=screen_note_pos[i]&&note_pt[0]<=screen_note_pos[i+2] &&
					note_pt[1]>=screen_note_pos[i+1]&&note_pt[1]<=screen_note_pos[i+3])
				{
					DuiLib::CPoint point(0,0);
					GetCursorPos(&point);
					CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
					pMenu->Init(NULL, _T("reader/menu/PDFContexMenu.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);
					break;
				}
				i += 4;
			}
		}
		else
		{
			CMenuWnd* pMenu = new CMenuWnd(g_pFrame->GetHWND());
			DuiLib::CPoint point(0,0);
			GetCursorPos(&point);
			pMenu->Init(NULL, _T("reader/menu/PDFPageSetMenu.xml"), point, &g_pFrame->m_pm, &g_pFrame->m_NoteTypeMenuCheckInfo);

			RECT rect1, rect2;
			GetWindowRect(g_pFrame->GetHWND(), &rect1);
			GetWindowRect(pMenu->GetHWND(), &rect2);

			if(rect1.bottom < rect2.bottom || rect1.right < rect2.right)
			{
				if(rect1.bottom < rect2.bottom)
				{
					rect2.top = rect2.top - (rect2.bottom - rect1.bottom);
					rect2.bottom = rect1.bottom;
				}
				if(rect1.right < rect2.right)
				{

					rect2.left = rect2.left - (rect2.right - rect1.right);
					rect2.right = rect1.right;
				}
				int width = rect2.right - rect2.left;
				int height = rect2.bottom - rect2.top;

				::SetWindowPos(pMenu->GetHWND(), HWND_TOPMOST, rect2.left, rect2.top, width, height, SWP_SHOWWINDOW);
			}
		}
	}
}
int CReaderFrame::AddAttachFileSelectPage()
{
	int iRet=m_current_page;
	if (m_pdf_show_model==4)
	{
		CAddAttachFileSelectPageFrame* AddFrame = new CAddAttachFileSelectPageFrame;
		AddFrame->Create(m_hWnd, _T("AddAttachFileSelectPageFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		AddFrame->CenterWindow();
		if (IDOK == AddFrame->ShowModal())
		{
			if(AddFrame->m_index==0)
				iRet=m_current_page;
			else
				iRet=m_current_page+1;
		}
		else
		{
			iRet=-1;
		}
		if(AddFrame)
		{
			delete AddFrame;
			AddFrame=NULL;
		}
	}
	return iRet;
}
int CReaderFrame::ShareLocal2Share(vector<CPDFNoteInfo*> list)
{
	
	m_freeLineFrame->ShowWindow(false);
	isShowFreePen=false;
	SetPenAndColor(NOTES_NONE, GetPenColor());
	if(m_freeLineFrame->erase_select->IsSelected())
	{
		m_freeLineFrame->erase_select->Selected(false);
		EraseModeUse();
	}
	int iRet=0;
	//���Ӵ������رʼǹ����ķ���
// 	if(!theApp.AnalysisConnect())
// 	{
// 		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
// 		return -1;
// 	}
	if(theApp.m_UserInfo.iUserType==2)
	{

		if(m_pShareNote->GetFolderList())
		{

	
			CShareNoteFrame* pShareNoteFrame = new CShareNoteFrame(m_pShareNote,m_pBookInfo->strSubjectId);
			pShareNoteFrame->Create(m_hWnd, _T("ShareNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
			pShareNoteFrame->CenterWindow();

			if (IDOK == pShareNoteFrame->ShowModal())
			{
				//�������ţB������ѧ���ϴ��Ʊʼ�
				if(pShareNoteFrame->m_type==1)
				{
					//ѡ�������ʦ
				
					iRet =m_pShareNote->LocalShareToTeacher(list,pShareNoteFrame->m_teacher_id);
					if(m_th.m_isNeedReLogin)
					{
						CloseApplication(1);
					}
				
				}
				if(pShareNoteFrame->m_type==2)
				{

					//ѡ������ļ���
				
					iRet =m_pShareNote->LocalShareToDir(list,pShareNoteFrame->m_folder_id);
					if(m_th.m_isNeedReLogin)
					{
						CloseApplication(1);
					}
					m_pLabelOper->DownloadAndSaveLabel();
				
				}
				if(iRet ==TRUE)
				{
					SetNeedReloadDB();
					m_pMyPDFBook->RedrawLines();
					ShowMultiOperator(0);
					GetNoteByCataIndex(m_current_mulu_index);
					UpdateBookNotes(m_SidebarWidth);
					CustomMessageBox(m_pShareNote->m_strActionRes,MSG_TYPE_NOTICE,TRUE);
				}else
				{
					if(m_th.m_curl->m_curlCode == CURLE_RECV_ERROR)
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
					ShowMultiOperator(0);
					//CustomMessageBox(L"�ʼǹ���ʧ��",MSG_TYPE_NOTICE,FALSE);
				}

			}
			else
			{
				iRet= -1;
			}

			if(pShareNoteFrame) 
			{
				delete pShareNoteFrame;
				pShareNoteFrame=NULL;
			}
		}else
		{
			CustomMessageBox(STRING_MSG_GET_TEACHER_TASK_ERR,MSG_TYPE_NOTICE,FALSE);
		}
	}
	else 
	{

		CShareTeacherNoteFrame* pShareTeacherNoteFrame = new CShareTeacherNoteFrame(m_pShareNote,m_pBookInfo->strGrade);
		pShareTeacherNoteFrame->Create(m_hWnd, _T("ShareTeacherNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		pShareTeacherNoteFrame->CenterWindow();
		if(!theApp.AnalysisConnect())
		{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			return -1;
		}
		if (IDOK == pShareTeacherNoteFrame->ShowModal())
		{
			//AfxMessageBox(_T("��ʦ�����ʼǵĴ�����ʽ�����أ�"));
			if(list.size()>0)
			{
				CString strShareDesc=pShareTeacherNoteFrame->m_share_desc;
				strShareDesc.TrimLeft();
				strShareDesc.TrimRight();
				if(strShareDesc.GetLength()<=0)
				{
					CPDFNoteInfo* noteinfo=list.at(0);
					int nNum =list.size();
					CString strDescribe;
					if(noteinfo->pdfNoteType==NoteLine)
						strDescribe=_T("���߱ʼ�");
					else if(noteinfo->pdfNoteType==NoteTextBox)
						strDescribe=_T("�ı���ʼ�");
					else if(noteinfo->pdfNoteType==NoteFreedom)
						strDescribe=_T("���ɻ���");
					else if(noteinfo->pdfNoteType==NoteAudio)
						strDescribe=_T("��Ƶ");
					else if(noteinfo->pdfNoteType==NoteVideo)
						strDescribe=_T("��Ƶ");
					else if(noteinfo->pdfNoteType==NoteImage)
						strDescribe=_T("ͼƬ");
					else if(noteinfo->pdfNoteType==NoteLink)
						strDescribe=_T("��������Դ�ʼ�");
					else if(noteinfo->pdfNoteType==NoteFile)
						strDescribe=_T("�������ͱʼ�");
					else if(noteinfo->pdfNoteType==NoteDoc)
						strDescribe=_T("Word");
					else if(noteinfo->pdfNoteType==NoteExcel)
						strDescribe=_T("Excel");
					else if(noteinfo->pdfNoteType==NotePpt)
						strDescribe=_T("PPT");
					else if(noteinfo->pdfNoteType==NotePdf)
						strDescribe=_T("PDF");
					pShareTeacherNoteFrame->m_share_desc.Format(L"%s��%d���ʼ�",strDescribe,nNum);
					
				}

// 				if(strShareDesc.GetLength()==0)
// 				{
// 					CustomMessageBox(L"�Ƿ��ļ�����",MSG_TYPE_NOTICE,FALSE);
// 					return -1;
// 				}
				//����������ʼǵķ���
				
				iRet =m_pShareNote->LocalShareToClass(list,pShareTeacherNoteFrame->m_select_classinfo,pShareTeacherNoteFrame->m_share_desc);
				if(m_th.m_isNeedReLogin)
				{
					CloseApplication(1);
				}
				m_pLabelOper->DownloadAndSaveLabel();
				
			}
			else
			{

				CustomMessageBox(_T("��ѡ����Ҫ�����ıʼǣ�"),MSG_TYPE_NOTICE,FALSE);
			}

			if(iRet ==TRUE)
			{
				SetNeedReloadDB();
				m_pMyPDFBook->RedrawLines();
				ShowMultiOperator(0);
				GetNoteByCataIndex(m_current_mulu_index);
				UpdateBookNotes(m_SidebarWidth);
				CustomMessageBox(m_pShareNote->m_strActionRes,MSG_TYPE_NOTICE,TRUE);
			}else
			{
				if(m_th.m_curl->m_curlCode == CURLE_RECV_ERROR)
					CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
				ShowMultiOperator(0);
				//CustomMessageBox(L"�ʼǹ���ʧ��",MSG_TYPE_NOTICE,FALSE);

			}

		}
		else
		{
			return -1;
		}

		if(pShareTeacherNoteFrame) 
		{
			delete pShareTeacherNoteFrame;
			pShareTeacherNoteFrame=NULL;
		}
	}
	return iRet;
}
int CReaderFrame::ShareCloud2Share(vector<CPDFNoteInfo*> list)
{

	
	int iRet=0;
	//���Ӵ������رʼǹ����ķ���
	if(theApp.m_UserInfo.iUserType==2)
	{
		if(m_pShareNote->GetFolderList())
		{

			CShareNoteFrame* pShareNoteFrame = new CShareNoteFrame(m_pShareNote,m_pBookInfo->strSubjectId);
			pShareNoteFrame->Create(m_hWnd, _T("ShareNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
			pShareNoteFrame->CenterWindow();
		
			if (IDOK == pShareNoteFrame->ShowModal())
			{
				//�������ţB������ѧ���ϴ��Ʊʼ�
				if(pShareNoteFrame->m_type==1)
				{
					//ѡ�������ʦ
				
					iRet =m_pShareNote->CloudShareToTeacher(list,pShareNoteFrame->m_teacher_id);
				
				}
				if(pShareNoteFrame->m_type==2)
				{

					//ѡ������ļ���

					iRet =m_pShareNote->CloudShareToDir(list,pShareNoteFrame->m_folder_id);
					m_pLabelOper->DownloadAndSaveLabel();
				
				}
				if(iRet ==TRUE)
				{
					SetNeedReloadDB();
					m_pMyPDFBook->RedrawLines();
					GetNoteByCataIndex(m_current_mulu_index);
					ShowMultiOperator(0);
					UpdateBookNotes(m_SidebarWidth);
					CustomMessageBox(STRING_MSG_SHARE_OK,MSG_TYPE_NOTICE,TRUE);
				}else
				{
// 					if(m_th.m_curl->m_curlCode == CURLE_RECV_ERROR)
// 						CustomMessageBox(_T("������ϣ����Ժ�����"),MSG_TYPE_NOTICE,FALSE);
					CustomMessageBox(STRING_MSG_SHARE_ERR,MSG_TYPE_NOTICE,FALSE);
				}

			}
			else
			{
				iRet= -1;
			}

			if(pShareNoteFrame) 
			{
				delete pShareNoteFrame;
				pShareNoteFrame=NULL;
			}
		}else
		{
			CustomMessageBox(STRING_MSG_GET_TEACHER_TASK_ERR,MSG_TYPE_NOTICE,FALSE);
		}
	}
	else 
	{

		CShareTeacherNoteFrame* pShareTeacherNoteFrame = new CShareTeacherNoteFrame(m_pShareNote,m_pBookInfo->strGrade);
		pShareTeacherNoteFrame->Create(m_hWnd, _T("ShareTeacherNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		pShareTeacherNoteFrame->CenterWindow();
		if(!theApp.AnalysisConnect())
		{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			return -1;
		}
		if (IDOK == pShareTeacherNoteFrame->ShowModal())
		{
			//AfxMessageBox(_T("��ʦ�����ʼǵĴ�����ʽ�����أ�"));
			if(list.size()>0)
			{
				pShareTeacherNoteFrame->m_share_desc.TrimLeft();
				pShareTeacherNoteFrame->m_share_desc.TrimRight();
				if(pShareTeacherNoteFrame->m_share_desc.GetLength()<=0)
				{
					CPDFNoteInfo* noteinfo=list.at(0);
					int nNum =list.size();
					CString strDescribe;
					if(noteinfo->pdfNoteType==NoteLine)
						strDescribe=_T("���߱ʼ�");
					else if(noteinfo->pdfNoteType==NoteTextBox)
						strDescribe=_T("�ı���ʼ�");
					else if(noteinfo->pdfNoteType==NoteFreedom)
						strDescribe=_T("���ɻ���");
					else if(noteinfo->pdfNoteType==NoteAudio)
						strDescribe=_T("��Ƶ");
					else if(noteinfo->pdfNoteType==NoteVideo)
						strDescribe=_T("��Ƶ");
					else if(noteinfo->pdfNoteType==NoteImage)
						strDescribe=_T("ͼƬ");
					else if(noteinfo->pdfNoteType==NoteLink)
						strDescribe=_T("��Դ");
					else if(noteinfo->pdfNoteType==NoteFile)
						strDescribe=_T("�ļ�");
					pShareTeacherNoteFrame->m_share_desc.Format(L"%s��%d���ʼ�",strDescribe,nNum);

				}
				//����������ʼǵķ���
				
				iRet =m_pShareNote->CloudShareToClass(list,pShareTeacherNoteFrame->m_select_classinfo,pShareTeacherNoteFrame->m_share_desc);
				m_pLabelOper->DownloadAndSaveLabel();
				
			}
			else
			{
				CustomMessageBox(_T("��ѡ����Ҫ�����ıʼǣ�"),MSG_TYPE_NOTICE,FALSE);
			}

			if(iRet ==TRUE)
			{
				SetNeedReloadDB();
				m_pMyPDFBook->RedrawLines();
				GetNoteByCataIndex(m_current_mulu_index);
				UpdateBookNotes(m_SidebarWidth);
				CustomMessageBox(STRING_MSG_SHARE_OK,MSG_TYPE_NOTICE,TRUE);
			}else
			{

				CustomMessageBox(STRING_MSG_SHARE_ERR,MSG_TYPE_NOTICE,FALSE);
			}

		}
		else
		{
			return -1;
		}

		if(pShareTeacherNoteFrame) 
		{
			delete pShareTeacherNoteFrame;
			pShareTeacherNoteFrame=NULL;
		}
	}
	return iRet;
}
int CReaderFrame::DeleteCloudNote(vector<CPDFNoteInfo*> list)
{
	int iRet=-1;
	int nStartPage=0;
	int nEndPage=9999;
	//����ɾ���ƱʼǵĴ�������
	if(m_pNotesFilter->IsSelected())
	{
		iRet =m_pcloudNote->DeleteCloudNote(list,m_nStartSearchPage,m_nEndSearchPage);
	}else
	{
		if(m_current_mulu_index>0)
		{
			if(m_cata_list.size()>0)
			{
				textbook_catalogInfo catalog =m_cata_list.at(m_current_mulu_index);
				nStartPage =catalog.startPage;
				nEndPage =catalog.endPage;
			}

		}

		iRet =m_pcloudNote->DeleteCloudNote(list,nStartPage,nEndPage);
	}

   
	return iRet;
}

int CReaderFrame::DownLoadCloud2LocalNote(vector<CPDFNoteInfo*> list)
{
	int iRet=-1;
	//�����Ʊʼǵ�����
	//nType=1:�Ʊʼ�
	iRet =ImportNoteToLocal(list,NOTE_CLOUD);
	return iRet;
}

// int CReaderFrame::SharCloud2ShareNote(vector<CPDFNoteInfo*> list)
// {
// 
// 	int iRet=-1;
// 	//�ƱʼǷ���������
// 	iRet =ShareLocal2Share(list);
// 	return iRet;
// }

int CReaderFrame::GetCloudNote()
{
	//��ȡ�Ʊʼ�
	
	int nRet=1;
	if(!theApp.AnalysisConnect())
	{
		
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		return -1;
	}
	if(m_current_mulu_index>=0 && m_current_mulu_index<m_cata_list.size())
	{
		textbook_catalogInfo info=m_cata_list.at(m_current_mulu_index);
		int nRet =m_pcloudNote->GetCloudNoteFromService(info.startPage,info.endPage);

	}
	else
	{
		int nRet =m_pcloudNote->GetCloudNoteFromService();

	}
	//Add By Ray 2019-06-10 ��ǩ���»�ȡ
	m_pLabelOper->DownloadAndSaveLabel();
	m_noteDao->GetAllLabelInfo(m_labelInfos);
	return nRet;
}

int CReaderFrame::GetShareNote(BOOL IsClear)
{
	if(!theApp.AnalysisConnect())
	{
	    m_pNoteList->RemoveAll();
		m_pShareNote->CleraFirstfolderList();
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		return -1;
	}else
	{
		if(theApp.m_strToken  ==L"tokenisnone")
		{
			CloseApplication(1);
		}
	}
	//��ȡ�����ʼ�

	int type_share = ComboShareSelect->GetCurSel();
	int class_type = m_ctrlClass->GetCurSel();
// 	if(m_class_list.size()==0)
// 	{
// 		return -1;
// 	}
	CString strId=L"",strName=L"";
	if(class_type<=0)
	{
		strName =L"ȫ���༶";
	}else
	{
		if(theApp.m_target_info.target_list.size()>class_type-1)
		{
			TARGET_INFO_SON classdata =theApp.m_target_info.target_list.at(class_type-1);
			strName =classdata.name;
			strId.Format(L"%lld",classdata.id);	
		}

	}
	

	if(type_share<0)
	{
		type_share=0;
	}
	
	
	
	

	////���////////
	theApp.m_EventLog.init();
	CString strType=L"";
	int nType=0;
	if(type_share==0)
	{
		nType =1;
	}else
	{
		nType =2;
	}
	strType.Format(L"%d",nType);
	theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_SHARE_NOTE_FILTER_CHG);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FROM_TO_ME_SEL,strType);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_ALL,strName);
	theApp.m_EventLog.MakeJsonFormat();
	////////////////
	//���↑ʼȡ��һ������
 	int nRet=0;
 	//int nType =_wtoi(theApp.m_UserInfo.strType);

	
	

	nRet =m_pShareNote->GetShareData(type_share,strId,m_shareNoteSearch,IsClear);
	if(m_th.m_isNeedReLogin)
	{
		CloseApplication(1);
		while (1)
		{

		}
	}
 //	nRet =m_pShareNote->GetShareData(REQ_SHARED_TO_ME);
 // nRet =m_pShareNote->GetMyShareNoteFromService(nType);
 //	nRet =m_pShareNote->GetShareToMeNoteFromService(nType);
	

	return nRet;
}

int CReaderFrame::CustomMessageBox(CString strData,int nType,bool bResult)
{
	//int CGlobalUI::ShowMessage(HWND hWnd, LPCTSTR szText, int type,bool bRet)
	//type==1 ȷ����Ϣ  2��ͨ��ʾ   
	int nRet =CGlobalUI::ShowMessage(this->GetHWND(),strData,nType,bResult);//����1��ʾȷ��
	return nRet;
}

int CReaderFrame::CleanAllFreePenNote()
{
	//CNoteDao NoteDao(m_pBookInfo->bookId);
	//�ҳ����е����ɻ���
	//���ݵ�ռ�滹ԭVector
	m_pdfNoteInfoListBK.assign(m_pdfNoteInfoList.begin(), m_pdfNoteInfoList.end());
	for(int nNum=0;nNum<m_pdfNoteInfoList.size();nNum++)
	{
		CPDFNoteInfo* Note =m_pdfNoteInfoList.at(nNum);
		if(Note->pdfNoteType == NoteFreedom)//ֻɾ�����ɻ���
		{
			m_noteDao->DeleteFreePenByFid(Note->fid);
			m_noteDao->CheckAndDeleteNoneRecord(Note->fid);
			//RemoveNoteInfoFromListById((Note)->id);
			//long id=NoteDao.DeleteNoteInfos(Note);
			
		}
	}
	
	//��鲢ɾ��NoteInfo

	//m_noteDao.DeleteNoteInfos(noteIds.Left(noteIds.GetLength()-1)); no use
	m_pResChoiceAll->Selected(false);
	m_pMyPDFBook->RedrawLines();
	return TRUE;
}

int CReaderFrame::CoordChange(CPDFNoteInfo* info)
{
	int iRet=-1;
	if (info->pageWidth>10 && info->pageHeight>10)
	{
		iRet=0;
		double width;
		double height;
		PDF_GetPageSize(info->pageIndex,width,height);
		float ratio_x=info->pageWidth/width;
		float ratio_y=info->pageHeight/height;
		if(info->pdfNoteType==NoteFreedom)
		{
			for(int i=0;i<info->m_free_pen_line.size();i++)
			{
				FREE_PEN_INFO* freePen=info->m_free_pen_line.at(i);
				CString StrCoord=freePen->coord;
				freePen->coord=_T("");
				SplitString2Float(StrCoord,ratio_x,ratio_y,freePen->coord);
			}
		}
		else
		{
			
			CString new_coord;
			SplitString2Float(info->coord,ratio_x,ratio_y,new_coord);
			info->coord=new_coord;

		}
	}
	else
	{
		iRet =-1;
	}
	return iRet;
}
CPDFNoteInfo* CReaderFrame::GetPdfInfoByIndexExtentFreePen(int& index)
{
	CPDFNoteInfo* temp=NULL;
	std::vector<CPDFNoteInfo*> temp_list;
	for (int i = 0; i < m_pdfNoteInfoList.size(); i++)
	{
		CPDFNoteInfo* info = m_pdfNoteInfoList.at(i);
		if(info->fid<=0)
			temp_list.push_back(info);
	}
	if (index>=0 && index<temp_list.size())
	{
		temp=temp_list.at(index);
		for (int j=0;j<m_pdfNoteInfoList.size();j++)
		{
			CPDFNoteInfo* info = m_pdfNoteInfoList.at(j);
			if(info->id==temp->id)
			{
				index=j;
				break;
			}
		}
	}
	return temp;
}
void CReaderFrame::UpdateSourceType()
{
	CHorizontalLayoutUI* res_type_layout=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("res_type_layout")));
	if(res_type_layout)
	{
		int size = res_type_layout->GetCount();
		for (int i=0;i<size;i++)
		{
			CControlUI* temp=res_type_layout->GetItemAt(i);
			COptionUI* op=(COptionUI*)temp;
			if(op->IsSelected())
			{
				if(i==0)
				{
					UpdateBookRes();
					break;
				}
				else
				{
					TypeStruct& temp=m_extrs->mTypeList.at(i-1);
					m_extrs->FilterResult(temp.nId);
					UpdateBookRes(i);

					break;
				}
			}
		}
	}
}
void CReaderFrame::AddResTypeElement()
{
	if(m_pResTypeLayout && m_extrs)
	{
		m_pResTypeLayout->RemoveAll();
		for (int i=0;i<m_extrs->m_extras_list.size();i++)
		{
			ExtrasType& type = m_extrs->m_extras_list.at(i);
			COptionUI* temp=new COptionUI;
			temp->SetAttribute(_T("group"),_T("resType"));
			temp->SetAttribute(_T("textcolor"),_T("#FF000000"));
			temp->SetAttribute(_T("selectedtextcolor"),_T("#FF48ACFB"));
			temp->SetAttribute(_T("font"),_T("4"));
			temp->SetAttribute(_T("padding"),_T("10,0,0,0"));
			temp->SetText(type.strTypeName);
			temp->SetTag(i);
			temp->SetName(_T("source_type"));
			if(0==i)
			{
				temp->Selected(true);
				m_extrs->m_current_index = i;
			}
			temp->SetFixedWidth(80/theApp.m_screen_ratio);
			m_pResTypeLayout->Add(temp);
		}
	}
}
void CReaderFrame::SetAttachFile(CPDFNoteInfo* info)
{
	CString strFileType =info->content;
	CString strFilePath;
	int pos = info->content.ReverseFind('.');
	if (pos > 0)
		strFileType = info->content.Right(strFileType.GetLength() - pos - 1);
	SYSTEMTIME tmSys;
	GetLocalTime(&tmSys);
	CTime tm3(tmSys);
	__int64 tmDst = __int64(tm3.GetTime())*1000 + tmSys.wMilliseconds;
	tmDst= tmDst+600000;
	CString strSignExp=L"",strSign=L"";
	strSignExp.Format(L"%lld",tmDst);
	CString strFileName =strSignExp;
	strFilePath.Format(L"%s%s\\%s\\%s.%s", theApp.m_strUser_Path,theApp.m_UserInfo.strUserId,m_pBookInfo->bookId,strFileName,strFileType);
	CString strSaveName;
	strSaveName.Format(L"\\source\\user\\%s\\%s\\%s.%s",theApp.m_UserInfo.strUserId,m_pBookInfo->bookId,strFileName,strFileType);
	//���������ϼв�����·��
	BOOL bRet =CopyFile(info->content,strFilePath,TRUE);
	if(!bRet)
	{
		DWORD n=GetLastError();
	}
	info->content =strSaveName;
}

void CReaderFrame::AddResource2Page()
{
	int index=m_pResList->m_current_index;
	if(index>=0)
	{
		CHorizontalLayoutUI* res_type_layout=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("res_type_layout")));
		if(res_type_layout)
		{
			int size = res_type_layout->GetCount();
			if(size>0)
			{
				CControlUI* temp=res_type_layout->GetItemAt(0);
				COptionUI* op=(COptionUI*)temp;
				CExtrasData info = m_extrs->GetSelectExtrasData(index);
				
				int pageTemp=m_current_page;
				if(pageTemp>=0)
				{
					CPDFNoteInfo* pdf_info = new CPDFNoteInfo;
					pdf_info->pdfNoteType=NoteLink;
					//CNoteDao NoteDao(m_pBookInfo->bookId);
					pdf_info->pageIndex=pageTemp;
					int x=0;
					int y=0;
					getFileNoteRc(x,y,pageTemp);
					pdf_info->coord_pt.push_back(x);
					pdf_info->coord_pt.push_back(y);
					pdf_info->coord_pt.push_back(30);
					pdf_info->coord_pt.push_back(30);
					Point2StrCoord(pdf_info->coord_pt,pdf_info->coord);
					pdf_info->content=info.strPicPath;
					CString temp=info.strBrief;
					if(temp.GetLength()>=46)
					{
						temp.Mid(0,46);
						temp+=_T("...");
					}
					pdf_info->noteText=info.strTitle+_T("\n*&^")+temp;
					pdf_info->LinkURL = info.strHtmlUrl;
					UpdateDBAndPDFList(pdf_info,true);
					CustomMessageBox(L"����ɹ������϶���Դ��ť������λ��",MSG_TYPE_NOTICE,TRUE);
					m_pMyPDFBook->RedrawLines();
				}
			}
		}
	}
}
void CReaderFrame::GetFolderNotes(int index,vector<CPDFNoteInfo*>& list)
{
	if(index>=0 && index<m_pShareNote->m_share_to_me_list.size())
	{
		CShareFolderList* listInfo=m_pShareNote->m_share_to_me_list.at(index);
		for (int j=0;j<listInfo->m_folder_list.size();j++)
		{
			CShareFolder* folderInfo = listInfo->m_folder_list.at(j);
			for (int i=0;i<folderInfo->m_note_list.size();i++)
			{
				CPDFNoteInfo* temp_info=folderInfo->m_note_list.at(i);
				list.push_back(temp_info);

			}
		}
	}
}

void CReaderFrame::GetFolderNotes(std::vector<int> select_list,vector<CPDFNoteInfo*>& list)
{
	for (int i=0;i<select_list.size();i++)
	{
		GetFolderNotes(select_list.at(i),list);
	}
}

void CReaderFrame::NoteTypeVectorToString(std::vector<int> note_type,std::vector<int> line_type,CString &strNType,CString &strLType)
{
	
	for(int i=0;i<note_type.size();i++)
	{
		int noteType=note_type.at(i);
		if(i!=(note_type.size()-1))
		{
			CString strTemp;
			strTemp.Format(L"%d",noteType);
			strNType =strNType+strTemp+L",";

		}else
		{
			CString strTemp;
			strTemp.Format(L"%d",noteType);
			strNType =strNType+strTemp;


		}

	}
	for(int i=0;i<line_type.size();i++)
	{
		int LineType=line_type.at(i);
		if(i!=(line_type.size()-1))
		{
			CString strTemp;
			strTemp.Format(L"%d",LineType);
			strLType =strLType+strTemp+L",";
		}else
		{
			CString strTemp;
			strTemp.Format(L"%d",LineType);
			strLType =strLType+strTemp;
		}
	}


}
int CReaderFrame::GetUserType()
{

		return theApp.m_UserInfo.iUserType;

}
void CReaderFrame::GetSelectShareNotes(int index,vector<CPDFNoteInfo*>& list)
{
	if(index<0)
		return;
	
	int type=ComboShareSelect->GetCurSel();
	if (type==0)//�ҹ�����
	{
		if(GetUserType()==2)//ѧ��
		{
			CShareFolder* folderInfo = m_pShareNote->m_student_share_from_me.at(index);
			for (int i=0;i<folderInfo->m_note_list.size();i++)
			{
				list.push_back(folderInfo->m_note_list.at(i));
			}
		}
		else
		{
			CShareFolder* folderInfo = m_pShareNote->m_share_from_me_list.at(index);
			for (int i=0;i<folderInfo->m_note_list.size();i++)
			{
				list.push_back(folderInfo->m_note_list.at(i));
			}
			//GetFolderNotes(index,list);
		}
	}
	else//�������ҵ�
	{
		if(GetUserType()==2)//ѧ��
		{
			CShareFolder* folderInfo = m_pShareNote->m_student_share_to_me.at(index);
			for (int i=0;i<folderInfo->m_note_list.size();i++)
			{
				list.push_back(folderInfo->m_note_list.at(i));
			}
		}
		else
		{
			GetFolderNotes(index,list);
		}
	}
}
void CReaderFrame::GetSelectShareNotes(std::vector<int> select_list,vector<CPDFNoteInfo*>& list)
{
	for (int i=0;i<select_list.size();i++)
	{
		GetSelectShareNotes(select_list.at(i),list);
	}
}
void CReaderFrame::DeleteShareNoteFromList(std::vector<int> select_index)
{
	std::sort(select_index.rbegin(),select_index.rend());
	for (int i=0;i<select_index.size();i++)
	{
		int index= select_index.at(i);
		DeleteShareNoteFromList(index);
	}
}
void CReaderFrame::DeleteShareNoteFromList(int index)
{
	if(GetUserType()==2)
	{
		if (index>=0 && index<m_pShareNote->m_student_share_from_me.size())
		{
			CShareFolder* folderInfo = m_pShareNote->m_student_share_from_me.at(index);
			for (int i=0;i<folderInfo->m_note_list.size();i++)
			{
				CPDFNoteInfo* info = folderInfo->m_note_list.at(i);
				delete info;
				info=NULL;
			}
			std::vector<CShareFolder*> :: iterator itr=m_pShareNote->m_student_share_from_me.begin();
			m_pShareNote->m_student_share_from_me.erase(itr+index);
		}
	}
	else
	{
		if (index>=0 && index<m_pShareNote->m_share_from_me_list.size())
		{
			CShareFolder* folderInfo = m_pShareNote->m_share_from_me_list.at(index);
			for (int i=0;i<folderInfo->m_note_list.size();i++)
			{
				CPDFNoteInfo* info = folderInfo->m_note_list.at(i);
				delete info;
				info=NULL;
			}
			std::vector<CShareFolder*> :: iterator itr=m_pShareNote->m_share_from_me_list.begin();
			m_pShareNote->m_share_from_me_list.erase(itr+index);
		}
	}
}

CString CReaderFrame::GetFreepenCoord(int nType,LONGLONG llId)
{
	//nType = 1 cloud, nType=2 share
	std::string strResult;
	CString strCoord=L"";

	int nRet =RemoteGetCoordFromServer(nType,llId,strResult);
	if(nRet==200||nRet==201)
	{
		CFunction fun;
		Json::Reader reader;//json����
		Json::Value value;//��ʾһ��json��ʽ�Ķ���
		if (reader.parse(strResult, value))
		{
			int res = value["result"].asInt();
			if (res != 0)
				return L"";

			const Json::Value coords = value["data"];
			int count = coords.size();
			for(int nNum=0;nNum<count;nNum++)
			{
				if(!coords[nNum]["coord"].isNull())
				{
					const char* Coord=coords[nNum]["coord"].asCString();
					strCoord =fun.AsciiToUnicode(Coord);
				}
			}
			return strCoord;
		}

	}
}
void CReaderFrame::GetShareFromMeTwo(std::vector<int> select_index,vector<CPDFNoteInfo*>& list)
{
	if(GetUserType()==2)
	{
		if(m_share_note_operator->m_type==0)
		{
			CShareFolder* folderInfo = m_pShareNote->m_student_share_from_me.at(m_share_note_operator->m_select_index);
		
			for (int i=0;i<select_index.size();i++)
			{
				int temp = select_index.at(i);
				if(temp>=0 && temp<folderInfo->m_note_list.size())
					list.push_back(folderInfo->m_note_list.at(temp));

			}
		}
	}
	else
	{
		if(m_share_note_operator->m_type==0)
		{
			CShareFolder* folderInfo = m_pShareNote->m_share_from_me_list.at(m_share_note_operator->m_select_index);

			for (int i=0;i<select_index.size();i++)
			{
				int temp = select_index.at(i);
				if(temp>=0 && temp<folderInfo->m_note_list.size())
					list.push_back(folderInfo->m_note_list.at(temp));

			}
		}
	}
}
void CReaderFrame::DeleteShareFromMeTwo(std::vector<int> select_index)
{
	std::sort(select_index.rbegin(),select_index.rend());
	if(GetUserType()==2)
	{
		if(m_share_note_operator->m_type==0)
		{
			CShareFolder* folderInfo = m_pShareNote->m_student_share_from_me.at(m_share_note_operator->m_select_index);

			for (int i=0;i<select_index.size();i++)
			{
				int temp = select_index.at(i);
				if(temp>=0 && temp<folderInfo->m_note_list.size())
				{
					CPDFNoteInfo* info =folderInfo->m_note_list.at(temp);
					delete info;
					info=NULL;
					std::vector<CPDFNoteInfo*> :: iterator itr=folderInfo->m_note_list.begin();
					folderInfo->m_note_list.erase(itr+temp);
				}

			}
		}
	}
	else
	{
		if(m_share_note_operator->m_type==0)
		{
			CShareFolder* folderInfo = m_pShareNote->m_share_from_me_list.at(m_share_note_operator->m_select_index);

			for (int i=0;i<select_index.size();i++)
			{
				int temp = select_index.at(i);
				if(temp>=0 && temp<folderInfo->m_note_list.size())
				{
					CPDFNoteInfo* info =folderInfo->m_note_list.at(temp);
					delete info;
					info=NULL;
					std::vector<CPDFNoteInfo*> :: iterator itr=folderInfo->m_note_list.begin();
					folderInfo->m_note_list.erase(itr+temp);
				}

			}
		}
	}
}

void CReaderFrame::OpenSeeNoteFrame( int index )
{
	g_pFrame->ShowMarkButtonClick(true);
	m_pdfToolFrame->ShowWindow(false);
	m_curSelNote=-1;
	if(m_pSeeNote)
	{
		delete m_pSeeNote;
		m_pSeeNote=NULL;
	}
	if(m_pSeeNoteFrameTitle)
	{
		m_pSeeNoteFrameTitle->SetVisible(true);
		m_pReadToolLayout->SetVisible(false);
		m_pSidebarLayout->SetVisible(false);
		m_pPreStudentNote->SetVisible(true);
		m_pNextStudentNote->SetVisible(true);
		m_seeNotemodel=m_pMyPDFBook->GetViewMode();
		m_bIsSeeNote=true;

		std::vector<CShareFolder*> temp_list;
		m_pShareNote->GetSubmitStudentList(temp_list);
		m_pSeeNote = new CSeeNote(temp_list,index);
		m_pSeeNote->GetInfo();
		ClearPdfNoteList();
		
		m_seeNotemodel = m_pMyPDFBook->GetViewMode();
		m_pMyPDFBook->SetViewMode(2);

		ShowNoteInfo();
	}
}

void CReaderFrame::CloseSeeNoteFrame()
{
	if(!m_bisShowNoteTemp)
	{
		ShowMarkButtonClick(false);
	}
	m_pdfToolFrame->ShowWindow(true);
	m_pSeeNoteFrameTitle->SetVisible(false);
	m_pReadToolLayout->SetVisible(true);
	m_pSidebarLayout->SetVisible(true);
	m_pPreStudentNote->SetVisible(false);
	m_pNextStudentNote->SetVisible(false);
	m_pMyPDFBook->SetViewMode(m_seeNotemodel);
	m_pdfNoteInfoList.clear();
	m_bIsSeeNote=false;
	SetNeedReloadDB();
	m_pMyPDFBook->RedrawLines();

	//m_seeNotemodel=m_pMyPDFBook->GetViewMode();
	
}

void CReaderFrame::ShowNoteInfo()
{
	if(m_pSeeNote)
	{
		m_pdfNoteInfoList_drawPdf.clear();
		CString strNextName=m_pSeeNote->GetNextName();
		CString strPreName = m_pSeeNote->GetPreName();
		if(strPreName.IsEmpty())
			pre_button->SetVisible(false);
		else
		{
			pre_button->SetVisible(true);
			pre_button->SetText(strPreName);
		}
		if(strNextName.IsEmpty())
			next_button->SetVisible(false);
		else
		{
			next_button->SetVisible(true);
			next_button->SetText(strNextName);
		}
		CLabelUI* studentName=static_cast<CLabelUI*>(m_pm.FindControl(_T("currentNoteStudentName")));
		studentName->SetText(m_pSeeNote->GetCurrentName());
		for(int nNum=0;nNum<m_pSeeNote->m_note_list.size();nNum++)
		{
			CPDFNoteInfo* noteifo=m_pSeeNote->m_note_list.at(nNum);

			if(noteifo->pdfNoteType==NoteFreedom)
			{	
				noteifo->isFather=1;
				m_pdfNoteInfoList_drawPdf.push_back(noteifo);
				if(!GetFreepenlineforPreView(m_pdfNoteInfoList_drawPdf,noteifo))
				{
					continue;
				}
			}else
			{
				m_pdfNoteInfoList_drawPdf.push_back(noteifo);
			}
				
		}
	
		m_pMyPDFBook->GotoPageNum(m_pSeeNote->m_page_list.at(m_pSeeNote->m_page_index));
		m_pMyPDFBook->RedrawLines();
		
	}
	
}

void CReaderFrame::MakeUrlString( CString& str )
{
	CString temp=_T("{f 0}{a ")+str+_T("/}")+str+_T("{/a}{/f}");
	str=temp;
}
    
void CReaderFrame::GetUrlInString( CString& str )
{
	std::string text = "http://www.baidu.com/��	//std::regex_match";

	//�����������ʽ
	//���� "()" ���ڲ�����, ������ı���ǰ��� "(" ���ֵ�˳��, ������, ��1��ʼ���б�ŵ� 
	//std::string pattern =  "http://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&amp;=]*)?";
	USES_CONVERSION;
	//std::regex express(W2A(str1));

	//ƥ��
	/*ģ�庯��1-1*/
	//��0��һ���������������ʽƥ����, ���������Dz�����Ľ��
	//����ʹ�õ��� std::string::iterator ������, �� begin()/ end() ���صĵ���������(std::string::iterator)Ҫһ��
	//std::match_results<std::string::iterator> results1;
	/*if(std::regex_match(text.begin(), text.end(), results1, express))
	{
	std::match_results<std::string::iterator>::const_iterator iter;
	for (iter = results1.begin(); iter != results1.end(); iter++)
	{
	std::string temp=iter->str();
	}
	}*/
 }

void CReaderFrame::ShowResourceMuLu()
{
	CComboUI* mulu = static_cast<CComboUI*>(m_pm.FindControl(_T("ComboMulu_Resource")));
	mulu->RemoveAll();
	for(int i=0;i<m_cata_list.size();i++)
	{
		textbook_catalogInfo info=m_cata_list.at(i);
		CListLabelElementUI* item=new CListLabelElementUI;
		item->SetAttribute(_T("text"),info.catalogName);
		item->SetFixedHeight(40/theApp.m_screen_ratio);
		item->SetAttribute(_T("textpadding"),_T("2,0,0,0"));
		
		mulu->Add(item);
	}
	mulu->SelectItem(m_current_mulu_index);
}

void CReaderFrame::HotKey_Oeration(BOOL bCtrl,BOOL bShift,int nKeyID,int nType)
{

	if(bCtrl&&(!m_bIsSeeNote))
	{

		//δѡ�бʼ�
		switch(nKeyID)
		{
		case KEY_K://��˫ҳ�л�
			g_pFrame->changeShowMode();
			break;
		case KEY_H://���ء���ʾ�ʼ�
			m_curSelNote=-1;
			g_pFrame->ShowMarkButtonClick();
			break;
		case KEY_T://�ı���ʼ�
			m_curSelNote=-1;
			OpenTextNoteFrame(NULL);

			break;
		case KEY_E://�����ʼ�
			WriteLog(OP_ADDITON_FILE);
			OpenAttachFileNoteFrame(NULL);

			break;
		case KEY_B://���ɻ��ʱʼ�
			{
				WriteLog(OP_FREEDOM);
				ShowFreeLineFrame();
				break;
			}

		case KEY_M://�������� ���޸� ����
			AddToLineNote(LineType::HighlightLine,m_nSelLineNote_Color);
			break;
		case KEY_U://�������� ���޸� ֱ��
			AddToLineNote(LineType::FullLine,m_nSelLineNote_Color);
			break;
		case KEY_P://�������� ���޸� ����
			AddToLineNote(LineType::DottedLine,m_nSelLineNote_Color);
			break;
		case KEY_W://�������� ���޸� ������
			AddToLineNote(LineType::WavyLine,m_nSelLineNote_Color);
			break;
		case KEY_D://ɾ��
			if(m_isShowNoteUi)
			{
				if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
				{
					DeleteSelNoteInList(FALSE,nType);
				}else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
				{
					DeleteSelNoteInList(TRUE);
				}
			}else
			{
				int iRet =CustomMessageBox(STRING_MSG_DELETE_DOUBLE_CHECK,MSG_TYPE_YESNO,0);
				if(iRet==IDOK)
				{
					DeleteSelNote();
				}
					
			}
			
			break;
		case KEY_C:
			if(nType==1)
			{
				if(m_curSelNote>=0 && m_pdfNoteInfoList_drawPdf.size()>0 && m_curSelNote<m_pdfNoteInfoList_drawPdf.size())
				{
					CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
					CopyToClipboard(info->content.GetBuffer(info->content.GetLength()),info->content.GetLength());
				}else
				{
					if(m_currentSelectInfo)
					{
						CopyToClipboard(m_currentSelectInfo->content.GetBuffer(m_currentSelectInfo->content.GetLength()),m_currentSelectInfo->content.GetLength());
					}
				}
			}
			break;
		case KEY_Y://�򿪱༭���߱ʼ�
			if(m_curSelNote>=0)
			{
				CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
				if(info->pdfNoteType==NoteLine)
				{
					RightClickEditLineNote();
				}
				else
				{
						
						CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
						ShowSelectNoteInfo(info);
						m_pMyPDFBook->RedrawLines();
				
				}
			}
			break;
		case KEY_I:
			if(m_curSelNote>=0)
			{
				CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
				if(info->pdfNoteType==NoteLine)
				{
					RightClickEditLineNote();
				}
				else if(info->pdfNoteType==NoteFile || info->pdfNoteType==NoteImage || info->pdfNoteType==NoteVideo || info->pdfNoteType==NoteAudio|| info->pdfNoteType==NoteDoc|| info->pdfNoteType==NoteExcel|| info->pdfNoteType==NotePpt|| info->pdfNoteType==NotePdf)
				{

					CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
					ShowSelectNoteInfo(info);
					m_pMyPDFBook->RedrawLines();
					
					

				}
			}

			break;
		case KEY_F:
			if(m_isShowResourceUi)
			{
				ResourceSearch();
			}else if(m_isShowNoteUi)
			{
				if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW||m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
				{
					if(!m_bIsSearch)
					{
						notes_search_option->Selected(true);
						NoteSearch();
					}
					else
					{
						notes_search_option->Selected(false);
						NoteSearch();
					}
				}
				
			}
			break;
		case KEY_J:
			if(m_isShowResourceUi)
			{
				AddResource2Page();
			}
			break;
		case KEY_O://����Դ�������ʼ�
			OpenFileNote();
			break;
		case KEY_Z://���ɻ��ʳ���
			BackOpertaion();
			break;
		case KEY_L://����ʼ�
			if(m_isShowNoteUi)
			{
				if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
				{
					NoteImport();
				}
				else if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
				{
					CHorizontalLayoutUI* two_h=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("show_share_folder_student")));

					if(two_h->IsVisible())//����ҳ��
					{
						vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
						m_pFolderList->GetSelectItems(m_pdfNoteInfoList,selectNoteInfos);
						ShareNoteImport2Local(selectNoteInfos);
					}
					else//�����ʼ�һ��ҳ��
					{
						int index=m_pNoteList->m_current_select_index;
						m_pShareNote->GetSingleSelFolderNotes(index);
						if(index>=0)
							ShareNoteImport2Local(m_pShareNote->m_temp_Second_note_list);
					}
				}
			}
			break;
		case KEY_G://�ϴ��Ʊʼ�
			if(m_isShowNoteUi)
			{
				if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
				{
					if(!theApp.AnalysisConnect())
					{
						CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
						return;
					}
					UpNoteToCloud();
				}
				
			}
			break;
		case KEY_S:
			if(m_isShowNoteUi)
			{
				if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
				{
					ShatrNoteInList();
				}
				else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
				{
					ShatrNoteInList(TRUE);
				}
			}
			break;
		case KEY_R:
			if(m_isShowNoteUi)
			{
				if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
				{
					int index=m_pNoteList->m_current_select_index;
					if(index>=0 && index<m_pdfNoteInfoList.size())
					{

						CPDFNoteInfo* info = GetPdfInfoByIndexExtentFreePen(index);
						SetCurSel(index);
						ShowSelectNoteInfo(info);
						m_pMyPDFBook->RedrawLines();

					}
				}
			}
			break;
		case KEY_N:
			if(m_isShowNoteUi&&theApp.m_UserInfo.iUserType==1)
			{
				if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
				{
					
					int index=ComboShareSelect->GetCurSel();
					CreateFolder();
				}
			}
			break;
		case KEY_Q:
			if(m_isShowNoteUi)
			{
				if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
				{
					int index=ComboShareSelect->GetCurSel();
					if(index ==0)
					{
					   RecallShareNote();
					}
				}
			}
			break;
		case KEY_A://ȫѡ�ʼ�
			{
				if(m_pNoteList->GetCurrentType() ==SHARE_NOTE_SHOW)
				{
				  CHorizontalLayoutUI* h_bo_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
				
				  if(h_bo_share->IsVisible())
				  {
					  COptionUI* all_choice = static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all_two")));
					  BOOL bSel =all_choice->IsSelected();
					  m_pFolderList->SelectAllItems(!bSel);
				  }
				}else
				{
					CHorizontalLayoutUI* h_bo=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
					if(h_bo->IsVisible())
					{
						COptionUI* all_choice = static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
						BOOL bSel =all_choice->IsSelected();
						m_pNoteList->SelectAllItems(!bSel);
					}
				}

				break;
			}

		case KEY_1://��
			
			if(isShowFreePen ==TRUE)
			{
				m_freeLineFrame->ChangPenColor(0);
				SetPenColor(MDR_COLOR_RED);
			}else
			{
				AddToLineNote(LineType::HighlightLine,PensColor[0],TRUE);
			}
			break;
		case KEY_2://��
			if(isShowFreePen ==TRUE)
			{
				m_freeLineFrame->ChangPenColor(1);
				SetPenColor(MDR_COLOR_YELLOW);
			}else
			{
				AddToLineNote(LineType::HighlightLine,PensColor[1],TRUE);
			}
			
			break;
		case KEY_3://��
			if(isShowFreePen ==TRUE)
			{
				m_freeLineFrame->ChangPenColor(2);
				SetPenColor(MDR_COLOR_GREEN);
				
			}else
			{
				AddToLineNote(LineType::HighlightLine,PensColor[2],TRUE);
			}
			break;
		case KEY_4://��
			if(isShowFreePen ==TRUE)
			{
				m_freeLineFrame->ChangPenColor(3);
				SetPenColor(MDR_COLOR_BLUE);
			}else
			{
				AddToLineNote(LineType::HighlightLine,PensColor[3],TRUE);
			}
			break;
		case KEY_5://��
			if(isShowFreePen ==TRUE)
			{
				m_freeLineFrame->ChangPenColor(4);
				SetPenColor(MDR_COLOR_PURPLE);
			}else
			{
				AddToLineNote(LineType::HighlightLine,PensColor[4],TRUE);
			}
			break;
			case KEY_DEGREE:
			case KEY_DEGREE_NUM:
				{
					float radio = GetCurrentRadio();
					if(m_minRadio-radio>0.05)
						DoReaderCommand(DCMD_ZOOM_OUT);
					break;
				}
				
			case KEY_PLUS:
				DoReaderCommand(DCMD_ZOOM_IN);
				break;
		default:
			break;
		}

	
	}else if(bShift&&(!m_bIsSeeNote))
	{	
		switch(nKeyID)
		{
		case KEY_C://Ŀ¼�б�
			showReadTool(READ_TOOL_SHOW::CATALOGUE);
			if(!m_pShowCalaButton->IsSelected())
			{
				m_pShowCalaButton->Selected(true);
			}else
			{
				m_pShowCalaButton->Selected(false);
			}
			break;
		case KEY_L://�ʼ��б�
			showReadTool(READ_TOOL_SHOW::NOTELIST);
			if(!m_pShowNoteButton->IsSelected())
			{
				m_pShowNoteButton->Selected(true);
			}else
			{
				m_pShowNoteButton->Selected(false);
			}
			break;
		case KEY_R://��Դ�б�
			showReadTool(READ_TOOL_SHOW::RESOURCELIST);
			if(!m_pShowSourceButton->IsSelected())
			{
				m_pShowSourceButton->Selected(true);
			}else
			{
				m_pShowSourceButton->Selected(false);
			}
			break;
		case KEY_E://��Ƥ��
			if(isShowFreePen)
			{
				m_freeLineFrame->SetEraseUse();
				EraseModeUse();
			}
			break;
		/*case KEY_1:
			SetLineSize(1);
			m_iLineWidth = 10;
			UpdateLineMode();
			break;
		case KEY_2:
			SetLineSize(2);
			m_iLineWidth = 4;
			UpdateLineMode();
			break;
		case KEY_3:
			SetLineSize(3);
			m_iLineWidth = 2;
			UpdateLineMode();
			break;
		case KEY_4:
			SetLineSize(4);
			m_iLineWidth = 1;
			UpdateLineMode();
			break;*/
		default:
			break;
		}
	}
	if(!bCtrl && nType==1)
	{
		if(nKeyID==KEY_LEFT)
		{

			if(m_bIsSeeNote)
			{
				m_pSeeNote->GetPreInfo();
				ShowNoteInfo();
			}
			else
			{
				GotoPrePage();
			}
		
		}
		if(nKeyID==KEY_UP)
		{
			if(m_bIsSeeNote)
			{
				m_pSeeNote->GetPrePageInfo();
				ShowNoteInfo();
			}
		}
		if(nKeyID==KEY_DOWN)
		{
			if(m_bIsSeeNote)
			{
				m_pSeeNote->GetNextPageInfo();
				ShowNoteInfo();
			}
		}
		if(nKeyID==KEY_RIGHT)
		{
			if(m_bIsSeeNote)
			{
				m_pSeeNote->GetNextInfo();
				ShowNoteInfo();
			}
			else
			{
				GotoNextPage();
				
			}
		
		}
	}
	
	if(nKeyID==VK_F11)
	{
		View_Size_Max();
	}
}

void CReaderFrame::View_Size_Max()
{
	if(m_bIsSeeNote)
		return;
	CVerticalLayoutUI* readtoolbar=static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("readtoolbar")));
	if(m_bMaxShow)
	{
		readtoolbar->SetVisible(true);
		m_bMaxShow=FALSE;

	}
	else
	{
		readtoolbar->SetVisible(false);
		m_bMaxShow=TRUE;
	}
	
}

void CReaderFrame::AddToLineNote(LineType type,DWORD Color,BOOL ChgColor)
{
	if(m_currentSelectInfo!=NULL)
	{

		m_currentSelectInfo->pdfNoteType=NoteLine;
		
		m_currentSelectInfo->lineColor=Color;
		m_currentSelectInfo->lineType=type;
		OnDrawLineFinish(m_currentSelectInfo); 
		if(m_bAddAndEdit)
			OpenLineNote(m_currentSelectInfo,0);
		m_currentSelectInfo=NULL;
		GetNoteByCataIndex(m_current_mulu_index);
		m_pMyPDFBook->RedrawLines();

	}
	else
	{
		
		if(m_curSelNote>=0)
		{
			CPDFNoteInfo* info = g_pFrame->m_pdfNoteInfoList_drawPdf[g_pFrame->m_curSelNote];
			if(!ChgColor)
			{
			  info->lineType =type;
			}else
			{
				info->lineColor =Color;
			}
			
			OnDrawLineFinish(info);
			SetNeedReloadDB();
		
			m_pMyPDFBook->RedrawLines();
		}
	}
}

void CReaderFrame::DeleteSelNote()
{
	std::vector<CPDFNoteInfo*> Notes;
	CPDFNoteInfo* Note;
	if(m_curSelNote>=0)
	{

		Note =m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
		Notes.push_back(Note);
		if(m_pPlayerWnd != NULL)
		{
			for (int i=0;i<Notes.size();i++)
			{
				CPDFNoteInfo* info = Notes.at(i);
				if(info->pdfNoteType==NoteAudio)
				{
					if(theApp.GetCurDir()+info->content == m_pPlayerWnd->m_strPath)
					{
						CustomMessageBox(L"ɾ��ʧ��,���ȹر���Ƶ���Ŵ���",MSG_TYPE_NOTICE,FALSE);
						return;
					}
				}

			}
		}
		if(!DeleteLocalNote(Notes))
		{
			CustomMessageBox(STRING_READERFRAME_DELETE_FAIL,MSG_TYPE_NOTICE,FALSE);
		}
		else
		{
			CustomMessageBox(STRING_READERFRAME_DELETE_SUCCESS,MSG_TYPE_NOTICE,TRUE);
			showNoteTool(NOTE_NONE);

		}
	}
}

void CReaderFrame::RightClickEditLineNote()
{
	m_isShowAllLabel=false;
	if(m_curSelNote>=0 && m_curSelNote<m_pdfNoteInfoList_drawPdf.size())
	{
		
		CPDFNoteInfo* info=m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
		////���////////
		theApp.m_EventLog.init();
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_NOTE);
		int nPage = info->pageIndex;
		CString strPage;
		strPage.Format(L"%d",nPage);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_WAY,L"1");
		CString strNoteLocalID;
		strNoteLocalID.Format(L"%d",info->id);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LOCAL_ID,strNoteLocalID);
		if(info->pdfNoteType==NoteFreedom||info->pdfNoteType==NoteLine)
		{
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
		}else
		{
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,info->coord);
		}
		int nType=0;

		nType =GetLogNoteType(info->pdfNoteType);
		CString strType;
		strType.Format(L"%d",nType);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,info->noteText);
		CString strLabeData=L"";
		for(int nNum=0;nNum<info->lableInfos.size();nNum++)
		{
			CLabelInfo label =info->lableInfos.at(nNum);
			strLabeData +=label.lableName;
			if(nNum!=info->lableInfos.size()-1)
			{
				strLabeData +=L"��";
			}
		}
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,strLabeData);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,info->content); 
		theApp.m_EventLog.MakeJsonFormat();
		////////////////
		if(info->pdfNoteType==NoteLine)
		{
			OpenLineNote(info);	
		}else
		{
			ShowSelectNoteInfo(info);
			m_pMyPDFBook->RedrawLines();
		}
	}	

}

void CReaderFrame::OpenFileNote()
{
	if(m_curSelNote>=0)
	{
		CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(m_curSelNote);
		if(info->pdfNoteType ==NoteLink)
		{
			ShowBrowser(3,info->LinkURL);
		}
		else if(info->pdfNoteType ==NoteVideo||info->pdfNoteType ==NoteAudio||info->pdfNoteType ==NoteImage||info->pdfNoteType ==NoteFile|| info->pdfNoteType==NoteDoc|| info->pdfNoteType==NoteExcel|| info->pdfNoteType==NotePpt|| info->pdfNoteType==NotePdf)
		{
			OpenFileNoteByNoteId(m_curSelNote);
		}
	}
}
void CReaderFrame::EraseModeUse()
{
	if(iserase)
	{
		iserase=false;
		m_pMyPDFBook->SetFreePenDeleteFlag(false);
		return;
	}
	else
	{
		iserase=true;
		m_pMyPDFBook->SetFreePenDeleteFlag(true);
		return;
	}
}

void CReaderFrame::ResourceSearch()
{
	CComboUI* mulu = static_cast<CComboUI*>(m_pm.FindControl(_T("ComboMulu_Resource")));
	CEditUI* key = static_cast<CEditUI*>(m_pm.FindControl(_T("resource_search_keyword")));
	CButtonUI* searchButton = static_cast<CButtonUI*>(m_pm.FindControl(_T("do_resource_search_button")));
	key->SetText(_T(""));
	if(m_bResourceSearch)
	{
		mulu->SetVisible(true);
		key->SetVisible(false);
		searchButton->SetVisible(false);
		m_bResourceSearch=false;
		//m_extrs->GetResourceByPage(L"",-1,GetCurrentMuluLevelCode());
		GetExtras();
		UpdateBookRes();

	}
	else
	{
		mulu->SetVisible(false);
		key->SetVisible(true);
		searchButton->SetVisible(true);
		m_bResourceSearch=true;
	}
}

void CReaderFrame::UpNoteToCloud()
{
	vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
	int index=m_pNoteList->m_current_select_index;
	if(index>=0 && index<m_pdfNoteInfoList.size())
	{
		if(!theApp.AnalysisConnect())
		{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			return;
		}
		selectNoteInfos.push_back(GetPdfInfoByIndexExtentFreePen(index));

		if(UploadLocal2CloudNote(selectNoteInfos))
		{
			
			CustomMessageBox(m_pcloudNote->m_strActionRes,MSG_TYPE_NOTICE,TRUE);
			SetNeedReloadDB();
			m_pMyPDFBook->RedrawLines();
		}else
		{
			if(m_th.m_curl->m_curlCode == CURLE_RECV_ERROR)
				CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			else
				CustomMessageBox(_T("�ϴ�ʧ��"),MSG_TYPE_NOTICE,FALSE);
			//CustomMessageBox(L"�ϴ�ʧ��",MSG_TYPE_NOTICE,FALSE);
		}
	}
}

void CReaderFrame::DeleteSelNoteInList(BOOL bCloud,int nType)
{
	int index=m_pNoteList->m_current_select_index;
	if(index<0)
	{
		CustomMessageBox(L"��ǰû��ѡ���καʼ�",MSG_TYPE_NOTICE,FALSE);
		return;
	}
	if(!bCloud)
	{
		vector<CPDFNoteInfo*> selectNoteInfos;//���ѡ�еıʼ��б�
		int index=m_pNoteList->m_current_select_index;
		if(index<0)
			return;
		if(nType ==1)
		{
			//index =m_pNoteList->m_current_select_index;
			selectNoteInfos.push_back(m_pdfNoteInfoList.at(index));
		}else
		{
			//index =m_pNoteList->m_current_select_index;
			selectNoteInfos.push_back(GetPdfInfoByIndexExtentFreePen(index));
		}
		
		if(index>=0 && index<m_pdfNoteInfoList.size())
		{
			int iRet =CustomMessageBox(STRING_MSG_DELETE_DOUBLE_CHECK,MSG_TYPE_YESNO);

			if (iRet == IDOK)
			{
				//�رղ�����
				if(m_pPlayerWnd != NULL)
				{
					for (int i=0;i<selectNoteInfos.size();i++)
					{
						CPDFNoteInfo* info = selectNoteInfos.at(i);
						if(info->pdfNoteType==NoteAudio)
						{
							if(theApp.GetCurDir()+info->content == m_pPlayerWnd->m_strPath)
							{
								CustomMessageBox(L"ɾ��ʧ��,���ȹر���Ƶ���Ŵ���",MSG_TYPE_NOTICE,FALSE);
								return;
							}
						}
					}
				}
				if(!DeleteLocalNote(selectNoteInfos))
				{
					CustomMessageBox(STRING_READERFRAME_DELETE_FAIL,MSG_TYPE_NOTICE,FALSE);
				}
				else
				{
					
					showNoteTool(NOTE_NONE);
					SetNeedReloadDB();
					m_pMyPDFBook->RedrawLines();
					CustomMessageBox(STRING_READERFRAME_DELETE_SUCCESS,MSG_TYPE_NOTICE,TRUE);
				}
			}
		}
	}else
	{
		if(!theApp.AnalysisConnect())
		{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			return;
		}
		if(CustomMessageBox(L"ȷ��ɾ�����Ʊʼǣ�",MSG_TYPE_YESNO)==IDOK)
		{
			vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
			int index=m_pNoteList->m_current_select_index;
			if(index>=0 && index<m_pcloudNote->GetCloudListSize())
			{
				selectNoteInfos.push_back(m_pcloudNote->GetNoteInfoByIndex(index));
				int res = DeleteCloudNote(selectNoteInfos);
				if(res==1)
				{
					CustomMessageBox(STRING_READERFRAME_DELETE_SUCCESS,MSG_TYPE_NOTICE,TRUE);
					m_pLabelOper->DownloadAndSaveLabel();
					UpdateBookNotes(m_SidebarWidth);
				}
				else
				{
					CustomMessageBox(STRING_READERFRAME_DELETE_FAIL,MSG_TYPE_NOTICE,FALSE);
				}
				
				//UpdateBookNotes(m_SidebarWidth);
			}

		}
	}


	
}

void CReaderFrame::RecallShareNote()
{
	if(!theApp.AnalysisConnect())
	{
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		return ;
	}
	if(!CheckHasTarget())
	{
		return ;
	}
	//vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
	BOOL bRet=FALSE;

	CHorizontalLayoutUI* two_h=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("show_share_folder_student")));
	
	if(two_h->IsVisible())//����ҳ��
	{
		int index=m_pFolderList->m_current_select_index;
		if(index<0)
		{
			CustomMessageBox(L"ѡ��ʼ�Ϊ��,������ѡ��",MSG_TYPE_NOTICE,FALSE);
			return;
		}
		bRet =m_pShareNote->RecallShareNote(index,1);
		ShowShareNoteTwo();
	
	}else
	{
		int index=m_pNoteList->m_current_select_index;
		if(index<0)
		{
			CustomMessageBox(L"ѡ��ʼ�Ϊ��,������ѡ��",MSG_TYPE_NOTICE,FALSE);
			return;
		}
		bRet =m_pShareNote->RecallShareNote(index);
		ShowShareNote(m_SidebarWidth);
	}

	if(bRet)
	{
		CustomMessageBox(L"�����ɹ�",MSG_TYPE_NOTICE,TRUE);
		

	}else
	{
		CustomMessageBox(L"����ʧ��",MSG_TYPE_NOTICE,FALSE);
	}

	
}
void CReaderFrame::RecallShareNotes(std::vector<int> SelItem)
{
		if(!theApp.AnalysisConnect())
		{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			return ;
		}
		BOOL bRet=FALSE;
		std::sort(SelItem.rbegin(),SelItem.rend());
		CHorizontalLayoutUI* two_h=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("show_share_folder_student")));

		if(two_h->IsVisible())//����ҳ��
		{

			if(SelItem.size()<0)
			{
				CustomMessageBox(L"ѡ��ʼ�Ϊ��,������ѡ��",MSG_TYPE_NOTICE,FALSE);
				return;
			}
			for(int nNum=0;nNum<SelItem.size();nNum++)
			{ 
			   int index =SelItem.at(nNum);
			   bRet =m_pShareNote->RecallShareNote(index,1);
			}
			ShowShareNoteTwo();

		}else
		{
			int index=m_pNoteList->m_current_select_index;
			if(SelItem.size()<0)
			{
				CustomMessageBox(L"ѡ��ʼ�Ϊ��,������ѡ��",MSG_TYPE_NOTICE,FALSE);
				return;
			}
			for(int nNum=0;nNum<SelItem.size();nNum++)
			{ 
			  int index =SelItem.at(nNum);
			  bRet =m_pShareNote->RecallShareNote(index);
			}
			ShowShareNote(m_SidebarWidth);
		}

		if(bRet)
		{
			CustomMessageBox(L"�����ɹ�",MSG_TYPE_NOTICE,TRUE);


		}else
		{
			CustomMessageBox(L"����ʧ��",MSG_TYPE_NOTICE,FALSE);
		}
}
void CReaderFrame::ShatrNoteInList(BOOL bCloud)
{
	if(!theApp.AnalysisConnect())
	{
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		return;
	}
	if(!CheckHasTarget())
	{
		return ;
	}
	vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
	int index=m_pNoteList->m_current_select_index;
	if(!bCloud)
	{
		if(index>=0 && index<m_pdfNoteInfoList.size())
		{
			selectNoteInfos.push_back(GetPdfInfoByIndexExtentFreePen(index));
			ShareLocal2Share(selectNoteInfos);
			m_pLabelOper->DownloadAndSaveLabel();
		}
	}else
	{
		if(index>=0 && index<m_pcloudNote->GetCloudListSize())
		{
			selectNoteInfos.push_back(m_pcloudNote->GetNoteInfoByIndex(index));
			ShareCloud2Share(selectNoteInfos);
			UpdateBookNotes(m_SidebarWidth);
		}
	}

}

void CReaderFrame::NoteSearch()
{

	if(m_bIsSearch)
	{
		m_pNotesFilter->SetEnabled(true);
		if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
		{
			m_ctrMulu->SetVisible(true);
			m_pSearch_layout->SetVisible(false);
			m_bIsSearch=false;
			SetNeedReloadDB();
			GetNoteByCataIndex(m_current_mulu_index);
			m_pMyPDFBook->RedrawLines();
			m_pNotesFilter->SetEnabled(true);
			return;
		}
		else
		{

			m_ctrMulu->SetVisible(true);
			m_pSearch_layout->SetVisible(false);
			m_bIsSearch=false;
			if(m_cata_list.size()<=0)
				m_pcloudNote->SearchCloudNoteByPage(0,9999);
			else
			{
				textbook_catalogInfo& info = m_cata_list.at(m_current_mulu_index);
				m_pcloudNote->SearchCloudNoteByPage(info.startPage,info.endPage);
			}
			//m_pcloudNote->NoteSearch(_T(""));
			UpdateBookNotes(m_SidebarWidth);
		}
		
	}
	else
	{
		m_pNotesFilter->SetEnabled(false);
		search_keyword->SetText(_T(""));
		search_keyword->SetFocus();
		m_ctrMulu->SetVisible(false);
		m_pSearch_layout->SetVisible(true);
		m_bIsSearch=true;
	}
}

void CReaderFrame::NoteImport()
{
	//�Ʊʼ�
	vector<CPDFNoteInfo*> selectNoteInfos;//ѡ�еıʼ��б�
	int index=m_pNoteList->m_current_select_index;
	if(index>=0 && index<m_pcloudNote->GetCloudListSize())
	{
		selectNoteInfos.push_back(m_pcloudNote->GetNoteInfoByIndex(index));
		int nRet =ImportNoteToLocal(selectNoteInfos,NOTE_CLOUD);
		if(nRet ==1)
		{
			CustomMessageBox(L"�Ʊʼǵ���ɹ�",MSG_TYPE_NOTICE,TRUE);
		}else if(nRet ==99)
		{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		}
		else
		{
			CustomMessageBox(L"�Ʊʼǵ���ʧ��",MSG_TYPE_NOTICE,FALSE);
		}
		SetNeedReloadDB();
		m_pMyPDFBook->RedrawLines();

	}
}

void CReaderFrame::CreateFolder()
{
	if(!theApp.AnalysisConnect())
	{
		return;
	}
	if(!CheckHasTarget())
	{
		return ;
	}
	CShareteacherAddFolderFrame* pAddFolderFrame= new CShareteacherAddFolderFrame(m_pShareNote,m_pBookInfo->strGrade);
	pAddFolderFrame->Create(m_hWnd, _T("ShareteacherAddFolderFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
	pAddFolderFrame->CenterWindow();
	if (IDOK == pAddFolderFrame->ShowModal())
	{
		
		//���ﴦ������Ҫ�½��ļ��е��߼�
		
		if(m_pFolderControl->CreateCloudFolder(pAddFolderFrame->m_fileName,pAddFolderFrame->m_datetime,pAddFolderFrame->m_select_classinfo,L"Task"))
		{
			GetShareNote();
			ShowShareNote(m_SidebarWidth);
			
			CustomMessageBox(L"��������ɹ�",MSG_TYPE_NOTICE,TRUE);
			if(ComboShareSelect->GetCurSel()==0)
			ComboShareSelect->SelectItem(1);
			////���////////
			CString strServerID=L"";
			theApp.m_EventLog.init();
			theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_CREATE_FOLDER);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_FOLDER_WAY,L"1");
			CString strClass=L"";
			for(int n=0;n<pAddFolderFrame->m_select_classinfo.size();n++)
			{
				TARGET_INFO_SON classdata =pAddFolderFrame->m_select_classinfo.at(n);
				strClass +=classdata.name;
				if(n!=(pAddFolderFrame->m_select_classinfo.size()-1))
				{
					strClass +=L",";
				}
			}
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_TARGET,strClass);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,pAddFolderFrame->m_fileName);
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_EXPIRY_TIME,pAddFolderFrame->m_datetime);
			theApp.m_EventLog.MakeJsonFormat();
			////////////////
		}
		else
		{
			
				CustomMessageBox(L"��������ʧ��",MSG_TYPE_NOTICE,FALSE);
		}
	}
}
void CReaderFrame::ModifyFolder(CShareFolder* info)
{
	if(theApp.AnalysisConnect())
	{
		if(info)
		{
			CShareteacherAddFolderFrame* pAddFolderFrame= new CShareteacherAddFolderFrame(m_pShareNote,m_pBookInfo->strGrade,info,1);
			pAddFolderFrame->Create(m_hWnd, _T("ShareteacherAddFolderFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
			pAddFolderFrame->CenterWindow();
			if (IDOK == pAddFolderFrame->ShowModal())
			{
				//���ﴦ������Ҫ�½��ļ��е��߼�
				if(m_pShareNote->UpdateCloudFolder(pAddFolderFrame->m_info->m_id,pAddFolderFrame->m_fileName,pAddFolderFrame->m_datetime))
				{
					ShowShareNote(m_SidebarWidth);
					CustomMessageBox(L"�����޸ijɹ�",MSG_TYPE_NOTICE,TRUE);

				}
				else
				{
					CustomMessageBox(L"�����޸�ʧ��",MSG_TYPE_NOTICE,FALSE);
				}
			}
		}
	}
	else
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);

}


LRESULT CReaderFrame::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if(m_nRedrawTime>0)
	{
		m_pMyPDFBook->RedrawLines();
		m_nRedrawTime--;
	}else
	{
		KillTimer(m_hWnd,1);
		m_pMyPDFBook->RedrawLines();
	}
	
	bHandled = TRUE;
	return 0;
}
void CReaderFrame::SetShowNoteIcon( CPDFNoteInfo* info,CString& imagePath )
{
	COleDateTime datetime;
	COleDateTime currentTime;
	SYSTEMTIME sysTm;
	::GetLocalTime(&sysTm);
	currentTime.SetDateTime(sysTm.wYear,sysTm.wMonth,sysTm.wDay,sysTm.wHour,sysTm.wMinute,sysTm.wSecond);
	if (datetime.ParseDateTime(info->updateTime.GetBuffer(0)))
	{
		COleDateTimeSpan tMinute = currentTime - datetime;  // ������������ʱ��IJ�ֵ
		int second = (int)tMinute.GetTotalSeconds();
		if (second>0 && second<=3)
		{
			int pos = imagePath.ReverseFind(_T('.'));
			if(pos>0)
			{
				imagePath=imagePath.Mid(0,pos)+_T("_s")+imagePath.Mid(pos,imagePath.GetLength()-pos);
			}
		}
	}
	info->updateTime.ReleaseBuffer();
}
BOOL CReaderFrame::CopyToClipboard(wchar_t* pszData, const int nDataLen)
{
	if(::OpenClipboard(NULL))
	{
		::EmptyClipboard();
		HGLOBAL clipbuffer;
		wchar_t *buffer;
		clipbuffer = ::GlobalAlloc(GMEM_DDESHARE,  2 * lstrlen(pszData) + sizeof(wchar_t));
		buffer = (wchar_t *)::GlobalLock(clipbuffer);
		wcscpy_s(buffer,nDataLen+1,pszData);

		//strcpy(buffer, buffer);
		::GlobalUnlock(clipbuffer);
		::SetClipboardData(CF_UNICODETEXT, clipbuffer);
		::CloseClipboard();
		return TRUE;

	}
	return FALSE;
}
void CReaderFrame::ShowAndHideMultyOption(NOTE_SHOW_TYPE type)
{
	bool bb=false;
	if(type==NOTE_SHOW_TYPE::LOCAL_NOTE_SHOW)
	{
		if(m_pdfNoteInfoList.size()==0)
			bb=true;
		else
		{
			for (int i=0;i<m_pdfNoteInfoList.size();i++)
			{
				CPDFNoteInfo* info = m_pdfNoteInfoList.at(i);
				if(info->noteOrigin==ORIGIN_USER)
				{
					bb=false;
					break;
				}
			}
		}
	}
	else if(type==NOTE_SHOW_TYPE::CLOUD_NOTE_SHOW)
	{
		if(m_pcloudNote->GetCloudListSize()==0)
			bb=true;
	}
	if(bb)
	{
		m_pOptionLocalNoteUpload->SetEnabled(false);
		m_pOptionLocalNoteShare->SetEnabled(false);
		m_pOptionLocalNoteDelete->SetEnabled(false);
		m_pOptionDownNote->SetEnabled(false);
	}
	else
	{
		m_pOptionLocalNoteUpload->SetEnabled(true);
		m_pOptionLocalNoteShare->SetEnabled(true);
		m_pOptionLocalNoteDelete->SetEnabled(true);
		m_pOptionDownNote->SetEnabled(true);
	}
}

void CReaderFrame::SetCurSel( int index )
{
	if(index>=0 && index<m_pdfNoteInfoList.size())
	{
		CPDFNoteInfo* info = m_pdfNoteInfoList.at(index);
		DataGetByPage(info->pageIndex-1);
		for (int i=0;i<m_pdfNoteInfoList_drawPdf.size();i++)
		{
			CPDFNoteInfo* temp = m_pdfNoteInfoList_drawPdf.at(i);
			if(temp->id== info->id)
				m_curSelNote=i;
		}
	}
}

void CReaderFrame::GetNoteByPage( int page )
{
	ClearPdfNoteList_left();
	//CNoteDao noteDao(m_pBookInfo->bookId);
	int cata_index =getCurrentMuluIndexByPage(page);
	if(cata_index<0)
		m_current_mulu_index=0;
	else
		m_current_mulu_index=cata_index;
	GetNoteByCataIndex(m_current_mulu_index);
	UpdateBookNotes(m_SidebarWidth);
}

void CReaderFrame::GetNoteByCataIndex( int index )
{
	if (m_bIsSearch)
	{
		
		//CNoteDao NoteDao(m_pBookInfo->bookId);
		m_pdfNoteInfoList=m_noteDao->ContentAndTextSelect(m_strSearchKey,FALSE);

	}
	else if(m_bIsSelect)
	{
		CString strNoteType;
		CString strLineType;
		int nSPage =m_search_condition.m_startPage;
		int nEPage =m_search_condition.m_endPage;
		if(nSPage <0)
		{
			nSPage =0;
		}
		if(nEPage <0)
		{
			nEPage =1000;
		}
		CString StartTime =m_search_condition.m_startDate;
		CString EndTime =m_search_condition.m_endDate;

		//CNoteDao NoteDao(m_pBookInfo->bookId);
		NoteTypeVectorToString(m_search_condition.m_select_note_type,m_search_condition.m_select_note_line_type,strNoteType,strLineType);
		m_pdfNoteInfoList=m_noteDao->IntegrationSelect(nSPage,nEPage,StartTime,EndTime,strNoteType,strLineType,m_search_condition.m_select_label_id);
		//SetNeedReloadDB();
		//m_pMyPDFBook->RedrawLines();
	}
	else
	{
		if(index<0)
			index=0;
		ClearPdfNoteList_left();
		//CNoteDao noteDao(m_pBookInfo->bookId);
		if(index==0)
			m_noteDao->GetNoteInfosByCatalog(0,1000,m_pBookInfo->bookId,m_pdfNoteInfoList);
		else
		{
			textbook_catalogInfo& info = m_cata_list.at(index);
			m_noteDao->GetNoteInfosByCatalog(info.startPage-1,info.endPage-1,m_pBookInfo->bookId,m_pdfNoteInfoList);
		}
	}
	if(isUpload || isShare || isDelete)
		UpdateBookNotes(m_SidebarWidth,TRUE);
	else
		UpdateBookNotes(m_SidebarWidth);
}

void CReaderFrame::ClearPdfNoteList_left()
{
	for (int i=m_pdfNoteInfoList.size()-1;i>=0;i--)
	{
		CPDFNoteInfo* info = m_pdfNoteInfoList.at(i);
		if(info)
		{
			delete info;
			info=NULL;
		}
	}
	m_pdfNoteInfoList.clear();
}

int CReaderFrame::GetTureIndex_Share2Me( int index )
{
	CShareFolderList* list = m_pShareNote->m_share_to_me_list.at(m_share_note_operator->m_select_index);
	int temp=-1;
	for (int i=0;i<list->m_folder_list.size();i++)
	{
		CShareFolder* info = list->m_folder_list.at(i);
		if(info->m_note_list.size()>0)
			temp++;
		if(temp==index)
		{
			temp=i;
			break;
		}
	}
	return temp;
}

void CReaderFrame::ShareFolderGoBack()
{
	m_pShareNote->CleraSecondfolderList();
	m_pShareNote->CleraSecondnoteList();

	m_bIsShowStudentSubmit=false;
	CButtonUI* pButton=static_cast<CButtonUI*>(m_pm.FindControl(_T("show_hide_share_student")));
	if(pButton)
	{
		pButton->SetText(_T("��ʾ�ύ���"));
		CHorizontalLayoutUI* submit_ok= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_ok")));
		CHorizontalLayoutUI* submit_no= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_no")));
		submit_ok->SetVisible(false);
		submit_no->SetVisible(false);

	}
	m_pSidebarTabLayout->SetVisible(true);
	m_pShareStudentFolderLayout->SetVisible(false);
	m_bShareTwoCancel=false;
	m_bShareTwoImport=false;
	COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes")));
	COptionUI* quxiao=static_cast<COptionUI*>(m_pm.FindControl(_T("share_notes_back")));
	if(import->IsSelected())
		import->Selected(false);
	if(quxiao->IsSelected())
		quxiao->Selected(false);

	CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
	CLabelUI* text_two=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num_two")));
	text_two->SetText(_T("��ѡ��0���ʼ�"));
	h_operator->SetVisible(false);
	m_pMyPDFBook->RedrawLines();
}

CString CReaderFrame::GetFileIconPath( CPDFNoteInfo* info )
{
	CString img=theApp.GetCurDir();
	if(info)
	{
		ResourceType type = info->GetResType(info->content);
		if(info->pdfNoteType==NoteDoc)
			img+=_T("RES//file_icon//word.png");
		else if(info->pdfNoteType==NoteExcel)
			img+=_T("RES//file_icon//excel.png");
		else if(info->pdfNoteType==NotePpt)
			img+=_T("RES//file_icon//ppt.png");
		else if(info->pdfNoteType==NotePdf)
			img+=_T("RES//file_icon//pdf.png");
		else
			img+=_T("RES//file_icon//qita.png");
	}
	return img;
}

void CReaderFrame::RealoadNote(int page)
{
	int index=getCurrentMuluIndexByPage(page);
	if(index!=m_current_mulu_index)
	{
		m_current_mulu_index=index;
		GetNoteByCataIndex(m_current_mulu_index);
		m_ctrMulu->SelectItem(m_current_mulu_index);
	}
}
 
void CReaderFrame::SaveAttachFile2Local( CString FileName )
{
	int pos = FileName.ReverseFind(_T('\\'));
	CString name = FileName.Mid(pos+1,FileName.GetLength()-pos-1);
	 CWnd* pWnd = CWnd::FromHandle(m_pMyPDFBook->GetHWND());
	 CString defaultDir = L"D:";	//Ĭ�ϴ򿪵��ļ�·��
	CFileDialog dlg(FALSE, //TRUEΪOPEN�Ի���FALSEΪSAVE AS�Ի���
		defaultDir,
		name,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		(LPCTSTR)_TEXT("ȫ���ļ� (*.*)|*.*|ͼ���ļ� (*.jpg,*.jpeg,*.png,*.gif,*.bmp)|*.jpg;*.jpeg;*.png;*.gif;*.bmp|��Ƶ�ļ� (*.mp3,*.wav)|*.mp3;*.wav|��Ƶ�ļ� (*.mpeg,*.wmv,*.mp4)|*.mpeg;*.wmv;*.mp4|Flash�ļ�(*.flv)|*.flv||"),
		pWnd);
	if(dlg.DoModal()==IDOK)
	{
		CString path = dlg.GetPathName();
		CopyFile(theApp.GetCurDir()+FileName,path,false);
	}
	//BOOL isOpen = FALSE;		//�Ƿ��(����Ϊ����)
	//CString defaultDir = L"E:\\FileTest";	//Ĭ�ϴ򿪵��ļ�·��
	//CString fileName = L"test.doc";			//Ĭ�ϴ򿪵��ļ���
	//CString filter = L"�ļ� (*.doc; *.ppt; *.xls)|*.doc;*.ppt;*.xls||";	//�ļ����ǵ�����
	//CFileDialog openFileDlg(isOpen, _T(""), _T(""), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T(""), NULL);
	//openFileDlg.GetOFN().lpstrInitialDir = L"E:\\FileTest\\test.doc";
	//INT_PTR result = openFileDlg.DoModal();
	//CString filePath = defaultDir + "\\" + fileName;
	//if(result == IDOK) {
	//	filePath = openFileDlg.GetPathName();
	//}
}

string CReaderFrame::searchHttp(string src) 
{
	string res = src;
	regex reg1("(com|cn|net|jsp|aspx|html|htm|php)((https?|ftp|file)://|www.)");
	regex reg2("((https?|ftp|file):\/\/|www\.)((https?|ftp|file):\/\/|www\.)");
	regex reg("((https?|ftp|file):\/\/|www\.)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]\.(com|cn|net|jsp|aspx|html|htm|php)");
	smatch r1;
	//cout << boolalpha << regex_match(src, r1, reg) << endl;//true
	//cout << "s1ƥ������" << r1.str() << endl;
	//cout << endl;
	//cout << "iterator�����" << endl;
	//sregex_iterator it(src.begin(), src.end(), reg);
	//sregex_iterator end;
	//for (; it != end; ++it)
	//{
	//cout << it->str() << endl;
	//string substr = "{f 1}{a ";
	//substr = substr + it->str() +"}" + it->str() + "{/a}{/f}";
	//int idx = res.find(it->str());
	//res.insert(idx, substr);
	//cout << *it << endl; ����
	//}
	res = regex_replace(res, reg1, "$1 $2");
	res = regex_replace(res, reg2, "$1 $3");
	res = regex_replace(res,reg,"{a $&}$&{/a}");
	res = "{f 0}"+res+"{/f}";
	return res;
}

void CReaderFrame::AddClassInfo2ComboCtrl()
{
	if(m_pShareNote)
	{
		m_ctrlClass->RemoveAll();
		CListLabelElementUI* element=new CListLabelElementUI;
		element->SetText(_T("ȫ���༶"));
		element->SetTag(-1);
		m_ctrlClass->Add(element);
		//m_class_list=m_pShareNote->GetClasses(m_pBookInfo->strGrade);
		for(int i=0;i<theApp.m_target_info.target_list.size();i++)
		{
			CListLabelElementUI* element_temp=new CListLabelElementUI;

			TARGET_INFO_SON& info = theApp.m_target_info.target_list.at(i);
			element_temp->SetText(info.name);
			element_temp->SetTag(UINT_PTR(*info.strID));
			m_ctrlClass->Add(element_temp);
		}
		m_ctrlClass->SelectItem(0);
		
	}
	
}

void CReaderFrame::SpreadFolder( int id )
{
	m_pShareNote->ModifyIsSpread(id);
	COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes")));
	if(import->IsSelected())
		ShowShareNoteTwo(true);
	else
		ShowShareNoteTwo(false);
}

BOOL CReaderFrame::GetFreepenlineforPreView(vector<CPDFNoteInfo*> &NoteList,CPDFNoteInfo* NoteInfo)
{

		//��ȡ����
			BOOL bRet=FALSE;
			NoteInfo->m_free_pen_line.clear();
			if(!theApp.AnalysisConnect())
			{
				CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
				return bRet;
			}
			CStringA strTemp;
			
			strTemp =GetFreepenCoord(NOTE_SHARE,NoteInfo->ShareID);
			if(strTemp.IsEmpty())
			{
				return bRet;
			}
			int res=m_pShareNote->GetFreePenCoord(NoteInfo,strTemp.GetBuffer(strTemp.GetLength()));
			strTemp.ReleaseBuffer();
			if(res<0)
			{
				return bRet;
			}
			if(-1==CoordChange(NoteInfo))
			{
					return bRet;
			}
	
		for(int nNum=0;nNum<NoteInfo->m_free_pen_line.size();nNum++)
		{
			CPDFNoteInfo* Note =new CPDFNoteInfo;
			FREE_PEN_INFO* FreePenLine =NoteInfo->m_free_pen_line.at(nNum);
			//Note->id =NoteInfo->id;
			Note->fid =NoteInfo->id;
			Note->pdfNoteType=NoteFreedom;
			Note->pageIndex =NoteInfo->pageIndex;
			//���ʱʼ���Ϣ
			Note->coord =FreePenLine->coord;
			DWORD dwColor;
			theApp.IDToColor(dwColor,FreePenLine->lineColor);
			Note->lineColor=dwColor;
			Note->lineWidth=FreePenLine->lineWidth;
			Note->lineType=LineNone;
			Note->noteOrigin=ORIGIN_USER;
			//////////////
			NoteList.push_back(Note);
		}
		bRet = TRUE;
		return bRet;
}
bool isFileExist(std::string dir,int type)
{
	DWORD dwAttrib = GetFileAttributesA(dir.c_str()); 
	if(type==0)
		return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
	else
		return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);

}
bool creatBookRootDir(std::string rootPath)
{
	bool bRet=false;
	if (_mkdir(rootPath.c_str()) == 0)
		bRet=true;
	return bRet;
}
CString CReaderFrame::GetFilepathforPreview(CPDFNoteInfo* CloudNotes)
{
	//����
	CString TempPath;
	TempPath.Format(L"%s\\PreViewFileTemp\\%lld.*",theApp.GetCurDir(),CloudNotes->ServerID);
	CFunction fun;
	string basepath=fun.UnicodeToAscii(theApp.GetCurDir()+L"\\PreViewFileTemp");
	if(!isFileExist(basepath,0))//���BOOKID DIR �Ƿ����
	{
		creatBookRootDir(basepath);//�����鼮��Ŀ¼
	}
	//   ����ɾ���ļ������ļ���    
	CFileFind   ff;    
	BOOL bFound = ff.FindFile(TempPath, 0);
	BOOL bExist=FALSE;
	if(bFound)
	{
		bExist=TRUE;
	}
	//���ظ�����ָ��λ��
	CURL_download down;
	CString strName=L"";
	CString strSaveName=L"";
	CString strSavePath=L"";
	int nPos =CloudNotes->content.ReverseFind('/');
	strName =CloudNotes->content.Mid(nPos+1,CloudNotes->content.GetLength());
	int pos = CloudNotes->content.ReverseFind('.');
	CString	strFileType = CloudNotes->content;
	if (pos > 0)
	{
		strFileType =CloudNotes->content.Right(strFileType.GetLength() - pos - 1);
	}else
	{
		return L"";
	}
	
	int nRet=1;
	strSavePath.Format(L"%sPreViewFileTemp\\%lld.%s",theApp.GetCurDir(),CloudNotes->ServerID,strFileType);
	if(!bExist)
	{
		
		   std::vector<CPDFNoteInfo*> NoteCopy;
			CPDFNoteInfo *Notes =new CPDFNoteInfo;
			*Notes =*CloudNotes;

			NoteCopy.push_back(Notes);
		

		//Notes = CloudNotes.at(0);
		//Notes.assign(*CloudNotes.begin(),*CloudNotes.end());
		m_th.AddDownLoadFileToQueue(NoteCopy,1);
		if(m_th.m_DownloadNoteFile_List.size()>0)
		{
			//���������̣߳��������ȿ�
			if(StartDownNote()==0)
			{
				return strSavePath;
			}
			else
			{
				
				CustomMessageBox(L"����ʧ�ܣ�������",MSG_TYPE_NOTICE,FALSE);
				DeleteFile(strSavePath);
				DWORD dd  =GetLastError();
				return L"";
			}
		}
		
	}else
	{
		return strSavePath;
	}


	
}
void CReaderFrame::OpenSeeNote( CPDFNoteInfo* info )
{
	if(info->pdfNoteType==NotePdf || info->pdfNoteType==NotePpt || info->pdfNoteType==NoteExcel || info->pdfNoteType==NoteDoc || info->pdfNoteType==NoteImage || info->pdfNoteType==NoteVideo || info->pdfNoteType==NoteAudio || info->pdfNoteType==NoteFile || info->pdfNoteType==NoteLink)
	{
		if(!theApp.AnalysisConnect())
		{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
			return;
		}
		else
		{
			CString path=_T("");//�������㷵�ص���Դ·��
			path = GetFilepathforPreview(info);
			CPreviewNoteFrame* NoteFrame = new CPreviewNoteFrame(info,path);
			NoteFrame->Create(this->GetHWND(), _T("PreviewNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
			NoteFrame->CenterWindow();
			NoteFrame->ShowModal();
		}
	}
	if(info->pdfNoteType==NoteTextBox)
	{
		CString path=_T("");//�������㷵�ص���Դ·��
		CPreviewNoteFrame* NoteFrame = new CPreviewNoteFrame(info,path);
		NoteFrame->Create(this->GetHWND(), _T("PreviewNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		NoteFrame->CenterWindow();
		NoteFrame->ShowModal();
	}
	if(info->pdfNoteType==NoteLine)
	{
		CPreviewLineNoteFrame* NoteFrame = new CPreviewLineNoteFrame(info);
		NoteFrame->Create(this->GetHWND(), _T("PreviewLineNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);
		NoteFrame->CenterWindow();
		NoteFrame->ShowModal();
	}
	if(m_bIsSeeNote)
	{
		////���////////
		theApp.m_EventLog.init();
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_VIEW_STD_DETIAL);
		int nPage =  info->pageIndex;
		CString strPage;
		strPage.Format(L"%d",nPage);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
		if(info->pdfNoteType==NoteFreedom||info->pdfNoteType==NoteLine)
		{
			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,L"");
		}else
		{

			theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_POS,info->coord);
		}
		int nType=0;
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_FILENAME,info->strClassId);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_STD_NAME,info->userName);
		nType =g_pFrame->GetLogNoteType(info->pdfNoteType);
		CString strType;
		strType.Format(L"%d",nType);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TYPE,strType); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_EXPAND,info->noteText);
		CString strLabeData=L"",strShareID=L"";
		strShareID.Format(L"%lld",info->ShareID);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_SHARE_SERVER_SHAREID,strShareID);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_TAG,L"");
		CString strData=info->content;

		strData.Replace(_T("\\"),_T("\\\\"));
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_CREATE_OTHER,strData);
		theApp.m_EventLog.MakeJsonFormat();
		////////////////

	}
}

void CReaderFrame::MultySelect()
{
	CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
	CHorizontalLayoutUI* h_bottom_operator_share=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
	if(h_operator->IsVisible() || h_bottom_operator_share->IsVisible())
	{
		//m_pNoteList->SetSelecterOption();
		CLabelUI* text=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num")));
		CLabelUI* text_two=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num_two")));
		if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW || m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)//���رʼ�
		{
			std::vector<CPDFNoteInfo*> select_list;
			m_pNoteList->GetSelectItems(m_pdfNoteInfoList,select_list);
			int allCount = m_pNoteList->GetCount();
			int size=select_list.size();
			if(allCount!=size)
			{
				COptionUI* note_choice_all=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
				if(note_choice_all->IsSelected())
				{
					m_bIsNeedModifySelectAll = true;
					note_choice_all->Selected(false);
					m_bIsNeedModifySelectAll = false;
				}
			}
			else
			{
				COptionUI* note_choice_all=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all")));
				if(!note_choice_all->IsSelected())
					note_choice_all->Selected(true);
			}
			CString str;
			str.Format(_T("��ѡ��%d���ʼ�"),size);
			text->SetText(str);
		}
		else if(m_pNoteList->GetCurrentType()==SHARE_NOTE_SHOW)
		{
			CHorizontalLayoutUI* two_h=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("show_share_folder_student")));
			if(two_h->IsVisible())//����ҳ��
			{
				vector<int> index_list;
				m_pFolderList->GetSelectItems(index_list);
				CString str;
				str.Format(_T("��ѡ��%d���ʼ�"),index_list.size());
				text_two->SetText(str);

				int allCount = m_pFolderList->GetCount();
				int size=index_list.size();
				if(allCount!=size)
				{
					COptionUI* note_choice_all_two=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all_two")));
					if(note_choice_all_two->IsSelected())
					{
						m_bIsNeedModifySelectAll = true;
						note_choice_all_two->Selected(false);
						m_bIsNeedModifySelectAll = false;
					}
				}
				else
				{
					COptionUI* note_choice_all_two=static_cast<COptionUI*>(m_pm.FindControl(_T("note_choice_all_two")));
					if(!note_choice_all_two->IsSelected())
						note_choice_all_two->Selected(true);
				}
			}
			else//һ��ҳ��
			{
				std::vector<int> list;
				m_pNoteList->GetSelectItems(list);
				CString str;
				str.Format(_T("��ѡ��%d���ʼ�"),list.size());
				text->SetText(str);
			}
			//CLabelUI* text=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num")));



		}
	}
}

void CReaderFrame::ClearShareNoteTwoOperator()
{
	CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator_share")));
	COptionUI* import=static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes")));
	COptionUI* quxiao=static_cast<COptionUI*>(m_pm.FindControl(_T("share_notes_back")));
	CLabelUI* text_two=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num_two")));
	text_two->SetText(_T("��ѡ��0���ʼ�"));
	m_bShareTwoImport=false;
	m_bShareTwoCancel=false;
	h_operator->SetVisible(false);
	if(import->IsSelected())
		import->Selected(false);
	if(quxiao->IsSelected())
		quxiao->Selected(false);
	ShowShareNoteTwo();
}

void CReaderFrame::ClearShareNoteOperator()
{
	COptionUI* share_down_notes_one = static_cast<COptionUI*>(m_pm.FindControl(_T("share_down_notes_one")));
	COptionUI* share_back_note = static_cast<COptionUI*>(m_pm.FindControl(_T("share_back_note")));
	COptionUI* share_note_move = static_cast<COptionUI*>(m_pm.FindControl(_T("share_note_move")));
	

	share_down_notes_one->Selected(false);
	share_back_note->Selected(false);
	share_note_move->Selected(false);
	m_bCancel=false;
	m_bMove=false;
	m_bImport=false;


	CHorizontalLayoutUI* h_operator=static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_bottom_operator")));
	h_operator->SetVisible(false);

	CLabelUI * select_num=static_cast<CLabelUI*>(m_pm.FindControl(_T("multi_select_note_num")));
	select_num->SetText(_T("��ѡ��0���ʼ�"));

}

int CReaderFrame::StartDownNote()
{
	int iRet=-1;

	CDownFrame dlg(&m_th,1,CWnd::FromHandle(m_hWnd));
	m_th.StartDownload();
	if(dlg.DoModal()==IDOK)
	{
		iRet=0;//�������
	}
	else
	{
		iRet=-1;//����ȡ��
	}
	//cwnd.Detach();
	return iRet;
}

void CReaderFrame::ShowFreeLineFrame()
{
	SetPenAndColor(NOTES_FREEDOM, GetPenColor());
	int cx = GetSystemMetrics(SM_CXSCREEN);
	int cy = GetSystemMetrics(SM_CYSCREEN);
	int nWidth =433/theApp.m_screen_ratio;
	int nHeight =268/theApp.m_screen_ratio;

	if(m_freeLineFrame)
	{
			m_freeLineFrame->SetWindowPos(NULL,cx-120-nWidth,cy-120-nHeight,nWidth,nHeight,1);
		m_freeLineFrame->ShowWindow(true);
		isShowFreePen=true;
	}
}

int CReaderFrame::GetLogNoteType(int nType)
{
	int nLogType=0;
	switch (nType)
	{
	case NoteLine:
		nLogType =1;
		break;
	case NoteTextBox:
		nLogType =7;
		break;
	case NoteFreedom:
		nLogType =13;
		break;
	case NoteLink:
		nLogType =14;
		break;
	case NoteFile:
		nLogType =11;
		break;
	case NoteAudio:
		nLogType =17;
		break;
	case NoteVideo:
		nLogType =18;
		break;
	case NoteImage:
		nLogType =19;
		break;
	default:
		break;
	}
	return nLogType;
}


void CReaderFrame::DoRedirect(CString strURL)
{
	
}
void CReaderFrame::GotoPrePage()
{
	int model=m_pMyPDFBook->GetViewMode();
	int nOrgPageNum=0;
	nOrgPageNum =m_current_page;
	if(model==4)
	{
		m_current_page-=2;
	}
	else
	{
		m_current_page-=1;
	}
	if(m_current_page<=0)
		m_current_page=0;
	m_bIsSetMuluIndex=false;
	SetNeedReloadDB();
	
	////���////////
	theApp.m_EventLog.init();
	CString strPage,strOrgPageNum;
	strPage.Format(L"%d",m_current_page);
	strOrgPageNum.Format(L"%d",nOrgPageNum);
	theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGE_CHANGE);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_CHG_TYPE_WAY,L"1");//1 or 2 or 3
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_PAGE_FROM,strOrgPageNum); 
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
	theApp.m_EventLog.MakeJsonFormat();
	/////////////
	if(IsNeedChangeCatalogue(m_current_page))
	{
		m_current_mulu_index=getCurrentMuluIndexByPage(m_current_page);
		GetNoteByCataIndex(m_current_mulu_index);
		m_ctrMulu->SelectItem(m_current_mulu_index);
		if(m_isShowResourceUi)
			m_ctrResourceMulu->SelectItem(m_current_mulu_index);
	}
	GoToPage(m_current_page);
	
	//m_bIsSetMuluIndex=true;
	//if(IsNeedChangeCatalogue(m_current_page))
	//	m_ctrMulu->SelectItem(m_current_mulu_index);

	if(m_current_page==1)
	{
		m_pdfToolFrame->SetPreButtonEnable(false);
	}
	m_pdfToolFrame->SetNextButtonEnable(true);
}

void CReaderFrame::GotoNextPage()
{
	int model=m_pMyPDFBook->GetViewMode();
	int nOrgPageNum=0;
	nOrgPageNum =m_current_page;
	int nPage =m_current_page;
	if(model==4)
		nPage+=2;
	else
		nPage+=1;
	m_bIsSetMuluIndex=false;
	//
	//m_current_mulu_index=getCurrentMuluIndexByPage(nPage);
	//SetNeedReloadDB();
	////���////////
	theApp.m_EventLog.init();
	CString strPage,strOrgPageNum;
	strPage.Format(L"%d",nPage);
	strOrgPageNum.Format(L"%d",nOrgPageNum);
	theApp.m_EventLog.SetLogEvent(EVENT_BOOK_PAGE_CHANGE);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_CHG_TYPE_WAY,L"1");//1 or 2 or 3
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE_PAGE_FROM,strOrgPageNum); 
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_PAGE,strPage);
	theApp.m_EventLog.MakeJsonFormat();
	if(IsNeedChangeCatalogue(nPage))
	{
		m_current_mulu_index=getCurrentMuluIndexByPage(nPage);
		m_ctrMulu->SelectItem(m_current_mulu_index);
		if(m_isShowResourceUi)
			m_ctrResourceMulu->SelectItem(m_current_mulu_index);
		if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
		{
			GetNoteByCataIndex(m_current_mulu_index);
		}
		else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
		{
			if(m_current_mulu_index<0)
				m_current_mulu_index=0;
			if(m_cata_list.size()>m_current_mulu_index)
			{
				textbook_catalogInfo& info = m_cata_list.at(m_current_mulu_index);
				m_pcloudNote->LoadFromDB(info.startPage,info.endPage);
				UpdateBookNotes(m_SidebarWidth);
			}

		}
	}
	
	GoToPage(nPage);

	/////////////
	//m_current_page =nPage;
	m_bIsSetMuluIndex=true;
	int total=m_pMyBook->GetPageCount();
	if(nPage==total-1)
	{
		m_pdfToolFrame->SetNextButtonEnable(false);
	}
	m_pdfToolFrame->SetPreButtonEnable(true);

}

void CReaderFrame::SetPageOperatorView( bool bFlag )
{
	CVerticalLayoutUI* ver_preImage= static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("ver_preImage")));
	CVerticalLayoutUI* ver_nextImage= static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("ver_nextImage")));
	if(bFlag)
	{
		m_pdfToolFrame->ShowWindow(true);
		m_btn_prePage->SetVisible(false);
		m_btn_nextPage->SetVisible(false);
		ver_preImage->SetVisible(false);
		ver_nextImage->SetVisible(false);
	}
	else
	{
		m_pdfToolFrame->ShowWindow(false);
		m_btn_prePage->SetVisible(true);
		m_btn_nextPage->SetVisible(true);
		ver_preImage->SetVisible(true);
		ver_nextImage->SetVisible(true);
	}
}
void CReaderFrame::SetShareTwoListSize()
{
	CHorizontalLayoutUI* submit_ok= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_ok")));
	CHorizontalLayoutUI* submit_no= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("share_student_submit_no")));
	int allHeight = (submit_ok->GetHeight()+submit_no->GetHeight());
	//int height=700/theApp.m_screen_ratio;
	CHorizontalLayoutUI* h_share_folder_list= static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("h_share_folder_list")));
	if(!submit_ok->IsVisible())
	{
		allHeight=0;
	}
	else
	{
		if(allHeight==0)
		{
			if(theApp.m_screen==1)
				allHeight+=250;
			else if(theApp.m_screen==2)
				allHeight+=200;
			else if(theApp.m_screen==3)
				allHeight+=350;
			else
				allHeight+=170;
		}
		else
			allHeight+=30;
	}
	
	if(theApp.m_screen==1)
		h_share_folder_list->SetFixedHeight(740-allHeight);
	else if(theApp.m_screen==2)
		h_share_folder_list->SetFixedHeight(600-allHeight);
	else if(theApp.m_screen==3)
		h_share_folder_list->SetFixedHeight(1150-allHeight);
	else 
		h_share_folder_list->SetFixedHeight(510-allHeight);
	


}

void CReaderFrame::Enable( bool bFlag )
{
	COptionUI* local = static_cast<COptionUI*>(m_pm.FindControl(_T("note_own")));
	COptionUI* cloud = static_cast<COptionUI*>(m_pm.FindControl(_T("note_list")));
	COptionUI* share = static_cast<COptionUI*>(m_pm.FindControl(_T("note_folder")));
	local->SetEnabled(bFlag);
	cloud->SetEnabled(bFlag);
	share->SetEnabled(bFlag);

	
}



BOOL CReaderFrame::ParsePageExercise(CString strBookId,std::string strRsult,ListExercise& exerciselist)
{
	if(strRsult.length()==0)
	{
		return FALSE;
	}
	CFunction func;
	rapidjson::Document doc;
	rapidjson::StringStream inputStream(func.StringToChar(strRsult));  //����һ��������
	doc.ParseStream<0>(inputStream);
	//Json::Reader reader;//json����  
	//Json::Value value;//��ʾһ��json��ʽ�Ķ���
	int nIconDL_Flag=FALSE;
	//if (reader.parse(strRsult, value))
	//{
	rapidjson::Value value;
	int res=0;
	if(doc.HasMember("code"))
	{
		value =doc["code"];
		res = value.GetInt();
	}
	

	
	if (res != 1)
	{
		//m_Log.WriteLog(_T("Get Book List Failed!"));
		return FALSE;
	}
	int nPageHeight=0;
	int nPageWidth=0;
	rapidjson::Value head;
	head= doc["data"];
	if(head.HasMember("page_height"))
	{
		nPageHeight = head["page_height"].GetInt();
	}
	if(head.HasMember("page_width"))
	{
	nPageWidth = head["page_width"].GetInt();
	}
	rapidjson::Value exercises;
	exercises= head["pages"];
	CString LocalPath;
	for (int i = 0; i < exercises.Size(); i++)
	{

		//Page 
		EXERCISE_INFO info;
		rapidjson::Value item;
		item= exercises[i]["icons"];

		for(int n=0;n<item.Size();n++)
		{
			if(item[n].HasMember("act"))
			{
				const char* act = item[n]["act"].GetString();
				info.fileAct = func.AsciiToUnicode(act);
			}
			if(item[n].HasMember("icon"))
			{
			const char* icon = item[n]["icon"].GetString();
			info.itemIcon = func.AsciiToUnicode(icon);
			}
			//һ����ֻ��һ������

			if(nIconDL_Flag==FALSE)
			{
				CURL_download dl;
				int nPos = info.itemIcon.ReverseFind('.');
				CString strType =info.itemIcon.Mid(nPos,info.itemIcon.GetLength());
				CString strPath=theApp.GetCurDir()+L"Res\\"+strBookId+strType;
				dl.downloadfile(func.UnicodeToAscii(info.itemIcon),func.UnicodeToAscii(strPath),1000);
				LocalPath =strPath;
				nIconDL_Flag=TRUE;
			}
			info.itemIcon = LocalPath;
			if(item[n].HasMember("x"))
			{
				info.x =item[n]["x"].GetInt();
			}
			if(item[n].HasMember("y"))
			{
			info.y =item[n]["y"].GetInt();
			}
			if(item[n].HasMember("w"))
			{
			info.w =item[n]["w"].GetInt();
			}
			if(item[n].HasMember("h"))
			{
			info.h =item[n]["h"].GetInt();
			}
			info.pageheight =nPageHeight;
			info.pagewidth =nPageWidth;
		}
		if(exercises[i].HasMember("page"))
		{
			info.page =exercises[i]["page"].GetInt();
		}

		exerciselist.push_back(info);
	}
	//}
}

BOOL CReaderFrame::NetWorkAndTokenCheck()
{
	BOOL bRet=FALSE;
	if(!theApp.AnalysisConnect())
	{
		CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
		return bRet;
	}
	string strret="";
	if(RemoteCheckToken(strret)==200)
	{
		bRet=TRUE;
	}
	return bRet;
}

BOOL CReaderFrame::CheckHasTarget()
{
	if(theApp.m_UserInfo.iUserType==2)
	{
		if((theApp.m_target_info.id<=0))
		{
			CustomMessageBox(L"�DZ�ѧ�ڽ̲��޷�ʹ�ù�������",MSG_TYPE_NOTICE,FALSE);
			return FALSE ;
		}
	}else
	{
		if((theApp.m_target_info.id<=0)||(theApp.m_target_info.target_list.size()<=0))
		{
			CustomMessageBox(L"�DZ�ѧ�ڽ̲��޷�ʹ�ù�������",MSG_TYPE_NOTICE,FALSE);
			return FALSE ;
		}
	}
	return TRUE;
}

bool CReaderFrame::IsNeedChangeCatalogue( int page )
{
	bool bRet=true;
	if(m_current_mulu_index>=0 && m_current_mulu_index<m_cata_list.size())
	{
		textbook_catalogInfo& info = m_cata_list.at(m_current_mulu_index);
		if(page>=info.startPage && page<=info.endPage)
			bRet=false;
	}
	return bRet;
}

int CReaderFrame::GetCurrentSelByInfoId( int id )
{
	int nRet=-1;
	for (int i=0;i<m_pdfNoteInfoList_drawPdf.size();i++)
	{
		CPDFNoteInfo* info = m_pdfNoteInfoList_drawPdf.at(i);
		if(info->id==id)
		{
			nRet=i;
			break;
		}
	}
	return nRet;
}

void CReaderFrame::FilterNote()
{
	BOOL bIsCloud=FALSE;
	if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)//����жϱ��ػ�����
	{
		bIsCloud=TRUE;
	}
	if(m_pNotesFilter->IsSelected())
	{
		//m_pNotesFilter->Selected(false);
		notes_search_option->SetEnabled(true);
		m_bIsSelect=false;
		m_ctrMulu->SetVisible(true);
		CHorizontalLayoutUI* mulu_hide = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("mulu_hide")));
		mulu_hide->SetVisible(false);
		
		if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
		{				

			SetNeedReloadDB();
			GetNoteByCataIndex(m_current_mulu_index);
			m_pMyPDFBook->RedrawLines();
			return;
		}
		else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
		{
			bIsCloud =TRUE;
			//CComboUI* ComboMulu_Resource=static_cast<CComboUI*>(m_pm.FindControl(_T("ComboMulu_Resource")));
			int index = m_ctrMulu->GetCurSel()-1;
			if(index<0)
			{
				index=0;
			}
			if(m_cata_list.size()>0)
			{
				textbook_catalogInfo& info = m_cata_list.at(index);
				m_pcloudNote->LoadFromDB(info.startPage,info.endPage);
				
			}
			else
				m_pcloudNote->LoadFromDB(0,9999);
			//Mark By Ray 2018-12-18
			//GetCloudNote();
			// 					 if(m_th.m_isNeedReLogin)
			// 					 {
			// 						 CloseApplication(1);
			// 					 }
			///////////////////////
			UpdateBookNotes(m_SidebarWidth);
			return;
		}
	}
	m_search_condition.ClearAllCondition();
	CSearchNoteFrame* searchNoteFrame= new CSearchNoteFrame(m_pLabelOper,m_pBookDao,m_pBookInfo->bookId,m_search_condition,bIsCloud);
	searchNoteFrame->Create(m_hWnd, _T("SearchNoteFrame"), UI_WNDSTYLE_DIALOG, 0L, 0,0,0,0, NULL);

	////���////////
	int nType=0;
	if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
	{
		nType =1;
	}else
	{
		nType=2;
	}
	CString strType=L"";
	strType.Format(L"%d",nType);
	theApp.m_EventLog.init();
	theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_FILTER_OPEN);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_CHG_MODEL,strType); 
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILTER_OPEN_CLOSE,L"1"); 
	theApp.m_EventLog.MakeJsonFormat();
	/////////////
	searchNoteFrame->CenterWindow();
	if(IDOK == searchNoteFrame->ShowModal())
	{
		notes_search_option->SetEnabled(false);
		ClearPdfNoteList_left();
		m_bIsSelect=true;
		m_ctrMulu->SetVisible(false);
		CHorizontalLayoutUI* mulu_hide = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("mulu_hide")));
		mulu_hide->SetVisible(true);
		m_search_condition=searchNoteFrame->m_condition;
		//CNoteDao NoteDao(m_pBookInfo->bookId);
		int nSPage =searchNoteFrame->m_condition.m_startPage;
		int nEPage =searchNoteFrame->m_condition.m_endPage;
		if(nSPage <0)
		{
			nSPage =0;
		}
		if(nEPage <0)
		{
			nEPage =1000;
		}
		CString StartTime =searchNoteFrame->m_condition.m_startDate;
		CString EndTime =searchNoteFrame->m_condition.m_endDate;
		CString strNoteType;
		CString strLineType;
		if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
		{
			NoteTypeVectorToString(searchNoteFrame->m_condition.m_select_note_type,searchNoteFrame->m_condition.m_select_note_line_type,strNoteType,strLineType);
			m_pdfNoteInfoList=m_noteDao->IntegrationSelect(nSPage,nEPage,StartTime,EndTime,strNoteType,strLineType,searchNoteFrame->m_condition.m_select_label_id);
			UpdateBookNotes(m_SidebarWidth);
			m_pMyPDFBook->RedrawLines();
		}else if(m_pNoteList->GetCurrentType()==CLOUD_NOTE_SHOW)
		{
			m_nStartSearchPage = nSPage;
			m_nEndSearchPage = nEPage;
			NoteTypeVectorToString(searchNoteFrame->m_condition.m_select_note_type,searchNoteFrame->m_condition.m_select_note_line_type,strNoteType,strLineType);
			m_pcloudNote->IntegrationSelectCloud(nSPage,nEPage,StartTime,EndTime,strNoteType,strLineType,searchNoteFrame->m_condition.m_select_label_id);
			//m_pdfNoteInfoList=NoteDao.IntegrationSelectCloud(nSPage,nEPage,StartTime,EndTime,strNoteType,strLineType,searchNoteFrame->m_condition.m_select_label_id);
			UpdateBookNotes(m_SidebarWidth);
			m_pMyPDFBook->RedrawLines();
		}

		////���////////
		int nType=0;
		if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
		{
			nType =1;
		}else
		{
			nType=2;
		}
		CString strType=L"",strCata=L"",strTime=L"";
		strType.Format(L"%d",nType);
		strCata.Format(L"%d,%d",nSPage,nEPage);
		strTime.Format(L"%s,%s",StartTime,EndTime);
		theApp.m_EventLog.init();
		theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_FILTER_SELECT);
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_CHG_MODEL,strType); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILTER_SEARCH_CHAPTERS,strCata); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILTER_SEARCH_TIME,strTime); 
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILTER_SEARCH_TYPE,strNoteType);
		CString strLabel=L"";
		for(int nNum=0;nNum<searchNoteFrame->m_condition.m_select_label_id.size();nNum++)
		{
			int nId =searchNoteFrame->m_condition.m_select_label_id.at(nNum);
			strLabel =m_noteDao->GetLabelNameById(nId);
			if(nNum!=(searchNoteFrame->m_condition.m_select_label_id.size()-1))
			{
				strLabel+=L",";
			}
		}
		theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILTER_SEARCH_TAG,strLabel); 
		theApp.m_EventLog.MakeJsonFormat();
		/////////////
		//AfxMessageBox(_T("���↑ʼɸѡ����"));

	}
	else
	{
		if(!m_pNotesFilter->IsSelected())
		{
			m_pNotesFilter->Selected(true);

		}


	}
	if(searchNoteFrame)
	{
		searchNoteFrame->m_condition.ClearAllCondition();
		delete searchNoteFrame;
		searchNoteFrame=NULL;
	}
	////���////////
	nType=0;
	if(m_pNoteList->GetCurrentType()==LOCAL_NOTE_SHOW)
	{
		nType =1;
	}else
	{
		nType=2;
	}
	strType=L"";
	strType.Format(L"%d",nType);
	theApp.m_EventLog.init();
	theApp.m_EventLog.SetLogEvent(EVENT_BOOK_NOTE_FILTER_OPEN);
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_LIST_CHG_MODEL,strType); 
	theApp.m_EventLog.AddOneEventLog(TITLE_EVENTINFO,KEY_BOOK_NOTE_FILTER_OPEN_CLOSE,L"0"); 
	theApp.m_EventLog.MakeJsonFormat();
}

CString CReaderFrame::GetCurrentMuluLevelCode()
{

	CString strRet=_T("");
	if(m_ctrMulu)
	{
		int index = m_ctrMulu->GetCurSel();
		int size = m_cata_list.size();
		if(index>=1 && size>0)
		{

			if(index<size && index>=0)
			{
				textbook_catalogInfo& info = m_cata_list.at(index);
				strRet = info.strLeverCode;
			}
		}
		else
		{
			for (int i=0;i<size;i++)
			{
				textbook_catalogInfo& info = m_cata_list.at(i);
				if(m_current_page+1>=info.startPage && m_current_page+1<=info.endPage)
				{
					strRet = info.strLeverCode;
				}
			}
		}

	return strRet;
	}
}

void CReaderFrame::GetExtras()
{
	if(!theApp.AnalysisConnect())
	{
			CustomMessageBox(STRING_MSG_NETWORK_ERR,MSG_TYPE_NOTICE,FALSE);
	}
	else
	{
		int index = m_ctrResourceMulu->GetCurSel();
		if(index<=0 || m_cata_list.size()<=0)
			m_extrs->GetResourceByPage(L"",m_current_page,_T(""));
		else
		{
			textbook_catalogInfo& info = m_cata_list.at(index);
			m_extrs->GetResourceByPage(L"",info.startPage,info.strLeverCode);
		}
		AddResTypeElement();
	}
}
void CReaderFrame::HideOrShowPdfToolFrame( bool isshow )
{
	CButtonUI* btn_preImage= static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_preImage")));
	if(isshow)
	{
		if(btn_preImage->IsVisible())
			m_pdfToolFrame->ShowWindow(false);
		else
			m_pdfToolFrame->ShowWindow(true);
	}
	else
	{
		m_pdfToolFrame->ShowWindow(false);
	}

}

#pragma endregion
}