#include "gType.h"
#include "GraphLow.h"
#include "GraphBase.h"
#include "GlobalString.h"
#include "RuntimeData.h"
#include "Runtime.h"
#include "PadInf.h"

#define TextTopOffSet	6
#define ListLineCnt	10
#define IconVcnt	5
#define IconHcnt	10

#define HLineTextRight	780
#define HSpace	33

#define clOdd	clMoneyGreen
#define clEven	clWhiteBlue


const int LeftTitlePoint[8] ={
	20, 100, 200, 320, 	420, 520, 620, 700
};

const int LeftTextPoint[8] ={
	20, 100, 200, 320, 	420, 520, 620, 720
};


void TPadInf::Init()
{
	Tag.Reset();
	Items.Reset();
	IsShow = 0;
	ViewingLevel = 0;
}

void TPadInf::RenderBackGround(void)
{
	RectFillRender(ContentGeometry.Left, ContentGeometry.Top, ContentGeometry.Right, ContentGeometry.Bottom, ContentColor);
}

void TPadInf::RenderBackGround(unsigned int aClr)
{
	RectFillRender(ContentGeometry.Left, ContentGeometry.Top, ContentGeometry.Right, ContentGeometry.Bottom, aClr);
}

void TPadInf::DrawSelf()
{
	RectFillRender(Lv.Caption.Left, Lv.Caption.Top, Lv.Caption.Right, Lv.Caption.Bottom, CaptionColor);
	if(LanguageEnCn==0)
		TextRender_string24(Lv.Caption.Left + 10, Lv.Caption.Top +4, clNearWhite, CaptionColor, "手动控制盘->信息");
	else
		TextRender_string24(Lv.Caption.Left + 10, Lv.Caption.Top +4, clNearWhite, CaptionColor, "Manual Control Unit->Information");
	
	for(int i=0; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);	
}

void TPadInf::DrawTitle(void)
{
	if(LanguageEnCn==0){
		TextRender_string24(LeftTitlePoint[0], Lv.Grid.Top[ 1]+ 4, clNearWhite, "名称");
		TextRender_string24(LeftTitlePoint[1], Lv.Grid.Top[ 1]+ 4, clNearWhite, "盘号");
		TextRender_string24(LeftTitlePoint[2], Lv.Grid.Top[ 1]+ 4, clNearWhite, "已配置");
		TextRender_string24(LeftTitlePoint[3], Lv.Grid.Top[ 1]+ 4, clNearWhite, "空闲");
		TextRender_string24(LeftTitlePoint[4], Lv.Grid.Top[ 1]+ 4, clNearWhite, "启动");
		TextRender_string24(LeftTitlePoint[5], Lv.Grid.Top[ 1]+ 4, clNearWhite, "反馈");
		TextRender_string24(LeftTitlePoint[6], Lv.Grid.Top[ 1]+ 4, clNearWhite, "故障");
		TextRender_string24(LeftTitlePoint[7], Lv.Grid.Top[ 1]+ 4, clNearWhite, "禁止");
	}else{
		TextRender_string24(LeftTitlePoint[0], Lv.Grid.Top[ 1]+ 4, clNearWhite, "Type");
		TextRender_string24(LeftTitlePoint[1], Lv.Grid.Top[ 1]+ 4, clNearWhite, "ID");
		TextRender_string24(LeftTitlePoint[2], Lv.Grid.Top[ 1]+ 4, clNearWhite, "Using");
		TextRender_string24(LeftTitlePoint[3], Lv.Grid.Top[ 1]+ 4, clNearWhite, "Unused");
		TextRender_string24(LeftTitlePoint[4], Lv.Grid.Top[ 1]+ 4, clNearWhite, "Act");
		TextRender_string24(LeftTitlePoint[5], Lv.Grid.Top[ 1]+ 4, clNearWhite, "FBCK");
		TextRender_string24(LeftTitlePoint[6], Lv.Grid.Top[ 1]+ 4, clNearWhite, "FLT.");
		TextRender_string24(LeftTitlePoint[7], Lv.Grid.Top[ 1]+ 4, clNearWhite, "Enabled");
	}
}

