LiFan
10 天以前 63eebabbfee1bc84850b36967ecac5116a28b73f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include <wobject/xstring.hpp>
#include <wobject/xwin.hpp>
#include <wobject/xaserver.hpp>
#include <wobject/xaserverarg.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xlayersheet.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <xcontrol/xsedit.hpp>
#include <xcontrol/xcombobox.hpp>
#include "XDevEditPage.hpp"
 
using xml = KXMLDOMDocument;
class export XDevEditXRuler : public XDevEditPage
{
    public:
    XDevEditXRuler(void* implPtr, HWND hWnd) :XDevEditPage(implPtr, hWnd) {}
public:
    static XDevEditXRuler* CreateInstance(void* implPtr, void* hWnd)
    {
        XDevEditXRuler* pWin = new XDevEditXRuler(implPtr, (HWND)hWnd);
        return pWin;
    }
private:    //
    //xdwgrid    dw_list;
 
    xnode    m_agentNode;    //Agent Condition
    xstring    m_agentCond;    //Agent Node
public:
    int SetAgent()
    {
        /*xstring xfNodeAgentArea  = L"agentarea";
        xnode anode = GetAgentNode(xfNodeAgentArea);
        var xframeElement =  GetElement();
        var agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*");
        if(agent)
        {
            xstring s = agent.xml;
            m_agentNode =  SetAgentNodeContent (anode,s);
        }*/
        return 1;
    }
 
    //½¹µã¼¤»î´¦Àíº¯Êý
    int OnSetFocus(TEvent* evt,LPARAM param)
    {
        SetAgent();
 
        //ÖØÖù¤¾ßÌõ
        return 1;
    }
 
    int LoadData()
    {
        if (!GetWinParam()) return 1;
        xstring content = GetData();
        if (content != L"")
        {
            xsedit xs = GetControl(L"xcontent");
            xs.LoadContent(content,L".xml");
        }
        return 1;
    }
 
    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;
    }
 
    //ÃüÁî·¢²¼º¯Êý
    int OnCmdDispatch(xstring comdid)
    {
        xstring content;
        xsedit xs = GetControl(L"xcontent");
        xs.GetContent(content);
 
        HCURSOR hCursor = xutil::SetCursorWait();
        if (comdid == L"xmFileSave")
        {
            //save xml content
            SaveContent(content);
        }
        else if (comdid == L"xmValid")
        {
            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")
        {
            OpenWindow(L"dev:xpage[xcode.finddlg]");
        }
        else if (comdid == L"xmEditReplace")
        {
            OpenWindow(L"dev:xpage[xcode.replacedlg]");
        }
        xutil::RestoreCursor(hCursor);
        return 0;
    }
 
    //ÃüÁî´¦Àíʼþ
    int OnXCommand(TEvent* evt,LPARAM param)
    {
        return OnCmdDispatch(evt->xcommand.pStrID);
    }
 
    int OnAttachEvent()
    {
        //°ó¶¨¹¤¾ßÌõµã»÷ʼþ
        AttachEvent(L"WM_XCOMMAND", (FEvent)&XDevEditXRuler::OnXCommand);
        //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
        AttachEvent(L"WM_SETFOCUS", (FEvent)&XDevEditXRuler::OnSetFocus);
 
        return 1;
    }
 
    int OnInitial()
    {
        SetAgent();
 
        OnAttachEvent();
 
        return 1;
    }
 
    int onload()
    {
        OnInitial();
        LoadData();
 
        return 1;
    }
};