/* function: "write_png(bmp, path[, color_type, text_dict])\n
Writes the bitmap as a png at the given path.\n
Raises OSError on failure.\n
\n
Optional parameters:\n
 - color_type: A constant from the png-module (e.g. png.RGB_ALPHA)\n
 - text_dict: A dictionary of key-strings to value-strings\n
   for png tEXt meta-data."
name: "write_png" */
static void write_png_py(const FilePath& p,
  const Bitmap& bmp,
  const Optional<int>& rawColorType,
  const Optional<png_tEXt_map>& maybeTextChunks)
{
  const auto defaultType = static_cast<int>(PngColorType::RGB_ALPHA);

  const auto colorType =
    to_enum<PngColorType>(rawColorType.Or(defaultType)).Visit(
      [](const PngColorType t){
        return t;
      },
      []() -> PngColorType{
        throw ValueError("color_type out of range.");
      });

  auto r = maybeTextChunks.Visit(
    [&](const png_tEXt_map& textChunks){
      return write_png(p, bmp, colorType, textChunks);
    },
    [&](){
      return write_png(p, bmp, colorType);
    });

  if (!r.Successful()){
    throw OSError(r.ErrorDescription());
  }
}
Exemplo n.º 2
0
void CMainForm::showAddform()
{
	if(m_pAddPlan == NULL)
	{
		m_pMainStack->addWidget(m_pAddPlan = new CSVAddPlan());
		WObject::connect(m_pAddPlan, SIGNAL(Successful(ADD_PLAN_OK)), this,
			SLOT(SaveNewPlanList(ADD_PLAN_OK)));

		WObject::connect(m_pAddPlan, SIGNAL(SCancel()), this,
			SLOT(CancelAdd()));
	}
	m_pAddPlan->clearContent();
	showAddPlan();
}
Exemplo n.º 3
0
void CMainForm::EditNewPlanList1(ADD_PLAN_OK addPlan)
{	
	if(m_pAddAbsolutePlan == NULL)
	{		
		m_pMainStack->addWidget(m_pAddAbsolutePlan = new CSVAddAbsolutePlan());
		WObject::connect(m_pAddAbsolutePlan, SIGNAL(Successful(ADD_PLAN_OK)), this,
			SLOT(SaveNewPlanList1(ADD_PLAN_OK)));

		WObject::connect(m_pAddAbsolutePlan, SIGNAL(SCancel1()), this,
			SLOT(CancelAdd()));
	}

	m_pAddAbsolutePlan->clearContent();
	m_pAddAbsolutePlan->UpdateData(addPlan);
	showAddPlan1();
}
Exemplo n.º 4
0
void CSVAddPlan::Save()
{
	bool bEnd = false;	
	string strUserID = GetWebUserID();

	HitLog LogItem;
	LogItem.sUserName = strUserID;
	LogItem.sHitPro = "Plan Set";
	LogItem.sHitFunc = "Save";
	LogItem.sDesc = szSaveAddInPlan;

	DWORD dcalBegin=GetTickCount();
	InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 0, 0);

