Пример #1
0
void
AutoMove(int From, int To, int Num)
{

	if(Num == 1) {
		MakeMove(From, To);
		return;
	}
	AutoMove(From, OTHER(From, To), Num-1);
	MakeMove(From, To);
	AutoMove(OTHER(From, To), To, Num-1);
}
Пример #2
0
static void
AutoMove(int From, int To, int Num)
{
    if (Num == 1) {
	MakeMove(From, To);
	napms(500);
    } else {
	AutoMove(From, OTHER(From, To), Num - 1);
	MakeMove(From, To);
	napms(500);
	AutoMove(OTHER(From, To), To, Num - 1);
    }
}
Пример #3
0
BOOL MessagesDlg::OnInitDialog()
{
	CBaseDialog::OnInitDialog();

	AutoMove(IDC_TAB,0,0,100,0);
	AutoMove(IDC_LAST_CALL,100,0,0,0);
	AutoMove(IDC_CLOSE_ALL,100,0,0,0);
	AutoMove(IDC_TRANSFER,100,0,0,0);
	AutoMove(IDC_HOLD,100,0,0,0);
	AutoMove(IDC_END,100,0,0,0);
	AutoMove(IDC_LIST,0,0,100,80);
	AutoMove(IDC_MESSAGE,0,80,100,20);

	lastCall = NULL;
	tab = &tabComponent;
	
	HICON m_hIcon = theApp.LoadIcon(IDR_MAINFRAME);
	SetIcon(m_hIcon, FALSE);
	
	TranslateDialog(this->m_hWnd);

#ifndef _GLOBAL_VIDEO
	GetDlgItem(IDC_VIDEO_CALL)->ShowWindow(SW_HIDE);
#endif

	CRichEditCtrl* richEdit = (CRichEditCtrl*)GetDlgItem(IDC_MESSAGE);
	richEdit->SetEventMask(richEdit->GetEventMask() | ENM_KEYEVENTS);

	CRichEditCtrl* richEditList = (CRichEditCtrl*)GetDlgItem(IDC_LIST);
    richEditList->SetEventMask(richEdit->GetEventMask() | ENM_MOUSEEVENTS);

	CFont* font = this->GetFont();
	LOGFONT lf;
	font->GetLogFont(&lf);
	lf.lfHeight = 16;
	_tcscpy(lf.lfFaceName, _T("Arial"));
	fontList.CreateFontIndirect(&lf);
	richEditList->SetFont(&fontList);
	lf.lfHeight = 18;
	fontMessage.CreateFontIndirect(&lf);
	richEdit->SetFont(&fontMessage);


	para.cbSize=sizeof(PARAFORMAT2);
	para.dwMask = PFM_STARTINDENT | PFM_LINESPACING | PFM_SPACEBEFORE | PFM_SPACEAFTER;
	para.dxStartIndent=100;
	para.dySpaceBefore=100;
	para.dySpaceAfter=0;
	para.bLineSpacingRule = 5;
	para.dyLineSpacing = 22;
	richEditList->SetParaFormat(para);
	return TRUE;
}
Пример #4
0
// Filter message handlers
BOOL Filter::OnInitDialog()
{
    CResizableDialog::OnInitDialog();
	
	AutoMove(IDC_LIST1, 0, 0, 100, 100);
	AutoMove(IDC_BUTTON5, 100, 0, 0, 0);

	AutoMove(IDC_BUTTON6, 0, 100, 0, 0);
	AutoMove(IDC_BUTTON8, 0, 100, 0, 0);
	AutoMove(IDC_BUTTON9, 0, 100, 0, 0);
	AutoMove(IDC_BUTTON10, 100, 100, 0, 0);

	AutoMove(IDC_COMBO_ENABLED, 0, 100, 0, 0);
	AutoMove(IDC_EDIT1, 0, 100, 0, 0);
	AutoMove(IDC_COMBO5, 0, 100, 0, 0);
	AutoMove(IDC_EDIT4, 0, 100, 0, 0);


	listControl.SetExtendedStyle(listControl.GetExtendedStyle() | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT );
	listControl.ModifyStyle(LVS_SINGLESEL, 0);
	listctrl = (CListCtrl *)GetDlgItem(IDC_LIST1);

	comboOptions.AddString("Exclude");
	comboOptions.AddString("Include");
	comboOptions.SetCurSel(1);

	comboEnabled.AddString("Enabled");
	comboEnabled.AddString("Disabled");
	comboEnabled.SetCurSel(1);

	listControl.InsertColumn(0, _T("Enabled"), LVCFMT_LEFT, 80);
	listControl.InsertColumn(1, _T("Message"), LVCFMT_LEFT,264);
	listControl.InsertColumn(2, _T("Include/Exclude"), LVCFMT_LEFT, 111);
	listControl.InsertColumn(3, _T("Comment"), LVCFMT_LEFT, 140);
	savePropersize(0,80);

	return TRUE;
}
Пример #5
0
int
main(int argc, char **argv)
{
    int NTiles, FromCol, ToCol;

    setlocale(LC_ALL, "");

    switch (argc) {
    case 1:
	NTiles = DEFAULTTILES;
	break;
    case 2:
	NTiles = atoi(argv[1]);
	if (NTiles > MAXTILES || NTiles < MINTILES) {
	    fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
	    ExitProgram(EXIT_FAILURE);
	}
	break;
    case 3:
	if (strcmp(argv[2], "a")) {
	    Usage();
	    ExitProgram(EXIT_FAILURE);
	}
	NTiles = atoi(argv[1]);
	if (NTiles > MAXTILES || NTiles < MINTILES) {
	    fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
	    ExitProgram(EXIT_FAILURE);
	}
	AutoFlag = TRUE;
	break;
    default:
	Usage();
	ExitProgram(EXIT_FAILURE);
    }
#ifdef TRACE
    trace(TRACE_MAXIMUM);
#endif
    initscr();
    if (has_colors()) {
	int i;
	short bg = COLOR_BLACK;
	start_color();
#if HAVE_USE_DEFAULT_COLORS
	if (use_default_colors() == OK)
	    bg = -1;
#endif
	for (i = 0; i < 9; i++)
	    init_pair((short) (i + 1), bg, TileColour[i]);
    }
    cbreak();
    if (LINES < 24) {
	endwin();
	fprintf(stderr, "Min screen length 24 lines\n");
	ExitProgram(EXIT_FAILURE);
    }
    if (AutoFlag) {
	curs_set(0);
	leaveok(stdscr, TRUE);	/* Attempt to remove cursor */
    }
    InitTiles(NTiles);
    DisplayTiles();
    if (AutoFlag) {
	do {
	    noecho();
	    AutoMove(0, 2, NTiles);
	} while (!Solved(NTiles));
	sleep(2);
    } else {
	echo();
	for (;;) {
	    if (GetMove(&FromCol, &ToCol))
		break;
	    if (InvalidMove(FromCol, ToCol)) {
		MvAddStr(STATUSLINE, 0, "Invalid Move !!");
		refresh();
		beep();
		continue;
	    }
	    MakeMove(FromCol, ToCol);
	    if (Solved(NTiles)) {
		MvPrintw(STATUSLINE, 0,
			 "Well Done !! You did it in %d moves", NMoves);
		refresh();
		sleep(5);
		break;
	    }
	}
    }
    endwin();
    ExitProgram(EXIT_SUCCESS);
}
Пример #6
0
int
main(int argc, char **argv)
{
int NTiles, FromCol, ToCol;
unsigned char AutoFlag = 0;

	switch(argc) {
	case 1:
		NTiles = DEFAULTTILES;
		break;
	case 2:
		NTiles = atoi(argv[1]);
		if (NTiles > MAXTILES || NTiles < MINTILES) {
			fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
			exit(1);
		}
		break;
	case 3:
		if (strcmp(argv[2], "a")) {
			Usage();
			exit(1);
		}
		NTiles = atoi(argv[1]);
		if (NTiles > MAXTILES || NTiles < MINTILES) {
			fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES);
			exit(1);
		}
		AutoFlag = TRUE;
		break;
	default:
		Usage();
		exit(1);
	}
