예제 #1
0
파일: DlgLogon.cpp 프로젝트: firehot/WH2008
//确定函数
void CDlgRegister::OnOK()
{
	CString strBuffer;

	//用户帐号
	GetDlgItemText(IDC_ACCOUNTS,strBuffer);
	strBuffer.TrimLeft();
	strBuffer.TrimRight();
	if (strBuffer.GetLength()<4)
	{
		ShowInformation(TEXT("帐号名字的长度最短为 4 位字符,请重新输入注册帐号!"),0,MB_ICONQUESTION);
		GetDlgItem(IDC_ACCOUNTS)->SetFocus();
		return;
	}
	lstrcpyn(m_szAccounts,strBuffer,CountArray(m_szAccounts));

	//用户密码
	GetDlgItemText(IDC_PASSWORD,strBuffer);
	if (strBuffer.GetLength()<6)
	{
		ShowInformation(TEXT("游戏密码长度最短为 6 位字符,请重新输入游戏密码!"),0,MB_ICONQUESTION);
		GetDlgItem(IDC_PASSWORD)->SetFocus();
		return;
	}

	//确认密码
	GetDlgItemText(IDC_PASSWORD2,m_szPassword,CountArray(m_szPassword));
	if (lstrcmp(m_szPassword,strBuffer)!=0)
	{
		ShowInformation(TEXT("游戏密码与确认密码不一致,请重新输入确认密码!"),0,MB_ICONQUESTION);
		GetDlgItem(IDC_PASSWORD2)->SetFocus();
		return;
	}

	//推广员名
	GetDlgItemText(IDC_SPREADER,strBuffer);
	strBuffer.TrimLeft();
	strBuffer.TrimRight();
	lstrcpyn(m_szSpreader,strBuffer,CountArray(m_szSpreader));

	//用户性别
	int nCurSel=((CComboBox *)GetDlgItem(IDC_GENDER))->GetCurSel();
	m_cbGender=(BYTE)((CComboBox *)GetDlgItem(IDC_GENDER))->GetItemData(nCurSel);

	//用户头像
	m_wFaceID=m_FaceSelect.GetCurSel();

	__super::OnOK();
}
예제 #2
0
//选择消息
void CPropertyItem::OnCbnSelchangeTargetUser()
{
	//当前选择
	int nSelectItem = m_ComboBoxTargetUser.GetCurSel();
	if ( CB_ERR == nSelectItem ) return;

	//获取玩家
	DWORD dwTargetUserID = DWORD(m_ComboBoxTargetUser.GetItemData(nSelectItem));
	tagUserData *pTargetUserData = m_pIPurchaseInfo->SearchUserItem(dwTargetUserID);

	//离开判断
	if ( pTargetUserData == NULL )
	{
		//删除玩家
		m_ComboBoxTargetUser.DeleteString(nSelectItem);

		//显示信息
		CString strMessage, strTargetName;
		m_ComboBoxTargetUser.GetLBText(nSelectItem, strTargetName);
		strMessage.Format(TEXT("[ % ]已经离开,请重新选择!"), strTargetName);
		ShowInformation(strMessage,0,MB_ICONINFORMATION);
		return;
	}

	return;
}
예제 #3
0
파일: GameFrameDlg.cpp 프로젝트: vsanth/kkj
//取消消息
void CGameFrameDlg::OnCancel()
{
	//退出提示
	if ((m_ClientKernelHelper.GetInterface()!=NULL)&&(m_ClientKernelHelper->GetExitFlags()==false))
	{
		WORD wChairID=GetMeChairID();
		const tagUserData * pUserData=GetUserData(wChairID);
		if (pUserData!=NULL)
		{
			int iRet=ShowInformation(TEXT("你正在游戏中,强行退出将被扣分,确实要强退吗?"),0,MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2);
			if (iRet!=IDYES) return;
		}
	}

	//保存配置
	g_GlobalOption.SaveOptionParameter();

	//注销接口
	m_ClientKernelHelper->DestroyClientKernel();

	//销毁组件
	SafeDelete(m_pKernelSink);
	m_UserFaceResHelper.CloseInstance();
	m_ClientKernelHelper.CloseInstance();

	//关闭窗口
	DestroyWindow();

	return;
}
예제 #4
0
//初始化函数
BOOL CGameFrameApp::InitInstance()
{
	__super::InitInstance();

	//内部初始化
	AfxOleInit();
	AfxInitRichEdit2();
	InitCommonControls();
	AfxEnableControlContainer();

	hMod = LoadLibrary(TEXT( "riched20.dll"));

	//加载资源
	if(g_GlobalOption.LoadGameFrameRes()==false)
	{
		ShowInformation(TEXT("加载资源失败!"),0,MB_ICONSTOP);
		return FALSE;
	}

	//加载配置
	g_GlobalOption.LoadOptionParameter();

	try
	{
		//创建主窗口
		m_pGameFrame=GetGameFrameDlg();
		ASSERT(m_pGameFrame!=NULL);
		if (m_pGameFrame==NULL) throw TEXT("游戏主窗口创建失败");

		//设置主窗口
		m_pMainWnd=m_pGameFrame;
		AfxSetResourceHandle(GetModuleHandle(GAME_FRAME_DLL_NAME));
		m_pGameFrame->Create(IDD_GAME_FRAME,NULL);
		AfxSetResourceHandle(GetModuleHandle(NULL));
	}
	catch (LPCTSTR pszMesssage)
	{
		CString strBuffer;
		strBuffer.Format(TEXT("由于 [ %s ] 游戏程序即将退出。"),pszMesssage);
		ShowInformation(strBuffer,0,MB_ICONSTOP);
		if (m_pGameFrame!=NULL) SafeDelete(m_pGameFrame);
		return FALSE;
	}

	return TRUE;
}
예제 #5
0
//保存输入
bool CDlgRegWizardAccount::SaveInputInfo()
{
	//变量定义
	CString strAccount;
	TCHAR szPassword[LEN_PASSWORD]=TEXT("");

	//保存输入
	GetDlgItemText(IDC_ACCOUNTS,strAccount);
	GetDlgItemText(IDC_PASSWORD,m_szPassword,CountArray(m_szPassword));
	GetDlgItemText(IDC_PASSWORD2,szPassword,CountArray(szPassword));

	//效验用户名
	strAccount.TrimLeft();
	strAccount.TrimRight();
	if (strAccount.IsEmpty())
	{
		ShowInformation(TEXT("用户帐号不能为空,请重新输入!"),MB_ICONERROR);
		m_edAccounts.SetFocus();
		return false;
	}
	lstrcpyn(m_szAccounts,strAccount,sizeof(m_szAccounts));

	//效验密码
	if (m_szPassword[0]==0)
	{
		ShowInformation(TEXT("登录密码不能为空,请重新输入!"),MB_ICONERROR);
		m_edPassword.SetFocus();
		return false;
	}
	if (lstrcmp(m_szPassword,szPassword)!=0)
	{
		ShowInformation(TEXT("两次输入的登录密码不相同,请重新输入!"),MB_ICONERROR);
		m_edPassword2.SetFocus();
		return false;
	}

	return true;
}
예제 #6
0
/** \fn     GalleryWidget::ShowRandomFile()
 *  \brief  Loads a random image
 *  \return void
 */
