-
Notifications
You must be signed in to change notification settings - Fork 3
/
pushbutton.go
37 lines (31 loc) · 921 Bytes
/
pushbutton.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
package main
import (
"github.com/chenqinghe/redis-desktop/i18n"
"github.com/chenqinghe/walk"
"github.com/lxn/win"
"strconv"
)
type PushButtonEx struct {
*walk.PushButton
root *MainWindowEX
}
func (pb *PushButtonEx) OnClick() {
h := pb.root.LE_host.Text()
if len(h) == 0 {
walk.MsgBox(nil, "ERROR", i18n.Tr("alert.hostcannotempty"), walk.MsgBoxIconError)
return
}
p, err := strconv.Atoi(pb.root.LE_port.Text())
if err != nil {
walk.MsgBox(nil, "ERROR", i18n.Tr("alert.invalidport", err.Error()), walk.MsgBoxIconError)
return
}
s := Session{Password: pb.root.LE_password.Text(), Host: pb.root.LE_host.Text(), Port: p}
if !pb.root.TV_sessions.SessionExist(s) {
ret := walk.MsgBox(pb.root, "INFO", "是否保存当前会话?", walk.MsgBoxIconQuestion|walk.MsgBoxYesNo)
if ret == win.IDYES { // save session
pb.root.TV_sessions.AddSession(s)
}
}
pb.root.TW_pages.startNewSession(s)
}