/
Form1Impl.go
72 lines (59 loc) · 1.74 KB
/
Form1Impl.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
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
// 在这里写你的事件
package main
import (
"fmt"
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/exts/multilang"
"github.com/ying32/govcl/vcl/types"
)
var (
testMessage = "这是一个测试消息!"
testMessage2 = "你确定么?"
)
//::private::
type TForm1Fields struct {
}
func (f *TForm1) OnFormCreate(sender vcl.IObject) {
multilang.InitComponentLang(f)
f.MainMenu1.SetAutoHotkeys(types.MaManual)
item := vcl.NewMenuItem(f)
item.SetCaption("Languages")
for key, val := range multilang.LocalLangs {
subitem := vcl.NewMenuItem(f)
subitem.SetGroupIndex(1)
subitem.SetRadioItem(true)
subitem.SetCaption(fmt.Sprintf("%d - %s", val.Language.Id, val.Language.Description))
subitem.SetOnClick(f.OnLanguageMenuItemClick)
subitem.SetTag(key)
if multilang.CurrentLang == val.Language.Name {
subitem.SetChecked(true)
}
item.Add(subitem)
}
f.MainMenu1.Items().Add(item)
}
func (f *TForm1) OnLanguageMenuItemClick(sender vcl.IObject) {
id := vcl.MenuItemFromObj(sender).Tag()
if lang, ok := multilang.LocalLangs[id]; ok {
fmt.Println(lang)
multilang.ChangeLang(lang.Language.Name)
multilang.WriteSetLang(lang.Language.Name)
vcl.MenuItemFromObj(sender).SetChecked(true)
}
}
func (f *TForm1) OnButton1Click(sender vcl.IObject) {
vcl.ShowMessage(testMessage)
}
func (f *TForm1) OnButton2Click(sender vcl.IObject) {
if vcl.MessageDlg(testMessage2, types.MtConfirmation, types.MbYes, types.MbNo) == types.IdYes {
}
}
func (f *TForm1) OnButton3Click(sender vcl.IObject) {
vcl.ShowMessage(multilang.IdRes("testMessage3"))
}
// 初始就注册
func init() {
multilang.RegsiterVarString("testMessage", &testMessage)
multilang.RegsiterVarString("testMessage2", &testMessage2)
//multilang.RegsiterVar(&testMessage)
}