#ifdef NCURSES_VERSION
	trace(TRACE_MAXIMUM);
#endif
	initscr();
	if (!has_colors()) {
		endwin();
		puts("terminal doesn't support color.");
		exit(1);
	}
	start_color();
	{
	int i;
	for (i = 0; i < 9; i++)
		init_pair(i+1, COLOR_BLACK, TileColour[i]);
	}
	cbreak();
	if (LINES < 24) {
		endwin();
		fprintf(stderr, "Min screen length 24 lines\n");
		exit(1);
	}
	if(AutoFlag)
		leaveok(stdscr, TRUE);	/* Attempt to remove cursor */
	InitTiles(NTiles);
	DisplayTiles();
	if(AutoFlag) {
		do {
			noecho();
			AutoMove(0, 2, NTiles);
		} while(!Solved(NTiles));
		sleep(2);
	} else {
		for(;;) {
			if(GetMove(&FromCol, &ToCol))
				break;
			if(InvalidMove(FromCol, ToCol)) {
				mvaddstr(STATUSLINE, 0, "Invalid Move !!");
				refresh();
				beep();
				continue;
			}
			MakeMove(FromCol, ToCol);
			if(Solved(NTiles)) {
				mvprintw(STATUSLINE, 0, "Well Done !! You did it in %d moves", NMoves);
				refresh();
				sleep(5);
				break;
			}
		}
	}
	curs_set(1);
	endwin();
	exit(0);
}
Пример #7
0
BOOL CMsgSignalSelect::OnInitDialog()
{
	CDialog::OnInitDialog();
	//m_omImageList1 = new CImageList();
	bCreateImageList();
	// use the initial dialog size as the default minimum
	if ((m_szMinimum.cx == 0) && (m_szMinimum.cy == 0))
	{
		CRect rcWindow;
		GetWindowRect(rcWindow);
		m_szMinimum = rcWindow.Size();
	}
	AutoMove(IDC_TREE_LIN, 0, 0, 100.0, 100.0); 
	AutoMove(IDOK, 100.0, 100.0, 0.0, 0.0); 
	AutoMove(IDCANCEL, 100.0, 100.0, 0.0, 0.0); 
	// keep the initial size of the client area as a baseline for moving/sizing controls
	CRect rcClient;
	GetClientRect(rcClient);
	m_szInitial = rcClient.Size();

	pTreeStruct = (CTreeCtrl*)GetDlgItem(IDC_TREE_LIN);

	/* Remove the style */
	pTreeStruct->ModifyStyle( TVS_CHECKBOXES, 0 );
	/* Now explicitly set it */
	pTreeStruct->ModifyStyle( 0, TVS_CHECKBOXES ); 
	if( NULL == pTreeStruct )
	{

		return FALSE;
	}

	HTREEITEM hNumofChannel,hmsg,sig;
	for(int i=0;i < m_ouCluster.m_nChannelsConfigured;i++)
	{
		hNumofChannel=pTreeStruct->InsertItem("Channel 1");	
		pTreeStruct->SetItemImage(hNumofChannel, 4, 4);
		list<FRAME_STRUCT> lstNumofFrames;
		m_ouCluster.m_ouFlexChannelConfig[0].m_ouClusterInfo.GetFrames(lstNumofFrames);
		pTreeStruct->SetImageList(&m_omImageList, TVSIL_NORMAL);

		list<FRAME_STRUCT>::iterator itr= lstNumofFrames.begin();
		while(itr != lstNumofFrames.end())
		{
			hmsg=pTreeStruct->InsertItem(itr->m_strFrameName.c_str(),hNumofChannel);
			pTreeStruct->SetItemImage(hmsg, 3, 3);

			int selkey = -1;
			if ( m_mapMsgIDtoSignallst[i].find(itr->m_nSlotId) != m_mapMsgIDtoSignallst[i].end() )
			{
				selkey=m_mapMsgIDtoSignallst[i].find(itr->m_nSlotId)->first;
			}

			if(selkey == itr->m_nSlotId)
			{
				pTreeStruct->SetCheck(hNumofChannel);
				pTreeStruct->SetCheck(hmsg);
			}

			pTreeStruct->SetItemData(hmsg,itr->m_nSlotId);
			list<SIGNAL_STRUCT> ouSignalList;
			itr->GetSignalList(ouSignalList);
			list<SIGNAL_STRUCT>:: iterator itr_sig=ouSignalList.begin();
			while(itr_sig != ouSignalList.end())
			{ 
				sig=pTreeStruct->InsertItem(itr_sig->m_strSignalName.c_str(),hmsg);

				pTreeStruct->SetItemImage(sig, 0, 0);
				if(selkey == itr->m_nSlotId)
				{
					if ( m_mapMsgIDtoSignallst[i].find(itr->m_nSlotId) != m_mapMsgIDtoSignallst[i].end() )
					{
						list<string> lstSignals=m_mapMsgIDtoSignallst[i].find(itr->m_nSlotId)->second;
						list<string>:: iterator itrselSignals= lstSignals.begin();

						while(itrselSignals != lstSignals.end())
						{
							string signame=pTreeStruct->GetItemText(sig);
							if(strcmpi(pTreeStruct->GetItemText(sig),(*itrselSignals).c_str())== 0)
							{
								pTreeStruct->SetCheck(sig);
							}
							itrselSignals++;
						}
					}
				}

				itr_sig++;
			}

			itr++;
		}

	}
	pTreeStruct->Expand(hNumofChannel,TVE_EXPAND);
	//vTest(pTreeStruct);
	return TRUE;

	// CTree message handlers
}
Пример #8
0
Файл: haino.c Проект: shixv/test
    int