OPEnd:
	if(bEnd)
	{
		DWORD dcalEnd=GetTickCount();
		InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 1, dcalEnd -dcalBegin);
		return;
	}
	
	ADD_PLAN_OK addPlan;
    bool bCheck = 0;

    addPlan.szName = m_pName->text();

	std::list<string> errorMsgList;

	
    if (addPlan.szName.empty())
    {
		errorMsgList.push_back(m_FormShowText.szErrorMsg);
		AddRangeTable->ShowErrorMsg(errorMsgList);
		//m_pPlanNameError->show();
		bEnd = true;	
		goto OPEnd;
    }
	//else
	//{
	//	AddRangeTable -> HideAllErrorMsg();
	//	//m_pPlanNameError-> hide();
	//}

	std::string str1 = m_pTasklist->m_pStart[1]->text();
	//Jansion.zhou 2006-12-25
    //m_pErrMsg->setText("");
    //m_pErrMsg->hide();

    addPlan.nIndex = m_nIndex;

	std::list<string> tasknamelist;
	std::list<string>::iterator m_pItem;
	bool IsSave = false;
	bool IsConn = GetAllTaskName(tasknamelist);
	
	if(IsConn)
	{
		OutputDebugString("----------------isconn true------------------\n");
		for(m_pItem = tasknamelist.begin(); m_pItem != tasknamelist.end(); m_pItem++)
		{
			std::string str = *m_pItem;
			if(strcmp(str.c_str(), addPlan.szName.c_str()) == 0)
			{
				IsSave = true;
				break;
			}
		}
		
		
		if(strcmp(chgstr.c_str(), "") == 0)
		{
			if(!IsSave)
			{
				OutputDebugString("----------------Issave false------------------\n");
				OBJECT hTask = CreateTask(addPlan.szName);
				
				SetTaskValue("Type", m_FormShowText.szPlanTypeRel, hTask);
				char buf[256];
				for(int i = 0; i < 7; i++)
				{

					itoa(i, buf, 10);
					std::string temp = m_pTasklist->m_pStart[i]->text();
					std::string temp1 = "start";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);
					
					temp = m_pTasklist->m_pEnd[i]->text();
					temp1 = "end";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);
					
					temp1 = "Allow";
					temp1 += buf;

					std::string temp3 = m_pTasklist->m_pCombo[i]->currentText();
					if(strcmp(temp3.c_str(), strAllown.c_str()) == 0)
					{
						SetTaskValue(temp1, m_FormShowText.szStatusAllow, hTask);
					}
					else
					{
						SetTaskValue(temp1, m_FormShowText.szStatusDeny, hTask);
					}
				}
				SetTaskValue("Description", textarea->text(), hTask);
				SubmitTask(hTask);

				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText("");
				//m_pErrMsg->hide();
				addPlan.nIndex = m_nIndex;

				//插记录到UserOperateLog表
				string strUserID = GetWebUserID();
				TTime mNowTime = TTime::GetCurrentTimeEx();
				OperateLog m_pOperateLog;
				m_pOperateLog.InsertOperateRecord("UserOperateLog",strUserID,mNowTime.Format(),strTypeAdd,strTimeTaskPlan,m_pName->text());

				emit Successful(addPlan);
			}
			else
			{
OutputDebugString("----------------Issave true------------------\n");
				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText(m_FormShowText.szErrorMsg1);
				//m_pErrMsg->show();

				errorMsgList.push_back(m_FormShowText.szErrorMsg1);
				AddRangeTable->ShowErrorMsg(errorMsgList);
			}
		}
		else
		{

			std::string str;
			for(m_pItem = tasknamelist.begin(); m_pItem != tasknamelist.end(); m_pItem++)
			{
				str = *m_pItem;
				if(strcmp(str.c_str(), addPlan.szName.c_str()) == 0)
				{
					if(strcmp(str.c_str(), chgstr.c_str()) != 0)
					{
						IsSave = true;
						break;
					}
					else
					{				
						IsSave = false;
						break;
					}
				}
			}

			
			if(!IsSave)
			{
				OutputDebugString("----------------Issave00 false------------------\n");
				OBJECT hTask = GetTask(chgstr);
				
				SetTaskValue("Type", m_FormShowText.szPlanTypeRel, hTask);
				char buf[256];
				for(int i = 0; i < 7; i++)
				{
					itoa(i, buf, 10);
					std::string temp = m_pTasklist->m_pStart[i]->text();
					std::string temp1 = "start";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);
					
					temp = m_pTasklist->m_pEnd[i]->text();
					temp1 = "end";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);

					temp1 = "Allow";
					temp1 += buf;

					std::string temp3 = m_pTasklist->m_pCombo[i]->currentText();
					if(strcmp(temp3.c_str(), strAllown.c_str()) == 0)
					{
						SetTaskValue(temp1, m_FormShowText.szStatusAllow, hTask);
					}
					else
					{
						SetTaskValue(temp1, m_FormShowText.szStatusDeny, hTask);
					}
				}
				SetTaskValue("Description", textarea->text(), hTask);
				EditTask(hTask,addPlan.szName);

				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText("");
				//m_pErrMsg->hide();

				addPlan.nIndex = m_nIndex;

				//插记录到UserOperateLog表
				string strUserID = GetWebUserID();
				TTime mNowTime = TTime::GetCurrentTimeEx();
				OperateLog m_pOperateLog;
				m_pOperateLog.InsertOperateRecord("UserOperateLog",strUserID,mNowTime.Format(),strTypeEdit,strTimeTaskPlan,m_pName->text());

				chgstr = "";
				emit Successful(addPlan);
			}
			else
			{
				OutputDebugString("----------------Issave000 true------------------\n");
				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText(m_FormShowText.szErrorMsg1);
				//m_pErrMsg->show();

				errorMsgList.push_back(m_FormShowText.szErrorMsg1);
				AddRangeTable->ShowErrorMsg(errorMsgList);
			}
		}
	}
	else
	{

	}

	DWORD dcalEnd1=GetTickCount();
	InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 1, dcalEnd1 - dcalBegin);
}