/**************************************************************************\
*
* Copyright (c)  炫彩界面库. All Rights Reserved.
*
* 炫彩界面库 - 官方网站 : http://www.xcgui.com
*
\**************************************************************************/
#include "stdafx.h"

CMainWnd  mainWnd;

BOOL CMainWnd::Create() //创建窗口和按钮
{
	m_SkinIndex=0;
	m_hWindow=XWnd_CreateWindow(0,0,850,600,L"炫彩界面库-窗口",NULL, XC_SY_BORDER | XC_SY_ROUND | XC_SY_CENTER); //创建窗口
	if(m_hWindow)
	{
		XWnd_SetBorderSize(m_hWindow,0,0,0,0);
		XWnd_EnableDragWindow(m_hWindow,TRUE);
		XWnd_SetRoundSize(m_hWindow,9);
		XWnd_EnableBorderStrokeOuter(m_hWindow,FALSE);
		XWnd_EnableBorderStrokeInner(m_hWindow,FALSE);

		HELE hPicTitle=XPic_Create(6,3,121,20,m_hWindow);
		XPic_SetImage(hPicTitle,XImage_LoadFile(L"360image\\title.png"));
		XEle_SetBkTransparent(hPicTitle,TRUE);
		XEle_EnableMouseThrough(hPicTitle,TRUE);

		m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame1.jpg");
		m_hThemeBorder=XImage_LoadFileAdaptive(L"360image\\skin\\framemod_sim.png",12,48,122,166);

		XImage_SetDrawType(m_hThemeBackground,XC_IMAGE_TILE);
		XWnd_SetImageNC(m_hWindow,m_hThemeBackground);
		XWnd_SetImage(m_hWindow,m_hThemeBorder);

		m_hBottomText=XStatic_Create(20,575,100,18,L"炫彩界面库 - 模仿<360安全卫士>软件UI演示程序,www.xcgui.com.",m_hWindow);
		XStatic_AdjustSize(m_hBottomText);
		XEle_SetTextColor(m_hBottomText,RGB(255,255,255));
		XEle_SetBkTransparent(m_hBottomText,TRUE);
		XEle_EnableMouseThrough(m_hBottomText,TRUE);
		RECT rect;
		XEle_GetClientRect(m_hBottomText,&rect);
		m_bottomText_width=rect.right-rect.left;

		//47*22
		m_hBtnClose=XBtn_Create(10,0,47,22,NULL,m_hWindow);
		XEle_SetBkTransparent(m_hBtnClose,TRUE);
		XEle_EnableFocus(m_hBtnClose,FALSE);
		XBtn_SetImageLeave(m_hBtnClose,XImage_LoadFileRect(L"360image\\sys_button_close.png",0,0,47,22));
		XBtn_SetImageStay(m_hBtnClose,XImage_LoadFileRect(L"360image\\sys_button_close.png",47,0,47,22));
		XBtn_SetImageDown(m_hBtnClose,XImage_LoadFileRect(L"360image\\sys_button_close.png",94,0,47,22));

		//44*22
		m_hBtnMax=XBtn_Create(10,0,33,22,NULL,m_hWindow);
		XEle_SetBkTransparent(m_hBtnMax,TRUE);
		XEle_EnableFocus(m_hBtnMax,FALSE);
		XBtn_SetImageLeave(m_hBtnMax,XImage_LoadFileRect(L"360image\\sys_button_max.png",0,0,33,22));
		XBtn_SetImageStay(m_hBtnMax,XImage_LoadFileRect(L"360image\\sys_button_max.png",33,0,33,22));
		XBtn_SetImageDown(m_hBtnMax,XImage_LoadFileRect(L"360image\\sys_button_max.png",66,0,33,22));

		m_hBtnMin=XBtn_Create(10,0,33,22,NULL,m_hWindow);
		XEle_SetBkTransparent(m_hBtnMin,TRUE);
		XEle_EnableFocus(m_hBtnMin,FALSE);
		XBtn_SetImageLeave(m_hBtnMin,XImage_LoadFileRect(L"360image\\sys_button_min.png",0,0,33,22));
		XBtn_SetImageStay(m_hBtnMin,XImage_LoadFileRect(L"360image\\sys_button_min.png",33,0,33,22));
		XBtn_SetImageDown(m_hBtnMin,XImage_LoadFileRect(L"360image\\sys_button_min.png",66,0,33,22));

		m_hBtnMenu=XBtn_Create(10,0,33,22,NULL,m_hWindow);
		XEle_SetBkTransparent(m_hBtnMenu,TRUE);
		XEle_EnableFocus(m_hBtnMenu,FALSE);
		XBtn_SetImageLeave(m_hBtnMenu,XImage_LoadFileRect(L"360image\\title_bar_menu.png",0,0,33,22));
		XBtn_SetImageStay(m_hBtnMenu,XImage_LoadFileRect(L"360image\\title_bar_menu.png",33,0,33,22));
		XBtn_SetImageDown(m_hBtnMenu,XImage_LoadFileRect(L"360image\\title_bar_menu.png",66,0,33,22));

		m_hBtnSkin=XBtn_Create(10,0,22,18,NULL,m_hWindow);
		XEle_SetBkTransparent(m_hBtnSkin,TRUE);
		XEle_EnableFocus(m_hBtnSkin,FALSE);
		XBtn_SetImageLeave(m_hBtnSkin,XImage_LoadFileRect(L"360image\\SkinButtom.png",0,0,22,18));
		XBtn_SetImageStay(m_hBtnSkin,XImage_LoadFileRect(L"360image\\SkinButtom.png",22,0,22,18));
		XBtn_SetImageDown(m_hBtnSkin,XImage_LoadFileRect(L"360image\\SkinButtom.png",44,0,22,18));


		//LOGO
		HELE hPicLogo=XPic_Create(700,35,140,67,m_hWindow);
		XEle_SetBkTransparent(hPicLogo,TRUE);
		XPic_SetImage(hPicLogo,XImage_LoadFile(L"360image\\logo.png"));
		XEle_EnableMouseThrough(hPicLogo,TRUE);

		CreateToolButtonAndPage();//创建页面切换按钮及子页面

		XCGUI_RegEleEvent(m_hBtnClose,XE_BNCLICK,&CMainWnd::OnEventBtnClick_Close);
		XCGUI_RegEleEvent(m_hBtnSkin,XE_BNCLICK,&CMainWnd::OnEventBtnClick_ChangeSkin);

		AdjustLayout();
		XWnd_ShowWindow(m_hWindow,SW_SHOW); //显示窗口
		return TRUE;
	}
	return FALSE;
}