main(int argc, char **argv)
{
    int NTiles, FromCol, ToCol,opt;
    unsigned char AutoFlag = 0;
    if(argc<2 || argc>3){ Usage();exit(0);}
    while( (opt=getopt(argc,argv,"a:n:h") )!=-1)
        switch (opt)
        {
            case 'n':
                NTiles = atoi(optarg);
                if (NTiles > MAXTILES || NTiles < MINTILES)
                {   fprintf(stderr, "步数从 %d 自 %d之间\n", MINTILES, MAXTILES);
                    return EXIT_FAILURE;
                }
                AutoFlag = FALSE;
                break;
            case 'a':
                NTiles = atoi(optarg);
                if (NTiles > MAXTILES || NTiles < MINTILES)
                {       fprintf(stderr, "步数从 %d 自 %d之间\n", MINTILES, MAXTILES);
                    return EXIT_FAILURE;
                }
                AutoFlag = TRUE;
                break;
            case 'h':
            case '?':
            case ':':
                Usage();
                exit(0);
        }
    initscr();
    if (has_colors())
    {
        int i;
        int bg = COLOR_BLACK;
        start_color();
        if (use_default_colors() == OK)
            bg = -1;
        for (i = 0; i < 9; i++)
            init_pair(i + 1, bg, TileColour[i]);
    }
    cbreak();
    /*LINES和COLS是Curses内部变量,用于存储当前终端的行数和列数*/
    if (LINES < 24 || COLS < 80)          /*标准的终端为24行80列*/
    {
        endwin();
        fprintf(stderr, "当前小于 24x80 \n");
        return EXIT_FAILURE;
    }
    if (AutoFlag)
    {
        curs_set(0);
        leaveok(stdscr, TRUE);
    }
    InitTiles(NTiles);
    DisplayTiles();
    if (AutoFlag) {
        do {
            noecho();
            AutoMove(0, 2, NTiles);
        } while (!Solved(NTiles));
        sleep(2);
    } 
    else {
        echo();
        for (;;) {
            if (GetMove(&FromCol, &ToCol))
                break;
            if (InvalidMove(FromCol, ToCol)) {
                mvaddstr(STATUSLINE, 0, "移 动 无 效 !!");
                refresh();
                beep();
                sleep(2);
                continue;
            }
            MakeMove(FromCol, ToCol);
            if (Solved(NTiles)) {
                mvprintw(STATUSLINE, 0, "恭喜!! 恭喜!! 你用 %d 步赢了", NMoves);
                refresh();
                sleep(5);
                break;
            }
        }
    }
    endwin();
    return EXIT_SUCCESS;
}
Пример #9
0
bool init_getpic(const char* rt_path)
{
    //using namespace xsetpic;
    if(!rt_path || 0==&vShmKey)
    {
        std::fprintf(stderr, "****init_getpic error :%s\n","invalid parameter !");
        return false;
    }

    if(!AutoMove(boost::filesystem::exists(AutoMove(boost::filesystem::path(rt_path)))))
    {
        std::fprintf(stderr, "****init_getpic error :%s\n","invalid runtime path,not exists !");
        return false;
    }
    else
    {
        if(!AutoMove(boost::filesystem::is_directory(AutoMove(boost::filesystem::path(rt_path)))))
        {
            std::fprintf(stderr, "****init_getpic error :%s\n","invalid runtime path,is not a directory !");
            return false;
        }
    }

    boost::filesystem::path tmp_path(rt_path);
    boost::filesystem::path tmp_path2(boost::filesystem::system_complete(tmp_path));;
    //std::string str_strart_up_dir(strart_up_dir.string());
    boost::filesystem::path _rt_path(tmp_path2);
    char vir_dir_sub[256];
    std::memset(vir_dir_sub,0x00,sizeof(vir_dir_sub));
    std::sprintf(vir_dir_sub,"%s/%s",_rt_path.string().c_str(),"map");
    vir_dir_sub[sizeof(vir_dir_sub)-1]='\0';
    boost::filesystem::path dir_map(std::string(vir_dir_sub).c_str());
    if(!boost::filesystem::exists(dir_map))
    {
        boost::filesystem::create_directories(dir_map);
    }
    else
    {
        if(!boost::filesystem::is_directory(dir_map))
        {
            boost::filesystem::remove(dir_map);
            boost::filesystem::create_directories(dir_map);
        }
    }


    std::list<boost::filesystem::path> list_shm_lua_file_path;
    list_shm_lua_file_path.clear();
    int32_t n_max_shared_memory_count(16);
    vShmKey.clear();
    vShmKey.reserve(16);
    while(n_max_shared_memory_count>0)
    {
        char _sz_file_path[256];
        std::memset(_sz_file_path,0x00,sizeof(_sz_file_path));
        std::sprintf(_sz_file_path,"%s/%d.lua",dir_map.string().c_str(),n_max_shared_memory_count-1);
        const boost::filesystem::path shminfo_path(std::string(_sz_file_path).c_str());
lable_recheck_shminfo_file_flag:
        if(boost::filesystem::exists(shminfo_path))
        {
            if(!boost::filesystem::is_directory(shminfo_path))
            {
                //bool b_over_write(false);
                uint32_t set_pic_base(_SETPIC_IPC_FLAG_);
                key_t real_key(ftok(shminfo_path.string().c_str(),set_pic_base));
                lua_script shm_info_script(shminfo_path.string().c_str());
                std::string _shm_file_path(".");
                //key_t shm_info_id(0);
                long shm_info_id(0);
                shm_info_script.get<std::string>("path",&_shm_file_path);
                shm_info_script.get<long>("id",&shm_info_id);

                if(0!=std::strcmp(_shm_file_path.c_str(),shminfo_path.string().c_str()) ||
                    real_key!=shm_info_id)
                {
                    std::fstream _file_shm_info(shminfo_path.c_str(),std::ios::out);
                    if(_file_shm_info)
                    {
                        try
                        {
                            std::string _shm_info_open_app( "#!/usr/bin/env lua\n");
                            _file_shm_info<<_shm_info_open_app<<std::endl;
                            std::string _shm_info_open_tip( "--[[\n\n"
                                                            "    ATTENTION : THIS FILE IS AUTO CREATED BY CAMERA SERVICE SETPIC V3 ,USING FOR SHARED MEMORY.\n"
                                                            "DO NOT CHANGE OR MOVE IT . ANY CHANGED IN THIS FILE MAY MAKE SHARED MEMORY NOT WORK .\n\n"
                                                            "                                           wangbin <*****@*****.**>\n"
                                                            "]]--\n");
                            _file_shm_info<<_shm_info_open_tip<<std::endl;
                            _file_shm_info<<"path   =\""<<shminfo_path.string()<<"\""<<std::endl;
                            _file_shm_info<<"id     ="<<real_key;
                            char _shm_info_delete_function[512];
                            std::memset(_shm_info_delete_function,0x00,sizeof(_shm_info_delete_function));
                            std::sprintf(_shm_info_delete_function,"\n\n--delete command: ipcrm -m shmid \n"
                                                               "function delete_this_shared_memory(...)\n"
                                                               "    io.write(tostring(_VERSION) .. tostring(\"\\t\") .. tostring(os.date()) .. tostring(\"\\n\"))\n"
                                                               "    if os.getenv [[USER]] ~= tostring(\"root\") then\n"
                                                               "        io.write(tostring(\"For Better Execute,Suggest You Login As \\\"root\\\"\\n\"))\n"
                                                               "    end\n"
                                                               "    os.execute(\"ipcrm -m %ld\")\n"
                                                               "end\n"
                                                                    ,real_key);
                            _shm_info_delete_function[sizeof(_shm_info_delete_function)-1]='\0';
                            _file_shm_info<<std::string(_shm_info_delete_function)<<std::endl;
                        }
                        catch(std::exception& e)
                        {
                            std::fprintf(stderr, "%s\n",e.what());

                        }
                        _file_shm_info.close();
                    }
                }
                else
                {
                    vShmKey.push_back(real_key);
                    --n_max_shared_memory_count;
                }

            }
            else // exist ,but is dir
            {
                boost::filesystem::remove_all(shminfo_path);//recursive delete dir
                std::fstream _file_shm_info(shminfo_path.string().c_str(),std::ios::out);
                if(_file_shm_info)
                {
                    _file_shm_info.close();
                }
                goto lable_recheck_shminfo_file_flag;
            }
        }
        else //not exists
        {
            std::fstream _file_shm_info(shminfo_path.string().c_str(),std::ios::out);
            if(_file_shm_info)
            {
                _file_shm_info.close();
            }
            goto lable_recheck_shminfo_file_flag;
        }
    }
    std::reverse(vShmKey.begin(),vShmKey.end());
    for(std::vector<long>::const_iterator _iter(vShmKey.begin());_iter!=vShmKey.end();++_iter)
    {
        std::fprintf(stderr, "%ld\n",*_iter);
    }
    return true;
}