forked from lee-soft/ViPad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProgramIO.bas
139 lines (93 loc) · 4.44 KB
/
ProgramIO.bas
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
Attribute VB_Name = "ProgramIO"
Option Explicit
Private m_sourceDoc As DOMDocument
Private Function LoadXMLPad(theBank As ViBank, ByRef XMLPad As IXMLDOMElement, targetCollection As Collection)
Dim thisPadItemXML As IXMLDOMElement
Dim thisPadItem As LaunchPadItem
Dim thisPadCollection As Collection
Dim thisIconImage As GDIPImage
Dim thisAlphaIcon As AlphaIcon
For Each thisPadItemXML In XMLPad.selectNodes("item")
Debug.Print thisPadItemXML.tagName
Set thisPadItem = New LaunchPadItem
Set thisPadItem.Icon = New GDIPImage
thisPadItem.TargetPath = thisPadItemXML.getAttribute("target")
thisPadItem.IconPath = thisPadItemXML.getAttribute("icon")
thisPadItem.Caption = thisPadItemXML.getAttribute("caption")
thisPadItem.Icon.FromFile ApplicationDataPath & "\" & thisPadItem.IconPath
thisPadItem.TargetArguements = thisPadItemXML.getAttribute("arguements")
'AddLaunchItem thisPadItem
targetCollection.Add thisPadItem, thisPadItem.GlobalIdentifer
theBank.masterCollection.Add thisPadItem, thisPadItem.GlobalIdentifer
Next
End Function
Public Function LoadBankXML(szPath As String) As ViBank
Dim padItems As DOMDocument
Dim thisPadItemXML As IXMLDOMElement
Dim thisPadItem As LaunchPadItem
Dim thisPadCollection As Collection
Dim thisIconImage As GDIPImage
Dim thisAlphaIcon As AlphaIcon
Dim padAlias As String
Dim newBank As ViBank
Dim windowCount As Long
Dim windowDimensions As GdiPlus.RECTL
Set newBank = New ViBank
Set LoadBankXML = newBank
Set padItems = New DOMDocument
If padItems.Load(szPath) = False Then
Exit Function
End If
For Each thisPadItemXML In padItems.selectNodes("pads/pad")
padAlias = thisPadItemXML.getAttribute("alias")
If Not IsNull(thisPadItemXML.getAttribute("height")) Then windowDimensions.Height = thisPadItemXML.getAttribute("height")
If Not IsNull(thisPadItemXML.getAttribute("width")) Then windowDimensions.Width = thisPadItemXML.getAttribute("width")
If Not IsNull(thisPadItemXML.getAttribute("top")) Then windowDimensions.Top = thisPadItemXML.getAttribute("top")
If Not IsNull(thisPadItemXML.getAttribute("left")) Then windowDimensions.Left = thisPadItemXML.getAttribute("left")
With newBank.AddNewCollection(padAlias)
.Dimensions = Serialize_RectL(windowDimensions)
End With
LoadXMLPad newBank, thisPadItemXML, newBank.GetCollectionByIndex(newBank.GetCollectionCount)
windowCount = windowCount + 1
Next
End Function
Public Function GetPadsXMLDocument(ByRef itemBank As ViBank) As DOMDocument
Dim rootElement As IXMLDOMElement
Dim thisCollection As Collection
Dim thisTab As ViTab
Dim thisWindow As ViPickWindow
Dim collectionIndex As Long
Set m_sourceDoc = New DOMDocument
Set rootElement = m_sourceDoc.createElement("pads")
m_sourceDoc.appendChild rootElement
For collectionIndex = 1 To itemBank.GetCollectionCount
Set thisTab = itemBank.GetTabByIndex(collectionIndex)
rootElement.appendChild GetPadXMLElement(thisTab.Children, thisTab.Alias, thisTab.Dimensions)
Next
Set GetPadsXMLDocument = m_sourceDoc
End Function
Private Function GetPadXMLElement(ByRef Items As Collection, ByVal collectionId As String, Optional szWindowDimensions As String) As IXMLDOMElement
Dim szXML As String
Dim thisLaunchPadItem As LaunchPadItem
Dim newPad As IXMLDOMElement
Dim newItem As IXMLDOMElement
Dim windowDimensions As RECTL
Set newPad = m_sourceDoc.createElement("pad")
newPad.setAttribute "alias", collectionId
If Not szWindowDimensions = vbNullString Then
windowDimensions = Unserialize_RectL(szWindowDimensions)
newPad.setAttribute "left", windowDimensions.Left
newPad.setAttribute "top", windowDimensions.Top
newPad.setAttribute "width", windowDimensions.Width
newPad.setAttribute "height", windowDimensions.Height
End If
For Each thisLaunchPadItem In Items
Set newItem = m_sourceDoc.createElement("item")
newPad.appendChild newItem
newItem.setAttribute "icon", thisLaunchPadItem.IconPath
newItem.setAttribute "caption", thisLaunchPadItem.Caption
newItem.setAttribute "target", thisLaunchPadItem.TargetPath
newItem.setAttribute "arguements", thisLaunchPadItem.TargetArguements
Next
Set GetPadXMLElement = newPad
End Function