void TPadInf::DrawBusPadInf()
{
	int i, x,  PadCnt, NodeCnt, NodeUsingCnt, KeyCnt;
	PadCnt = 0;
	NodeCnt =0;
	NodeUsingCnt = 0;
	for(i=0; i<dHANDCTL_MAX_COUNT; i++){
		if(HandCtlBoard[i].PadIsProhibit ==0){
			PadCnt++;
			KeyCnt = HandCtlBoard[i].KeyCount;
			if( (KeyCnt != 48) && (KeyCnt != 64) && (KeyCnt != 128) ) KeyCnt = 48;
			NodeCnt += KeyCnt;
			for(x=0; x<KeyCnt; x++){
				if(HandCtlBoard[i].KeyHasConfig[x]){
					NodeUsingCnt++;
				}
			}
		}
	}
	const int y = Lv.Grid.Top[ 0]+ 34;
	if(LanguageEnCn==0){
		TextRender_string24(10, y, clNearWhite, "总线盘");
		TextDigitRender2Right24(82, y, clNearWhite, ItemColor, PadCnt);
		TextRender_string24(106, y, clNearWhite, "个.");
		
		TextRender_string24(170, y, clNearWhite, "总计");
		TextDigitRender5Right24(218, y, clNearWhite, ItemColor, NodeCnt);
		TextRender_string24(280, y, clNearWhite, "点.");
		
		TextRender_string24(344, y, clNearWhite, "已配置");
		TextDigitRender5Right24(416, y, clNearWhite, ItemColor, NodeUsingCnt);
		TextRender_string24(476, y, clNearWhite, "点.");
		
		TextRender_string24(570, y, clNearWhite, "空闲");
		TextDigitRender5Right24(618, y, clNearWhite, ItemColor, NodeCnt - NodeUsingCnt);
		TextRender_string24(678, y, clNearWhite, "点.");
	}else{
		TextRender_string24(10, y, clNearWhite, "BusBrd");
		TextDigitRender2Right24(82, y, clNearWhite, ItemColor, PadCnt);
		TextRender_string24(106, y, clNearWhite, "Pcs");
		
		TextRender_string24(170, y, clNearWhite, "Pads");
		TextDigitRender5Right24(218, y, clNearWhite, ItemColor, NodeCnt);
		TextRender_string24(280, y, clNearWhite, "  ");
		
		TextRender_string24(344, y, clNearWhite, "Using");
		TextDigitRender5Right24(416, y, clNearWhite, ItemColor, NodeUsingCnt);
		TextRender_string24(476, y, clNearWhite, "");
		
		TextRender_string24(570, y, clNearWhite, "Unused");
		TextDigitRender5Right24(618, y, clNearWhite, ItemColor, NodeCnt - NodeUsingCnt);
		TextRender_string24(678, y, clNearWhite, "Pcs");
	}
}

