|  |  | 
 |  |  | #include "XDevEditPage.hpp" | 
 |  |  |  | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  | class export XDevEditXRuler : public XDevEditPage | 
 |  |  | class export XDevEditWorkNode : public XDevEditPage | 
 |  |  | { | 
 |  |  |    public: | 
 |  |  |    XDevEditXRuler(void* implPtr, HWND hWnd) :XDevEditPage(implPtr, hWnd) {} | 
 |  |  |    XDevEditWorkNode(void* implPtr, HWND hWnd) :XDevEditPage(implPtr, hWnd) {} | 
 |  |  | public: | 
 |  |  |    static XDevEditXRuler* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    static XDevEditWorkNode* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       XDevEditXRuler* pWin = new XDevEditXRuler(implPtr, (HWND)hWnd); | 
 |  |  |       XDevEditWorkNode* pWin = new XDevEditWorkNode(implPtr, (HWND)hWnd); | 
 |  |  |       return pWin; | 
 |  |  |    } | 
 |  |  | private:   // | 
 |  |  |    xaserverarg arg; | 
 |  |  |    //xdwgrid   dw_list; | 
 |  |  |  | 
 |  |  |    xnode   m_agentNode;   //Agent Condition | 
 |  |  |    xstring   m_agentCond;   //Agent Node | 
 |  |  | public: | 
 |  |  |    int SetAgent() | 
 |  |  |    { | 
 |  |  |       /*xstring xfNodeAgentArea  = L"agentarea"; | 
 |  |  |       /* | 
 |  |  |       xstring xfNodeAgentArea  = L"agentarea"; | 
 |  |  |       xnode anode = GetAgentNode(xfNodeAgentArea); | 
 |  |  |       var xframeElement =  GetElement(); | 
 |  |  |       var agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); | 
 |  |  | 
 |  |  |       { | 
 |  |  |          xstring s = agent.xml; | 
 |  |  |          m_agentNode =  SetAgentNodeContent (anode,s); | 
 |  |  |       }*/ | 
 |  |  |       } | 
 |  |  |       */ | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    //焦点激活处理函数 | 
 |  |  |    int OnSetFocus(TEvent* evt,LPARAM param) | 
 |  |  |    int OnSetFocus(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       SetAgent(); | 
 |  |  |  | 
 |  |  |       //重置工具条 | 
 |  |  |       SetAgent(); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int LoadData() | 
 |  |  |    { | 
 |  |  |       SetArg(); | 
 |  |  |       if (!GetWinParam()) return 1; | 
 |  |  |       xstring content = GetData(); | 
 |  |  |       if (content != L"") | 
 |  |  |       { | 
 |  |  |          xsedit xs = GetControl(L"xcontent"); | 
 |  |  |          xs.LoadContent(content,L".xml"); | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |          xml x; | 
 |  |  |          auto xdoc = x; | 
 |  |  |          xdoc.load(content); | 
 |  |  |          xstring s = xdoc.xml(); | 
 |  |  |          trace(s); | 
 |  |  |  | 
 |  |  |    xstring OnGetType() | 
 |  |  |    { | 
 |  |  |       xwin w = GetFrameWindow(); | 
 |  |  |       xtreeview tv_folder = w.GetControl(L"DevExplorer"); | 
 |  |  |       HTREEITEM hItem = (HTREEITEM)GetWinParam(); | 
 |  |  |       KXMLDOMElement e = tv_folder.GetItemData(hItem); | 
 |  |  |       xstring str = e.getAttribute(L"type"); | 
 |  |  |       return str; | 
 |  |  |          //IXMLDOMDocument xdoc = x.GetXmlDoc(); | 
 |  |  |          //IXMLDOMElement e = x.GetXmlDoc().selectSingleNode(L"config/ruler"); | 
 |  |  |       } | 
 |  |  |       /*arg = GetParam(); | 
 |  |  |       if(arg) | 
 |  |  |       { | 
 |  |  |          xstring val; | 
 |  |  |          xcontrol xc; | 
 |  |  |  | 
 |  |  |          val = arg.GetArgString(L"typename"); | 
 |  |  |          xc = GetControl(L"xmDevType"); | 
 |  |  |          if(val)xc.SetText(val); | 
 |  |  |          val = arg.GetArgString(L"name"); | 
 |  |  |          xc = GetControl(L"xmDevName"); | 
 |  |  |          if(val)xc.SetText(val); | 
 |  |  |          val = arg.GetArgString(L"desc"); | 
 |  |  |          xc = GetControl(L"xmDevDesc"); | 
 |  |  |          if(val)xc.SetText(val); | 
 |  |  |          val = arg.GetArgString(L"uri"); | 
 |  |  |          xc = GetControl(L"xmDevUri"); | 
 |  |  |          if(val)xc.SetText(val); | 
 |  |  |          val = arg.GetArgString(L"src"); | 
 |  |  |          xc = GetControl(L"xmDevPath"); | 
 |  |  |          if(val)xc.SetText(val); | 
 |  |  |          val = arg.GetArgString(L"guid"); | 
 |  |  |          xc = GetControl(L"xmDevGuid"); | 
 |  |  |          if(val)xc.SetText(val); | 
 |  |  |       }*/ | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    //命令发布函数 | 
 |  |  |    int OnCmdDispatch(xstring comdid) | 
 |  |  |    { | 
 |  |  |       xstring content; | 
 |  |  |       xsedit xs = GetControl(L"xcontent"); | 
 |  |  |       xs.GetContent(content); | 
 |  |  |  | 
 |  |  |       HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  |       if (comdid == L"xmFileSave") | 
 |  |  |       if (comdid == L"xmWorkNodeSave") | 
 |  |  |       { | 
 |  |  |          //save xml content | 
 |  |  |          HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  | 			 | 
 |  |  |          xstring content; | 
 |  |  |          xsedit xs = GetControl(L"sqlcontent"); | 
 |  |  |          xs.GetContent(content); | 
 |  |  |          SaveContent(content); | 
 |  |  |  | 
 |  |  |          xutil::RestoreCursor(hCursor); | 
 |  |  |       } | 
 |  |  |       else if (comdid == L"xmValid") | 
 |  |  |       else if (comdid == L"xmPreview") | 
 |  |  |       { | 
 |  |  |          xml x ; | 
 |  |  |          if (!x.loadXML(content)) | 
 |  |  |          { | 
 |  |  |             KXMLDOMParseError pError = x.parseError(); | 
 |  |  |             if (pError) | 
 |  |  |             { | 
 |  |  |                xstring str = pError.srcText(); | 
 |  |  |                xstring sError = L"\r\nXML错误: " + str.trim() + L"\r\n"; | 
 |  |  |                int s = pError.errorCode(); | 
 |  |  |                sError += L"   代码: " + xstring(s) + L"\r\n"; | 
 |  |  |                s = pError.line(); | 
 |  |  |                sError += L"   位置: 第" + xstring(s) + L"行,L"; | 
 |  |  |                s = pError.linepos(); | 
 |  |  |                sError += L"第" + xstring(s) + L"列" + L"\r\n"; | 
 |  |  |                str = pError.reason(); | 
 |  |  |                sError += L"   原因: " + str; | 
 |  |  |                trace(sError); | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                trace(L"XML 错误"); | 
 |  |  |             } | 
 |  |  |             return -1; | 
 |  |  |          } | 
 |  |  |          /*xstring sType = OnGetType(); | 
 |  |  |          if (sType == L"xml.xsd") | 
 |  |  |          { | 
 |  |  |             xstring sError; | 
 |  |  |             x.ValidSchema(content, &sError); | 
 |  |  |             trace(sError); | 
 |  |  |          }*/ | 
 |  |  |       } | 
 |  |  |       else if (comdid == L"xmEditFind") | 
 |  |  |       else if (comdid == L"xmWorkNodeSelect") | 
 |  |  |       { | 
 |  |  |          OpenWindow(L"dev:xpage[xcode.finddlg]"); | 
 |  |  |       } | 
 |  |  |       else if (comdid == L"xmEditReplace") | 
 |  |  |       else if (comdid == L"xmWorkNodeSelectEx") | 
 |  |  |       { | 
 |  |  |          OpenWindow(L"dev:xpage[xcode.replacedlg]"); | 
 |  |  |       } | 
 |  |  |       xutil::RestoreCursor(hCursor); | 
 |  |  |       else if (comdid == L"xmWorkNodeSelectEx1") | 
 |  |  |       { | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    //命令处理事件 | 
 |  |  |    int OnXCommand(TEvent* evt,LPARAM param) | 
 |  |  |    int OnXCommand(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       //绑定工具条点击事件 | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&XDevEditXRuler::OnXCommand); | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&XDevEditWorkNode::OnXCommand); | 
 |  |  |       //获取焦点事件,用于重置工具条 | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", (FEvent)&XDevEditXRuler::OnSetFocus); | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", (FEvent)&XDevEditWorkNode::OnSetFocus); | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnInitial() |