Exemple #1
1
func createBitmap() *walk.Bitmap {
	bounds := walk.Rectangle{Width: 200, Height: 200}

	bmp, _ := walk.NewBitmap(bounds.Size())

	succeeded := false
	defer func() {
		if !succeeded {
			bmp.Dispose()
		}
	}()

	canvas, _ := walk.NewCanvasFromImage(bmp)
	defer canvas.Dispose()

	brushBmp, _ := walk.NewBitmapFromFile("../img/plus.png")
	defer brushBmp.Dispose()

	brush, _ := walk.NewBitmapBrush(brushBmp)
	defer brush.Dispose()

	canvas.FillRectangle(brush, bounds)

	font, _ := walk.NewFont("Times New Roman", 40, walk.FontBold|walk.FontItalic)
	defer font.Dispose()

	canvas.DrawText("Walk Drawing Example", font, walk.RGB(0, 0, 0), bounds, walk.TextWordbreak)

	succeeded = true
	return bmp
}
Exemple #2
0
func NewLinkLabel(parent walk.Container, txt string, w, h, x, y int) *LinkLabel {
	ll := new(LinkLabel)
	ll.Label, _ = walk.NewLabel(parent)

	font, _ := walk.NewFont("微软雅黑", 9, walk.FontUnderline)
	ll.Label.SetFont(font)

	ll.Label.SetText(txt)
	ll.Label.SetWidth(w)
	ll.Label.SetHeight(h)
	ll.Label.SetX(x)
	ll.Label.SetY(y)

	return ll
}
Exemple #3
0
func NewLabel(parent walk.Container, txt string, w, h, x, y int) *Label {
	ll := new(Label)
	ll.Label, _ = walk.NewLabel(parent)

	font, _ := walk.NewFont("微软雅黑", 9, 0)
	ll.Label.SetFont(font)
	//WS_EX_TRANSPARENT
	ll.Label.SetText(txt)
	ll.Label.SetWidth(w)
	ll.Label.SetHeight(h)
	ll.Label.SetX(x)
	ll.Label.SetY(y)

	//win.SetWindowLongPtr(ll.Label.Handle(), win.GWL_EXSTYLE, win.WS_EX_TRANSPARENT)

	return ll
}
Exemple #4
0
func NewLineEdit(parent walk.Container, text string, w, h, x, y int) *LineEdit {
	t, err := walk.NewLineEdit(parent)
	if err != nil {
		return nil
	}

	font, _ := walk.NewFont("微软雅黑", 9, 0)
	t.SetFont(font)

	t.SetText(text)
	t.SetWidth(w)
	t.SetHeight(h)
	t.SetX(x)
	t.SetY(y)

	te := new(LineEdit)
	te.LineEdit = t

	return te
}
Exemple #5
0
func (f Font) Create() (*walk.Font, error) {
	if f.Family == "" && f.PointSize == 0 {
		return nil, nil
	}

	var fs walk.FontStyle

	if f.Bold {
		fs |= walk.FontBold
	}
	if f.Italic {
		fs |= walk.FontItalic
	}
	if f.Underline {
		fs |= walk.FontUnderline
	}
	if f.StrikeOut {
		fs |= walk.FontStrikeOut
	}

	return walk.NewFont(f.Family, f.PointSize, fs)
}
Exemple #6
0
func (mw *MyDialog) init(owner walk.Form) (err error) {
	// 设置最小化
	mw.SetMinimizeBox(true)
	// 禁用最大化
	mw.SetMaximizeBox(false)
	// 设置窗口固定
	mw.SetFixedSize(true)
	// // 设置窗口前置
	// mw.SetWindowPos(true)

	mw.Dialog, err = walk.NewDialog(owner)
	mw.checkError(err)

	succeeded := false
	defer func() {
		if !succeeded {
			mw.Dispose()
		}
	}()

	// 设置主窗体大小
	err = mw.SetClientSize(walk.Size{700, 560})
	mw.checkError(err)

	// 设置主窗体标题
	err = mw.SetTitle("iMan-打包工具   V【" + _VERSION_ + "】")
	mw.checkError(err)

	// 设置
	mw.ui.SettingMenu, _ = walk.NewMenu()
	mw.ui.SettingAction = walk.NewMenuAction(mw.ui.SettingMenu)
	mw.ui.SettingAction.SetText("设置")

	mw.ui.ServerAction = walk.NewAction()
	mw.ui.ServerAction.SetText("服务器")

	mw.ui.SettingMenu.Actions().Add(mw.ui.ServerAction)

	// 帮助
	mw.ui.HelpMenu, _ = walk.NewMenu()
	mw.ui.HelpAction = walk.NewMenuAction(mw.ui.HelpMenu)
	mw.ui.HelpAction.SetText("帮助")

	mw.ui.AboutAction = walk.NewAction()
	mw.ui.AboutAction.SetText("关于")

	mw.ui.HelpMenu.Actions().Add(mw.ui.AboutAction)

	// 菜单配置
	mw.Menu().Actions().Add(mw.ui.SettingAction)
	mw.Menu().Actions().Add(mw.ui.HelpAction)

	// 设置字体和图标
	fountTitle, _ := walk.NewFont("幼圆", 10, walk.FontBold)
	otherFont, _ := walk.NewFont("幼圆", 10, 0)

	// 开始打包
	mw.ui.StartPackingBtn, err = walk.NewPushButton(mw)
	mw.checkError(err)

	mw.ui.StartPackingBtn.SetText("开始打包")

	mw.ui.StartPackingBtn.SetBounds(walk.Rectangle{310, 20, 75, 30})

	// 版本配置
	mw.ui.VersionGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)
	mw.ui.VersionGb.SetTitle("版本配置")
	mw.ui.VersionGb.SetFont(otherFont)

	err = mw.ui.VersionGb.SetBounds(walk.Rectangle{10, 60, 330, 260})
	mw.checkError(err)

	// 版本类型
	mw.ui.VersionTypeLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.VersionTypeLb.SetText("版本类型:")
	mw.ui.VersionTypeLb.SetFont(fountTitle)

	mw.ui.VersionTypeLb.SetBounds(walk.Rectangle{10, 20, 70, 25})

	// 测试版
	mw.ui.VersionTestRadio, err = walk.NewRadioButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.VersionTestRadio.SetText("测试版")

	mw.ui.VersionTestRadio.SetBounds(walk.Rectangle{110, 20, 60, 25})
	mw.ui.VersionTestRadio.SetChecked(true)

	// 正式版
	mw.ui.VersionOffRadio, err = walk.NewRadioButton(mw.ui.VersionGb)
	mw.checkError(err)
	mw.ui.VersionOffRadio.SetText("正式版")

	mw.ui.VersionOffRadio.SetBounds(walk.Rectangle{180, 20, 70, 25})

	// 主版本号
	mw.ui.MasterVersionLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.MasterVersionLb.SetText("主版本号:")
	mw.ui.MasterVersionLb.SetFont(fountTitle)

	mw.ui.MasterVersionLb.SetBounds(walk.Rectangle{10, 60, 70, 25})

	// 主版本号内容
	mw.ui.MasterVersionLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.MasterVersionLe.SetBounds(walk.Rectangle{110, 60, 60, 25})

	// 生成版本号
	mw.ui.PackVersionLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PackVersionLb.SetText("生成版本:")
	mw.ui.PackVersionLb.SetFont(fountTitle)

	mw.ui.PackVersionLb.SetBounds(walk.Rectangle{10, 100, 70, 25})

	// 生成版本号内容
	mw.ui.PackVersionLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PackVersionLe.SetEnabled(false)

	mw.ui.PackVersionLe.SetBounds(walk.Rectangle{110, 100, 140, 25})

	// PC助手
	mw.ui.PcHelperLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PcHelperLb.SetText("PC助手:")
	mw.ui.PcHelperLb.SetFont(fountTitle)

	mw.ui.PcHelperLb.SetBounds(walk.Rectangle{10, 140, 70, 25})

	// PC助手上传路径
	mw.ui.PcHelperLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PcHelperLe.SetBounds(walk.Rectangle{110, 140, 150, 25})

	// PC助手上传按钮
	mw.ui.PcUploadBtn, err = walk.NewPushButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PcUploadBtn.SetText("上传")
	mw.ui.PcUploadBtn.SetBounds(walk.Rectangle{270, 140, 50, 25})

	// Android助手
	mw.ui.AndroidHelperLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.AndroidHelperLb.SetText("Android助手:")
	mw.ui.AndroidHelperLb.SetFont(fountTitle)

	mw.ui.AndroidHelperLb.SetBounds(walk.Rectangle{10, 180, 100, 25})

	// Android助手上传路径
	mw.ui.AndroidHelperLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.AndroidHelperLe.SetBounds(walk.Rectangle{110, 180, 150, 25})

	// Android助手上传按钮
	mw.ui.AndUploadBtn, err = walk.NewPushButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.AndUploadBtn.SetText("上传")

	mw.ui.AndUploadBtn.SetBounds(walk.Rectangle{270, 180, 50, 25})

	// Web 数据库
	mw.ui.WebSqlLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.WebSqlLb.SetText("Web 数据库:")
	mw.ui.WebSqlLb.SetFont(fountTitle)

	mw.ui.WebSqlLb.SetBounds(walk.Rectangle{10, 220, 90, 25})

	// Web 数据库上传路径
	mw.ui.WebSqlLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.WebSqlLe.SetBounds(walk.Rectangle{110, 220, 150, 25})

	// Web 数据库上传按钮
	mw.ui.WebSqlBtn, err = walk.NewPushButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.WebSqlBtn.SetText("上传")

	mw.ui.WebSqlBtn.SetBounds(walk.Rectangle{270, 220, 50, 25})

	// 打包内容配置
	mw.ui.PackGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)

	mw.ui.PackGb.SetTitle("打包内容配置")
	mw.ui.PackGb.SetFont(otherFont)

	mw.ui.PackGb.SetBounds(walk.Rectangle{355, 60, 335, 260})

	// 全选
	mw.ui.CheckAllLb, err = walk.NewLabel(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.CheckAllLb.SetText("全选:")
	mw.ui.CheckAllLb.SetFont(fountTitle)

	mw.ui.CheckAllLb.SetBounds(walk.Rectangle{10, 20, 55, 25})

	// 全选框
	mw.ui.CheckAllCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)
	mw.ui.CheckAllCb.SetVisible(true)

	mw.ui.CheckAllCb.SetBounds(walk.Rectangle{80, 20, 70, 25})

	// 服务器
	mw.ui.ServerLb, err = walk.NewLabel(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.ServerLb.SetText("服务器:")
	mw.ui.ServerLb.SetFont(fountTitle)

	mw.ui.ServerLb.SetBounds(walk.Rectangle{10, 50, 55, 25})

	// Java Web复选框
	mw.ui.JavaWebCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.JavaWebCb.SetText("Java Web")

	mw.ui.JavaWebCb.SetBounds(walk.Rectangle{80, 50, 80, 25})

	// Web 数据库复选框
	mw.ui.WebSqlCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.WebSqlCb.SetText("Web 数据库")

	mw.ui.WebSqlCb.SetBounds(walk.Rectangle{170, 50, 90, 25})

	// PC助手
	mw.ui.PcHelperCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.PcHelperCb.SetText("PC助手")

	mw.ui.PcHelperCb.SetBounds(walk.Rectangle{80, 90, 60, 25})

	// Android助手
	mw.ui.AndroidHelperCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.AndroidHelperCb.SetText("Android助手")

	mw.ui.AndroidHelperCb.SetBounds(walk.Rectangle{170, 90, 90, 25})

	// 控制器
	mw.ui.ControlLb, err = walk.NewLabel(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.ControlLb.SetText("控制器:")
	mw.ui.ControlLb.SetFont(fountTitle)

	mw.ui.ControlLb.SetBounds(walk.Rectangle{10, 130, 55, 25})

	// Linux knl
	mw.ui.LinuxKnlCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.LinuxKnlCb.SetText("Linux Knl")

	mw.ui.LinuxKnlCb.SetBounds(walk.Rectangle{80, 130, 80, 25})

	// Linux App
	mw.ui.LinuxAppCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.LinuxAppCb.SetText("Linux App")

	mw.ui.LinuxAppCb.SetBounds(walk.Rectangle{170, 130, 80, 25})

	// Linux Ruby
	mw.ui.LinuxRubyCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.LinuxRubyCb.SetText("Linux Ruby")

	mw.ui.LinuxRubyCb.SetBounds(walk.Rectangle{80, 170, 90, 25})

	// 打包日志
	mw.ui.PackLogLb, err = walk.NewLabel(mw)
	mw.checkError(err)

	mw.ui.PackLogLb.SetText("打包日志")
	mw.ui.PackLogLb.SetFont(fountTitle)

	mw.ui.PackLogLb.SetBounds(walk.Rectangle{20, 330, 60, 20})

	// 日志输出
	mw.ui.lv, err = NewLogView(mw)
	mw.checkError(err)

	err = mw.ui.lv.SetBounds(walk.Rectangle{10, 360, 680, 190})
	mw.checkError(err)

	log.SetOutput(mw.ui.lv)

	// img, _ = walk.NewIconFromResourceId(7)
	// mw.ui.browseBtn.SetImage(img)
	// mw.ui.browseBtn.SetImageAboveText(false)
	// mw.ui.browseBtn.SetBackground(bg)

	// reader, _ := os.Open("../../img/folder_add.png")
	// add, _, _ := image.Decode(reader)
	// var img walk.Image
	// img, _ = walk.NewBitmapFromImage(add)

	// mw.ui.browseBtn.SetImage(img)

	// img, _ = walk.NewImageFromFile("../../img/arrow_divide.png")
	// mw.ui.uploadBtn.SetImage(img)

	succeeded = true

	return nil
}
Exemple #7
0
func (mw *MyDialog) init(owner walk.Form) (err error) {
	// 设置最小化
	mw.SetMinimizeBox(true)
	// 禁用最大化
	mw.SetMaximizeBox(false)
	// 设置窗口固定
	mw.SetFixedSize(true)

	mw.Dialog, err = walk.NewDialogCody(owner)
	mw.checkError(err)

	succeeded := false
	defer func() {
		if !succeeded {
			mw.Dispose()
		}
	}()

	// 设置主窗体大小
	mw.SetClientSize(walk.Size{376, 287})
	mw.checkError(err)

	// 居中
	mw.SetScreenCenter(true)

	// 设置主窗体在所有窗体之前
	mw.SetForegroundWindow()
	mw.SwitchToThisWindow(true)

	// 设置主窗体标题
	mw.SetTitle("iMan-升级工具   V【" + _VERSION_ + "】")
	mw.checkError(err)

	// 设置上传组合窗体
	mw.ui.uploadGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)

	err = mw.ui.uploadGb.SetTitle("升级包上传")
	mw.checkError(err)

	err = mw.ui.uploadGb.SetBounds(walk.Rectangle{3, 7, 368, 138})
	mw.checkError(err)

	// 升级包
	mw.ui.fileLb, err = walk.NewLabel(mw.ui.uploadGb)
	mw.checkError(err)

	err = mw.ui.fileLb.SetText("升级包:")
	mw.checkError(err)

	err = mw.ui.fileLb.SetBounds(walk.Rectangle{10, 33, 70, 25})
	mw.checkError(err)

	// 上传路径
	mw.ui.fileLe, err = walk.NewLineEdit(mw.ui.uploadGb)
	mw.checkError(err)

	err = mw.ui.fileLe.SetBounds(walk.Rectangle{96, 33, 166, 25})
	mw.checkError(err)

	err = mw.ui.fileLe.SetReadOnly(true)
	mw.checkError(err)

	// 浏览按钮
	mw.ui.browseBtn, err = walk.NewPushButton(mw.ui.uploadGb)
	mw.checkError(err)

	err = mw.ui.browseBtn.SetText("浏览")
	mw.checkError(err)

	err = mw.ui.browseBtn.SetBounds(walk.Rectangle{288, 34, 55, 25})
	mw.checkError(err)

	mw.ui.browseBtn.SetCursor(walk.CursorHand())

	// 服务器IP lb
	mw.ui.ipLb, err = walk.NewLabel(mw.ui.uploadGb)
	mw.checkError(err)

	err = mw.ui.ipLb.SetText("服务器IP:")
	mw.checkError(err)

	err = mw.ui.ipLb.SetBounds(walk.Rectangle{10, 94, 70, 25})
	mw.checkError(err)

	// 服务器IP le
	mw.ui.ipLe, err = walk.NewLineEdit(mw.ui.uploadGb)
	mw.checkError(err)

	err = mw.ui.ipLe.SetBounds(walk.Rectangle{96, 92, 166, 25})
	mw.checkError(err)

	// 控制IP输入长度为15
	mw.ui.ipLe.SetMaxLength(15)

	// 上传按钮
	mw.ui.uploadBtn, err = walk.NewPushButton(mw.ui.uploadGb)
	mw.checkError(err)

	// // // 设置背景
	// color := walk.RGB(0, 255, 0)
	// bg, _ := walk.NewSolidColorBrush(color)
	// mw.SetBackground(bg)
	// mw.ui.uploadBtn.SetBackground(bg)
	// mw.ui.uploadBtn.ImageAboveText()

	err = mw.ui.uploadBtn.SetText("上传")
	mw.checkError(err)

	err = mw.ui.uploadBtn.SetBounds(walk.Rectangle{288, 92, 55, 25})
	mw.checkError(err)

	mw.ui.uploadBtn.SetCursor(walk.CursorHand())

	// 日志
	mw.ui.logLb, err = walk.NewLabel(mw)
	mw.checkError(err)

	err = mw.ui.logLb.SetText("日志")
	mw.checkError(err)

	err = mw.ui.logLb.SetBounds(walk.Rectangle{5, 152, 29, 13})
	mw.checkError(err)

	// 日志输出
	mw.ui.lv, err = NewLogView(mw)
	mw.checkError(err)

	err = mw.ui.lv.SetBounds(walk.Rectangle{6, 172, 365, 106})
	mw.checkError(err)

	log.SetOutput(mw.ui.lv)

	// 设置字体和图标
	fount, _ := walk.NewFont("幼圆", 10, walk.FontBold)
	mw.ui.logLb.SetFont(fount)
	mw.ui.uploadGb.SetFont(fount)

	succeeded = true

	return nil
}
Exemple #8
0
func (mw *MyDialog) init(owner walk.Form) (err error) {
	// 设置最小化
	mw.SetMinimizeBox(true)
	// 禁用最大化
	mw.SetMaximizeBox(false)
	// 窗口屏幕居中
	mw.SetFixedSize(true)

	mw.Dialog, err = walk.NewDialog(owner)
	mw.checkError(err)

	succeeded := false
	defer func() {
		if !succeeded {
			mw.Dispose()
		}
	}()

	// 设置主窗体大小
	mw.SetClientSize(walk.Size{600, 450})
	mw.checkError(err)

	// 设置主窗体标题
	mw.SetTitle("邮件群发-by Cody.Guo")
	mw.checkError(err)

	// 设置上传组合窗体
	mw.ui.mailListGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)

	err = mw.ui.mailListGb.SetTitle("发送邮件列表")
	mw.checkError(err)

	err = mw.ui.mailListGb.SetBounds(walk.Rectangle{7, 8, 165, 434})
	mw.checkError(err)

	// 邮件编辑框
	mw.ui.mailListLe, err = walk.NewTextEdit(mw.ui.mailListGb)
	mw.checkError(err)

	err = mw.ui.mailListLe.SetBounds(walk.Rectangle{7, 25, 155, 405})
	mw.checkError(err)

	// 邮件服务器配置
	mw.ui.mailServerGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)
	err = mw.ui.mailServerGb.SetTitle("邮件服务器配置")
	mw.checkError(err)
	err = mw.ui.mailServerGb.SetBounds(walk.Rectangle{185, 8, 405, 113})
	mw.checkError(err)

	// 用户名
	mw.ui.userNameLb, err = walk.NewLabel(mw.ui.mailServerGb)
	mw.checkError(err)
	err = mw.ui.userNameLb.SetText("用户名:")
	mw.checkError(err)
	err = mw.ui.userNameLb.SetBounds(walk.Rectangle{8, 20, 80, 20})
	mw.checkError(err)

	// 用户名编辑框
	mw.ui.userNameLe, err = walk.NewLineEdit(mw.ui.mailServerGb)
	mw.checkError(err)
	mw.ui.userNameLe.SetText(MS.UserName)

	err = mw.ui.userNameLe.SetBounds(walk.Rectangle{110, 20, 150, 20})
	mw.checkError(err)

	// 密码
	mw.ui.passwdLb, err = walk.NewLabel(mw.ui.mailServerGb)
	mw.checkError(err)

	err = mw.ui.passwdLb.SetText("密码:")
	mw.checkError(err)

	err = mw.ui.passwdLb.SetBounds(walk.Rectangle{8, 50, 80, 20})
	mw.checkError(err)

	// 密码编辑框
	mw.ui.passwdLe, err = walk.NewLineEdit(mw.ui.mailServerGb)
	mw.checkError(err)
	mw.ui.passwdLe.SetText(MS.Passwd)

	err = mw.ui.passwdLe.SetBounds(walk.Rectangle{110, 50, 150, 20})
	mw.checkError(err)

	mw.ui.passwdLe.SetPasswordMode(true)

	// SMTP服务器
	mw.ui.smtpLb, err = walk.NewLabel(mw.ui.mailServerGb)
	mw.checkError(err)

	err = mw.ui.smtpLb.SetText("SMTP服务器:")
	mw.checkError(err)

	err = mw.ui.smtpLb.SetBounds(walk.Rectangle{8, 80, 90, 20})
	mw.checkError(err)

	// // SMTP服务器编辑框
	mw.ui.smtpLe, err = walk.NewLineEdit(mw.ui.mailServerGb)
	mw.checkError(err)
	mw.ui.smtpLe.SetText(MS.Smtp)

	err = mw.ui.smtpLe.SetBounds(walk.Rectangle{110, 80, 150, 20})
	mw.checkError(err)

	// PORT 25
	mw.ui.portLe, err = walk.NewLineEdit(mw.ui.mailServerGb)
	mw.checkError(err)

	mw.ui.portLe.SetBounds(walk.Rectangle{270, 80, 30, 20})
	mw.ui.portLe.SetText(MS.Port)

	// 发送配置
	mw.ui.mailContentGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)

	mw.ui.mailContentGb.SetTitle("发送配置")
	err = mw.ui.mailContentGb.SetBounds(walk.Rectangle{185, 135, 405, 187})
	mw.checkError(err)

	// 邮件主题
	mw.ui.mailSubLb, err = walk.NewLabel(mw.ui.mailContentGb)
	mw.checkError(err)

	mw.ui.mailSubLb.SetText("邮件主题:")
	err = mw.ui.mailSubLb.SetBounds(walk.Rectangle{8, 20, 80, 20})
	mw.checkError(err)

	// 邮件主题编辑框
	mw.ui.mailSubLe, err = walk.NewLineEdit(mw.ui.mailContentGb)
	mw.checkError(err)
	mw.ui.mailSubLe.SetText(MS.Subject)

	err = mw.ui.mailSubLe.SetBounds(walk.Rectangle{110, 20, 150, 20})
	mw.checkError(err)

	// 邮件内容
	mw.ui.mailBodyLb, err = walk.NewLabel(mw.ui.mailContentGb)
	mw.checkError(err)

	mw.ui.mailBodyLb.SetText("邮件内容:")
	err = mw.ui.mailBodyLb.SetBounds(walk.Rectangle{8, 50, 80, 20})
	mw.checkError(err)

	// 邮件内容编辑框
	mw.ui.mailBodyLe, err = walk.NewTextEdit(mw.ui.mailContentGb)
	mw.checkError(err)

	mw.ui.mailBodyLe.SetText(MS.Body)

	err = mw.ui.mailBodyLe.SetBounds(walk.Rectangle{110, 50, 280, 100})
	mw.checkError(err)

	// 附件
	mw.ui.mailAdjLb, err = walk.NewLabel(mw.ui.mailContentGb)
	mw.checkError(err)

	mw.ui.mailAdjLb.SetText("附件:")
	err = mw.ui.mailAdjLb.SetBounds(walk.Rectangle{8, 160, 80, 20})
	mw.checkError(err)

	// 附件编辑框
	mw.ui.mailAdjLe, err = walk.NewLineEdit(mw.ui.mailContentGb)
	mw.checkError(err)

	err = mw.ui.mailAdjLe.SetBounds(walk.Rectangle{110, 160, 150, 20})
	mw.checkError(err)

	mw.ui.mailAdjLe.SetText(MS.Adjunct)

	mw.ui.mailAdjLe.SetReadOnly(true)

	// 浏览
	mw.ui.browseBtn, err = walk.NewPushButton(mw.ui.mailContentGb)
	mw.checkError(err)
	mw.ui.browseBtn.SetText("浏览")
	err = mw.ui.browseBtn.SetBounds(walk.Rectangle{270, 155, 35, 30})
	mw.checkError(err)

	// 日志
	mw.ui.logLb, err = walk.NewLabel(mw)
	mw.checkError(err)

	mw.ui.logLb.SetText("日志")

	err = mw.ui.logLb.SetBounds(walk.Rectangle{185, 325, 30, 20})
	mw.checkError(err)

	// 日志输出
	mw.ui.lv, err = NewLogView(mw)
	mw.checkError(err)

	err = mw.ui.lv.SetBounds(walk.Rectangle{185, 345, 405, 70})
	mw.checkError(err)

	log.SetOutput(mw.ui.lv)

	// 发送邮件
	mw.ui.sendBtn, err = walk.NewPushButton(mw)
	mw.checkError(err)

	mw.ui.sendBtn.SetText("开始发送")

	err = mw.ui.sendBtn.SetBounds(walk.Rectangle{350, 420, 80, 30})
	mw.checkError(err)

	// // 设置背景
	// color := walk.RGB(255, 0, 0)
	// bg, _ := walk.NewSolidColorBrush(color)
	// mw.SetBackground(bg)

	// 设置字体和图标
	fount, _ := walk.NewFont("宋体", 11, 0)
	mw.SetFont(fount)
	mw.ui.mailListGb.SetFont(fount)
	mw.ui.mailServerGb.SetFont(fount)
	mw.ui.mailContentGb.SetFont(fount)

	succeeded = true

	return nil
}
Exemple #9
0
func (dlg *DlgServer) init(owner walk.Form) (err error) {
	dlg.Dialog, err = walk.NewDialogWithFixedSize(owner)
	dlg.checkError(err)

	// 读取配置文件
	ConfSer.Read()

	succeeded := false
	defer func() {
		if !succeeded {
			dlg.Dispose()
		}
	}()

	// 设置主窗体大小
	err = dlg.SetClientSize(walk.Size{250, 180})
	dlg.checkError(err)

	// 设置窗体标题
	err = dlg.SetTitle("服务器设置")
	dlg.checkError(err)

	// 设置字体和图标
	fountTitle, _ := walk.NewFont("幼圆", 10, walk.FontBold)
	fountOther, _ := walk.NewFont("幼圆", 10, 0)

	// IP标题
	dlg.ui.IpLb, err = walk.NewLabel(dlg)
	dlg.ui.IpLb.SetText("IP:")
	dlg.ui.IpLb.SetFont(fountTitle)
	dlg.ui.IpLb.SetBounds(walk.Rectangle{30, 20, 60, 20})

	// IP编辑框
	dlg.ui.IpLe, err = walk.NewLineEdit(dlg)
	dlg.ui.IpLe.SetBounds(walk.Rectangle{100, 20, 120, 20})
	dlg.ui.IpLe.SetFont(fountOther)
	dlg.ui.IpLe.SetText(ConfSer.Ip)
	dlg.ui.IpLe.SetMaxLength(15)

	// 用户名标题
	dlg.ui.UserLb, err = walk.NewLabel(dlg)
	dlg.ui.UserLb.SetText("用户名:")
	dlg.ui.UserLb.SetFont(fountTitle)

	dlg.ui.UserLb.SetBounds(walk.Rectangle{30, 60, 60, 20})

	// 用户名编辑框
	dlg.ui.UserLe, err = walk.NewLineEdit(dlg)
	dlg.ui.UserLe.SetBounds(walk.Rectangle{100, 60, 120, 20})
	dlg.ui.UserLe.SetFont(fountOther)
	dlg.ui.UserLe.SetText(ConfSer.User)

	// 密码标题
	dlg.ui.PasswdLb, err = walk.NewLabel(dlg)
	dlg.ui.PasswdLb.SetText("密码:")
	dlg.ui.PasswdLb.SetFont(fountTitle)

	dlg.ui.PasswdLb.SetBounds(walk.Rectangle{30, 100, 60, 20})

	// 密码编辑框
	dlg.ui.PasswdLe, err = walk.NewLineEdit(dlg)
	dlg.ui.PasswdLe.SetBounds(walk.Rectangle{100, 100, 120, 20})
	dlg.ui.PasswdLe.SetPasswordMode(true)
	dlg.ui.PasswdLe.SetText(ConfSer.Passwd)

	// 确定
	dlg.ui.AcceptPB, err = walk.NewPushButton(dlg)
	dlg.ui.AcceptPB.SetText("确定")

	dlg.ui.AcceptPB.SetBounds(walk.Rectangle{150, 140, 70, 25})

	// 设置图标
	icon, _ := walk.NewIconFromResourceId(3)
	dlg.SetIcon(icon)

	succeeded = true

	return nil
}
Exemple #10
0
func (mw *MyWindow) init() (err error) {
	// 设置最小化
	mw.SetMinimizeBox(true)
	// 禁用最大化
	mw.SetMaximizeBox(false)
	// 设置窗口固定
	mw.SetFixedSize(true)
	// // 设置窗口前置
	// mw.SetWindowPos(true)

	mw.MainWindow, err = walk.NewMainWindow()
	mw.checkError(err)

	succeeded := false
	defer func() {
		if !succeeded {
			mw.Dispose()
		}
	}()

	// 设置主窗体大小
	err = mw.SetClientSize(walk.Size{700, 560})
	mw.checkError(err)

	// 设置主窗体标题
	err = mw.SetTitle("iMan-打包工具   V【" + _VERSION_ + "】")
	mw.checkError(err)

	// 设置
	mw.ui.SettingMenu, _ = walk.NewMenu()
	mw.ui.SettingAction = walk.NewMenuAction(mw.ui.SettingMenu)
	mw.ui.SettingAction.SetText("设置")

	mw.ui.ServerAction = walk.NewAction()
	mw.ui.ServerAction.SetText("服务器")

	mw.ui.SettingMenu.Actions().Add(mw.ui.ServerAction)

	// 帮助
	mw.ui.HelpMenu, _ = walk.NewMenu()
	mw.ui.HelpAction = walk.NewMenuAction(mw.ui.HelpMenu)
	mw.ui.HelpAction.SetText("帮助")

	mw.ui.AboutAction = walk.NewAction()
	mw.ui.AboutAction.SetText("关于")

	mw.ui.HelpMenu.Actions().Add(mw.ui.AboutAction)

	// 菜单配置
	mw.Menu().Actions().Add(mw.ui.SettingAction)
	mw.Menu().Actions().Add(mw.ui.HelpAction)

	// 设置字体和图标
	fountTitle, _ := walk.NewFont("幼圆", 10, walk.FontBold)
	otherFont, _ := walk.NewFont("幼圆", 10, 0)

	// 编译服务器IP
	mw.ui.BuildServerLb, err = walk.NewLabel(mw)
	mw.checkError(err)

	mw.ui.BuildServerLb.SetText("编译服务器IP: " + ConfSer.Ip)
	mw.ui.BuildServerLb.SetFont(otherFont)

	mw.ui.BuildServerLb.SetBounds(walk.Rectangle{480, 10, 220, 20})

	// 开始打包
	mw.ui.StartPackingBtn, err = walk.NewPushButton(mw)
	mw.checkError(err)

	mw.ui.StartPackingBtn.SetText("开始打包")

	mw.ui.StartPackingBtn.SetBounds(walk.Rectangle{310, 20, 75, 30})

	// 版本配置
	mw.ui.VersionGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)
	mw.ui.VersionGb.SetTitle("版本配置")
	mw.ui.VersionGb.SetFont(otherFont)

	err = mw.ui.VersionGb.SetBounds(walk.Rectangle{10, 60, 330, 260})
	mw.checkError(err)

	// 版本类型
	mw.ui.VersionTypeLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.VersionTypeLb.SetText("版本类型:")
	mw.ui.VersionTypeLb.SetFont(fountTitle)

	mw.ui.VersionTypeLb.SetBounds(walk.Rectangle{10, 20, 70, 25})

	// 测试版
	mw.ui.VersionTestRadio, err = walk.NewRadioButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.VersionTestRadio.SetText("测试版")

	mw.ui.VersionTestRadio.SetBounds(walk.Rectangle{110, 20, 60, 25})
	mw.ui.VersionTestRadio.SetChecked(true)

	// 正式版
	mw.ui.VersionOffRadio, err = walk.NewRadioButton(mw.ui.VersionGb)
	mw.checkError(err)
	mw.ui.VersionOffRadio.SetText("正式版")

	mw.ui.VersionOffRadio.SetBounds(walk.Rectangle{180, 20, 70, 25})

	// 主版本号
	mw.ui.MasterVersionLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.MasterVersionLb.SetText("主版本号:")
	mw.ui.MasterVersionLb.SetFont(fountTitle)

	mw.ui.MasterVersionLb.SetBounds(walk.Rectangle{10, 60, 70, 25})

	// 主版本号内容
	mw.ui.MasterVersionLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.MasterVersionLe.SetBounds(walk.Rectangle{110, 60, 60, 25})

	// 生成版本号
	mw.ui.PackVersionLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PackVersionLb.SetText("生成版本:")
	mw.ui.PackVersionLb.SetFont(fountTitle)

	mw.ui.PackVersionLb.SetBounds(walk.Rectangle{10, 100, 70, 25})

	// 生成版本号内容
	mw.ui.PackVersionLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PackVersionLe.SetEnabled(false)

	mw.ui.PackVersionLe.SetBounds(walk.Rectangle{110, 100, 140, 25})

	// PC助手
	mw.ui.PcHelperLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PcHelperLb.SetText("PC助手:")
	mw.ui.PcHelperLb.SetFont(fountTitle)

	mw.ui.PcHelperLb.SetBounds(walk.Rectangle{10, 140, 70, 25})

	// PC助手上传路径
	mw.ui.PcHelperLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PcHelperLe.SetBounds(walk.Rectangle{110, 140, 150, 25})

	// PC助手上传按钮
	mw.ui.PcUploadBtn, err = walk.NewPushButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.PcUploadBtn.SetText("上传")
	mw.ui.PcUploadBtn.SetBounds(walk.Rectangle{270, 140, 50, 25})

	// Android助手
	mw.ui.AndroidHelperLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.AndroidHelperLb.SetText("Android助手:")
	mw.ui.AndroidHelperLb.SetFont(fountTitle)

	mw.ui.AndroidHelperLb.SetBounds(walk.Rectangle{10, 180, 100, 25})

	// Android助手上传路径
	mw.ui.AndroidHelperLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.AndroidHelperLe.SetBounds(walk.Rectangle{110, 180, 150, 25})

	// Android助手上传按钮
	mw.ui.AndUploadBtn, err = walk.NewPushButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.AndUploadBtn.SetText("上传")

	mw.ui.AndUploadBtn.SetBounds(walk.Rectangle{270, 180, 50, 25})

	// Web 数据库
	mw.ui.WebSqlLb, err = walk.NewLabel(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.WebSqlLb.SetText("Web 数据库:")
	mw.ui.WebSqlLb.SetFont(fountTitle)

	mw.ui.WebSqlLb.SetBounds(walk.Rectangle{10, 220, 90, 25})

	// Web 数据库上传路径
	mw.ui.WebSqlLe, err = walk.NewLineEdit(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.WebSqlLe.SetBounds(walk.Rectangle{110, 220, 150, 25})

	// Web 数据库上传按钮
	mw.ui.WebSqlBtn, err = walk.NewPushButton(mw.ui.VersionGb)
	mw.checkError(err)

	mw.ui.WebSqlBtn.SetText("上传")

	mw.ui.WebSqlBtn.SetBounds(walk.Rectangle{270, 220, 50, 25})

	// 打包内容配置
	mw.ui.PackGb, err = walk.NewGroupBox(mw)
	mw.checkError(err)

	mw.ui.PackGb.SetTitle("打包内容配置")
	mw.ui.PackGb.SetFont(otherFont)

	mw.ui.PackGb.SetBounds(walk.Rectangle{355, 60, 335, 260})

	// 全选
	mw.ui.CheckAllLb, err = walk.NewLabel(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.CheckAllLb.SetText("全选:")
	mw.ui.CheckAllLb.SetFont(fountTitle)

	mw.ui.CheckAllLb.SetBounds(walk.Rectangle{10, 20, 55, 25})

	// 全选框
	mw.ui.CheckAllCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)
	mw.ui.CheckAllCb.SetVisible(true)

	mw.ui.CheckAllCb.SetBounds(walk.Rectangle{80, 20, 70, 25})

	// 服务器
	mw.ui.ServerLb, err = walk.NewLabel(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.ServerLb.SetText("服务器:")
	mw.ui.ServerLb.SetFont(fountTitle)

	mw.ui.ServerLb.SetBounds(walk.Rectangle{10, 50, 55, 25})

	// Java Web复选框
	mw.ui.JavaWebCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.JavaWebCb.SetText("Java Web")

	mw.ui.JavaWebCb.SetBounds(walk.Rectangle{80, 50, 80, 25})

	// Web 数据库复选框
	mw.ui.WebSqlCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.WebSqlCb.SetText("Web 数据库")

	mw.ui.WebSqlCb.SetBounds(walk.Rectangle{170, 50, 90, 25})

	// PC助手
	mw.ui.PcHelperCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.PcHelperCb.SetText("PC助手")

	mw.ui.PcHelperCb.SetBounds(walk.Rectangle{80, 90, 60, 25})

	// Android助手
	mw.ui.AndroidHelperCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.AndroidHelperCb.SetText("Android助手")

	mw.ui.AndroidHelperCb.SetBounds(walk.Rectangle{170, 90, 90, 25})

	// 控制器
	mw.ui.ControlLb, err = walk.NewLabel(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.ControlLb.SetText("控制器:")
	mw.ui.ControlLb.SetFont(fountTitle)

	mw.ui.ControlLb.SetBounds(walk.Rectangle{10, 130, 55, 25})

	// Linux knl
	mw.ui.LinuxKnlCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.LinuxKnlCb.SetText("Linux Knl")

	mw.ui.LinuxKnlCb.SetBounds(walk.Rectangle{80, 130, 80, 25})

	// Linux App
	mw.ui.LinuxAppCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.LinuxAppCb.SetText("Linux App")

	mw.ui.LinuxAppCb.SetBounds(walk.Rectangle{170, 130, 80, 25})

	// Linux Ruby
	mw.ui.LinuxRubyCb, err = walk.NewCheckBox(mw.ui.PackGb)
	mw.checkError(err)

	mw.ui.LinuxRubyCb.SetText("Linux Ruby")

	mw.ui.LinuxRubyCb.SetBounds(walk.Rectangle{80, 170, 90, 25})

	// 打包日志 TabWidget
	mw.ui.PackTabWidget, err = walk.NewTabWidget(mw)
	mw.checkError(err)
	mw.ui.PackTabWidget.SetBounds(walk.Rectangle{10, 330, 680, 200})

	// 打包日志 TabPage
	mw.ui.PackTabPage, err = walk.NewTabPage()
	mw.ui.PackTabPage.SetTitle("打包日志")

	// 历史版本记录 TabPage
	mw.ui.VersionPage, err = walk.NewTabPage()
	mw.ui.VersionPage.SetTitle("历史版本记录")

	// TabPage 添加到 TabWidget
	mw.ui.PackTabWidget.Pages().Add(mw.ui.PackTabPage)
	mw.ui.PackTabWidget.Pages().Add(mw.ui.VersionPage)

	// 打包日志 输出记录
	mw.ui.lv, err = NewLogView(mw.ui.PackTabPage)
	mw.checkError(err)
	err = mw.ui.lv.SetBounds(walk.Rectangle{-1, -1, 680, 180})
	mw.checkError(err)

	log.SetOutput(mw.ui.lv)

	// 历史版本记录 TableView
	mw.ui.VersionTableView, err = walk.NewTableView(mw.ui.VersionPage)
	mw.checkError(err)

	mw.ui.VersionTableView.SetBounds(walk.Rectangle{-1, -1, 680, 180})

	// 历史版本记录 - 序号
	mw.ui.VersionTabVieConIndex = walk.NewTableViewColumn()
	mw.ui.VersionTabVieConIndex.SetTitle("序号")
	mw.ui.VersionTabVieConIndex.SetWidth(50)

	// 历史版本记录 - 版本
	mw.ui.VersionTabVieConVer = walk.NewTableViewColumn()
	mw.ui.VersionTabVieConVer.SetTitle("版本")
	mw.ui.VersionTabVieConVer.SetWidth(100)

	// 历史版本记录 - 打包内容
	mw.ui.VersionTabVieConPack = walk.NewTableViewColumn()
	mw.ui.VersionTabVieConPack.SetTitle("打包内容")
	mw.ui.VersionTabVieConPack.SetWidth(120)

	// 历史版本记录 - 是否打Tag
	mw.ui.VersionTabVieConTag = walk.NewTableViewColumn()
	mw.ui.VersionTabVieConTag.SetTitle("Tag")
	mw.ui.VersionTabVieConTag.SetWidth(120)

	// 历史版本记录 - Tag 路径
	mw.ui.VersionTabVieConTagPath = walk.NewTableViewColumn()
	mw.ui.VersionTabVieConTagPath.SetTitle("Tag路径")
	mw.ui.VersionTabVieConTagPath.SetWidth(150)

	// 历史版本记录 - 打包时间
	mw.ui.VersionTabVieConTime = walk.NewTableViewColumn()
	mw.ui.VersionTabVieConTime.SetTitle("打包时间")
	mw.ui.VersionTabVieConTime.SetWidth(100)

	// TableViewColumn 添加到 TableView
	mw.ui.VersionTableView.Columns().Add(mw.ui.VersionTabVieConIndex)
	mw.ui.VersionTableView.Columns().Add(mw.ui.VersionTabVieConVer)
	mw.ui.VersionTableView.Columns().Add(mw.ui.VersionTabVieConPack)
	mw.ui.VersionTableView.Columns().Add(mw.ui.VersionTabVieConTag)
	mw.ui.VersionTableView.Columns().Add(mw.ui.VersionTabVieConTagPath)
	mw.ui.VersionTableView.Columns().Add(mw.ui.VersionTabVieConTime)

	// 历史版本记录数据
	mw.ui.VersionTableView.SetCheckBoxes(true)
	mw.ui.VersionTableView.SetModel(ConfVerModel)

	succeeded = true

	return nil
}