void TPadInf::DrawDirectPadInf()
{
	int i, x,  PadCnt, NodeCnt, NodeUsingCnt, KeyCnt;
	PadCnt = 0;
	NodeCnt =0;
	NodeUsingCnt = 0;
	for(i=0; i<dDIRECTCTL_MAX_COUNT; i++){
		if(DirectCtlBoard[i].PadIsProhibit ==0){
			PadCnt++;
			KeyCnt = DirectCtlBoard[i].NodeCount;
			if(KeyCnt != 8){
				KeyCnt = 8;
			}
			NodeCnt += KeyCnt;
			for(x=0; x<KeyCnt; x++){
				if(DirectCtlBoard[i].IsRegisted[x]){
					NodeUsingCnt++;
				}
			}
		}
	}
	const int y = Lv.Grid.Top[ 0]+ 4;
	if(LanguageEnCn==0){
		TextRender_string24(10, y, clNearWhite, "多线盘");
		TextDigitRender2Right24(82, y, clNearWhite, ItemColor, PadCnt);
		TextRender_string24(106, y, clNearWhite, "个.");
		
		TextRender_string24(170, y, clNearWhite, "总计");
		TextDigitRender5Right24(218, y, clNearWhite, ItemColor, NodeCnt);
		TextRender_string24(280, y, clNearWhite, "点.");
		
		TextRender_string24(344, y, clNearWhite, "已配置");
		TextDigitRender5Right24(416, y, clNearWhite, ItemColor, NodeUsingCnt);
		TextRender_string24(476, y, clNearWhite, "点.");
		
		TextRender_string24(570, y, clNearWhite, "空闲");
		TextDigitRender5Right24(618, y, clNearWhite, ItemColor, NodeCnt - NodeUsingCnt);
		TextRender_string24(678, y, clNearWhite, "点.");
	}else{
		TextRender_string24(10, y, clNearWhite, "DirectB");
		TextDigitRender2Right24(82, y, clNearWhite, ItemColor, PadCnt);
		TextRender_string24(106, y, clNearWhite, "Pcs");
		
		TextRender_string24(170, y, clNearWhite, "Pads");
		TextDigitRender5Right24(218, y, clNearWhite, ItemColor, NodeCnt);
		TextRender_string24(280, y, clNearWhite, "  ");
		
		TextRender_string24(344, y, clNearWhite, "Using");
		TextDigitRender5Right24(416, y, clNearWhite, ItemColor, NodeUsingCnt);
		TextRender_string24(476, y, clNearWhite, "Pads");
		
		TextRender_string24(570, y, clNearWhite, "Unused");
		TextDigitRender5Right24(618, y, clNearWhite, ItemColor, NodeCnt - NodeUsingCnt);
		TextRender_string24(678, y, clNearWhite, "Pads");
	}
}

