void CParticleModelParamGridProperty::Init(BOOL bEnable) { if(bEnable) m_sParamType="Constant"; else m_sParamType="Default"; // Param Type CParticleTypesGridProperty* pType=new CParticleTypesGridProperty("Type",m_sParamType); pType->AddOption("Default"); pType->AddOption("Constant"); pType->AddOption("Mutable"); pType->AddOption("Random"); pType->AddOption("Mutable And Random"); pType->AddOption("Interpolator"); pType->AllowEdit(FALSE); pType->SetDescription("Choose param type: Default、Constant、Mutable、Random、Mutable And Random、Interpolator."); pType->SetType(Property_ModelParamType); AddSubItem(pType); // Interpolator Type m_pInterpolatorType=new CParticleTypesGridProperty("Interpolator Type","SelfDefine"); m_pInterpolatorType->AddOption("SelfDefine"); m_pInterpolatorType->AddOption("Sinusoidal"); m_pInterpolatorType->AddOption("Polynomial"); m_pInterpolatorType->AllowEdit(FALSE); m_pInterpolatorType->SetDescription("Choose interpolator type: Self Define、Sinusoidal、Polynomial."); m_pInterpolatorType->SetType(Property_InterpolatorType); AddSubItem(m_pInterpolatorType); // m_InterpolatorVector.push_back(pInterpolatorType); SetModelParamType(m_sParamType,FALSE); Expand(FALSE); }
CMFCPropertyGridProperty * ChannelGrid::CreateTcpServer() { auto pGroup = new CMFCPropertyGridProperty(_T("TCP服务器"), 0, TRUE); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("绑定地址"), (_variant_t)_T("0.0.0.0"), _T("本机网络绑定地址"))); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("绑定端口"), (_variant_t)4000u, _T("本机网络绑定端口"))); pGroup->Expand(FALSE); return pGroup; }
CMFCPropertyGridProperty * ChannelGrid::CreateUdp() { auto pGroup = new CMFCPropertyGridProperty(_T("UDP端口"), 0, TRUE); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("远程地址"), (_variant_t)_T("192.168.1.9"), _T("远程服务地址"))); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("远程端口"), (_variant_t)4000u, _T("远程服务端口"))); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("绑定地址"), (_variant_t)_T("192.168.1.200"), _T("远端设备本机网络绑定地址"))); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("绑定端口"), (_variant_t)4000u, _T("远端设备本机网络绑定端口"))); pGroup->Expand(FALSE); return pGroup; }
CMFCPropertyGridProperty * ChannelGrid::CreatePlugin() { auto pGroup = new CMFCPropertyGridProperty(_T("插件")); auto pProp = new CMFCPropertyGridProperty(_T("插件"), (_variant_t)_T("Example"), _T("插件选择")); pProp->AddOption(_T("MultiNet")); pProp->AddOption(_T("Example")); pProp->AllowEdit(FALSE); pGroup->AddSubItem(pProp); pGroup->AddSubItem(new CMFCPropertyGridPluginProperty(_T("本地插件配置"), pProp, (_variant_t)_T(""), _T("远端插件配置"))); pGroup->AddSubItem(new CMFCPropertyGridPluginProperty(_T("本地插件配置"), pProp, (_variant_t)_T(""), _T("远端插件配置"))); return pGroup; }
CMFCPropertyGridProperty * ChannelGrid::CreateSerialLocal() { auto pGroup = new CMFCPropertyGridProperty(_T("本地串口"), 0, TRUE); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("串口设备"), (_variant_t)_T("COM4"), _T("本机虚拟串口名称,如COM4."))); pGroup->Expand(FALSE); return pGroup; }
void CParticleModelParamGridProperty::SetInterpolatorType(CString sType,BOOL bNotify) { if(sType==m_sInterpolatorType&&bNotify) return ; unsigned int i; for(i=0;i<m_InterpolatorVector.size();++i) RemoveSubItem(m_InterpolatorVector[i]); m_InterpolatorVector.clear(); float ratio=1.0f; if(m_bRGBA) ratio=255.0f; else if(m_bAngle) ratio=180.0f; if(sType=="SelfDefine") { CParticleEntrysGridProperty* pEntrysProperty=new CParticleEntrysGridProperty("Entrys"); if(m_bRGBA) pEntrysProperty->SetIsRGBA(); else if(m_bAngle) pEntrysProperty->SetIsAngle(); pEntrysProperty->SetDescription("Right click mouse can popup menu to add new entry."); m_InterpolatorVector.push_back(pEntrysProperty); m_InterpolatorVector.push_back(new CParticleInterpolatorGraphProperty("Show Graph",COleVariant(""))); } else if(sType=="Sinusoidal") { m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Period",COleVariant(1.0f))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Min Amplitude",COleVariant(1.0f*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Max Amplitude",COleVariant(1.0f*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X Offset",COleVariant(0.0f))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Y Offset",COleVariant(0.0f*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X Start",COleVariant(0.0f))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Length",COleVariant((long)1))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Samples",COleVariant((long)2),"This value must >=2")); m_InterpolatorVector.push_back(new CParticleInterpolatorGraphProperty("Show Graph",COleVariant(""))); } else if(sType=="Polynomial") { m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Constant Value",COleVariant(0.0f*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Linear Value",COleVariant(1.0f*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Quad Value",COleVariant(0.0f*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Cubic Value",COleVariant(0.0f*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X Start",COleVariant(0.0f))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X End",COleVariant(1.0f))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Samples",COleVariant((long)2),"This value must >=2")); m_InterpolatorVector.push_back(new CParticleInterpolatorGraphProperty("Show Graph",COleVariant(""))); } for(i=0;i<m_InterpolatorVector.size();++i) AddSubItem(m_InterpolatorVector[i]); if(sType=="SelfDefine") { for(i=0;i<m_InterpolatorVector.size()-1;++i) { ((CParticleEntrysGridProperty*)m_InterpolatorVector[i])->Init(); } } m_sInterpolatorType=sType; if(bNotify) m_pWndList->GetParent()->PostMessage(UM_UPDATE_PROPERTYCTRL); }
/** * This method adds a row to the listview. * * @param hContact - contact to add the line for * @param pszProto - contact's protocol * @param ad - anniversary to add * @param mtNow - current time * @param wDaysBefore - number of days in advance to remind the user of the anniversary * * @retval TRUE if successful * @retval FALSE if failed **/ BYTE AddRow(MCONTACT hContact, LPCSTR pszProto, MAnnivDate &ad, MTime &mtNow, WORD wDaysBefore) { TCHAR szText[MAX_PATH]; int diff, iItem = -1; CItemData *pdata; // first column: ETA diff = ad.CompareDays(mtNow); if (diff < 0) diff += IsLeap(mtNow.Year() + 1) ? 366 : 365; // is filtered if (diff <= _filter.wDaysBefore) { // read reminder options for the contact ad.DBGetReminderOpts(hContact); if ((_filter.bFilterIndex != FILTER_DISABLED_REMINDER) || (ad.RemindOption() == BST_UNCHECKED)) { // set default offset if required if (ad.RemindOffset() == (WORD)-1) { ad.RemindOffset(wDaysBefore); // create data object pdata = new CItemData(hContact, ad); if (!pdata) return FALSE; // add item iItem = AddItem(_itot(diff, szText, 10), (LPARAM)pdata); if (iItem == -1) { delete pdata; return FALSE; } // second column: contact name AddSubItem(iItem, COLUMN_CONTACT, DB::Contact::DisplayName(hContact)); // third column: protocol TCHAR *ptszProto = mir_a2t(pszProto); AddSubItem(iItem, COLUMN_PROTO, ptszProto); mir_free(ptszProto); // forth line: age if (ad.Age(&mtNow)) AddSubItem(iItem, COLUMN_AGE, _itot(ad.Age(&mtNow), szText, 10)); else AddSubItem(iItem, COLUMN_AGE, _T("???")); // fifth line: anniversary AddSubItem(iItem, COLUMN_DESC, (LPTSTR)ad.Description()); // sixth line: date ad.DateFormatAlt(szText, _countof(szText)); AddSubItem(iItem, COLUMN_DATE, szText); _numRows++; } } } return TRUE; }
CMFCPropertyGridProperty * ChannelGrid::CreateSerial() { auto pGroup = new CMFCPropertyGridProperty(_T("本地串口"), 0, TRUE); pGroup->AddSubItem(new CMFCPropertyGridProperty(_T("串口设备"), (_variant_t)_T("ttyS1"), _T("设备中串口的文件名,如ttyS1 ttyUSB0 ttyM0等"))); auto pProp = new CMFCPropertyGridProperty(_T("波特率"), (_variant_t)9600u, _T("串口波特率")); pProp->AddOption(_T("4800")); pProp->AddOption(_T("9600")); pProp->AddOption(_T("115200")); pProp->AllowEdit(TRUE); pGroup->AddSubItem(pProp); pProp = new CMFCPropertyGridProperty(_T("数据位"), (_variant_t)8u, _T("串口数据位长度")); pProp->AddOption(_T("5")); pProp->AddOption(_T("6")); pProp->AddOption(_T("7")); pProp->AddOption(_T("8")); pProp->AllowEdit(FALSE); pGroup->AddSubItem(pProp); pProp = new CMFCPropertyGridProperty(_T("停止位"), (_variant_t)_T("1"), _T("串口停止位长度")); pProp->AddOption(_T("1")); pProp->AddOption(_T("2")); pProp->AddOption(_T("1.5")); pProp->AllowEdit(FALSE); pGroup->AddSubItem(pProp); pProp = new CMFCPropertyGridProperty(_T("校验"), (_variant_t)_T("无"), _T("串口校验方式")); pProp->AddOption(_T("无")); pProp->AddOption(_T("偶校验")); pProp->AddOption(_T("奇校验")); pProp->AddOption(_T("置1")); pProp->AddOption(_T("置0")); pProp->AllowEdit(FALSE); pGroup->AddSubItem(pProp); pProp = new CMFCPropertyGridProperty(_T("流控制"), (_variant_t)_T("无"), _T("串口数据流控制")); pProp->AddOption(_T("无")); pProp->AddOption(_T("软件")); pProp->AddOption(_T("硬件")); pProp->AllowEdit(FALSE); pGroup->AddSubItem(pProp); pGroup->Expand(FALSE); return pGroup; }
void CGradientEditor::SetGradient(CGradient *gradient) { this->gradient = gradient; if ((unsigned)gradient->GetStepCount() > stepHandles.size()) { for (unsigned int i = stepHandles.size(); i < gradient->GetStepCount(); i++) { CStepHandle *handle = new CStepHandle(this); stepHandles.push_back(handle); AddSubItem(handle); } } for (unsigned int i = 0; i < stepHandles.size(); i++) { stepHandles[i]->SetEnabled(i < gradient->GetStepCount()); if (i < gradient->GetStepCount()) { stepHandles[i]->SetGradientInfo(gradient, gradient->GetStepID(i)); } } }
void CParticleModelParamGridProperty::LoadFromData(ParticleInterpolatorParam& data,ParticleModelParam& model) { uint32 flag=(1<<m_Index); ASSERT(flag&model.m_EnableFlag); ASSERT(flag&model.m_InterpolatedFlag); ASSERT((flag&model.m_RandomFlag)==0); ASSERT((flag&model.m_MutableFlag)==0); m_PropertyVector.clear(); m_InterpolatorVector.clear(); float ratio=1.0f; if(m_bRGBA) ratio=255.0f; else if(m_bAngle) ratio=180.0f/float_Pi; switch(data.m_InterpolatorType) { case Interpolator_SelfDefine: { m_sInterpolatorType="SelfDefine"; ParticleSelfDefInterpolatorData& selfData=data.m_SelfDefData; CParticleEntrysGridProperty* pEntrysProperty=new CParticleEntrysGridProperty("Entrys"); if(m_bRGBA) pEntrysProperty->SetIsRGBA(); else if(m_bAngle) pEntrysProperty->SetIsAngle(); pEntrysProperty->SetDescription("Right click mouse can popup menu to add new entry."); m_InterpolatorVector.push_back(pEntrysProperty); m_InterpolatorVector.push_back(new CParticleInterpolatorGraphProperty("Show Graph",COleVariant(""))); } break; case Interpolator_Sinusoidal: { m_sInterpolatorType="Sinusoidal"; ParticleSinInterpolatorData& sinData=data.m_SinData; m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Period",COleVariant(sinData.m_period))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Min Amplitude",COleVariant(sinData.m_amplitudeMin*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Max Amplitude",COleVariant(sinData.m_amplitudeMax*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X Offset",COleVariant(sinData.m_offsetX))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Y Offset",COleVariant(sinData.m_offsetY*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X Start",COleVariant(sinData.m_startX))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Length",COleVariant((long)sinData.m_length))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Samples",COleVariant((long)sinData.m_nbSamples))); m_InterpolatorVector.push_back(new CParticleInterpolatorGraphProperty("Show Graph",COleVariant(""))); } break; case Interpolator_Polynomial: { m_sInterpolatorType="Polynomial"; ParticlePolyInterpolatorData& polyData=data.m_PolyData; m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Constant Value",COleVariant(polyData.m_constant*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Linear Value",COleVariant(polyData.m_linear*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Quad Value",COleVariant(polyData.m_quadratic*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Cubic Value",COleVariant(polyData.m_cubic*ratio))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X Start",COleVariant(polyData.m_startX))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("X End",COleVariant(polyData.m_endX))); m_InterpolatorVector.push_back(new CMFCPropertyGridProperty("Samples",COleVariant((long)polyData.m_nbSamples))); m_InterpolatorVector.push_back(new CParticleInterpolatorGraphProperty("Show Graph",COleVariant(""))); } break; default: ASSERT(FALSE); break; } m_sParamType="Interpolator"; // Param Type CParticleTypesGridProperty* pType=new CParticleTypesGridProperty("Type",m_sParamType); pType->AddOption("Default"); pType->AddOption("Constant"); pType->AddOption("Mutable"); pType->AddOption("Random"); pType->AddOption("Mutable And Random"); pType->AddOption("Interpolator"); pType->AllowEdit(FALSE); pType->SetDescription("Choose param type: Default、Constant、Mutable、Random、Mutable And Random、Interpolator."); pType->SetType(Property_ModelParamType); AddSubItem(pType); // Interpolator Type m_pInterpolatorType=new CParticleTypesGridProperty("Interpolator Type",m_sInterpolatorType); m_pInterpolatorType->AddOption("SelfDefine"); m_pInterpolatorType->AddOption("Sinusoidal"); m_pInterpolatorType->AddOption("Polynomial"); m_pInterpolatorType->AllowEdit(FALSE); m_pInterpolatorType->SetDescription("Choose interpolator type: Self Define、Sinusoidal、Polynomial."); m_pInterpolatorType->SetType(Property_InterpolatorType); AddSubItem(m_pInterpolatorType); for(uint32 i=0;i<m_InterpolatorVector.size();++i) AddSubItem(m_InterpolatorVector[i]); if(m_sInterpolatorType=="SelfDefine") ((CParticleEntrysGridProperty*)m_InterpolatorVector[0])->LoadFromData(data.m_SelfDefData); Expand(FALSE); }
void CParticleModelParamGridProperty::LoadFromData(ParticleRegularParam& data,ParticleModelParam& model) { m_PropertyVector.clear(); m_InterpolatorVector.clear(); uint32 flag=(1<<m_Index); switch(data.m_count) { case 1: { ASSERT(flag&model.m_EnableFlag); ASSERT((flag&model.m_MutableFlag)==0); ASSERT((flag&model.m_RandomFlag)==0); ASSERT((flag&model.m_InterpolatedFlag)==0); m_sParamType="Constant"; if(m_bRGBA) m_PropertyVector.push_back(new CMFCPropertyGridProperty("Value",COleVariant((long)(data.m_data[0]*255)),m_sDescription)); else if(m_bAngle) m_PropertyVector.push_back(new CMFCPropertyGridProperty("Value",COleVariant((long)(data.m_data[0]*180/float_Pi)),m_sDescription)); else m_PropertyVector.push_back(new CMFCPropertyGridProperty("Value",COleVariant(data.m_data[0]),m_sDescription)); } break; case 2: { ASSERT(flag&model.m_EnableFlag); ASSERT((flag&model.m_InterpolatedFlag)==0); if((flag&model.m_MutableFlag)!=0)// Mutable { ASSERT((flag&model.m_RandomFlag)==0); m_sParamType="Mutable"; if(m_bRGBA) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth Value",COleVariant((long)(data.m_data[0]*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death Value",COleVariant((long)(data.m_data[1]*255)),m_sDescription)); } else if(m_bAngle) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth Value",COleVariant((long)(data.m_data[0]*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death Value",COleVariant((long)(data.m_data[1]*180/float_Pi)),m_sDescription)); } else { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth Value",COleVariant(data.m_data[0]),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death Value",COleVariant(data.m_data[1]),m_sDescription)); } } else// Random { ASSERT((flag&model.m_MutableFlag)==0); ASSERT(flag&model.m_RandomFlag); m_sParamType="Random"; if(m_bRGBA) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Min Value",COleVariant((long)(data.m_data[0]*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Max Value",COleVariant((long)(data.m_data[1]*255)),m_sDescription)); } else if(m_bAngle) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Min Value",COleVariant((long)(data.m_data[0]*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Max Value",COleVariant((long)(data.m_data[1]*180/float_Pi)),m_sDescription)); } else { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Min Value",COleVariant(data.m_data[0]),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Max Value",COleVariant(data.m_data[1]),m_sDescription)); } } } break; case 4: { ASSERT(flag&model.m_EnableFlag); ASSERT(flag&model.m_MutableFlag); ASSERT(flag&model.m_RandomFlag); ASSERT((flag&model.m_InterpolatedFlag)==0); m_sParamType="Mutable And Random"; if(m_bRGBA) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MinVal",COleVariant((long)(data.m_data[0]*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MaxVal",COleVariant((long)(data.m_data[1]*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MinVal",COleVariant((long)(data.m_data[2]*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MaxVal",COleVariant((long)(data.m_data[3]*255)),m_sDescription)); } else if(m_bAngle) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MinVal",COleVariant((long)(data.m_data[0]*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MaxVal",COleVariant((long)(data.m_data[1]*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MinVal",COleVariant((long)(data.m_data[2]*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MaxVal",COleVariant((long)(data.m_data[3]*180/float_Pi)),m_sDescription)); } else { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MinVal",COleVariant(data.m_data[0]),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MaxVal",COleVariant(data.m_data[1]),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MinVal",COleVariant(data.m_data[2]),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MaxVal",COleVariant(data.m_data[3]),m_sDescription)); } } break; default: ASSERT(FALSE); break; } // Param Type CParticleTypesGridProperty* pType=new CParticleTypesGridProperty("Type",m_sParamType); pType->AddOption("Default"); pType->AddOption("Constant"); pType->AddOption("Mutable"); pType->AddOption("Random"); pType->AddOption("Mutable And Random"); pType->AddOption("Interpolator"); pType->AllowEdit(FALSE); pType->SetDescription("Choose param type: Default、Constant、Mutable、Random、Mutable And Random、Interpolator."); pType->SetType(Property_ModelParamType); AddSubItem(pType); // Interpolator Type m_pInterpolatorType=new CParticleTypesGridProperty("Interpolator Type","SelfDefine"); m_pInterpolatorType->AddOption("SelfDefine"); m_pInterpolatorType->AddOption("Sinusoidal"); m_pInterpolatorType->AddOption("Polynomial"); m_pInterpolatorType->AllowEdit(FALSE); m_pInterpolatorType->SetDescription("Choose interpolator type: Self Define、Sinusoidal、Polynomial."); m_pInterpolatorType->SetType(Property_InterpolatorType); AddSubItem(m_pInterpolatorType); m_pInterpolatorType->Show(FALSE,FALSE); for(uint32 i=0;i<m_PropertyVector.size();++i) AddSubItem(m_PropertyVector[i]); Expand(FALSE); }
void CParticleModelParamGridProperty::SetModelParamType(CString sType,BOOL bNotify) { if(m_sParamType==sType&&bNotify) return ; unsigned int i; for(i=0;i<m_PropertyVector.size();++i) RemoveSubItem(m_PropertyVector[i]); m_PropertyVector.clear(); if(sType=="Default") { CMFCPropertyGridProperty *pDefaultValue; if(m_bRGBA) pDefaultValue=new CMFCPropertyGridProperty("Default Value",COleVariant((long)(m_fDefaultVal*255))); else if(m_bAngle) pDefaultValue=new CMFCPropertyGridProperty("Default Value",COleVariant((long)(m_fDefaultVal*180/float_Pi))); else pDefaultValue=new CMFCPropertyGridProperty("Default Value",COleVariant(m_fDefaultVal)); pDefaultValue->AllowEdit(FALSE); m_PropertyVector.push_back(pDefaultValue); m_pInterpolatorType->Show(FALSE,FALSE); for(i=0;i<m_InterpolatorVector.size();++i) RemoveSubItem(m_InterpolatorVector[i]); m_InterpolatorVector.clear(); } else if(sType=="Constant") { CMFCPropertyGridProperty* pValue; if(m_bRGBA) pValue=new CMFCPropertyGridProperty("Value",COleVariant((long)(m_fDefaultVal*255)),m_sDescription); else if(m_bAngle) pValue=new CMFCPropertyGridProperty("Value",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription); else pValue=new CMFCPropertyGridProperty("Value",COleVariant(m_fDefaultVal),m_sDescription); m_PropertyVector.push_back(pValue); m_pInterpolatorType->Show(FALSE,FALSE); for(i=0;i<m_InterpolatorVector.size();++i) RemoveSubItem(m_InterpolatorVector[i]); m_InterpolatorVector.clear(); } else if(sType=="Random") { if(m_bRGBA) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Min Value",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Max Value",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); } else if(m_bAngle) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Min Value",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Max Value",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); } else { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Min Value",COleVariant(m_fDefaultVal),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Max Value",COleVariant(m_fDefaultVal),m_sDescription)); } m_pInterpolatorType->Show(FALSE,FALSE); for(i=0;i<m_InterpolatorVector.size();++i) RemoveSubItem(m_InterpolatorVector[i]); m_InterpolatorVector.clear(); } else if(sType=="Mutable") { if(m_bRGBA) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth Value",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death Value",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); } else if(m_bAngle) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth Value",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death Value",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); } else { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth Value",COleVariant(m_fDefaultVal),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death Value",COleVariant(m_fDefaultVal),m_sDescription)); } m_pInterpolatorType->Show(FALSE,FALSE); for(i=0;i<m_InterpolatorVector.size();++i) RemoveSubItem(m_InterpolatorVector[i]); m_InterpolatorVector.clear(); } else if(sType=="Mutable And Random") { if(m_bRGBA) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MinVal",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MaxVal",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MinVal",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MaxVal",COleVariant((long)(m_fDefaultVal*255)),m_sDescription)); } else if(m_bAngle) { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MinVal",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MaxVal",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MinVal",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MaxVal",COleVariant((long)(m_fDefaultVal*180/float_Pi)),m_sDescription)); } else { m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MinVal",COleVariant(m_fDefaultVal),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Birth MaxVal",COleVariant(m_fDefaultVal),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MinVal",COleVariant(m_fDefaultVal),m_sDescription)); m_PropertyVector.push_back(new CMFCPropertyGridProperty("Death MaxVal",COleVariant(m_fDefaultVal),m_sDescription)); } m_pInterpolatorType->Show(FALSE,FALSE); for(i=0;i<m_InterpolatorVector.size();++i) RemoveSubItem(m_InterpolatorVector[i]); m_InterpolatorVector.clear(); } else if(sType=="Interpolator") { m_pInterpolatorType->Show(TRUE,FALSE); SetInterpolatorType(m_pInterpolatorType->GetValue(),FALSE); } else ASSERT(FALSE); m_sParamType=sType; for(i=0;i<m_PropertyVector.size();++i) AddSubItem(m_PropertyVector[i]); if(bNotify) m_pWndList->GetParent()->PostMessage(UM_UPDATE_PROPERTYCTRL); }
int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { #if defined(_DEBUG) || defined(NETLIB_LOG) InitNetlib(); Sent_NetLog("onModuleLoaded begin"); #endif bMetaContacts = ServiceExists(MS_MC_GETMETACONTACT)!=0; bPopupExists = ServiceExists(MS_POPUP_ADDPOPUPEX)!=0; bPopupUnicode = ServiceExists(MS_POPUP_ADDPOPUPW)!=0; g_hFolders = FoldersRegisterCustomPath(szModuleName, "Icons", MIRANDA_PATH"\\icons"); if( g_hFolders==(HANDLE)CALLSERVICE_NOTFOUND ) g_hFolders = 0; InitIcons(); GetFlags(); #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("rsa_init"); #endif { // RSA/AES rsa_init(&exp,&imp); DBVARIANT dbv; dbv.type = DBVT_BLOB; if( DBGetContactSetting(0,szModuleName,"rsa_priv",&dbv) == 0 ) { exp->rsa_set_keypair(CPP_MODE_RSA_4096,dbv.pbVal,dbv.cpbVal); DBFreeVariant(&dbv); rsa_4096=1; } else if( DBGetContactSetting(0,szModuleName,"rsa_priv_4096",&dbv) == 0 ) { exp->rsa_set_keypair(CPP_MODE_RSA_4096|CPP_MODE_RSA_BER,dbv.pbVal,dbv.cpbVal); DBFreeVariant(&dbv); char priv_key[4096]; int priv_len; char pub_key[4096]; int pub_len; DBCONTACTWRITESETTING cws; cws.szModule = szModuleName; cws.value.type = DBVT_BLOB; exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len); cws.szSetting = "rsa_priv"; cws.value.pbVal = (PBYTE)&priv_key; cws.value.cpbVal = priv_len; CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); cws.szSetting = "rsa_pub"; cws.value.pbVal = (PBYTE)&pub_key; cws.value.cpbVal = pub_len; CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)0, (LPARAM)&cws); DBDeleteContactSetting(0, szModuleName, "rsa_priv_2048"); DBDeleteContactSetting(0, szModuleName, "rsa_pub_2048"); // DBDeleteContactSetting(0, szModuleName, "rsa_priv_4096"); // DBDeleteContactSetting(0, szModuleName, "rsa_pub_4096"); rsa_4096=1; } if( !rsa_4096 ) { unsigned int tID; CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttGenerateRSA, NULL, 0, &tID) ); } exp->rsa_set_timeout( DBGetContactSettingWord(0,szModuleName,"ket",10) ); } #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("pgp_init"); #endif bPGP = DBGetContactSettingByte(0, szModuleName, "pgp", 0); if(bPGP) { //PGP bPGPloaded = pgp_init(); bUseKeyrings = DBGetContactSettingByte(0,szModuleName,"ukr",1); LPSTR priv = myDBGetStringDecode(0,szModuleName,"pgpPrivKey"); if(priv) { bPGPprivkey = true; if(bPGPloaded) pgp_set_priv_key(priv); mir_free(priv); }// if(priv) if(bPGPloaded && bUseKeyrings) { char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; PubRingPath[0]='\0'; SecRingPath[0]='\0'; if(pgp_get_version()<0x02000000) { // 6xx bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); } else { LPSTR tmp; tmp = myDBGetString(0,szModuleName,"pgpPubRing"); if(tmp) { strncpy(PubRingPath,tmp,sizeof(PubRingPath)); mir_free(tmp); } tmp = myDBGetString(0,szModuleName,"pgpSecRing"); if(tmp) { strncpy(SecRingPath,tmp,sizeof(SecRingPath)); mir_free(tmp); } if(PubRingPath[0] && SecRingPath[0]) { bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); if(bPGPkeyrings) { DBWriteContactSettingString(0,szModuleName,"pgpPubRing",PubRingPath); DBWriteContactSettingString(0,szModuleName,"pgpSecRing",SecRingPath); } else { DBDeleteContactSetting(0, szModuleName, "pgpPubRing"); DBDeleteContactSetting(0, szModuleName, "pgpSecRing"); } } } }// if(bPGPloaded && bUseKeyrings) }// if(bPGP) #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("gpg_init"); #endif bGPG = DBGetContactSettingByte(0, szModuleName, "gpg", 0); if(bGPG) { //GPG LPSTR tmp; bGPGloaded = gpg_init(); char gpgexec[MAX_PATH], gpghome[MAX_PATH]; gpgexec[0]='\0'; gpghome[0]='\0'; tmp = myDBGetString(0,szModuleName,"gpgExec"); if(tmp) { strncpy(gpgexec,tmp,sizeof(gpgexec)); mir_free(tmp); } tmp = myDBGetString(0,szModuleName,"gpgHome"); if(tmp) { strncpy(gpghome,tmp,sizeof(gpghome)); mir_free(tmp); } if(DBGetContactSettingByte(0, szModuleName, "gpgLogFlag",0)) { tmp = myDBGetString(0,szModuleName,"gpgLog"); if(tmp) { gpg_set_log(tmp); mir_free(tmp); } } if(DBGetContactSettingByte(0, szModuleName, "gpgTmpFlag",0)) { tmp = myDBGetString(0,szModuleName,"gpgTmp"); if(tmp) { gpg_set_tmp(tmp); mir_free(tmp); } } bGPGkeyrings = gpg_open_keyrings(gpgexec,gpghome); if(bGPGkeyrings) { DBWriteContactSettingString(0,szModuleName,"gpgExec",gpgexec); DBWriteContactSettingString(0,szModuleName,"gpgHome",gpghome); } else { DBDeleteContactSetting(0, szModuleName, "gpgExec"); DBDeleteContactSetting(0, szModuleName, "gpgHome"); } bSavePass = DBGetContactSettingByte(0,szModuleName,"gpgSaveFlag",0); if(bSavePass) { tmp = myDBGetString(0,szModuleName,"gpgSave"); if(tmp) { gpg_set_passphrases(tmp); mir_free(tmp); } } } #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("loadContactList"); #endif loadContactList(); // add new skin sound SkinAddNewSound("IncomingSecureMessage","Incoming Secure Message","Sounds\\iSecureMessage.wav"); SkinAddNewSound("OutgoingSecureMessage","Outgoing Secure Message","Sounds\\oSecureMessage.wav"); #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("init extra icons"); #endif // init extra icons for(int i=0;i<1+MODE_CNT*IEC_CNT;i++) { g_IEC[i].cbSize = sizeof(g_IEC[i]); g_IEC[i].ColumnType = bADV; g_IEC[i].hImage = (HANDLE)-1; } // build extra imagelist //onExtraImageListRebuilding(0,0); #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("hook events"); #endif AddHookFunction(ME_CLIST_PREBUILDCONTACTMENU, onRebuildContactMenu); // g_hMC = HookEvent(ME_MC_SUBCONTACTSCHANGED, onMC); if( ServiceExists(MS_EXTRAICON_REGISTER) ) { g_hCLIcon = ExtraIcon_Register(szModuleName, Translate("SecureIM status"), "sim_cm_est", (MIRANDAHOOK)onExtraImageListRebuilding, (MIRANDAHOOK)onExtraImageApplying); } else { AddHookFunction(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuilding); AddHookFunction(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying); } // hook init options AddHookFunction(ME_OPT_INITIALISE, onRegisterOptions); if(bPopupExists) AddHookFunction(ME_OPT_INITIALISE, onRegisterPopOptions); AddHookFunction(ME_PROTO_ACK, onProtoAck); AddHookFunction(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); AddHookFunction(ME_DB_CONTACT_ADDED, onContactAdded); AddHookFunction(ME_DB_CONTACT_DELETED, onContactDeleted); // hook message transport AddProtoServiceFunction(PSR_MESSAGE, onRecvMsg); AddProtoServiceFunction(PSS_MESSAGE, (MIRANDASERVICE)onSendMsg); AddProtoServiceFunction(PSS_MESSAGE"W", (MIRANDASERVICE)onSendMsgW); AddProtoServiceFunction(PSS_FILE, (MIRANDASERVICE)onSendFile); #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("create Native/RSA menu"); #endif // create a menu item for creating a secure im connection to the user. g_hMenu[0] = AddMenuItem(sim301,110000,g_hICO[ICO_CM_EST],MODULENAME"/SIM_EST",CMIF_NOTOFFLINE); g_hMenu[1] = AddMenuItem(sim302,110001,g_hICO[ICO_CM_DIS],MODULENAME"/SIM_DIS",CMIF_NOTOFFLINE); if(ServiceExists(MS_CLIST_ADDSUBGROUPMENUITEM)) { g_hMenu[2] = AddMenuItem(sim312[0],110002,NULL,NULL,CMIF_ROOTPOPUP); g_hMenu[3] = AddSubItem(g_hMenu[2],sim232[0],110003,110002,MODULENAME"/SIM_ST_DIS"); g_hMenu[4] = AddSubItem(g_hMenu[2],sim232[1],110004,110002,MODULENAME"/SIM_ST_ENA"); g_hMenu[5] = AddSubItem(g_hMenu[2],sim232[2],110005,110002,MODULENAME"/SIM_ST_TRY"); } else { g_hMenu[2] = 0; g_hMenu[3] = AddMenuItem(sim232[0],110003,NULL,MODULENAME"/SIM_ST_DIS"); g_hMenu[4] = AddMenuItem(sim232[1],110004,NULL,MODULENAME"/SIM_ST_ENA"); g_hMenu[5] = AddMenuItem(sim232[2],110005,NULL,MODULENAME"/SIM_ST_TRY"); } #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("create PGP/GPG menu"); #endif HICON icon; if( bPGPloaded ) { icon=mode2icon(MODE_PGP|SECURED,2); g_hMenu[6] = AddMenuItem(sim306,110006,icon,MODULENAME"/PGP_SET",0); icon=mode2icon(MODE_PGP,2); g_hMenu[7] = AddMenuItem(sim307,110007,icon,MODULENAME"/PGP_DEL",0); } if(bGPGloaded) { icon=mode2icon(MODE_GPG|SECURED,2); g_hMenu[8] = AddMenuItem(sim308,110008,icon,MODULENAME"/GPG_SET",0); icon=mode2icon(MODE_GPG,2); g_hMenu[9] = AddMenuItem(sim309,110009,icon,MODULENAME"/GPG_DEL",0); } #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("create Mode menu"); #endif if(ServiceExists(MS_CLIST_ADDSUBGROUPMENUITEM)) { g_hMenu[10] = AddMenuItem(sim311[0],110010,NULL,NULL,CMIF_ROOTPOPUP); g_hMenu[11] = AddSubItem(g_hMenu[10],sim231[0],110011,110010,MODULENAME"/MODE_NAT"); g_hMenu[12] = AddSubItem(g_hMenu[10],sim231[1],110012,110010,MODULENAME"/MODE_PGP"); g_hMenu[13] = AddSubItem(g_hMenu[10],sim231[2],110013,110010,MODULENAME"/MODE_GPG"); g_hMenu[14] = AddSubItem(g_hMenu[10],sim231[3],110014,110010,MODULENAME"/MODE_RSA"); } else { g_hMenu[10] = 0; g_hMenu[11] = AddMenuItem(sim231[0],110011,NULL,MODULENAME"/MODE_NAT"); g_hMenu[12] = AddMenuItem(sim231[1],110012,NULL,MODULENAME"/MODE_PGP"); g_hMenu[13] = AddMenuItem(sim231[2],110013,NULL,MODULENAME"/MODE_GPG"); g_hMenu[14] = AddMenuItem(sim231[3],110014,NULL,MODULENAME"/MODE_RSA"); } // updater plugin support if(ServiceExists(MS_UPDATE_REGISTERFL)) { CallService(MS_UPDATE_REGISTERFL, (WPARAM)2445, (LPARAM)&pluginInfo); } #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("create srmm icons"); #endif // add icon to srmm status icons if(ServiceExists(MS_MSG_ADDICON)) { StatusIconData sid; memset(&sid,0,sizeof(sid)); sid.cbSize = sizeof(sid); sid.szModule = (char*)szModuleName; sid.flags = MBF_DISABLED|MBF_HIDDEN; // Native sid.dwId = MODE_NATIVE; sid.hIcon = mode2icon(MODE_NATIVE|SECURED,3); sid.hIconDisabled = mode2icon(MODE_NATIVE,3); sid.szTooltip = Translate("SecureIM [Native]"); CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); // PGP sid.dwId = MODE_PGP; sid.hIcon = mode2icon(MODE_PGP|SECURED,3); sid.hIconDisabled = mode2icon(MODE_PGP,3); sid.szTooltip = Translate("SecureIM [PGP]"); CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); // GPG sid.dwId = MODE_GPG; sid.hIcon = mode2icon(MODE_GPG|SECURED,3); sid.hIconDisabled = mode2icon(MODE_GPG,3); sid.szTooltip = Translate("SecureIM [GPG]"); CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); // RSAAES sid.dwId = MODE_RSAAES; sid.hIcon = mode2icon(MODE_RSAAES|SECURED,3); sid.hIconDisabled = mode2icon(MODE_RSAAES,3); sid.szTooltip = Translate("SecureIM [RSA/AES]"); CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); // hook the window events so that we can can change the status of the icon AddHookFunction(ME_MSG_WINDOWEVENT, onWindowEvent); AddHookFunction(ME_MSG_ICONPRESSED, onIconPressed); } #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onModuleLoaded end"); #endif return 0; }
int COutlook2Ctrl::AddSubItem(LPCTSTR m_strName, int iIcoID, DWORD dwStyle, DWORD lParam, int iFolder, int iFolderItem) { HICON hIco = (HICON) LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(iIcoID),IMAGE_ICON,16,16,0); return AddSubItem(m_strName, hIco, dwStyle, lParam, iFolder, iFolderItem); }