#include #include #include #include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) SKUProductPictureView3 : public xframe { public: ximageview im; xml doc; HWND m_winHwnd; HWND ParentHWND; public: SKUProductPictureView3(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static SKUProductPictureView3* CreateInstance(void* implPtr, void* hWnd) { SKUProductPictureView3* pWin = new SKUProductPictureView3(implPtr, (HWND)hWnd); return pWin; } int hiddenBox(xstring name, bool f) { //xnode anode = GetAgentNode(name); xnode anode = GetAgentNode(name); int LayerFlow_None_ = 0x00000001; int LayerFlow_UnLayer_ = 0x00000100; int LayerFlow_NS_ = 0x00000004; int LayerFlow_WE_ = 0x00000008; int LayerFlow_Control_ = 0x00000010; if (f) anode.SetLayerFlow(LayerFlow_WE_ | LayerFlow_Control_); else anode.SetLayerFlow(LayerFlow_None_ | LayerFlow_UnLayer_); return 1; } int OnImgDBClicked(TEvent* evt, LPARAM pr) { IMGNNMHDR& nmtv = *(IMGNNMHDR*)evt->notify.pnmh; xstring src = nmtv.path; /*if(src.length() > 60) src = src.right(44); else src=src.mid(src.find(L"Thumbs", 0)+6, 50); */ xaserverarg arg; //arg.AddArg(L"src",L"/business/products/chanpin"+src); arg.AddArg(L"src", src); //win::OpenWindow(L"dev:xpage[BigPicture.vx]",arg); int h = openUrl(L"/sale/view/ProductLibrary/xpage/bigpictureview", arg); return 1; /*xwin x = new xwin; x.setNativePointer(h); m_winHwnd = x.GetHWND(); xstring sh = doc.xml(); int p = cast(sh as int); win32::SendMessage(m_winHwnd, 0x401, p, 0); return 1;*/ } int OnCmdDispatch(xstring comdid) { if (comdid == L"xmSave") { xstring x = L" "; xutil::OpenDialog(GetHWND(), x); if (x == L"") return 0; KXMLDOMElement e = doc.selectSingleNode(L"ImageList"); KXMLDOMNodeList nlist = e.selectNodes(L"image"); HCURSOR hCursor = xutil::SetCursorWait(); int s = nlist.length(); xstring result = L""; for (int i = 0; i < s; i++) { KXMLDOMElement xitem = nlist.item(i); xstring picname = xitem.selectSingleNode(L"PicPath").text(); if (picname == L"") continue; xstring goodsno = xitem.selectSingleNode(L"GoodsNo").text(); xstring src = picname.mid(26, picname.length()); //trace(picname + L"-->" + src + L"\r\n"); if (src == L"" || src == L"/") continue; int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/products/chanpin/" + src, L"", x + L"/" + goodsno + L".jpg"); if (openRet < 0) { //trace(picname + L"-->" + src + L"\r\n"); result += goodsno + L" "; } } xutil::RestoreCursor(hCursor); if (result != L"") alert(result + L"\r\nÒÔÉÏ»õºÅÏÂÔØÍ¼Æ¬Ê§°Ü!"); else alert(L"±£´æÍê±Ï!"); } else if (comdid == L"xmDelete") { if (ParentHWND) { int nIndex = im.GetSelectIndex(); if (nIndex < 0 || nIndex >= im.GetImageCount()) return 0; im.RemoveImage(nIndex); im.Redraw(); xstring comd = L"Delete:" +xstring(nIndex); SendMessage(ParentHWND, 0x401, (WPARAM)comd.c_str(), 0); } } return 0; } int OnXCommand(TEvent* evt, int param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnCombboChange(TEvent* evt, int lParam) { xcombobox xc = GetControl(L"precent"); xstring text = xc.GetLBText(); int p = text.toInt(); if (p == 0) p = 100; im.Preview(p); return 1; } int OnAttachEvent() { AttachEvent(L"im1", L"IMG_LDBCLICK", (FEvent)&SKUProductPictureView3::OnImgDBClicked); AttachEvent(L"WM_XCOMMAND", (FEvent)&SKUProductPictureView3::OnXCommand); AttachEvent(L"precent", L"CBN_SELCHANGE", (FEvent)&SKUProductPictureView3::OnCombboChange); return 1; } int init() { xml x ; xaserverarg arg; if (GetWinParam()) arg = GetArg(); else return 0; if (xurl::get(GetEntityName(1) + L"/pref/category/picture/list", arg.GetString(), x) != 1) { trace(L"error:" + xstring(x.xml(), true)); return 0; } //trace(arg.GetString()); //trace(x.GetXml()); return 1; } int onload() { SetArg(); im = GetControl(L"im1"); OnAttachEvent(); ParentHWND = 0; if (GetWinParam()) { xaserverarg arg = GetArg(); ParentHWND = (HWND)arg.GetParam(L"ParentHWND"); xstring openflag = arg.GetArgString(L"OpenFlag"); //alert(openflag); if (openflag != L"0") hiddenBox(L"xmDelete", false); //trace(arg.GetString()); xml x ; //alert(arg.GetString()); //if(url::get(L"/sale/data/product/pref/category/picture/list",arg.GetString(),x)!=1) if (xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNoList", arg.GetString(), x) != 1) { trace(L"error:" + xstring(x.xml(), true)); return 0; } doc = x; //alert(x.xml()); KXMLDOMElement e = x.selectSingleNode(L"ImageList"); KXMLDOMNodeList nlist = e.selectNodes(L"image"); int i; int s = nlist.length(); for (i = 0; i < s; i++) { KXMLDOMElement xitem = nlist.item(i); xstring picname = xitem.selectSingleNode(L"PicPath").text(); xstring goodno = xitem.selectSingleNode(L"GoodsNo").text(); //trace(picname + L"\r\n"); if (picname == L"/business/products/Thumbs//") picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg"; im.AddImages(picname, goodno); } im.Redraw(); } else { im.AddImages(L"/business/products/chanpin/BL-002/291679.jpg", L"x1"); im.AddImages(L"/business/products/chanpin/BL-002/291759.jpg", L"x2"); im.AddImages(L"/business/products/chanpin/BL-002/417884.jpg", L"x3"); im.Redraw(); } SetFocus(im.GetHWND()); xstring userno = xaserver::GetUserNo(); /*if(userno == L"1003" || userno == L"1137" || userno == L"admin") { //hiddenBox(); } else { hiddenBox(L"xmSave", false); }*/ hiddenBox(L"xmSave", false); return -1; } };