void TPadInf::DrawList(int aIsNotFull)
{
	int i,t,x,y;
	unsigned int tAddr;
	unsigned int ExistCnt, cnt, aP0, UsingKeyCnt;
	unsigned int tClr;
	if(ViewingLevel == 0){
		for(i=0, t=Items.TopInx; (i<8) && (t<Items.Count); i++, t++){
			if(aIsNotFull){
				if(i>=3)return;
			}
			if(Items.Type[t] == 0){
				aP0 = Items.Num[t];
				UsingKeyCnt = HandCtlBoard[aP0].KeyCount;
				if(HandCtlBoard[aP0].PadIsProhibit == 0)tClr = clNearWhite; else tClr = clWhiteGray;
				//Draw Pad Type
				if(LanguageEnCn==0)
					TextRender_string24(LeftTextPoint[0], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "总线");
				else 
					TextRender_string24(LeftTextPoint[0], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "Bus");
				//Draw Pad Num
				TextDigitRender2Right24(LeftTextPoint[1], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, Items.Num[t]+1);
				if( (UsingKeyCnt != 48) && (UsingKeyCnt != 64) && (UsingKeyCnt != 128) ) {
					UsingKeyCnt = 48;
				}
				ExistCnt = 0;
				for(x=0; x<UsingKeyCnt; x++){
					if(HandCtlBoard[aP0].KeyHasConfig[x])ExistCnt++;
				}
				//Draw Registed 
				TextDigitRender3Right24(LeftTextPoint[2], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, ExistCnt);
				//Draw UnRegisted 
				TextDigitRender3Right24(LeftTextPoint[3], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, UsingKeyCnt - ExistCnt);
				
				//Draw Start
				ExistCnt =0;
				for(x=0; x<UsingKeyCnt; x++){
					if(HandCtlBoard[aP0].KeyHasConfig[x] && HandCtlBoard[aP0].KeyState[x])ExistCnt++;
				}
				TextDigitRender3Right24(LeftTextPoint[4], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, ExistCnt);
				//Draw Feed Back
				ExistCnt =0;
				for(x=0; x<UsingKeyCnt; x++){
					if(HandCtlBoard[aP0].KeyHasConfig[x] && HandCtlBoard[aP0].KeyFbState[x])ExistCnt++;
				}
				TextDigitRender3Right24(LeftTextPoint[5], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, ExistCnt);
				//Draw Fault
				ExistCnt =0;
				for(x=0; x<UsingKeyCnt; x++){
					if(HandCtlBoard[aP0].KeyHasConfig[x] && HandCtlBoard[aP0].KeyFbState[x])ExistCnt++;
				}
				TextDigitRender3Right24(LeftTextPoint[6], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, 0);
				//Draw Prohibit
				if(LanguageEnCn==0){
					if(HandCtlBoard[aP0].PadIsProhibit)
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "禁止");
					else
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "    ");
				}else{
					if(HandCtlBoard[aP0].PadIsProhibit)
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "    ");
					else
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "Yes ");
				}
			}else{
				aP0 = Items.Num[t];
				UsingKeyCnt = DirectCtlBoard[aP0].NodeCount;
				if(DirectCtlBoard[aP0].PadIsProhibit == 0)tClr = clNearWhite; else tClr = clWhiteGray;
				//Draw Pad Type
				if(LanguageEnCn==0){
					TextRender_string24(LeftTextPoint[0], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "多线");
				}else{
					TextRender_string24(LeftTextPoint[0], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "Direct");
				}
				//Draw Pad Num
				TextDigitRender2Right24(LeftTextPoint[1], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, Items.Num[t]+1);
				if( (UsingKeyCnt != 8) && (UsingKeyCnt != 8) ) {
					UsingKeyCnt = 8;
				}
				ExistCnt = 0;
				for(x=0; x<UsingKeyCnt; x++){
					if(DirectCtlBoard[aP0].IsRegisted[x])ExistCnt++;
				}
				//Draw Registed 
				TextDigitRender3Right24(LeftTextPoint[2], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, ExistCnt);
				//Draw UnRegisted 
				TextDigitRender3Right24(LeftTextPoint[3], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, UsingKeyCnt - ExistCnt);
				
				//Draw Start
				ExistCnt =0;
				for(x=0; x<UsingKeyCnt; x++){
					if(DirectCtlBoard[aP0].IsRegisted[x] && DirectCtlBoard[aP0].OutputState[x])ExistCnt++;
				}
				TextDigitRender3Right24(LeftTextPoint[4], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, ExistCnt);
				//Draw Feed Back
				ExistCnt =0;
				for(x=0; x<UsingKeyCnt; x++){
					if(DirectCtlBoard[aP0].IsRegisted[x] && DirectCtlBoard[aP0].FeedbackState[x])ExistCnt++;
				}
				TextDigitRender3Right24(LeftTextPoint[5], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, ExistCnt);
				//Draw Fault
				ExistCnt =0;
				for(x=0; x<UsingKeyCnt; x++){
					if(DirectCtlBoard[aP0].IsRegisted[x] && DirectCtlBoard[aP0].FaultState[x])ExistCnt++;
				}
				TextDigitRender3Right24(LeftTextPoint[6], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, ExistCnt);
				//Draw Prohibit
				if(LanguageEnCn==0){
					if(DirectCtlBoard[aP0].PadIsProhibit)
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "禁止");
					else
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "    ");
				}else{
					if(DirectCtlBoard[aP0].PadIsProhibit)
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "    ");
					else
						TextRender_string24(LeftTextPoint[7], Lv.Grid.Top[i+2] + 4, tClr, ItemColor, "Yes ");
				}
			}
		}
	}
}

void TPadInf::Show(void)
{
	RenderBackGround();
	DrawSelf();
	DrawTitle();
	LoadItem();
	DrawDirectPadInf();
	DrawBusPadInf();
	DrawList();	
	Check4Selected();
	IsShow = 1;
}

void TPadInf::FullRedraw(int Prm)
{
	if(Prm == 0){
		RenderBackGround();
		if(ViewingLevel == 0){
			DrawList();	
		}else
		if(ViewingLevel == 1){
			
		}		
	}else{
		RectFillRender(GuiRedrawDataList[1][0], GuiRedrawDataList[1][1], GuiRedrawDataList[1][2], GuiRedrawDataList[1][3], ContentColor);
		if(ViewingLevel == 0){
			for(int i=0; i<5; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			DrawDirectPadInf();
			DrawBusPadInf();
			DrawTitle();
			DrawList(1);	
			Check4Selected();
		}else
		if(ViewingLevel == 1){
			if(LoadedPad.Type == 0){
				BusPadLnk.FullRedraw(Prm);
			}else
			if(LoadedPad.Type == 1){
				DirectPadCfg.FullRedraw(Prm);
			}
		}	
	}
}

TGuiMsgReturn TPadInf::QueryKeyIn(unsigned char aKey)
{
	TGuiMsgReturn aMsg;
	if(LoadedPad.Type == 0){
		aMsg = this->BusPad->KeyIn(aKey);
	}else
	if(LoadedPad.Type == 1){
		aMsg = this->DirectPad->KeyIn(aKey);
	}
	
	if(aMsg == guiMsgReturn){
		return guiMsgReturn;
	}
	return guiMsgNone;
}

TGuiMsgReturn TPadInf::EditKeyIn(unsigned char aKey)
{
	TGuiMsgReturn aMsg;
	//editting
	return guiMsgNone;
}

void TPadInf::ClearSelected(void)
{
	int iT;
	iT = Tag.Inx + 2;
	if(iT > 9)return;
	RectFillRender(Lv.Grid.Left[iT],  Lv.Grid.Top[iT],  Lv.Grid.Left[iT] + Lv.Grid.Right[iT],  Lv.Grid.Top[iT] + 3,  ItemColor);   //draw rectangle
	RectFillRender(Lv.Grid.Left[iT],  Lv.Grid.Top[iT],  Lv.Grid.Left[iT] + 3,  Lv.Grid.Bottom[iT],  ItemColor);   //draw rectangle
	RectFillRender(Lv.Grid.Right[iT] -3,  Lv.Grid.Top[iT],  Lv.Grid.Right[iT],  Lv.Grid.Bottom[iT],  ItemColor);   //draw rectangle
	RectFillRender(Lv.Grid.Left[iT],  Lv.Grid.Bottom[iT] -3,  Lv.Grid.Right[iT],  Lv.Grid.Bottom[iT],  ItemColor);   //draw rectangle
}

void TPadInf::Check4Selected(void)
{
	int iT;
	iT = Tag.Inx + 2;
	if(iT > 9)return;
	RectFillRender(Lv.Grid.Left[iT],  Lv.Grid.Top[iT],  Lv.Grid.Left[iT] + Lv.Grid.Right[iT],  Lv.Grid.Top[iT] + 3,  clBlue);   //draw rectangle
	RectFillRender(Lv.Grid.Left[iT],  Lv.Grid.Top[iT],  Lv.Grid.Left[iT] + 3,  Lv.Grid.Bottom[iT],  clBlue);   //draw rectangle
	RectFillRender(Lv.Grid.Right[iT] -3,  Lv.Grid.Top[iT],  Lv.Grid.Right[iT],  Lv.Grid.Bottom[iT],  clBlue);   //draw rectangle
	RectFillRender(Lv.Grid.Left[iT],  Lv.Grid.Bottom[iT] -3,  Lv.Grid.Right[iT],  Lv.Grid.Bottom[iT],  clBlue);   //draw rectangle
}


TGuiMsgReturn TPadInf::KeyIn(unsigned char aKey)
{
	int ind,i,aIndex, Found;
	unsigned char aP0;
	TGuiMsgReturn aMsg = guiMsgNone;
	TGuiMsgReturn aMsg2Rtn = guiMsgNone;
	//Up or Down One Index___________________
	
	if(ViewingLevel == 0){
		if(VK_LEFT ==aKey){
						
		}else
		if(VK_RIGHT == aKey){

		}else
		if(VK_UP == aKey){
			if(Tag.Inx >0){
				ClearSelected();
				Tag.Inx--;
				Items.Inx--; 
				Check4Selected();
			}else{
				if(Items.Inx >0){
					Items.Inx--;
					Items.TopInx--;
					DrawList();
				}
			}
		}else
		if(VK_DOWN == aKey){
			if(Tag.Inx < 7){
				if(Items.Inx < (Items.Count-1)){
					ClearSelected();
					Tag.Inx++;
					Items.Inx++; 
					Check4Selected();
				}
			}else{
				Tag.Inx = 7;
				if(Items.Inx < (Items.Count-1)){
					Items.Inx++; 
					Items.TopInx++;
					DrawList();
				}
			}
		}else
		if(aKey == VK_TAB){

		}else
		if(aKey == VK_EXECUTE){
				//Open path Device
			if(Items.Count > 0){
				if(Items.Inx < Items.Count){
					if(Items.Type[Items.Inx] == 0){
						LoadedPad.Type = 0;
						LoadedPad.Num = Items.Num[Items.Inx];
						//设置总线盘联动编程
						BusPadLnk.Init(1);
						BusPadLnk.aPanel = &CommonPanel;
						BusPadLnk.IList = &ItemList;
						BusPadLnk.Show();
						BusPadLnk.SetPath(0,LoadedPad.Num+1,1);
						ViewingLevel = 1;
					}else
					if(Items.Type[Items.Inx] == 1){
						LoadedPad.Type = 1;
						LoadedPad.Num = Items.Num[Items.Inx];
						//设置多线盘
						DirectPadCfg.Init(1);
						DirectPadCfg.aPanel = &CommonPanel;
						DirectPadCfg.IList = &ItemList;
						DirectPadCfg.Show();
						DirectPadCfg.SetPath(0,LoadedPad.Num+1,1);
						ViewingLevel = 1;	
					}
				}
			}
		}else
		if(aKey == VK_RETURN){
			aMsg = guiMsgReturn;
		}else{

		}
	}else
	if(ViewingLevel == 1){
		if(LoadedPad.Type == 0){
			if(this->BusPad == nullptr){
				aMsg2Rtn = guiMsgReturn;
			}else{
				aMsg2Rtn = this->BusPad->KeyIn(aKey);
			}
		}else{
			if(this->DirectPad == nullptr){
				aMsg2Rtn = guiMsgReturn;
			}else{
				aMsg2Rtn = this->DirectPad->KeyIn(aKey);
			}
		}
		if(aMsg2Rtn == guiMsgReturn){
			ViewingLevel = 0;
			RenderBackGround();
			DrawSelf();
			DrawTitle();
			DrawDirectPadInf();
			DrawBusPadInf();
			DrawList();
			Check4Selected();
		}
	}
	//____________________________________________________________________<- List View

	return aMsg;
}

void TPadInf::LoadItem(void) 
{
	int i;
	Items.Count = 0;
	for(i=0; i<dDIRECTCTL_MAX_COUNT; i++){
		if(DirectCtlBoard[i].PadIsProhibit == 0){
			Items.Type[Items.Count] = 1;
			Items.Num[Items.Count] = i;
			Items.Count++;
		}
	}
	for(i=0; i<dHANDCTL_MAX_COUNT; i++){
		if(HandCtlBoard[i].PadIsProhibit == 0){
			Items.Type[Items.Count] = 0;
			Items.Num[Items.Count] = i;
			Items.Count++;
		}
	}
}

void TPadInf::ReLoadItem(void) 
{
	int i;
	Items.Count = 0;
	for(i=0; i<dDIRECTCTL_MAX_COUNT; i++){
		if(DirectCtlBoard[i].PadIsProhibit == 0){
			Items.Type[Items.Count] = 1;
			Items.Num[Items.Count] = i;
			Items.Count++;
		}
	}
	for(i=0; i<dHANDCTL_MAX_COUNT; i++){
		if(HandCtlBoard[i].PadIsProhibit == 0){
			Items.Type[Items.Count] = 0;
			Items.Num[Items.Count] = i;
			Items.Count++;
		}
	}
	
	if(Items.Inx >= Items.Count){
		Items.Inx = Items.Count-1;
	}
}

void TPadInf::ClearItem(void) 
{
	Items.Count = 0;
}
		








