ÿþ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xlayersheet.hpp> #include <xcontrol/xdatetimepick.hpp> #include <xcontrol/ximageview.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) ProductPictureView3 : public xframe { public: ProductPictureView3(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static ProductPictureView3* CreateInstance(void* implPtr, void* hWnd) { return new ProductPictureView3(implPtr, (HWND)hWnd); } public: ximageview im; xstring CategoryID; xml doc; HWND m_winHwnd; HWND ParentHWND; 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, int 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 = *new xaserverarg; //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.GetXml(); 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"";//=L" ".space(256); 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åN N'÷S N}þVGr1Y%!"); else alert(L"ÝOX[Œ[Õk!"); } else if(comdid == L"xmDelete") { HWND hh = ParentHWND; if(hh) { int nIndex = im.GetSelectIndex(); if(nIndex < 0 || nIndex >= im.GetImageCount()) return 0; im.RemoveImage(nIndex); im.Redraw(); xstring comd = L"Delete:"+xstring(nIndex); SendMessage(hh, 0x401, (WPARAM)comd.c_str(), 0); } } return 0; } int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnCombboChange(TEvent* evt, LPARAM 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)&ProductPictureView3::OnImgDBClicked); AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductPictureView3::OnXCommand); AttachEvent(L"precent",L"CBN_SELCHANGE", (FEvent)&ProductPictureView3::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(xstring(L"xxx",x.xml())); return 0; } //trace(arg.GetString()); //trace(x.xml()); return 1; } int onload() { SetArg(); im = GetControl(L"im1"); OnAttachEvent(); ParentHWND = 0; if (GetWinParam()) { xaserverarg arg; arg = GetArg(); CategoryID=arg.GetArgString(L"parentID"); 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(xurl::get(L"/sale/data/product/pref/category/picture/list",arg.GetString(),x)!=1) if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelist",arg.GetString(),x)!=1) { trace(xstring(L"xxx",x.xml())); 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; } };