void CMainWnd::AdjustLayout()
{
	RECT rect;
	XWnd_GetClientRect(m_hWindow,&rect);

	RECT rc=rect;
	rc.left++;
	rc.right--;
	rc.top =110;
	rc.bottom-=26;

	XEle_SetRect(m_page1.m_hEle,&rc);
	XEle_SetRect(m_page2.m_hEle,&rc);
	XEle_SetRect(m_page3.m_hEle,&rc);
	XEle_SetRect(m_page5.m_hEle,&rc);
	XEle_SetRect(m_page9.m_hEle,&rc);

	m_page1.AdjustLayout();
	m_page2.AdjustLayout();
	m_page9.AdjustLayout();

	rc.left=10;
	rc.right=rc.left+m_bottomText_width;
	rc.top=rect.bottom-23;
	rc.bottom=rc.top+18;
	XEle_SetRect(m_hBottomText,&rc);

	rc.top=0;
	rc.right=rect.right-5;
	rc.left=rc.right-47;
	rc.bottom=rc.top+22;
	XEle_SetRect(m_hBtnClose,&rc);

	rc.right=rc.left;
	rc.left=rc.right-33;
	XEle_SetRect(m_hBtnMax,&rc);

	rc.right=rc.left;
	rc.left=rc.right-33;
	XEle_SetRect(m_hBtnMin,&rc);

	rc.right=rc.left;
	rc.left=rc.right-33;
	XEle_SetRect(m_hBtnMenu,&rc);

	rc.right=rc.left-5;
	rc.left=rc.right-22;
	rc.bottom=18;
	XEle_SetRect(m_hBtnSkin,&rc);
}

