-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathWindow.ahk
78 lines (70 loc) · 2.88 KB
/
Window.ahk
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
class YunitWindow
{
__new(instance)
{
global YunitWindowTitle, YunitWindowEntries, YunitWindowStatusBar
Gui, Yunit:Font, s16, Arial
Gui, Yunit:Add, Text, x0 y0 h30 vYunitWindowTitle Center, Test Results
hImageList := IL_Create()
IL_Add(hImageList,"shell32.dll",132) ;red X
IL_Add(hImageList,"shell32.dll",78) ;yellow triangle with exclamation mark
IL_Add(hImageList,"shell32.dll",147) ;green up arrow
IL_Add(hImageList,"shell32.dll",135) ;two sheets of paper
this.icons := {fail: "Icon1", issue: "Icon2", pass: "Icon3", detail: "Icon4"}
Gui, Yunit:Font, s10
Gui, Yunit:Add, TreeView, x10 y30 vYunitWindowEntries ImageList%hImageList%
Gui, Yunit:Font, s8
Gui, Yunit:Add, StatusBar, vYunitWindowStatusBar -Theme BackgroundGreen
Gui, Yunit:+Resize +MinSize320x200
Gui, Yunit:Show, w500 h400, Yunit Testing
Gui, Yunit:+LastFound
this.Categories := {}
Return this
YunitGuiSize:
GuiControl, Yunit:Move, YunitWindowTitle, w%A_GuiWidth%
GuiControl, Yunit:Move, YunitWindowEntries, % "w" . (A_GuiWidth - 20) . " h" . (A_GuiHeight - 60)
Gui, Yunit:+LastFound
DllCall("user32.dll\InvalidateRect", "uInt", WinExist(), "uInt", 0, "uInt", 1)
Return
YunitGuiClose:
ExitApp
}
Update(Category, TestName, Result)
{
Gui, Yunit:Default
If !this.Categories.HasKey(Category)
this.AddCategories(Category)
Parent := this.Categories[Category]
If IsObject(result)
{
hChildNode := TV_Add(TestName,Parent,this.icons.fail)
TV_Add("Line #" result.line ": " result.message "(" result.line ")",hChildNode,this.icons.detail)
GuiControl, Yunit: +BackgroundRed, YunitWindowStatusBar
key := category
pos := 1
while (pos)
{
TV_Modify(this.Categories[key], "Expand " . this.icons.issue)
pos := InStr(key, ".", false, (A_AhkVersion < "2") ? 0 : -1, 1)
key := SubStr(key, 1, pos-1)
}
TV_Modify(Parent, "Expand")
}
Else
TV_Add(TestName,Parent,this.icons.pass)
TV_Modify(TV_GetNext(), "VisFirst") ;// scroll the treeview back to the top
}
AddCategories(Categories)
{
Parent := 0
Category := ""
Categories_Array := StrSplit(Categories, ".")
for k,v in Categories_Array
{
Category .= (Category == "" ? "" : ".") v
If (!this.Categories.HasKey(Category))
this.Categories[Category] := TV_Add(v, Parent, this.icons.pass)
Parent := this.Categories[Category]
}
}
}