void GalleryWidget::ShowRandomFile()
{
    volatile bool exit = false;

    int size = m_gvh->m_currentNode->getSelectedChild()->siblingCount();
    int counter = 0;
    int position = 0;

    MythGenericTree *node = NULL;
    ImageMetadata *im = NULL;

    PauseSlideShow();

    // Get a random node from the list. If its not an image or
    // video continue and try to get a new one until its an image
    // or all siblings have been checked.
    if (size > 0)
    {
        while (!exit)
        {
            position = (qrand() % size);
            counter++;

            node = m_gvh->m_currentNode->getChildAt(position);
            im = m_gvh->GetImageMetadataFromNode(node);

            if ((im && (im->m_type == kImageFile ||
                          im->m_type == kVideoFile)) || counter == size)
                exit = true;
        }

        // If we have data then is is already an image or
        // video. This has been checked in the while loop
        if (im)
        {
            m_gvh->m_currentNode->setSelectedChild(node);
            LoadFile();
        }
    }
    else
    {
        QString msg = "There are no images in the current directory.";
        ShowInformation(msg);
    }
}
예제 #7
0
/** \fn     GalleryWidget::ShowPrevFile()
 *  \brief  Loads the previous image file if possible
 *  \return void
 */
void GalleryWidget::ShowPrevFile()
{
    MythGenericTree *node = m_gvh->m_currentNode->getSelectedChild()->prevSibling(1);
    ImageMetadata *im = m_gvh->GetImageMetadataFromNode(node);

    // If a data object exists then a node must also exist
    if (im && (im->m_type == kImageFile ||
                 im->m_type == kVideoFile))
    {
        m_gvh->m_currentNode->setSelectedChild(node);
        LoadFile();
    }
    else
    {
        QString msg = "You have reached the beginning of the gallery.";
        ShowInformation(msg);
    }
}
예제 #8
0
//输入信息
void CFlowerSetting::OnEnChangeFlowerCount()
{
	CString strCount;
	GetDlgItem(IDC_FLOWER_COUNT)->GetWindowText(strCount);
	m_nFlowerCount=_tstoi(strCount);

	//合法判断
	if ( m_nFlowerCount <= 0 || m_nFlowerCount > MAX_FLOWER_COUNT )
	{
		CString strError;
		strError.Format(TEXT("赠送数目必须大于0且小于等于%d"), MAX_FLOWER_COUNT);
		ShowInformation(strError,0,MB_ICONINFORMATION);
		SetDlgItemInt(IDC_FLOWER_COUNT,1);
		GetDlgItem(IDC_FLOWER_COUNT)->SetFocus();
		((CEdit*)GetDlgItem(IDC_FLOWER_COUNT))->SetSel(0,-1);

		return ;
	}

	return;
}
예제 #9
0
//头像选择
VOID CDlgRegWizardAccount::OnBnClickedSelectFace()
{
	//创建组件
	if ((m_FaceSelectControl.GetInterface()==NULL)&&(m_FaceSelectControl.CreateInstance()==false))
	{
		ShowInformation(m_FaceSelectControl.GetErrorDescribe(),MB_ICONERROR);
		return;
	}

	//隐藏界面
	GetParent()->ShowWindow(SW_HIDE);

	//选择头像
	m_FaceSelectControl->SetSelectItemCount(MAX_NORMAL_FACE);
	if (m_FaceSelectControl->GetSelectFaceID(m_wFaceID)==true) m_FaceItemView.SetFaceItem(m_wFaceID);

	//显示界面
	GetParent()->ShowWindow(SW_SHOW);

	return;
}
예제 #10
0
//关闭消息
void CGameFrame::OnClose()
{
	//关闭提示
	if (g_GlobalUnits.GetGolbalUserData().dwUserID!=0L)
	{
		int nCode=ShowInformation(TEXT("您确实要关闭游戏广场吗?"),0,MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION);
		if (nCode!=IDYES) return;
	}

	//隐藏界面
	ShowWindow(SW_HIDE);

	//关闭房间
	CloseAllRoomViewItem();

	//保存配置
	g_GlobalOption.SaveOptionParameter();
	g_GlobalUnits.m_CompanionManager->SaveCompanion();

	__super::OnClose();
}
예제 #11
0
파일: DlgLogon.cpp 프로젝트: firehot/WH2008
//效验输入
bool CDlgLogon::CheckLogonInput(bool bShowError)
{
	//定义变量
	UINT uControlID=0;
	CString strBuffer;

	try
	{
		//屏幕像素
		RECT reWindowSize;
		GetDesktopWindow()->GetWindowRect(&reWindowSize);
		INT nHeight =reWindowSize.bottom-reWindowSize.top;
		INT nWidth =reWindowSize.right-reWindowSize.left;
		
		//判断像素
		if(nWidth<LESS_SCREEN_W || nHeight<LESS_SCREEN_H)
		{
			TCHAR szInfo[255]=TEXT("");
			_sntprintf(szInfo,CountArray(szInfo),TEXT("屏幕像素需要在%d*%d或以上才可以正常游戏!"),LESS_SCREEN_W,LESS_SCREEN_H);
			throw szInfo;
		}

		//登录服务器
		GetDlgItemText(IDC_SERVER,m_strLogonServer);
		m_strLogonServer.TrimLeft();
		m_strLogonServer.TrimRight();
		if (m_strLogonServer.IsEmpty())
		{
			uControlID=IDC_SERVER;
			throw TEXT("登录服务器不能为空,请重新选择或者输入登录服务器!");
		}

		//登录帐号
		switch (m_LogonMode)
		{
		case LogonMode_Accounts:		//帐号登录
			{
				GetDlgItemText(IDC_ACCOUNTS,strBuffer);
				strBuffer.TrimLeft();
				strBuffer.TrimRight();
				if (strBuffer.IsEmpty())
				{
					uControlID=IDC_ACCOUNTS;
					throw TEXT("用户登录帐号不能为空,请重新输入登录帐号!");
				}
				lstrcpyn(m_szAccounts,strBuffer,CountArray(m_szAccounts));
				break;
			}
		case LogonMode_UserID:			//ID 登录
			{
				GetDlgItemText(IDC_USER_ID,strBuffer);
				strBuffer.TrimLeft();
				strBuffer.TrimRight();
				m_dwUserID=atoi(strBuffer);
				if (m_dwUserID==0L)
				{
					uControlID=IDC_USER_ID;
					throw TEXT("用户登录 ID 不能为空,请重新输入登录 ID !");
				}
				break;
			}
		}

		//用户密码
		if (m_bChangePassWord==true)
		{
			m_bChangePassWord=false;
			GetDlgItemText(IDC_PASSWORD,m_szPassword,CountArray(m_szPassword));
		}
		if (m_szPassword[0]==0)
		{
			uControlID=IDC_PASSWORD;
			throw TEXT("登录密码不能为空,请重新输入登录密码!");
		}

		//代理类型
		CComboBox * pComProxyType=(CComboBox *)GetDlgItem(IDC_PROXY_TYPE);
		enProxyServerType ProxyServerType=(enProxyServerType)pComProxyType->GetItemData(pComProxyType->GetCurSel());

		//代理信息
		tagProxyServerInfo ProxyServerInfo;
		ZeroMemory(&ProxyServerInfo,sizeof(ProxyServerInfo));
		ProxyServerInfo.wProxyPort=GetDlgItemInt(IDC_PROXY_PORT);
		GetDlgItemText(IDC_PROXY_USER,ProxyServerInfo.szUserName,CountArray(ProxyServerInfo.szUserName));
		GetDlgItemText(IDC_PROXY_PASS,ProxyServerInfo.szPassword,CountArray(ProxyServerInfo.szPassword));
		GetDlgItemText(IDC_PROXY_SERVER,ProxyServerInfo.szProxyServer,CountArray(ProxyServerInfo.szProxyServer));

		//效验代理
		if (ProxyServerType!=ProxyType_None)
		{
			//代理地址
			if (ProxyServerInfo.szProxyServer[0]==0)
			{
				ShowInformation(TEXT("代理服务器地址不能为空,请重新输入!"),0,MB_ICONINFORMATION);
				if (m_bNetOption==false) SwitchNetOption(true);
				m_edProxyServer.SetFocus();
				return false;
			}

			//代理端口
			if (ProxyServerInfo.wProxyPort==0)
			{
				ShowInformation(TEXT("请输入代理服务器端口号,例如:1080!"),0,MB_ICONINFORMATION);
				if (m_bNetOption==false) SwitchNetOption(true);
				m_edProxyPort.SetFocus();
				return false;
			}
		}

		//保存配置
		g_GlobalOption.m_ProxyServerType=ProxyServerType;
		g_GlobalOption.m_ProxyServerInfo=ProxyServerInfo;

		return true;
	}
	catch (LPCTSTR pszError)
	{
		if (bShowError)
		{
			ShowWindow(SW_SHOW);
			BringWindowToTop();
			ShowInformation(pszError,0,MB_ICONQUESTION);
			if (uControlID!=0) GetDlgItem(uControlID)->SetFocus();
		}

	}
	return false;
}
예제 #12
0
//确认道具
void CPropertyItem::OnBnClickedOk()
{
	//合法判断
	if ( m_nPropCount <= 0 || m_nPropCount > MAX_PROPERTY_COUNT )
	{
		CString strError;
		strError.Format(TEXT("赠送数目必须大于0且小于等于%d"), MAX_PROPERTY_COUNT);
		ShowInformationEx(strError,0,MB_ICONINFORMATION,TEXT("系统消息"));
		GetDlgItem(IDC_PURCHASE_COUNT)->SetFocus();
		((CEdit*)GetDlgItem(IDC_PURCHASE_COUNT))->SetSel(0,-1);

		return ;
	}

	//查找用户
	DWORD dwTargetUserID=0;
	tagUserData *pTargetUserData=NULL;
	CString strTargetName;
	if(!m_bPlazaRoom)
	{
		int nSelectItem = m_ComboBoxTargetUser.GetCurSel();
		if ( CB_ERR == nSelectItem ) return;

		//获取信息
		dwTargetUserID = DWORD(m_ComboBoxTargetUser.GetItemData(nSelectItem));
		m_ComboBoxTargetUser.GetLBText(nSelectItem, strTargetName);
		pTargetUserData = m_pIPurchaseInfo->SearchUserItem(dwTargetUserID);
	}
	else
	{
		//获取信息
		GetDlgItem(IDC_PRO_USER_ID)->GetWindowText(strTargetName);
		pTargetUserData = m_pIPurchaseInfo->SearchUserItem(strTargetName);
		if (pTargetUserData!=NULL)dwTargetUserID=pTargetUserData->dwUserID;
	}

	//判断在线
	if ( pTargetUserData == NULL )
	{
		CString strMessage;
		strMessage.Format(TEXT("[ % ]已经离开,请重新选择!"), strTargetName);
		ShowInformation(strMessage,0,MB_ICONINFORMATION);
		return;
	}

	//类型判断
	WORD wGameGenre= m_pIPurchaseInfo->GetGameGenre();

	if ( wGameGenre == GAME_GENRE_GOLD && ( m_nPropertyID==PROP_NEGAGIVE || m_nPropertyID == PROP_DOUBLE || m_nPropertyID == PROP_FOURDOLD ))
	{
		ShowInformation(TEXT("金币房间不可以使用此功能!"),0,MB_ICONINFORMATION);
		return ;
	}
	if ( wGameGenre == GAME_GENRE_MATCH && ( m_nPropertyID==PROP_NEGAGIVE || m_nPropertyID == PROP_DOUBLE ||
		m_nPropertyID == PROP_FOURDOLD || m_nPropertyID == PROP_BUGLE ))
	{
		ShowInformation(TEXT("比赛房间不可以使用此功能!"),0,MB_ICONINFORMATION);
		return ;
	}

	//获取玩家
	const tagUserData *pMeUserData = m_pIPurchaseInfo->GetMeUserInfo();

	//获取价格
	LONG lNormalPrice = 0, lMemberPrice = 0;
	GetPropertyPrice(lNormalPrice, lMemberPrice);
	
	//判断金额
	LONGLONG lMePrice = pMeUserData->cbMemberOrder ? lMemberPrice : lNormalPrice;
	LONGLONG lMeScore = pMeUserData->lInsureScore;
	if ( lMeScore < lMePrice )
	{
		if ( IDYES == ShowInformation(TEXT("您的金币不足,是否充值?"),0,MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) )	
		{
			ShellExecute(NULL,TEXT("open"),TEXT("http://www.52e8.com"),NULL,NULL,SW_SHOWDEFAULT);
		}
		
		return;
	}

	//设置数据
	CMD_GF_Property PropertyHeadInfo;
	ZeroMemory(&PropertyHeadInfo, sizeof(PropertyHeadInfo));
	PropertyHeadInfo.cbSendLocation = m_pIPurchaseInfo->GetLocation();
	PropertyHeadInfo.nPropertyID = m_nPropertyID;
	PropertyHeadInfo.dwSourceUserID = pMeUserData->dwUserID;
	PropertyHeadInfo.dwTargetUserID = dwTargetUserID;
	PropertyHeadInfo.dwPachurseCount = m_nPropCount;
	PropertyHeadInfo.dwOnceCount = (DWORD)m_nPropertyType;

	//发送数据
	m_pIPurchaseInfo->SendData(MDM_GF_PRESENT, SUB_GF_PROPERTY, &PropertyHeadInfo, sizeof(PropertyHeadInfo));

	OnOK();
	return;
}
예제 #13
0
void CMatchingDlg::Execute(void)
{
	int res;
	char msg[256];

	m_FrameID = 0;
	g_free(m_CatFile);
	m_CatFile = NULL;
	g_free(m_SelectionName);
	m_SelectionName = NULL;
	m_FileList = NULL;

	// Restore path to catalog files
	gchar *fpath = CConfig::GetStr("MakeCatDlg", "Folder", NULL);
	if (fpath && *fpath!='\0' && g_file_test(fpath, G_FILE_TEST_IS_DIR)) 
		gtk_entry_set_text(GTK_ENTRY(m_PathEntry), fpath);
	else {
		gchar *defpath = g_build_filename(get_user_data_dir(), "Catalog files", NULL);
		if (force_directory(defpath))
			gtk_entry_set_text(GTK_ENTRY(m_PathEntry), defpath);
		g_free(defpath);
	}
	g_free(fpath);

	// Update list of frames
	ReadFrames(false, g_Project->GetInt("MatchingDlg", "Frame", 0));

	// Update list of catalog files
	gchar *path = g_Project->GetStr("MatchingDlg", "File", NULL);
	if (!path)
		path = CConfig::GetStr("MatchingDlg", "File", NULL);
	ReadCatalogs(path);
	g_free(path);

	gtk_widget_show(m_UseFrame);

	// Check inputs
	if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_Frames), NULL)==0) {
		ShowError(m_pParent, "There are no frames usable as a reference frame.");
		return;
	}

	// Select reference frame or the first frame
	SetSelectMode(m_SelectMode);
	SetSortMode(m_FrameSort);
	UpdatePreview(true);
	UpdateControls();

	if (gtk_dialog_run(GTK_DIALOG(m_pDlg))!=GTK_RESPONSE_ACCEPT)
		return;
	gtk_widget_hide(m_pDlg);

	g_Project->SetInt("MatchingDlg", "Select", m_SelectMode);
	if (m_SelectMode == REFERENCE_FRAME)
		g_Project->SetInt("MatchingDlg", "Frame", m_FrameID);
	else {
		g_Project->SetStr("MatchingDlg", "File", m_CatFile);
		CConfig::SetStr("MatchingDlg", "File", m_CatFile);
	}
	g_Project->ClearReference();
	
	// Always all files
	gtk_tree_model_foreach(g_Project->FileList(), GtkTreeModelForeachFunc(make_list), &m_FileList);

	CProgressDlg pDlg(m_pParent, "Matching photometry files");
	pDlg.SetMinMax(0, g_list_length(m_FileList));
	res = pDlg.Execute(ExecuteProc, this);
	if (res!=0) {
		char *msg = cmpack_formaterror(res);
		ShowError(m_pParent, msg, true);
		cmpack_free(msg);
	} else if (m_OutFiles==0) {
		ShowError(m_pParent, "No file was successfully processed.", true);
	} else if (m_OutFiles!=m_InFiles) {
		sprintf(msg, "%d file(s) were successfully processed, %d file(s) failed.", 
			m_OutFiles, m_InFiles-m_OutFiles);
		ShowWarning(m_pParent, msg, true);
	} else {
		sprintf(msg, "All %d file(s) were successfully processed.", m_OutFiles);
		ShowInformation(m_pParent, msg, true);
	}

	// Free allocated memory
	g_list_foreach(m_FileList, (GFunc)gtk_tree_row_reference_free, NULL);
	g_list_free(m_FileList);
	m_FileList = NULL;
	g_free(m_CatFile);
	m_CatFile = NULL;
	g_free(m_SelectionName);
	m_SelectionName = NULL;
}
예제 #14
0
void StartSmartConfig(void)
{
  long rval;

  if (!isInitialized)
    {
      printf("CC3000 not initialized; can't run Smart Config.\n");
      return;
    }

  printf("Starting Smart Config\n");

  printf("  Disabling auto-connect policy...");
  if ((rval = wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE)) !=0)
    {
      printf(" Failed!\n    Setting auto connection policy failed, error: %lx\n",
             (unsigned long)rval);
      return;
    }

  printf(" Succeed\n");
  printf("  Deleting all existing profiles...");
  fflush(stdout);

  if ((rval = wlan_ioctl_del_profile(255)) !=0)
    {
      printf(" Failed!\n    Deleting all profiles failed, error: %lx\n",
             (unsigned long)rval);
      return;
    }

  printf(" Succeed\n");
  wait_on(20*MS_PER_SEC, &ulCC3000Connected, 0, "  Waiting until disconnected");

  printf("  Setting smart config prefix...");
  fflush(stdout);

  if ((rval = wlan_smart_config_set_prefix(simpleConfigPrefix)) !=0)
    {
      printf(" Failed!\n    Setting smart config prefix failed, error: %lx",
             (unsigned long)rval);
      return;
    }

  printf(" Succeed\n");
  printf("  Starting smart config...");
  fflush(stdout);

  if ((rval = wlan_smart_config_start(0)) !=0)
    {
      printf(" Failed!\n    Starting smart config failed, error: %lx\n",
             (unsigned long)rval);
      return;
    }

  printf(" Succeed\n");

  if (!wait_on(30*MS_PER_SEC, &ulSmartConfigFinished, 1, "  Waiting on Starting smart config done"))
    {
      printf("    Timed out waiting for Smart Config to finish. Hopefully it did anyway\n");
    }

  printf("  Smart Config packet %s!\n",ulSmartConfigFinished ? "seen" : "NOT seen");

  printf("  Enabling auto-connect policy...");
  fflush(stdout);

  if ((rval = wlan_ioctl_set_connection_policy(DISABLE, DISABLE, ENABLE)) !=0)
    {
      printf(" Failed!\n    Setting auto connection policy failed, error: %lx\n",
             (unsigned long)rval);
      return;
    }

  printf(" Succeed\n");
  printf("  Stopping CC3000...\n");
  fflush(stdout);
  wlan_stop();  /* No error returned here, so nothing to check */

  printf("  Pausing for 2 seconds...\n");
  sleep(2);

  printf("  Restarting CC3000... \n");
  wlan_start(0);  /* No error returned here, so nothing to check */

  if (!wait_on(20*MS_PER_SEC, &ulCC3000Connected, 1, "  Waiting for connection to AP"))
    {
      printf("    Timed out waiting for connection to AP\n");
      return;
    }

  if (!wait_on(15*MS_PER_SEC, &ulCC3000DHCP, 1, "  Waiting for IP address from DHCP"))
    {
      printf("    Timed out waiting for IP address from DHCP\n");
      return;
    }

  printf("  Sending mDNS broadcast to signal we're done with Smart Config...\n");
  fflush(stdout);

  /* The API documentation says mdnsAdvertiser() is supposed to return 0 on
   * success and SOC_ERROR on failure, but it looks like what it actually
   * returns is the socket number it used. So we ignore it.
   */

  mdnsadvertiser(1, device_name, strlen(device_name));

  printf("  Smart Config finished Successfully!\n");
  ShowInformation();
  fflush(stdout);
}
예제 #15
0
//按钮消息
void CFlowerSetting::OnBnClickedOk()
{
	//合法判断
	if ( m_nFlowerCount <= 0 || m_nFlowerCount > MAX_FLOWER_COUNT )
	{
		CString strError;
		strError.Format(TEXT("赠送数目必须大于0且小于等于%d"), MAX_FLOWER_COUNT);
		ShowInformation(strError,0,MB_ICONINFORMATION);
		GetDlgItem(IDC_FLOWER_COUNT)->SetFocus();
		((CEdit*)GetDlgItem(IDC_FLOWER_COUNT))->SetSel(0,-1);
		return ;
	}

	//查找用户
	DWORD dwTargetUserID=0;
	tagUserData *pSelectedUserData =NULL;
	if(!m_bPlazaRoom)
	{
		int nSelectedItem = m_ComboBoxTargetUser.GetCurSel();
		if ( CB_ERR != nSelectedItem )
		{
			dwTargetUserID = (DWORD)m_ComboBoxTargetUser.GetItemData(nSelectedItem);
			tagUserData *pTargetUserData = m_pIPurchaseInfo->SearchUserItem(dwTargetUserID);
			if ( pTargetUserData == NULL )
			{
				m_ComboBoxTargetUser.DeleteString(nSelectedItem);
				ShowInformation(TEXT("您要赠送的玩家已经离开,请重新选择赠送玩家"),0,MB_ICONINFORMATION);
				m_ComboBoxTargetUser.SetFocus();
				return;
			}
		}
		else
		{
			ShowInformation(TEXT("请选择赠送玩家"),0,MB_ICONINFORMATION);
			m_ComboBoxTargetUser.SetFocus();
		}
		pSelectedUserData = m_pIPurchaseInfo->SearchUserItem(dwTargetUserID) ;
	}
	else
	{
		//获取信息
		CString strTargetName;
		GetDlgItem(IDC_PRO_USER_ID)->GetWindowText(strTargetName);
		pSelectedUserData = m_pIPurchaseInfo->SearchUserItem(strTargetName);
		if (pSelectedUserData!=NULL)dwTargetUserID=pSelectedUserData->dwUserID;
	}

	//////////////////////////////////////////////////////////////////////////////////////////////////
	//存在判断
	if ( pSelectedUserData == NULL )
	{
		ShowInformation(TEXT("对方已经离开,赠送失败!"),0,MB_ICONINFORMATION);
		return ;
	}

	//获取玩家
	const tagUserData *pMeUserData = m_pIPurchaseInfo->GetMeUserInfo();
	
	//设置信息
	LONGLONG lNormalPrice = CPropertyBar::m_FlowerInfo[m_nFlowerID].lPrice * m_nFlowerCount;
	LONGLONG lMemberPrice = LONG(lNormalPrice * (CPropertyBar::m_FlowerInfo[m_nFlowerID].cbDiscount / 100.));

	LONGLONG lMePrice = pMeUserData->cbMemberOrder ? lMemberPrice : lNormalPrice;
	LONGLONG lMeScore = pMeUserData->lInsureScore;
	if ( lMeScore < lMePrice )
	{
		if ( IDYES == ShowInformation(TEXT("您的金币不足,是否充值?"),0,MB_ICONQUESTION |MB_YESNO|MB_DEFBUTTON2))	
		{
			ShellExecute(NULL,TEXT("open"),TEXT("http://www.52e8.com"),NULL,NULL,SW_SHOWDEFAULT);
		}

		return;
	}

	//构造数据
	CMD_GF_Gift Gift;
	ZeroMemory( &Gift, sizeof( Gift ) );
	Gift.cbSendLocation = m_pIPurchaseInfo->GetLocation();
	Gift.dwRcvUserID = pSelectedUserData->dwUserID;
	Gift.dwSendUserID = m_pIPurchaseInfo->GetMeUserInfo()->dwUserID;
	Gift.wFlowerCount = m_nFlowerCount;
	Gift.wGiftID = m_nFlowerID;

	//发送消息
	m_pIPurchaseInfo->SendData( MDM_GF_PRESENT,SUB_GF_FLOWER,&Gift, sizeof(Gift));

	OnOK();
	return;
}
예제 #16
0
파일: DlgLogon.cpp 프로젝트: firehot/WH2008
//代理测试
void CDlgLogon::OnBnClickedProxyTest()
{
	//代理类型
	CComboBox * pComProxyType=(CComboBox *)GetDlgItem(IDC_PROXY_TYPE);
	enProxyServerType ProxyServerType=(enProxyServerType)pComProxyType->GetItemData(pComProxyType->GetCurSel());

	//代理信息
	tagProxyServerInfo ProxyServerInfo;
	ZeroMemory(&ProxyServerInfo,sizeof(ProxyServerInfo));
	ProxyServerInfo.wProxyPort=GetDlgItemInt(IDC_PROXY_PORT);
	GetDlgItemText(IDC_PROXY_USER,ProxyServerInfo.szUserName,CountArray(ProxyServerInfo.szUserName));
	GetDlgItemText(IDC_PROXY_PASS,ProxyServerInfo.szPassword,CountArray(ProxyServerInfo.szPassword));
	GetDlgItemText(IDC_PROXY_SERVER,ProxyServerInfo.szProxyServer,CountArray(ProxyServerInfo.szProxyServer));

	//效验代理
	if (ProxyServerType!=ProxyType_None)
	{
		//代理地址
		if (ProxyServerInfo.szProxyServer[0]==0)
		{
			ShowInformation(TEXT("代理服务器地址不能为空,请重新输入!"),0,MB_ICONINFORMATION);
			if (m_bNetOption==false) SwitchNetOption(true);
			m_edProxyServer.SetFocus();
			return;
		}

		//代理端口
		if (ProxyServerInfo.wProxyPort==0)
		{
			ShowInformation(TEXT("请输入代理服务器端口号,例如:1080!"),0,MB_ICONINFORMATION);
			if (m_bNetOption==false) SwitchNetOption(true);
			m_edProxyPort.SetFocus();
			return;
		}
	}
	else 
	{
		//错误提示
		ShowInformation(TEXT("请先配置代理服务器连接信息!"),0,MB_ICONINFORMATION);
		pComProxyType->SetFocus();
		return;
	}

	//创建组件
	CNetworkManagerHelper NetworkManagerModule;
	if (NetworkManagerModule.CreateInstance()==false)
	{
		ShowInformation(TEXT("网络服务管理组件创建失败,测试失败!"),0,MB_ICONINFORMATION);
		return;
	}

	try
	{
		//代理测试
		DWORD dwSuccess=NetworkManagerModule->ProxyServerTesting(ProxyServerType,ProxyServerInfo);

		//结果提示
		if (dwSuccess==CONNECT_SUCCESS)
		{
			ShowInformation(TEXT("代理服务器工作正常!"),0,MB_ICONINFORMATION);
			return;
		}
		else throw TEXT("无法连接代理服务器!");
	}
	catch (LPCTSTR pszDescribe)
	{
		ShowInformation(pszDescribe,0,MB_ICONINFORMATION);
		return;
	}

	return;
}
예제 #17
0
//网络测试
VOID CDlgProxyConfig::OnBnClickedProxyTest()
{
	//代理类型
	BYTE cbProxyType=(BYTE)m_cmProxyType.GetItemData(m_cmProxyType.GetCurSel());

	//代理信息
	tagProxyServer ProxyServer;
	ZeroMemory(&ProxyServer,sizeof(ProxyServer));
	ProxyServer.wProxyPort=GetDlgItemInt(IDC_PROXY_PORT);
	GetDlgItemText(IDC_PROXY_USER,ProxyServer.szUserName,CountArray(ProxyServer.szUserName));
	GetDlgItemText(IDC_PROXY_PASS,ProxyServer.szPassword,CountArray(ProxyServer.szPassword));
	GetDlgItemText(IDC_PROXY_SERVER,ProxyServer.szProxyServer,CountArray(ProxyServer.szProxyServer));

	//效验代理
	if (cbProxyType!=PROXY_NONE)
	{
		//代理地址
		if (ProxyServer.szProxyServer[0]==0)
		{
			//错误提示
			CInformation Information(this);
			Information.ShowMessageBox(TEXT("代理服务器地址不能为空,请重新输入!"),MB_ICONERROR,30);

			//设置焦点
			m_edProxyServer.SetFocus();

			return;
		}

		//代理端口
		if (ProxyServer.wProxyPort==0)
		{
			//错误提示
			CInformation Information(this);
			Information.ShowMessageBox(TEXT("请输入代理服务器端口号,例如:1080!"),MB_ICONERROR,30);

			//设置焦点
			m_edProxyPort.SetFocus();

			return;
		}
	}
	else 
	{
		//错误提示
		CInformation Information(this);
		Information.ShowMessageBox(TEXT("请先选择代理服务器类型与代理服务器连接信息!"),MB_ICONERROR,30);

		//设置焦点
		m_cmProxyType.SetFocus();

		return;
	}

	//创建组件
	CWHNetworkHelper WHNetworkModule;
	if (WHNetworkModule.CreateInstance()==false)
	{
		ShowInformation(TEXT("网络服务管理组件创建失败,测试失败!"),MB_ICONERROR,30);
		return;
	}

	//代理测试
	switch (WHNetworkModule->ProxyServerTesting(cbProxyType,ProxyServer))
	{
	case CONNECT_SUCCESS:				//连接成功
		{
			CInformation Information(this);
			Information.ShowMessageBox(TEXT("代理服务器工作正常!"),MB_ICONINFORMATION);
			return;
		}
	case CONNECT_PROXY_USER_INVALID:	//用户错误
		{
			CInformation Information(this);
			Information.ShowMessageBox(TEXT("代理服务器用户名或者密码错误!"),MB_ICONERROR);
			return;
		}
	default:							//默认处理
		{
			CInformation Information(this);
			Information.ShowMessageBox(TEXT("代理服务器不存在或者连接失败!"),MB_ICONERROR);
			return;
		}
	}

	return;
}
예제 #18
0
bool CNewFilesDlg::Execute(void)
{
	int mode, res;
	char msg[256];
	bool recursive, name_check, object_check, filter_check, background;
	const char *name, *object, *filter, *dirpath;

	// Default state
	mode = g_Project->GetInt("NewFiles", "Mode", 0);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_AllBtn), !mode);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_FilesBtn), mode);

	// Go to last folder
	gchar *aux = g_Project->GetStr("AddFiles", "Folder", NULL);
	if (!aux || !g_file_test(aux, G_FILE_TEST_IS_DIR))
		aux = CConfig::GetStr("AddFiles", "Folder", NULL);
	if (aux) 
		gtk_entry_set_text(GTK_ENTRY(m_DirEdit), aux);
	else
		gtk_entry_set_text(GTK_ENTRY(m_DirEdit), "");
	g_free(aux);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_SubDirs), 
		g_Project->GetBool("NewFiles", "SubDirs"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_NameCheck), 
		g_Project->GetBool("NewFiles", "Name"));
	aux = g_Project->GetStr("NewFiles", "NameText", "");
	if (aux) 
		gtk_entry_set_text(GTK_ENTRY(m_NameEdit), aux);
	else
		gtk_entry_set_text(GTK_ENTRY(m_NameEdit), "");
	g_free(aux);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_FilterCheck), 
		g_Project->GetBool("NewFiles", "Filter"));
	aux = g_Project->GetStr("NewFiles", "FilterText", "");
	if (aux) 
		gtk_entry_set_text(GTK_ENTRY(m_FilterEdit), aux);
	else
		gtk_entry_set_text(GTK_ENTRY(m_FilterEdit), "");
	g_free(aux);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_ObjectCheck), 
		g_Project->GetBool("NewFiles", "Object"));
	aux = g_Project->GetStr("NewFiles", "ObjectText", "");
	if (aux) 
		gtk_entry_set_text(GTK_ENTRY(m_ObjectEdit), aux);
	else
		gtk_entry_set_text(GTK_ENTRY(m_ObjectEdit), "");
	g_free(aux);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_BgCheck), 
		g_Project->GetBool("NewFiles", "Background"));

	m_InFiles = m_OutFiles = 0;
	UpdateControls();

	if (gtk_dialog_run(GTK_DIALOG(m_pDlg))!=GTK_RESPONSE_ACCEPT)
		return false;
	gtk_widget_hide(m_pDlg);

	// Save parameters
	mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_FilesBtn));
	g_Project->SetInt("NewFiles", "Mode", (!mode ? 0 : 1));
	dirpath = gtk_entry_get_text(GTK_ENTRY(m_DirEdit));
	g_Project->SetStr("AddFiles", "Folder", dirpath);
	CConfig::SetStr("AddFiles", "Folder", dirpath);
	recursive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_SubDirs))!=0;
	g_Project->SetBool("NewFiles", "SubDirs", recursive);
	name_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_NameCheck))!=0;
	g_Project->SetBool("NewFiles", "Name", name_check);
	name = gtk_entry_get_text(GTK_ENTRY(m_NameEdit));
	g_Project->SetStr("NewFiles", "NameText", name);
	filter_check  = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_FilterCheck))!=0;
	g_Project->SetBool("NewFiles", "Filter", filter_check);
	filter = gtk_entry_get_text(GTK_ENTRY(m_FilterEdit));
	g_Project->SetStr("NewFiles", "FilterText", filter);
	object_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_ObjectCheck))!=0;
	g_Project->SetBool("NewFiles", "Object", object_check);
	object = gtk_entry_get_text(GTK_ENTRY(m_ObjectEdit));
	g_Project->SetStr("NewFiles", "ObjectText", object);
	background = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_BgCheck))!=0;
	g_Project->SetBool("NewFiles", "Background", background);

	// Background process?
	if (background) {
		CNewFilesBox *pBox = g_MainWnd->NewFilesBox();
		if (pBox)
			pBox->Show(true);
		return true;
	}

	// Make list of files
	m_FrameList = NULL;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_AllBtn))) {
		// Make list of unprocessed frames
		gtk_tree_model_foreach(g_Project->FileList(), foreach_all_files, &m_FrameList);
		if (!m_FrameList) {
			ShowError(m_pParent, "There are no unprocessed frames in the project.");	
			return false;
		}
		CProgressDlg pDlg(m_pParent, "Processing frames");
		pDlg.SetMinMax(0, g_list_length(m_FrameList));
		res = pDlg.Execute(FramesProc, this);
		if (res!=0) {
			char *msg = cmpack_formaterror(res);
			ShowError(m_pParent, msg, true);
			cmpack_free(msg);
		} else if (m_OutFiles==0) {
			ShowError(m_pParent, "No frame was successfully processed.", true);
		} else if (m_OutFiles!=m_InFiles) {
			sprintf(msg, "%d frame(s) was successfully processed, %d frame(s) failed.", m_OutFiles, m_InFiles-m_OutFiles);
			ShowWarning(m_pParent, msg, true);
		} else {
			sprintf(msg, "All %d frame(s) was successfully processed.", m_OutFiles);
			ShowInformation(m_pParent, msg, true);
		}
		g_list_foreach(m_FrameList, (GFunc)gtk_tree_row_reference_free, NULL);
		g_list_free(m_FrameList);
		m_FrameList = NULL;
	} else {
		// Add new files to the project
		CProgressDlg pDlg(m_pParent, "Processing files");
		res = pDlg.Execute(FilesProc, this);
		if (res!=0) {
			char *msg = cmpack_formaterror(res);
			ShowError(m_pParent, msg, true);
			cmpack_free(msg);
		} else if (m_InFiles==0) {
			ShowError(m_pParent, "There are no unprocessed files that fit the specified conditions.");
		} else if (m_OutFiles==0) {
			ShowError(m_pParent, "No file was successfully processed.", true);
		} else if (m_OutFiles!=m_InFiles) {
			sprintf(msg, "%d new file(s) were successfully processed, %d file(s) failed.", m_OutFiles, m_InFiles-m_OutFiles);
			ShowWarning(m_pParent, msg, true);
		} else {
			sprintf(msg, "All %d file(s) were successfully processed.", m_OutFiles);
			ShowInformation(m_pParent, msg, true);
		}
	}
	g_Project->Save();
	return true;
}
예제 #19
0
void CExpressDlg::Execute()
{
	int res, id;
	char msg[256], buf[256];
	GtkTreeModel *pList = g_Project->FileList();
	GtkTreeIter iter, iter2;

	m_Updating = true;

	// Default state
	GtkTreeSelection *pSel = g_MainWnd->GetSelection();
	gtk_widget_set_sensitive(m_SelBtn, gtk_tree_selection_count_selected_rows(pSel)>0);
	m_Selected = gtk_tree_selection_count_selected_rows(pSel)>1;
	if (m_Selected)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_SelBtn), true);
	else
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_AllBtn), true);

	// Restore last settings
	if (m_ConvertBtn) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_ConvertBtn), 
			g_Project->GetBool("ExpressReduction", "Convert", true));
		CmpackChannel channel = (CmpackChannel)g_Project->GetInt("Convert", "ColorChannel", CMPACK_CHANNEL_DEFAULT);
		SelectChannel(channel);
	}
	if (m_TimeCorrBtn) {
		m_TimeCorr = g_Project->GetDbl("TimeCorr", "Seconds", 0);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_TimeCorrBtn), 
			g_Project->GetBool("ExpressReduction", "TimeCorr", false));
		UpdateTimeCorrection();
	}
	if (m_BiasCorrBtn && m_BiasFrameEdit) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_BiasCorrBtn), 
			g_Project->GetBool("ExpressReduction", "BiasCorr", false));
		char *bias = g_Project->GetStr("BiasCorr", "File", NULL);
		if (bias)
			gtk_entry_set_text(GTK_ENTRY(m_BiasFrameEdit), bias);
		else
			gtk_entry_set_text(GTK_ENTRY(m_BiasFrameEdit), "");
		g_free(bias);
	}
	if (m_DarkCorrBtn && m_DarkFrameEdit) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_DarkCorrBtn), 
			g_Project->GetBool("ExpressReduction", "DarkCorr", false));
		char *dark = g_Project->GetStr("DarkCorr", "File", NULL);
		if (dark)
			gtk_entry_set_text(GTK_ENTRY(m_DarkFrameEdit), dark);
		else
			gtk_entry_set_text(GTK_ENTRY(m_DarkFrameEdit), "");
		g_free(dark);
	}
	if (m_FlatCorrBtn && m_FlatFrameEdit) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_FlatCorrBtn), 
			g_Project->GetBool("ExpressReduction", "FlatCorr", false));
		char *flat = g_Project->GetStr("FlatCorr", "File", NULL);
		if (flat)
			gtk_entry_set_text(GTK_ENTRY(m_FlatFrameEdit), flat);
		else
			gtk_entry_set_text(GTK_ENTRY(m_FlatFrameEdit), "");
		g_free(flat);
	}
	if (m_PhotometryBtn) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_PhotometryBtn), 
			g_Project->GetBool("ExpressReduction", "Photometry", false));
	}
	if (m_MatchingBtn && m_RefBtn && m_CatBtn) {
		m_Matching = g_Project->GetBool("ExpressReduction", "Matching", false);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_MatchingBtn), m_Matching && !m_Selected);
		if (g_Project->GetInt("MatchingDlg", "Select", 0)==0)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_RefBtn), true);
		else
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CatBtn), true);
	}
	if (m_RefFrameCombo) {
		gtk_combo_box_set_model(GTK_COMBO_BOX(m_RefFrameCombo), NULL);
		gtk_list_store_clear(m_Frames);
		gboolean ok = gtk_tree_model_get_iter_first(pList, &iter);
		while (ok) {
			gtk_tree_model_get(GTK_TREE_MODEL(pList), &iter, FRAME_ID, &id, -1);
			gtk_list_store_append(m_Frames, &iter2);
			sprintf(buf, "Frame #%d", id);
			gtk_list_store_set(m_Frames, &iter2, 0, id, 1, buf, -1);
			ok = gtk_tree_model_iter_next(pList, &iter);
		}
		gtk_combo_box_set_model(GTK_COMBO_BOX(m_RefFrameCombo), GTK_TREE_MODEL(m_Frames));
		SelectRefFrame(g_Project->GetInt("MatchingDlg", "Frame", 0));
		if (gtk_combo_box_get_active(GTK_COMBO_BOX(m_RefFrameCombo))<0) {
			GtkTreeIter iter3;
			if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(m_Frames), &iter3))
				gtk_combo_box_set_active_iter(GTK_COMBO_BOX(m_RefFrameCombo), &iter3);
		}
	}
	if (m_CatFrameEdit) {
		char *path = g_Project->GetStr("MatchingDlg", "File", NULL);
		if (path)
			gtk_entry_set_text(GTK_ENTRY(m_CatFrameEdit), path);
		else
			gtk_entry_set_text(GTK_ENTRY(m_CatFrameEdit), "");
		g_free(path);
	}
	m_Updating = false;

	UpdateControls();

	if (gtk_dialog_run(GTK_DIALOG(m_pDlg))!=GTK_RESPONSE_ACCEPT)
		return;
	gtk_widget_hide(m_pDlg);

	// Save parameters
	memset(&m_Params, 0, sizeof(tProcParams));
	if (m_ConvertBtn) {
		m_Params.Convert = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_ConvertBtn))!=0;
		g_Project->SetBool("ExpressReduction", "Convert", m_Params.Convert);
		g_Project->SetInt("Convert", "ColorChannel", SelectedChannel());
	}
	if (m_TimeCorrBtn) {
		m_Params.TimeCorr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_TimeCorrBtn))!=0;
		g_Project->SetBool("ExpressReduction", "TimeCorr", m_Params.TimeCorr);
		m_Params.Seconds = m_TimeCorr;
		g_Project->SetDbl("TimeCorr", "Seconds", m_Params.Seconds);
	}
	if (m_BiasCorrBtn && m_BiasFrameEdit) {
		m_Params.BiasCorr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_BiasCorrBtn))!=0;
		g_Project->SetBool("ExpressReduction", "BiasCorr", m_Params.BiasCorr);
		m_Params.BiasFrame = gtk_entry_get_text(GTK_ENTRY(m_BiasFrameEdit));
		g_Project->SetStr("BiasCorr", "File", m_Params.BiasFrame);
		CConfig::SetStr("BiasCorr", "File", m_Params.BiasFrame);
	}
	if (m_DarkCorrBtn && m_DarkFrameEdit) {
		m_Params.DarkCorr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_DarkCorrBtn))!=0;
		g_Project->SetBool("ExpressReduction", "DarkCorr", m_Params.DarkCorr);
		m_Params.DarkFrame = gtk_entry_get_text(GTK_ENTRY(m_DarkFrameEdit));
		g_Project->SetStr("DarkCorr", "File", m_Params.DarkFrame);
		CConfig::SetStr("DarkCorr", "File", m_Params.DarkFrame);
	}
	if (m_FlatCorrBtn && m_FlatFrameEdit) {
		m_Params.FlatCorr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_FlatCorrBtn))!=0;
		g_Project->SetBool("ExpressReduction", "FlatCorr", m_Params.FlatCorr);
		m_Params.FlatFrame = gtk_entry_get_text(GTK_ENTRY(m_FlatFrameEdit));
		g_Project->SetStr("FlatCorr", "File", m_Params.FlatFrame);
		CConfig::SetStr("FlatCorr", "File", m_Params.FlatFrame);
	}
	if (m_PhotometryBtn) {
		m_Params.Photometry = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_PhotometryBtn))!=0;
		g_Project->SetBool("ExpressReduction", "Photometry", m_Params.Photometry);
	}
	if (m_MatchingBtn && m_RefBtn) {
		m_Params.Matching = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_MatchingBtn))!=0;
		g_Project->SetBool("ExpressReduction", "Matching", m_Matching);
		m_Params.UseRef = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_RefBtn))!=0;
		g_Project->SetInt("MatchingDlg", "Select", (m_Params.UseRef ? 0 : 1));
	}
	if (m_RefFrameCombo) {
		m_Params.RefFrame = SelectedRefFrame();
		g_Project->SetInt("MatchingDlg", "Frame", m_Params.RefFrame);
	}
	if (m_CatFrameEdit) {
		m_Params.CatFile = gtk_entry_get_text(GTK_ENTRY(m_CatFrameEdit));
		g_Project->SetStr("MatchingDlg", "File", m_Params.CatFile);
		CConfig::SetStr("MatchingDlg", "File", m_Params.CatFile);
	}
	
	// Make list of unprocessed frames
	if (!m_Selected) {
		// All files
		GtkTreeModel *pList = g_Project->FileList();
		if (gtk_tree_model_iter_n_children(pList, NULL)>0) 
			gtk_tree_model_foreach(pList, foreach_all_files, &m_Params.FileList);
		else
			ShowError(m_pParent, "There are no files in the project.");
	} else {
		// Selected files
		GtkTreeSelection *pSel = g_MainWnd->GetSelection();
		if (gtk_tree_selection_count_selected_rows(pSel)>0) 
			gtk_tree_selection_selected_foreach(pSel, foreach_sel_files, &m_Params.FileList);
		else
			ShowError(m_pParent, "There are no selected files.");
	}

	if (m_Params.FileList) {
		if (m_Params.Convert && !m_Selected) {
			g_Project->ClearThumbnails();
			g_Project->ClearTempFiles();
			g_Project->ClearCorrections();
			g_Project->ClearReference();
			g_Project->ClearObject();
		}
		if (m_Params.Matching)
			g_Project->ClearReference();
		CProgressDlg pDlg(m_pParent, "Processing files");
		pDlg.SetMinMax(0, g_list_length(m_Params.FileList));
		res = pDlg.Execute(ExecuteProc, this);
		if (res!=0) {
			char *msg = cmpack_formaterror(res);
			ShowError(m_pParent, msg, true);
			cmpack_free(msg);
		} else
		if (m_Params.OutFiles==0) {
			ShowError(m_pParent, "No file was successfully processed.", true);
		} else 
		if (m_Params.OutFiles!=m_Params.InFiles) {
			sprintf(msg, "%d file(s) were successfully processed, %d file(s) failed.", 
				m_Params.OutFiles, m_Params.InFiles-m_Params.OutFiles);
			ShowWarning(m_pParent, msg, true);
		} else {
			sprintf(msg, "All %d file(s) were successfully processed.", m_Params.OutFiles);
			ShowInformation(m_pParent, msg, true);
		}
		g_list_foreach(m_Params.FileList, (GFunc)gtk_tree_row_reference_free, NULL);
		g_list_free(m_Params.FileList);
	}
	g_Project->Save();
}
예제 #20
0
int execute(int cmd)
{
  int ret = 0;
  if (asyncNotificationWaiting)
    {
      asyncNotificationWaiting = false;
      AsyncEventPrint();
    }

  printf("\n");
  switch(cmd)
    {
    case '1':
      Initialize();
      break;

    case '2':
      ShowBufferSize();
      break;

    case '3':
      StartSmartConfig();
      break;

    case '4':
      ManualConnect();
      break;

    case '5':
      ManualAddProfile();
      break;

    case '6':
      ListAccessPoints();
      break;

    case '7':
      ShowInformation();
      break;

    case '8':
     if (!isInitialized)
       {
         Initialize();
       }

#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
      mmprevious= mallinfo();
      show_memory_usage(&mmstart,&mmprevious);
#endif
      shell_main(0, 0);
#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
      mmprevious= mallinfo();
      show_memory_usage(&mmstart,&mmprevious);
#endif
      break;

    case 'q':
    case 'Q':
      ret = 1;
      break;

    default:
      printf("**Unknown command \"%d\" **\n", cmd);
      break;
    }

    return ret;
}
예제 #21
0
void CMasterBiasDlg::Execute()
{
	char msg[256];
	char *folder, *filename;

	// Default state
	GtkTreeSelection *pSel = g_MainWnd->GetSelection();
	gtk_widget_set_sensitive(m_SelBtn, 
		gtk_tree_selection_count_selected_rows(pSel)>0);
	if (gtk_tree_selection_count_selected_rows(pSel)>1) 
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_SelBtn), true);
	else
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_AllBtn), true);

	// Restore last folder and file name
	folder = g_Project->GetStr("MasterBias", "Folder", NULL);
	if (!folder)
		folder = CConfig::GetStr("MasterBias", "Folder", NULL);
	if (!folder)
		folder = g_path_get_dirname(g_Project->Path());
	if (folder && g_file_test(folder, G_FILE_TEST_IS_DIR)) 
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_pDlg), folder);
	g_free(folder);
	filename = g_Project->GetStr("MasterBias", "File", "masterbias." FILE_EXTENSION_FITS);
	if (filename) 
		gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_pDlg), filename);
	g_free(filename);

	// Execute the dialog
	if (gtk_dialog_run(GTK_DIALOG(m_pDlg))!=GTK_RESPONSE_ACCEPT)
		return;
	gtk_widget_hide(m_pDlg);

	// Target file path and name
	m_FilePath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_pDlg));
	CConfig::SetStr("BiasCorr", "File", m_FilePath);

	gchar *dirpath = g_path_get_dirname(m_FilePath);
	g_Project->SetStr("MasterBias", "Folder", dirpath);
	CConfig::SetStr("MasterBias", "Folder", dirpath);
	g_free(dirpath);
	gchar *basename = g_path_get_basename(m_FilePath);
	g_Project->SetStr("MasterBias", "File", basename);
	g_free(basename);

	// Make list of files
	m_FileList = NULL;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_AllBtn))) {
		// All files
		GtkTreeModel *pList = g_Project->FileList();
		if (gtk_tree_model_iter_n_children(pList, NULL)>0) 
			gtk_tree_model_foreach(pList, foreach_all_files, &m_FileList);
		else
			ShowError(m_pParent, "There are no files in the project.");
	} else {
		// Selected files
		GtkTreeSelection *pSel = g_MainWnd->GetSelection();
		if (gtk_tree_selection_count_selected_rows(pSel)>0) 
			gtk_tree_selection_selected_foreach(pSel, foreach_sel_files, &m_FileList);
		else
			ShowError(m_pParent, "There are no selected files.");
	}

	// Process files
	if (m_FileList) {
		CProgressDlg pDlg(m_pParent, "Reading files");
		pDlg.SetMinMax(0, g_list_length(m_FileList));
		int res = pDlg.Execute(ExecuteProc, this);
		if (res!=0) {
			char *msg = cmpack_formaterror(res);
			ShowError(m_pParent, msg, true);
			cmpack_free(msg);
		} else if (!pDlg.Cancelled()) {
			sprintf(msg, "All %d file(s) were successfully processed.", m_InFiles);
			ShowInformation(m_pParent, msg, true);
			CCCDFileDlg *pdlg = new CCCDFileDlg();
			GError *error = NULL;
			if (pdlg->Load(m_FilePath, &error)) {
				pdlg->Show();
				CConfig::AddFileToRecentList(TYPE_IMAGE, m_FilePath);
			} else {
				if (error) {
					ShowError(m_pParent, error->message, true);
					g_error_free(error);
				}
				delete pdlg;
			}
		}
		g_list_foreach(m_FileList, (GFunc)gtk_tree_row_reference_free, NULL);
		g_list_free(m_FileList);
		m_FileList = NULL;
	}
	g_free(m_FilePath);
	m_FilePath = NULL;
	g_Project->Save();
	CConfig::Flush();
}