void CMainWnd::CreateToolButtonAndPage()
{
	int left=3;
	int top=28;
	m_hImage_check_leave=XImage_LoadFile(L"360image\\toolBar\\toolbar_normal.png");
	m_hImage_check_stay=XImage_LoadFile(L"360image\\toolBar\\toolbar_hover.png");
	m_hImage_check_down=XImage_LoadFile(L"360image\\toolBar\\toolbar_pushed.png");

	HIMAGE hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_Examine.png");
	HELE hRadio1=CreateToolButton(left,top,hIcon,L"电脑体验"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_dsmain.png");
	HELE hRadio2=CreateToolButton(left,top,hIcon,L"查杀木马"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_VulRepair.png");
	HELE hRadio3=CreateToolButton(left,top,hIcon,L"漏洞修复"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_SysRepair.png");
	HELE hRadio4=CreateToolButton(left,top,hIcon,L"系统修复"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_TraceCleaner.png");
	HELE hRadio5=CreateToolButton(left,top,hIcon,L"电脑清理"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_SpeedupOpt.png");
	HELE hRadio6=CreateToolButton(left,top,hIcon,L"优化加速"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_diannaomenzhen.png");
	HELE hRadio7=CreateToolButton(left,top,hIcon,L"电脑门诊"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_softmgr.png");
	HELE hRadio8=CreateToolButton(left,top,hIcon,L"软件管理"); left+=74;
	hIcon=XImage_LoadFile(L"360image\\toolBar\\ico_AdvTools.png");
	HELE hRadio9=CreateToolButton(left,top,hIcon,L"功能大全"); left+=74;

	XBtn_SetCheck(hRadio1,TRUE);

	m_page1.Create();
	m_page2.Create();
	m_page3.Create();
	m_page5.Create();
	m_page9.Create();

	XRadio_SetBindEle(hRadio1,m_page1.m_hEle);
	XRadio_SetBindEle(hRadio2,m_page2.m_hEle);
	XRadio_SetBindEle(hRadio3,m_page3.m_hEle);
	XRadio_SetBindEle(hRadio5,m_page5.m_hEle);
	XRadio_SetBindEle(hRadio9,m_page9.m_hEle);
}

HELE CMainWnd::CreateToolButton(int x,int y,HIMAGE hIcon,wchar_t *pName)
{
	HELE hRadio=XRadio_Create(x,y,74,82,pName,m_hWindow);
	XRadio_EnableButtonStyle(hRadio,TRUE);
	XRadio_SetGroupID(hRadio,1);

	XBtn_SetIcon(hRadio,hIcon);
	XBtn_SetIconAlign(hRadio,XC_ICON_ALIGN_TOP);
	XEle_SetBkTransparent(hRadio,TRUE);
	XEle_SetTextColor(hRadio,RGB(255,255,255));
	XBtn_SetOffset(hRadio,0,-3);

	XRadio_SetImageLeave_UnCheck(hRadio,m_hImage_check_leave);
	XRadio_SetImageStay_UnCheck(hRadio,m_hImage_check_stay);
	XRadio_SetImageDown_UnCheck(hRadio,m_hImage_check_down);

	XRadio_SetImageLeave_Check(hRadio,m_hImage_check_down);
	XRadio_SetImageStay_Check(hRadio,m_hImage_check_down);
	XRadio_SetImageDown_Check(hRadio,m_hImage_check_down);

	XEle_EnableFocus(hRadio,FALSE);
	return hRadio;
}

BOOL CMainWnd::OnEventBtnClick_Close(HELE hEle,HELE hEleEvent) //按钮点击事件响应
{
	if(hEle!=hEleEvent) return FALSE;
	XWnd_CloseWindow(m_hWindow);
	return FALSE;
}

BOOL CMainWnd::OnEventBtnClick_ChangeSkin(HELE hEle,HELE hEleEvent)
{
	if(hEle!=hEleEvent) return FALSE;

	CSkinDlg  *pSkinDlg=new CSkinDlg;
	pSkinDlg->Create();

	return FALSE;
}

//////////////////////////////////////////////
void CXPage1::Create()
{
	m_hEle=XPic_Create(2,110,300,465,mainWnd.m_hWindow);
	XPic_SetImage(m_hEle, XImage_LoadFileAdaptive(L"360image\\page1\\frame_page1.png",5,42,10,60));
	XEle_SetBkTransparent(m_hEle,TRUE);

	HELE    hEleT=NULL;
	HIMAGE  hImageT=NULL;

	//体检结果图片
	HELE hPicRadar=XPic_Create(18,20,126,109,m_hEle);
	XPic_SetImage(hPicRadar,XImage_LoadFile(L"360image\\page1\\Radar0.png"));
	XEle_SetBkTransparent(hPicRadar,TRUE);

	//立即体检上方文字
	HELE hPicText=XPic_Create(155,20,352,93,m_hEle);
	XPic_SetImage(hPicText,XImage_LoadFile(L"360image\\page1\\text1.png"));
	XEle_SetBkTransparent(hPicText,TRUE);

	//立即体检
	HELE hButton=XBtn_Create(200,195,174,72,NULL,m_hEle);
	XBtn_SetImageLeave(hButton,XImage_LoadFile(L"360image\\page1\\button1_leave.png"));
	XBtn_SetImageStay(hButton,XImage_LoadFile(L"360image\\page1\\button1_stay.png"));
	XBtn_SetImageDown(hButton,XImage_LoadFile(L"360image\\page1\\button1_leave.png"));
	XEle_SetBkTransparent(hButton,TRUE);
	XEle_EnableFocus(hButton,FALSE);

	//////////右侧内容//////////////////////////
	//背景
	m_hPane_right=XPic_Create(0,00,100,100,m_hEle);
	XPic_SetImage(m_hPane_right,XImage_LoadFile(L"360image\\page1\\page1_right.png"));
	XEle_SetBkTransparent(m_hPane_right,TRUE);

	//登录我的安全账号
	m_hBtn_all_opened=XBtn_Create(10,10,242,64,NULL,m_hPane_right);
	XBtn_SetImageLeave(m_hBtn_all_opened,XImage_LoadFile(L"360image\\page1\\all_opened.png"));
	XBtn_SetImageStay(m_hBtn_all_opened,XImage_LoadFile(L"360image\\page1\\all_opened_stay.png"));
	XBtn_SetImageDown(m_hBtn_all_opened,XImage_LoadFile(L"360image\\page1\\all_opened.png"));
	XEle_SetBkTransparent(m_hBtn_all_opened,TRUE);
	XEle_EnableFocus(m_hBtn_all_opened,FALSE);

	//文字前面图标
	hEleT=XPic_Create(33,80,18,18,m_hPane_right);
	XPic_SetImage(hEleT,XImage_LoadFile(L"360image\\page1\\reminderdlgflag.png"));
	XEle_SetBkTransparent(hEleT,TRUE);

	//领额外奖励4G云盘空间
	hEleT=XTextLink_Create(53,80,125,18,L"领额外奖励4G云盘空间",m_hPane_right);
	XEle_SetTextColor(hEleT,RGB(26,102,162));
	XEle_SetBkTransparent(hEleT,TRUE);

	//分割
	hEleT=XStatic_Create(175,81,12,18,L"|",m_hPane_right);
	XEle_SetTextColor(hEleT,RGB(128,128,128));
	XEle_SetBkTransparent(hEleT,TRUE);

	//免费注册
	hEleT=XTextLink_Create(188,80,50,18,L"免费注册",m_hPane_right);
	XEle_SetTextColor(hEleT,RGB(230,113,56));
	XEle_SetBkTransparent(hEleT,TRUE);

	//实时防护已开启,动画按钮 54*55
	hEleT=XBtn_Create(15,100,54,55,NULL,m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	int x=0;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),100); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_AddAnimationFrame(hEleT,XImage_LoadFileRect(L"360image\\page1\\state_safe.png",x,0,54,55),200); x+=54;
	XBtn_EnableAnimation(hEleT,TRUE,TRUE);

	//实时防护已开启 文字按钮
	hEleT=XTextLink_Create(75,120,130,25,L"实时防护已开启",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(49,109,30));
	XEle_SetFont(hEleT, XFont_Create2(L"宋体",18,TRUE));
	XTextLink_AdjustSize(hEleT);

	//木马防火墙,图标
	hImageT=XImage_LoadFile(L"360image\\page1\\item_opened.png");
	hEleT=XPic_Create(20,160,37,22,m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XPic_SetImage(hEleT,hImageT);

	//木马防火墙
	hEleT=XTextLink_Create(80,162,60,20,L"木马防火墙",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(49,109,30));

	//进入
	hEleT=XTextLink_Create(220,162,100,20,L"进入",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XTextLink_AdjustSize(hEleT);

	//360保镖,图标
	hEleT=XPic_Create(20,190,37,22,m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XPic_SetImage(hEleT,hImageT);

	//360保镖
	hEleT=XTextLink_Create(80,192,50,20,L"360保镖",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(49,109,30));

	//进入
	hEleT=XTextLink_Create(220,192,100,20,L"进入",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XTextLink_AdjustSize(hEleT);

	//IE主页被锁定,图标
	hImageT=XImage_LoadFile(L"360image\\page1\\item_closed.png");
	hEleT=XPic_Create(20,220,37,22,m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XPic_SetImage(hEleT,hImageT);

	//IE主页被锁定
	hEleT=XTextLink_Create(80,222,75,20,L"IE主页被锁定",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(230,113,56));

	//进入
	hEleT=XTextLink_Create(220,222,100,20,L"进入",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XTextLink_AdjustSize(hEleT);

	/////////图标列表视图////////////////////////
	CreateListView();

	CreateRightBottom(); //列表视下方内容
}	

void  CXPage1::CreateListView()
{
	HELE hListView=XListView_Create(2,260,260,138,m_hPane_right);
	XSView_SetSpacing(hListView,0,0,0,0);
	XListView_SetIconSize(hListView,30,30);
	XListView_SetViewLeftAlign(hListView,0);
	XListView_SetViewTopAlign(hListView,0);
	XListView_SetColumnSpacing(hListView,1);
	XListView_SetItemBorderSpacing(hListView,17,10,17,8);
	XEle_SetBkTransparent(hListView,TRUE);
	XEle_SetBkTransparent(XSView_GetView(hListView),TRUE);

	XListView_AddItem(hListView,L"免费修电脑");
	XListView_AddItem(hListView,L"安全桌面");
	XListView_AddItem(hListView,L"网盾");
	XListView_AddItem(hListView,L"手机卫士");

	XListView_AddItem(hListView,L"测网速");
	XListView_AddItem(hListView,L"开机加速");
	XListView_AddItem(hListView,L"手机助手");
	XListView_AddItem(hListView,L"流量防火墙");

	HXCGUI hImageList=XImageList_Create(50,50);
	XImageList_EnableFixedSize(hImageList,TRUE);
	XListView_SetImageList(hListView,hImageList);
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\360jishi.png"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\360desktop.png"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\360WDMain.png"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\360shoujiweishi.png"));

	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\wangsuceshiqi.png"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\autorun.png"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\360MobileMgr.png"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\recommend\\netmon.png"));

	XListView_SetItemIcon(hListView,-1,0,0);
	XListView_SetItemIcon(hListView,-1,1,1);
	XListView_SetItemIcon(hListView,-1,2,2);
	XListView_SetItemIcon(hListView,-1,3,3);

	XListView_SetItemIcon(hListView,-1,4,4);
	XListView_SetItemIcon(hListView,-1,5,5);
	XListView_SetItemIcon(hListView,-1,6,6);
	XListView_SetItemIcon(hListView,-1,7,7);

	HIMAGE  hImageStay=XImage_LoadFileRect(L"360image\\recommend\\hover_btn.png",64,0,64,68);
	HIMAGE  hImageSelect=XImage_LoadFileRect(L"360image\\recommend\\hover_btn.png",128,0,64,68);
	for (int i=0;i<8;i++)
	{
		XListView_SetItemImageStay(hListView,-1,i,hImageStay);
		XListView_SetItemImageSelect(hListView,-1,i,hImageSelect);
	}

	XSView_EnableVScroll(hListView,FALSE);
}

void  CXPage1::CreateRightBottom()
{
	//免费企业版
	HELE hEleT=XTextLink_Create(20,405,100,20,L"免费企业版",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(26,102,162));
	XTextLink_AdjustSize(hEleT);

	//论坛求助
	hEleT=XTextLink_Create(100,405,100,20,L"论坛求助",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(26,102,162));
	XTextLink_AdjustSize(hEleT);

	//查杀异常恢复
	hEleT=XTextLink_Create(165,405,100,20,L"查杀异常恢复",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(26,102,162));
	XTextLink_AdjustSize(hEleT);

	//360杀毒或AV-C国际评测"最佳"奖项
	hEleT=XTextLink_Create(20,432,100,20,L"360杀毒或AV-C国际评测\"最佳\"奖项",m_hPane_right);
	XEle_SetBkTransparent(hEleT,TRUE);
	XEle_SetTextColor(hEleT,RGB(177,21,6));
	XTextLink_AdjustSize(hEleT);
}

void CXPage1::AdjustLayout()
{
	RECT rect;
	XEle_GetClientRect(m_hEle,&rect);
	
	rect.left=rect.right-265;
	XEle_SetRect(m_hPane_right,&rect);
}

/////////////////////////////////////////////////////////
void CXPage2::Create()
{
	m_hEle=XPic_Create(2,110,300,465,mainWnd.m_hWindow);
	XPic_SetImage(m_hEle, XImage_LoadFileAdaptive(L"360image\\page2\\page.png",10,72,76,190));
	XEle_SetBkTransparent(m_hEle,TRUE);
	XEle_ShowEle(m_hEle,FALSE);

	HELE hButton=XBtn_Create(33,158,140,140,NULL,m_hEle);
	XEle_SetBkTransparent(hButton,TRUE);
	XEle_EnableFocus(hButton,FALSE);
	XBtn_SetImageLeave(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_leave.png"));
	XBtn_SetImageStay(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_stay.png"));
	XBtn_SetImageDown(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_down.png"));

	hButton=XBtn_Create(220,158,140,140,NULL,m_hEle);
	XEle_SetBkTransparent(hButton,TRUE);
	XEle_EnableFocus(hButton,FALSE);
	XBtn_SetImageLeave(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_leave.png"));
	XBtn_SetImageStay(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_stay.png"));
	XBtn_SetImageDown(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_down.png"));

	hButton=XBtn_Create(410,158,140,140,NULL,m_hEle);
	XEle_SetBkTransparent(hButton,TRUE);
	XEle_EnableFocus(hButton,FALSE);
	XBtn_SetImageLeave(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_leave.png"));
	XBtn_SetImageStay(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_stay.png"));
	XBtn_SetImageDown(hButton,XImage_LoadFile(L"360image\\page2\\saomiao_down.png"));
}

void CXPage2::AdjustLayout()
{

}

//////////////////////////////////////////////////////////////////////////
void CXPage3::Create()
{
	m_hEle=XPic_Create(2,110,300,465,mainWnd.m_hWindow);
	XPic_SetImage(m_hEle,XImage_LoadFileAdaptive(L"360image\\page3\\bg.png",446,562,68,105));
	XEle_SetBkTransparent(m_hEle,TRUE);
	XEle_ShowEle(m_hEle,FALSE);

	m_hList=XList_Create(0,64,613,358,m_hEle);
	//XSView_SetSpacing(m_hList,0,0,0,0);
	XEle_EnableBorder(m_hList,FALSE);
	XList_EnableCheckBox(m_hList,TRUE);
	XEle_SetBkTransparent(m_hList,TRUE);
	XEle_SetBkTransparent(XSView_GetView(m_hList),TRUE);
	XList_AddColumn(m_hList,100,L"类型"); //类型
	XList_AddColumn(m_hList,80,L"补丁名称"); //补丁名称
	XList_AddColumn(m_hList,220,L"描述"); //描述
	XList_AddColumn(m_hList,80,L"发布日期"); //发布日期
	XList_AddColumn(m_hList,80,L"状态"); //状态

	wchar_t name[256]={0};
	for (int i=0;i<50;i++)
	{
		wsprintf(name,L"严重 - %d",i+1);
		XList_AddItem(m_hList,name);
		XList_SetItemText(m_hList,i,1,L"KB370050");
		XList_SetItemText(m_hList,i,2,L"Windows 内核提权漏洞");
		XList_SetItemText(m_hList,i,3,L"2012-12-21");
		XList_SetItemText(m_hList,i,4,L"未修复");
	}

	//right
	m_hRichEdit=XRichEdit_Create(625,64,220,358,m_hEle);
	XSView_SetSpacing(m_hRichEdit,0,0,0,0);
	XEle_EnableBorder(m_hRichEdit,FALSE);
	XEle_SetBkTransparent(m_hRichEdit,TRUE);
	XEle_SetBkTransparent(XSView_GetView(m_hRichEdit),TRUE);

	LOGFONT fontInfo;
	XC_InitFont(&fontInfo,L"宋体",12,TRUE);
	XRichEdit_InsertTextEx(m_hRichEdit,L"360系统蓝屏修复\n",0,0,&fontInfo);

	XRichEdit_InsertText(m_hRichEdit,L"在安装微软补丁后，如发生蓝屏或无法\n启动系统等问题，能够更快速帮您轻松\n解决问题，顺利进入系统。\n\n",1,0);

	XRichEdit_InsertTextEx(m_hRichEdit,L"补丁是不是安装的越多越好？\n",5,0,&fontInfo);
	XRichEdit_InsertText(m_hRichEdit,L"不是的。如果安装了不需要安装的补\n丁，不但浪费系统资源，还有可能导致\n系统崩溃。360漏洞修复会根据您电脑\n环境的情况智能安装补丁，节省系统资\n源，保证电脑安全。\n\n",6,0);

	XRichEdit_InsertTextEx(m_hRichEdit,L"360安全卫士\n",12,0,&fontInfo);
	XRichEdit_InsertText(m_hRichEdit,L"打补丁、省带宽，统一管理企业安全。\n",13,0);
}

void CXPage3::AdjustLayout()
{

}

///////////////////////////////////////////////////////////////////////
void CXPage5::Create()
{
	m_hEle=XPic_Create(2,110,300,465,mainWnd.m_hWindow);
	XPic_SetImage(m_hEle,XImage_LoadFileAdaptive(L"360image\\page5\\bg.png",14,215,107,142));
	XEle_SetBkTransparent(m_hEle,TRUE);
	XEle_ShowEle(m_hEle,FALSE);

	HELE hTabBar=XTabBar_Create(5,5,730,31,m_hEle);
	XEle_EnableBorder(hTabBar,FALSE);
	XEle_SetBkTransparent(hTabBar,TRUE);
	XTabBar_SetLabelSpacing(hTabBar,0);
	XTabBar_AddLabel(hTabBar,L"   清理痕迹   ");
	XTabBar_AddLabel(hTabBar,L"   一键清理   ");
	XTabBar_AddLabel(hTabBar,L"   清理垃圾   ");
	XTabBar_AddLabel(hTabBar,L"   清理插件   ");
	XTabBar_AddLabel(hTabBar,L"   清理注册表  ");
	XTabBar_AddLabel(hTabBar,L"   查找大文件  ");

	HIMAGE  hImageLeave = XImage_LoadFileAdaptive(L"360image\\page5\\tab_leave.png",9,103,10,25);
	HIMAGE  hImageStay = XImage_LoadFileAdaptive(L"360image\\page5\\tab_stay.png",9,103,10,25);
	HIMAGE  hImageCheck = XImage_LoadFileAdaptive(L"360image\\page5\\tab_check.png",9,102,8,21);

	for (int i=0;i<6;i++)
	{
		HELE hButton=XTabBar_GetLabel(hTabBar,i);
		XEle_EnableFocus(hButton,FALSE);
		XEle_SetBkTransparent(hButton,TRUE);
		XBtn_SetOffset(hButton,0,3);

		XBtn_SetImageLeave(hButton,hImageLeave);
		XBtn_SetImageStay(hButton,hImageStay);
		XBtn_SetImageDown(hButton,hImageCheck);
		XBtn_SetImageCheck(hButton,hImageCheck);
	}


	HELE hListBox=XListBox_Create(2,100,612,360,m_hEle);
	XListBox_SetItemHeight(hListBox,60);
	XListBox_EnableCheckBox(hListBox,TRUE);
	XEle_SetBkTransparent(hListBox,TRUE);
	XEle_SetBkTransparent(XSView_GetView(hListBox),TRUE);
	XEle_EnableBorder(hListBox,FALSE);

	HIMAGE  hImageIcon = XImage_LoadFile(L"360image\\page5\\1.png");
	HXCGUI  hImageList=XImageList_Create(35,36);
	XImageList_AddImage(hImageList,hImageIcon);
	XListBox_SetImageList(hListBox,hImageList);


	HFONTX hFontInfo=XFont_Create2(L"宋体",12,TRUE);
	wchar_t name[256]={0};
	for (int i=0;i<10;i++)
	{
		XListBox_AddString(hListBox,L"",0);

		wsprintf(name,L"Windows 使用痕迹 - %d",i);
		itemBindEle_  info;
		info.hEle=XStatic_Create(0,0,100,20,name);
		info.left=60;
		info.top=15;
		info.height=20;
		info.width=150;
		XListBox_SetItemBindEle(hListBox,i,&info);
		XEle_SetFont(info.hEle,hFontInfo);
		XEle_SetBkTransparent(info.hEle,TRUE);

		info.hEle=XStatic_Create(0,0,100,20,L"Windows的运行痕迹,打开文档痕迹等.");
		info.left=60;
		info.top=35;
		info.height=20;
		info.width=200;
		XListBox_SetItemBindEle(hListBox,i,&info);
		XEle_SetTextColor(info.hEle,RGB(128,128,128));
		XEle_SetBkTransparent(info.hEle,TRUE);

		info.hEle=XStatic_Create(0,0,100,20,L"重要隐私");
		info.left=480;
		info.top=25;
		info.height=20;
		info.width=60;
		XListBox_SetItemBindEle(hListBox,i,&info);
		XEle_SetTextColor(info.hEle,RGB(255,0,0));
		XEle_SetBkTransparent(info.hEle,TRUE);
	}
}

void CXPage5::AdjustLayout()
{

}


/////////////////////////////////////////////////////////////////////////

void CXPage9::Create()
{
	m_hEle=XPic_Create(2,110,300,465,mainWnd.m_hWindow);
	XEle_ShowEle(m_hEle,FALSE);
	XPic_SetImage(m_hEle, XImage_LoadFileAdaptive(L"360image\\page9\\bg.png",10,340,10,150));
	XEle_SetBkTransparent(m_hEle,TRUE);

	m_hListView=XListView_Create(2,10,844,420,m_hEle);
	XListView_SetIconSize(m_hListView,58,58);
	XListView_SetItemBorderSpacing(m_hListView,16,5,16,8);
	XListView_SetColumnSpacing(m_hListView,10);
	XListView_SetRowSpacing(m_hListView,35);
	XSView_SetSpacing(m_hListView,0,0,0,0);
	XEle_SetBkTransparent(m_hListView,TRUE);
	XEle_SetBkTransparent(XSView_GetView(m_hListView),TRUE);
	XEle_EnableBorder(m_hListView,FALSE);

	HELE hScrollBar=XSView_GetVScrollBar(m_hListView);
	XSBar_EnableScrollButton2(hScrollBar,FALSE);
	XSBar_SetImage(hScrollBar,XImage_LoadFileAdaptive(L"360image\\ScrollBar\\bkg.png",1,15,10,55));//16*65
	XSBar_SetImageLeaveSlider(hScrollBar,XImage_LoadFileAdaptive(L"360image\\ScrollBar\\slider_leave.png",3,13,15,45));
	XSBar_SetImageStaySlider(hScrollBar,XImage_LoadFileAdaptive(L"360image\\ScrollBar\\slider_stay.png",3,13,15,45));
	XSBar_SetImageDownSlider(hScrollBar,XImage_LoadFileAdaptive(L"360image\\ScrollBar\\slider_down.png",3,13,15,45));

	XEle_SetBkTransparent(hScrollBar,TRUE);

	HXCGUI hImageLsit=XImageList_Create(58,58);
	XImageList_EnableFixedSize(hImageLsit,FALSE);
	wchar_t iconName[256]={0};
	for (int i=1;i<28;i++)
	{
		wsprintf(iconName,L"360image\\AppIcon\\%d.png",i);
		XImageList_AddImage(hImageLsit,XImage_LoadFile(iconName));
	}

	XListView_SetImageList(m_hListView,hImageLsit);
	XListView_AddItem(m_hListView,L"360电脑专家",0);
	XListView_AddItem(m_hListView,L"360安全桌面",1);
	XListView_AddItem(m_hListView,L"360游戏盒子",2);
	XListView_AddItem(m_hListView,L"360手机助手",3);
	XListView_AddItem(m_hListView,L"360软件小助手",4);
	XListView_AddItem(m_hListView,L"一键装机",5);
	XListView_AddItem(m_hListView,L"360手机卫士",6);
	XListView_AddItem(m_hListView,L"360手机浏览器",7);
	XListView_AddItem(m_hListView,L"360宽带测速器",8);
	XListView_AddItem(m_hListView,L"360开机加速",9);
	XListView_AddItem(m_hListView,L"默认软件设置",10);
	XListView_AddItem(m_hListView,L"360游戏保险箱",11);
	XListView_AddItem(m_hListView,L"360木马防火墙",12);
	XListView_AddItem(m_hListView,L"360游戏优化器",13);
	XListView_AddItem(m_hListView,L"360流量防火墙",14);
	XListView_AddItem(m_hListView,L"360保镖",15);
	XListView_AddItem(m_hListView,L"强力卸载助手",16);
	XListView_AddItem(m_hListView,L"360断网急救箱",17);
	XListView_AddItem(m_hListView,L"360系统急救箱",18);
	XListView_AddItem(m_hListView,L"360网盾",19);
	XListView_AddItem(m_hListView,L"文件粉碎机",20);
	XListView_AddItem(m_hListView,L"系统服务状态",21);
	XListView_AddItem(m_hListView,L"360隔离沙箱",22);
	XListView_AddItem(m_hListView,L"修复网络(LSP)",13);
	XListView_AddItem(m_hListView,L"网购先赔",24);
	XListView_AddItem(m_hListView,L"CAD病毒专杀",25);
	XListView_AddItem(m_hListView,L"CAD病毒专杀",26);

	HIMAGE hImageStay=XImage_LoadFile(L"360image\\page9\\listView_stay.png");
	HIMAGE hImageSelect=XImage_LoadFile(L"360image\\page9\\listView_select.png");
	for (int i=0;i<28;i++)
	{
		XListView_SetItemImageStay(m_hListView,-1,i,hImageStay);
		XListView_SetItemImageSelect(m_hListView,-1,i,hImageSelect);
	}

	//底部
	m_hBottom=XPic_Create(0,100,100,30,m_hEle);
	XPic_SetImage(m_hBottom,XImage_LoadFileAdaptive(L"360image\\page9\\bottomBar.png",420,450,5,30));
	XEle_SetBkTransparent(m_hBottom,TRUE);

	//添加小工具
	XBtn_Create(625,6,100,28,L"添加小工具",m_hBottom);
	
	//管理
	XBtn_Create(750,6,60,28,L"管理",m_hBottom);

}

void CXPage9::AdjustLayout()
{
	RECT rect;
	XEle_GetClientRect(m_hEle,&rect);

	RECT rc;
	rc.left=20;
	rc.right=rect.right-5;
	rc.top=10;
	rc.bottom=rect.bottom-40;
	XEle_SetRect(m_hListView,&rc);

	rc.top=rc.bottom;
	rc.bottom=rect.bottom-2;
	rc.left=0;
	rc.right=rect.right;
	XEle_SetRect(m_hBottom,&rc);
}

///////////////////////////////////////////////////////////////////////////

void CSkinDlg::Create()
{
	int width=380;
	int height=320;

	RECT rect;
	XEle_GetRect(mainWnd.m_hBtnSkin,&rect);

	POINT pt;
	pt.x=rect.right-width;
	pt.y=rect.bottom;

	HWND hMainWnd=XWnd_GetHWnd(mainWnd.m_hWindow);
	ClientToScreen(hMainWnd,&pt);

	m_hWindow=XWnd_CreateWindow(pt.x,pt.y,width,height,L"Skin",hMainWnd,XC_SY_ROUND);
	XWnd_SetRoundSize(m_hWindow,9);

	XWnd_SetImage(m_hWindow,mainWnd.m_hThemeBackground);
	XWnd_SetImageNC(m_hWindow,mainWnd.m_hThemeBorder);

	HELE hPicTitle=XPic_Create(10,10,360,25,m_hWindow);
	XEle_SetBkTransparent(hPicTitle,TRUE);
	XPic_SetImage(hPicTitle,XImage_LoadFile(L"360image\\skinDlg\\titleBG.png"));
	
	HELE hStaticTitle=XStatic_Create(10,5,100,20,L"更换皮肤",hPicTitle);
	XEle_SetBkTransparent(hStaticTitle,TRUE);
	XEle_SetTextColor(hStaticTitle,RGB(255,255,255));

	m_hListView=XListView_Create(20,45,350,205,m_hWindow);
	XListView_SetIconSize(m_hListView,97,62);
	XListView_SetItemBorderSpacing(m_hListView,3,3,3,3);
	XListView_SetViewLeftAlign(m_hListView,0);
	XListView_SetViewTopAlign(m_hListView,0);
	XEle_SetTextColor(m_hListView,RGB(255,255,255));
	XEle_EnableBorder(m_hListView,FALSE);
	XEle_SetBkTransparent(m_hListView,TRUE);
	XEle_SetBkTransparent(XSView_GetView(m_hListView),TRUE);

	HXCGUI hImageList=XImageList_Create(97,62);
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\skin\\skin1.jpg"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\skin\\skin2.jpg"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\skin\\skin3.jpg"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\skin\\skin4.jpg"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\skin\\skin5.jpg"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\skin\\skin6.jpg"));
	XImageList_AddImage(hImageList,XImage_LoadFile(L"360image\\skin\\skin7.jpg"));

	XListView_SetImageList(m_hListView,hImageList);
	XListView_AddItem(m_hListView,L"默认皮肤",0);
	XListView_AddItem(m_hListView,L"优雅爵士",1);
	XListView_AddItem(m_hListView,L"神秘星空",2);
	XListView_AddItem(m_hListView,L"粉色之恋",3);
	XListView_AddItem(m_hListView,L"奋斗的小鸟",4);
	XListView_AddItem(m_hListView,L"青青世界",5);
	XListView_AddItem(m_hListView,L"古典木纹",6);
	
	HIMAGE  hImageStay=XImage_LoadFile(L"360image\\skinDlg\\listView_stay.png");
	HIMAGE  hImageSelect=XImage_LoadFile(L"360image\\skinDlg\\listView_select.png");
	for (int i=0;i<7;i++)
	{
		XListView_SetItemImageStay(m_hListView,-1,i,hImageStay);
		XListView_SetItemImageSelect(m_hListView,-1,i,hImageSelect);
	}
	XListView_SetSelectItem(m_hListView,-1,mainWnd.m_SkinIndex,TRUE);

	HELE hScrollBar=XSView_GetVScrollBar(m_hListView);
	XEle_SetBkTransparent(hScrollBar,TRUE);
	XSBar_EnableScrollButton2(hScrollBar,FALSE);
	XSBar_SetImageLeaveSlider(hScrollBar,XImage_LoadFileAdaptive(L"360image\\skinDlg\\ScrollBar_leave.png",1,14,10,40));
	XSBar_SetImageStaySlider(hScrollBar,XImage_LoadFileAdaptive(L"360image\\skinDlg\\ScrollBar_stay.png",1,14,10,40));
	XSBar_SetImageDownSlider(hScrollBar,XImage_LoadFileAdaptive(L"360image\\skinDlg\\ScrollBar_stay.png",1,14,10,40));

	XCGUI_RegEleEvent(m_hListView,XE_LISTVIEW_SELECT,&CSkinDlg::OnEventListViewSelect);
	XCGUI_RegWndMessage(m_hWindow,WM_KILLFOCUS,&CSkinDlg::OnWndKillFocus);
	XWnd_ShowWindow(m_hWindow,SW_SHOW);
}

BOOL CSkinDlg::OnEventListViewSelect(HELE hEle,HELE hEventEle,int groupIndex,int itemIndex)
{
	if(itemIndex<0) return FALSE;

	if(mainWnd.m_SkinIndex!=itemIndex) //切换皮肤
	{
		mainWnd.m_SkinIndex=itemIndex;
		switch(itemIndex)
		{
		case 0: mainWnd.m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame1.jpg"); break;
		case 1: mainWnd.m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame2.jpg"); break;
		case 2: mainWnd.m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame3.jpg"); break;
		case 3: mainWnd.m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame4.jpg"); break;
		case 4: mainWnd.m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame5.jpg"); break;
		case 5: mainWnd.m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame6.jpg"); break;
		case 6: mainWnd.m_hThemeBackground=XImage_LoadFile(L"360image\\skin\\frame7.jpg"); break;
		}
		
		XImage_SetDrawType(mainWnd.m_hThemeBackground,XC_IMAGE_TILE);

		XWnd_SetImageNC(mainWnd.m_hWindow,mainWnd.m_hThemeBackground);
		XWnd_SetImageNC(m_hWindow,mainWnd.m_hThemeBackground);

		XWnd_RedrawWnd(mainWnd.m_hWindow);
		XWnd_RedrawWnd(m_hWindow);
	}
	return FALSE;
}

BOOL CSkinDlg::OnWndKillFocus(HWINDOW hWindow)
{
	HWND hWnd=XWnd_GetHWnd(m_hWindow);
	::DestroyWindow(hWnd);
	delete this;
	return TRUE;
}

int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine, int nCmdShow)
{
	XInitXCGUI();

	if(mainWnd.Create())
	{
		XRunXCGUI();
	}
	return 0;
}
