-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuserdefined.go
42 lines (38 loc) · 944 Bytes
/
userdefined.go
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
package main
import (
"embed"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
//go:embed userdefined
var userDefined embed.FS
var curUserDefined string
func GetUserDefinedComboBox() ComboBox {
files, err := userDefined.ReadDir("userdefined")
if err != nil {
panic(err)
}
var models []string
for _, file := range files {
fileName := file.Name()
models = append(models, fileName[:len(fileName)-len(".lss")])
}
var comboBox *walk.ComboBox
return ComboBox{
AssignTo: &comboBox,
Model: models,
OnCurrentIndexChanged: func() {
newUserDefined := comboBox.Text()
if len(newUserDefined) == 0 || newUserDefined == curUserDefined {
return
}
curUserDefined = newUserDefined
buf, err := userDefined.ReadFile("userdefined/" + newUserDefined + ".lss")
if err != nil {
walk.MsgBox(mainWindow, "内部错误", err.Error(), walk.MsgBoxIconError)
return
}
loadSplitFile(buf)
},
}
}