void CALLBACK CUICommandHistory::UIAdd(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strParentName = pElement->Attribute("parentname"); pElement->RemoveAttribute("parentname"); if(strParentName.IsEmpty()) return; CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); CPaintManagerUI* pManager = pUIView->GetPaintManager(); CControlUI* pParentControl = pManager->FindControl(StringConvertor::Utf8ToWide(strParentName)); if(pParentControl == NULL) return; TiXmlDocument xmlDoc; TiXmlDeclaration Declaration("1.0","utf-8","yes"); xmlDoc.InsertEndChild(Declaration); TiXmlElement* pRootElem = new TiXmlElement("UIAdd"); pRootElem->InsertEndChild(*pElement); xmlDoc.InsertEndChild(*pRootElem); TiXmlPrinter printer; xmlDoc.Accept(&printer); delete pRootElem; CDialogBuilder builder; CControlUI* pRoot=builder.Create(StringConvertor::Utf8ToWide(printer.CStr()), (UINT)0, NULL, pManager); if(pRoot) pUIView->RedoUI(pRoot, pParentControl); }
void CImageDialog::OnBnClickedOk() { // TODO: Add your control notification handler code here m_strImageProperty=m_ImagePreview.GetImageProperty(); CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); g_pResourceView->InsertImage(m_strImagePathName, pUIView->GetDocument()->GetTitle()); OnOK(); }
BOOL CUIDesignerDoc::OnSaveDocument(LPCTSTR lpszPathName) { // TODO: 在此添加专用代码和/或调用基类 POSITION pos = this->GetFirstViewPosition(); while(pos) { CView* pView = this->GetNextView(pos); CUIDesignerView* pUIView = DYNAMIC_DOWNCAST(CUIDesignerView, pView); ASSERT(pUIView); pUIView->OnSaveSkinFile(lpszPathName); } return TRUE/*CDocument::OnSaveDocument(lpszPathName)*/; }
void CUIDesignerDoc::SetTitle(LPCTSTR lpszTitle) { // TODO: 在此添加专用代码和/或调用基类 if(m_strTitle != lpszTitle) { POSITION pos = this->GetFirstViewPosition(); while(pos) { CView* pView = this->GetNextView(pos); CUIDesignerView* pUIView = DYNAMIC_DOWNCAST(CUIDesignerView, pView); ASSERT(pUIView); pUIView->OnTitleChanged(m_strTitle, lpszTitle); } } CDocument::SetTitle(lpszTitle); }
void CALLBACK CUICommandHistory::UIDelete(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strName = pElement->Attribute("myname"); if(strName.IsEmpty()) return; CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); CPaintManagerUI* pManager = pUIView->GetPaintManager(); CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName)); if(pControl == NULL) return; CControlUI* pParent=pControl->GetParent(); HTREEITEM hDelete=(HTREEITEM)(((ExtendedAttributes*)pControl->GetTag())->hItem); g_pClassView->RemoveUITreeItem(hDelete); pUIView->DeleteUI(pControl); if(pParent) pParent->NeedUpdate(); }
BOOL CImageDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_btnMask.EnableOtherButton(_T("Other")); m_btnMask.SetColor((COLORREF)0); m_btnMask.SetColumnsNumber(10); m_ctlFade.SetRange(0,255); m_ctlFade.SetPos(255); CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); m_pManager = pUIView->GetPaintManager(); m_ImagePreview.SetManager(m_pManager); m_strImagePathName=m_strImageProperty; LPCTSTR pStrImage=m_strImageProperty; CDuiString sItem; CDuiString sValue; LPTSTR pstr = NULL; while( *pStrImage != _T('\0') ) { sItem.Empty(); sValue.Empty(); while( *pStrImage != _T('\0') && *pStrImage != _T('=') ) { LPTSTR pstrTemp = ::CharNext(pStrImage); while( pStrImage < pstrTemp) { sItem += *pStrImage++; } } if( *pStrImage++ != _T('=') ) break; if( *pStrImage++ != _T('\'') ) break; while( *pStrImage != _T('\0') && *pStrImage != _T('\'') ) { LPTSTR pstrTemp = ::CharNext(pStrImage); while( pStrImage < pstrTemp) { sValue += *pStrImage++; } } if( *pStrImage++ != _T('\'') ) break; if( !sValue.IsEmpty() ) { if( sItem == _T("file")) m_strImagePathName = sValue; else if( sItem == _T("dest") ) m_strDest = sValue; else if( sItem == _T("source") ) m_strSource = sValue; else if( sItem == _T("corner") ) m_strCorner = sValue; else if( sItem == _T("mask") ) { DWORD dwMask; if( sValue[0] == _T('#')) dwMask = _tcstoul(sValue.GetData() + 1, &pstr, 16); else dwMask = _tcstoul(sValue.GetData(), &pstr, 16); dwMask&=0x00FFFFFF; m_btnMask.SetColor(RGB(GetBValue(dwMask),GetGValue(dwMask),GetRValue(dwMask))); } else if( sItem == _T("fade") ) { m_nFade = (BYTE)_tcstoul(sValue.GetData(), &pstr, 10); } else if( sItem == _T("hole") ) { m_bHole = (_tcscmp(sValue.GetData(), _T("true")) == 0); } } if( *pStrImage++ != _T(' ') ) break; } m_ctlFade.SetPos(m_nFade); int nIndex=m_lstImages.AddString(_T("(无)")); m_lstImages.SetItemDataPtr(nIndex,(void*)(LPCTSTR)m_strNullImage); LPCTSTR pstrImage=NULL; LPTSTR pszFileName=NULL; const CStringArray* parrImage=g_pResourceView->GetImageTree(pUIView->GetDocument()->GetTitle()); if(parrImage) { for(int i=0;i<parrImage->GetSize();i++) { pstrImage=parrImage->GetAt(i); pszFileName=_tcsrchr((LPTSTR)pstrImage,_T('\\'))+1; nIndex=m_lstImages.AddString(pszFileName); m_lstImages.SetItemDataPtr(nIndex,(void*)pstrImage); } } int nPos = m_strImagePathName.ReverseFind(_T('\\')); CString strFileName = (nPos==-1) ? m_strImagePathName : m_strImagePathName.Right(m_strImagePathName.GetLength() - nPos - 1); m_strImagePathName.IsEmpty()?m_lstImages.SelectString(-1,_T("(无)")):m_lstImages.SelectString(-1,strFileName); UpdateData(FALSE); SetImageProperty(m_strImagePathName); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }