コード例 #1
1
ファイル: walkerGUI.go プロジェクト: IniZio/Go
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
}
コード例 #2
0
ファイル: walkerGUI.go プロジェクト: IniZio/Go
func (mw *MainWindow) drawStuff(canvas *walk.Canvas, updateBounds walk.Rectangle) error {
	bmp := createBitmap()
	defer bmp.Dispose()

	bounds := mw.paintWidget.ClientBounds()

	rectPen, _ := walk.NewCosmeticPen(walk.PenSolid, walk.RGB(255, 0, 0))
	defer rectPen.Dispose()

	canvas.DrawRectangle(rectPen, bounds)

	ellipseBrush, _ := walk.NewHatchBrush(walk.RGB(0, 255, 0), walk.HatchCross)
	defer ellipseBrush.Dispose()

	canvas.FillEllipse(ellipseBrush, bounds)

	linesBrush, _ := walk.NewSolidColorBrush(walk.RGB(0, 0, 255))
	defer linesBrush.Dispose()

	linesPen, _ := walk.NewGeometricPen(walk.PenDash, 8, linesBrush)
	defer linesPen.Dispose()

	canvas.DrawLine(linesPen, walk.Point{bounds.X, bounds.Y}, walk.Point{bounds.Width, bounds.Height})
	canvas.DrawLine(linesPen, walk.Point{bounds.X, bounds.Height}, walk.Point{bounds.Width, bounds.Y})

	bmpSize := bmp.Size()
	canvas.DrawImage(bmp, walk.Point{(bounds.Width - bmpSize.Width) / 2, (bounds.Height - bmpSize.Height) / 2})

	return nil
}
コード例 #3
0
ファイル: tableview.go プロジェクト: 2105666566/walk
func main() {
	rand.Seed(time.Now().UnixNano())

	model := NewFooModel()

	MainWindow{
		Title:  "Walk TableView Example",
		Size:   Size{800, 600},
		Layout: VBox{},
		Children: []Widget{
			PushButton{
				Text:      "Reset Rows",
				OnClicked: model.ResetRows,
			},
			TableView{
				AlternatingRowBGColor: walk.RGB(255, 255, 224),
				CheckBoxes:            true,
				ColumnsOrderable:      true,
				Columns: []TableViewColumn{
					{Title: "#"},
					{Title: "Bar"},
					{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
					{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
				},
				Model: model,
			},
		},
	}.Run()
}
コード例 #4
0
ファイル: settings.go プロジェクト: 2105666566/walk
func RunMainWindow() error {
	if _, err := (MainWindow{
		Name:    "mainWindow", // Name is needed for settings persistence
		Title:   "Walk Settings Example",
		MinSize: Size{800, 600},
		Layout:  VBox{},
		Children: []Widget{
			TableView{
				Name: "tableView", // Name is needed for settings persistence
				AlternatingRowBGColor: walk.RGB(255, 255, 200),
				ColumnsOrderable:      true,
				Columns: []TableViewColumn{
					{DataMember: "Index"},
					{DataMember: "Bar"},
					{DataMember: "Baz", Format: "%.2f", Alignment: AlignFar},
					{DataMember: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
				},
				Model: NewFooModel(),
			}},
	}.Run()); err != nil {
		return err
	}

	return nil
}
コード例 #5
0
ファイル: ae2vod.go プロジェクト: thesyncim/ae2vod
func main() {
	model := NewClipsModel()

	MainWindow{
		Title:  "VitecTV",
		Size:   Size{800, 600},
		Layout: VBox{},
		Children: []Widget{
			PushButton{
				Text:      "Actualizar Lista",
				OnClicked: model.ResetRows,
			},
			TableView{
				AlternatingRowBGColor: walk.RGB(255, 255, 224),
				CheckBoxes:            true,
				ColumnsOrderable:      true,
				Columns: []TableViewColumn{
					{Title: "ID"},
					{Title: "Titulo"},
					{Title: "Duração"},
					{Title: "Data", Format: "2006-01-02 15:04:05", Width: 150},
				},
				Model: model,
			},
			PushButton{
				Text:      "Converter",
				OnClicked: model.Select,
			},
			TextEdit{AssignTo: &model.output, ReadOnly: true},
		},
	}.Run()
}
コード例 #6
0
ファイル: main.go プロジェクト: CodyGuo/Go-Cody
func main() {
	var mw *walk.MainWindow
	var c1 *walk.Composite
	var c2 *walk.Composite

	bmp, err := walk.NewBitmapFromFile("../../img/plus.png")
	if err != nil {
		panic(err)
	}
	defer bmp.Dispose()

	MainWindow{
		AssignTo: &mw,
		Title:    "Background Example",
		Layout:   VBox{MarginsZero: true},
		MinSize:  Size{300, 400},
		Children: []Widget{
			Composite{
				AssignTo: &c1,
				Layout:   VBox{},
				Children: []Widget{
					TextEdit{},
				},
			},
			Composite{
				AssignTo: &c2,
				Layout:   VBox{},
				Children: []Widget{
					TextEdit{},
				},
			},
			ImageView{
				Image: bmp,
			},
		},
	}.Create()

	scb, err := walk.NewSolidColorBrush(walk.RGB(255, 0, 0))
	if err != nil {
		panic(err)
	}
	defer scb.Dispose()

	c1.SetBackground(scb)

	bmb, err := walk.NewBitmapBrush(bmp)
	if err != nil {
		panic(err)
	}
	defer bmb.Dispose()

	c2.SetBackground(bmb)

	mw.Show()
	mw.Run()
}
コード例 #7
0
ファイル: projectview.go プロジェクト: starmoonlove/packutil
/**
** 查看所有项目的方法
**/
func CreateProj_Query(owner walk.Form) {
	var dlg *walk.Dialog
	var tv *walk.TableView
	var dialog = Dialog{}
	model := xorm.NewProjectModel()

	dialog.AssignTo = &dlg
	dialog.Title = "项目管理"
	dialog.Layout = VBox{}
	dialog.MinSize = Size{650, 300}
	dialog.Children = []Widget{
		TableView{
			AssignTo:              &tv,
			AlternatingRowBGColor: walk.RGB(255, 255, 224),
			ColumnsOrderable:      true,
			Columns: []TableViewColumn{
				{Title: "编号", Width: 50},
				{Title: "名称"},
				{Title: "创建者"},
				{Title: "创建时间", Format: "2006-01-02 15:04:05", Width: 130},
				{Title: "描述", Width: 200},
			},
			Model: model,
		},
		Composite{
			Layout: HBox{},
			Children: []Widget{
				HSpacer{},
				PushButton{
					Text: "创建",
					OnClicked: func() {
						CreateProj_Triggered(owner, model)
					},
				},
				PushButton{
					Text: "删除",
					OnClicked: func() {
						indexs := tv.SelectedIndexes()
						if indexs.Len() == 0 {
							walk.MsgBox(owner, "提示", "请选择要删除的数据", walk.MsgBoxIconError)
							return
						}
						walk.MsgBox(owner, "提示", "确认是否删除此工程", walk.MsgBoxOKCancel)

						obj := model.GetItemByindex(int64(indexs.At(0)))
						xorm.DeleteProjectByObj(obj)
						model.ResetRows()
					},
				},
			},
		},
	}
	dialog.Run(owner)
}
コード例 #8
0
ファイル: main.go プロジェクト: CodyGuo/Go-Cody
func main() {
	mw := new(MyWindow)
	if err := (MainWindow{
		AssignTo: &mw.MainWindow,
		MinSize:  Size{800, 600},
		Layout:   HBox{},
		Children: []Widget{

			TabWidget{
				MinSize: Size{700, 500},
				Pages: []TabPage{
					TabPage{
						Title:   "测试1",
						MinSize: Size{500, 300},
						Layout:  HBox{},
						Children: []Widget{
							TableView{
								AlternatingRowBGColor: walk.RGB(255, 255, 224),
								CheckBoxes:            true,
								ColumnsOrderable:      true,
								Columns: []TableViewColumn{
									{Title: "#"},
									{Title: "Bar"},
									{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
									{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
								},
							},
						},
					},
					TabPage{
						Title:   "测试2",
						MinSize: Size{500, 300},
						Layout:  HBox{},
						Children: []Widget{
							Label{
								Text: "测试",
							},
							PushButton{
								Text: "提交",
							},
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		log.Fatal(err)
	}

	mw.Run()
}
コード例 #9
0
ファイル: xgrid.go プロジェクト: enderlu/vfp
func main() {
	defer SqlDisConnect(conn)
	_, ex := SqlExec(conn, `select * from dbo.product`, "product")
	Browse("product")
	if ex != nil {
		fmt.Println("can not load product:", ex)
		return
	}

	model := new(productModel)

	MainWindow{
		Title:  "VFP data and Walk table view Example",
		Size:   Size{800, 600},
		Layout: VBox{},
		Children: []Widget{
			PushButton{
				Text: "Reset Rows",
				OnClicked: func() {
					Usein("product")
					_, ex := SqlExec(conn, `select * from dbo.product`, "product")
					if ex != nil {
						fmt.Println("can not reload product:", ex)
						return
					}
					model.ResetRows()
				},
			},
			TableView{
				AlternatingRowBGColor: walk.RGB(255, 255, 224),
				CheckBoxes:            true,
				ReorderColumnsEnabled: true,
				Columns: []TableViewColumn{
					{Title: "产品编号"},
					{Title: "产品名称"},
					{Title: "产品价格", Format: "%.2f", Alignment: AlignFar},
					{Title: "类别"},
				},
				Model: model,
			},
		},
	}.Run()
}
コード例 #10
0
ファイル: tableview.go プロジェクト: Ryanker/walk
func main() {
	rand.Seed(time.Now().UnixNano())

	model := NewFooModel()

	var tv *walk.TableView

	MainWindow{
		Title:  "Walk TableView Example",
		Size:   Size{800, 600},
		Layout: VBox{MarginsZero: true},
		Children: []Widget{
			PushButton{
				Text:      "Reset Rows",
				OnClicked: model.ResetRows,
			},
			PushButton{
				Text: "Select first 5 even Rows",
				OnClicked: func() {
					tv.SetSelectedIndexes([]int{0, 2, 4, 6, 8})
				},
			},
			TableView{
				AssignTo:              &tv,
				AlternatingRowBGColor: walk.RGB(255, 255, 224),
				CheckBoxes:            true,
				ColumnsOrderable:      true,
				MultiSelection:        true,
				Columns: []TableViewColumn{
					{Title: "#"},
					{Title: "Bar"},
					{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
					{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
				},
				Model: model,
				OnSelectedIndexesChanged: func() {
					fmt.Printf("SelectedIndexes: %v\n", tv.SelectedIndexes())
				},
			},
		},
	}.Run()
}
コード例 #11
0
ファイル: tableview.go プロジェクト: etel/walk
func main() {
	walk.Initialize(walk.InitParams{PanicOnError: true})
	defer walk.Shutdown()

	rand.Seed(time.Now().UnixNano())

	mainWnd, _ := walk.NewMainWindow()

	mw := &MainWindow{
		MainWindow: mainWnd,
		model:      NewFooModel(),
	}

	mw.SetLayout(walk.NewVBoxLayout())
	mw.SetTitle("Walk TableView Example")

	resetRowsButton, _ := walk.NewPushButton(mw)
	resetRowsButton.SetText("Reset Rows")

	resetRowsButton.Clicked().Attach(func() {
		// Get some fresh data.
		mw.model.ResetRows()
	})

	tableView, _ := walk.NewTableView(mw)

	tableView.SetAlternatingRowBGColor(walk.RGB(255, 255, 224))
	tableView.SetReorderColumnsEnabled(true)

	// Everybody loves check boxes.
	tableView.SetCheckBoxes(true)

	// Don't forget to set the model.
	tableView.SetModel(mw.model)

	mw.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
	mw.SetSize(walk.Size{800, 600})
	mw.Show()

	mw.Run()
}
コード例 #12
0
ファイル: externalwidgets.go プロジェクト: richardjoo/walk
func NewMyWidget(parent walk.Container) (*MyWidget, error) {
	w := new(MyWidget)

	if err := walk.InitChildWidget(
		w,
		parent,
		myWidgetWindowClass,
		winapi.WS_VISIBLE,
		0); err != nil {

		return nil, err
	}

	bg, err := walk.NewSolidColorBrush(walk.RGB(0, 255, 0))
	if err != nil {
		return nil, err
	}
	w.SetBackground(bg)

	return w, nil
}
コード例 #13
0
ファイル: main.go プロジェクト: ZhuBicen/EnvSetting
func main() {
	font := Font{
		Family:    "Times New Roman",
		PointSize: 13,
		Bold:      true,
	}
	usr, _ := user.Current()
	usrModel := env.NewModel(0)
	sysModel := env.NewModel(1)
	var usrTableView, sysTableView *walk.TableView
	var mw *walk.MainWindow
	MainWindow{
		Title:    "Enviroment Variable",
		Size:     Size{600, 700},
		Layout:   VBox{},
		AssignTo: &mw,
		Font:     font,
		Children: []Widget{
			VSplitter{
				Children: []Widget{
					GroupBox{
						Title:  "User variables for " + usr.Username,
						Font:   font,
						Layout: VBox{},
						Children: []Widget{
							TableView{
								AssignTo:              &usrTableView,
								AlternatingRowBGColor: walk.RGB(255, 255, 224),
								ColumnsOrderable:      true,
								Columns: []TableViewColumn{
									{Title: "name", Width: 200},
									{Title: "value"},
								},
								LastColumnStretched: true,
								Model:               usrModel,
								OnItemActivated: func() {
									index := usrTableView.CurrentIndex()
									if index != -1 {
										EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
									}
								},
							},
							Composite{
								Layout: HBox{},
								Children: []Widget{
									HSpacer{},
									PushButton{
										Text: "New...",
										OnClicked: func() {
											NewVariable(mw, usrModel)
										},
									},
									PushButton{
										Text: "Edit...",
										OnClicked: func() {
											index := usrTableView.CurrentIndex()
											if index != -1 {
												EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
											}
										},
									},
									PushButton{
										Text: "Delete",
										OnClicked: func() {
											index := usrTableView.CurrentIndex()
											if index != -1 {
												DeleteVariable(mw, usrModel, usrModel.GetVariable(index).Name)
											}
										},
									},
								},
							},
						},
					},
					GroupBox{
						Title:  "System variables",
						Font:   font,
						Layout: VBox{},
						Children: []Widget{
							TableView{
								AssignTo:              &sysTableView,
								AlternatingRowBGColor: walk.RGB(255, 255, 224),
								ColumnsOrderable:      true,
								Columns: []TableViewColumn{
									{Title: "Variable", Width: 200},
									{Title: "Value"},
								},
								LastColumnStretched: true,
								Model:               sysModel,
								OnItemActivated: func() {
									index := sysTableView.CurrentIndex()
									if index != -1 {
										EditVariable(mw, sysModel, sysModel.GetVariable(index).Name, sysModel.GetVariable(index).Value)
									}
								},
							},
							Composite{
								Layout: HBox{},
								Children: []Widget{
									HSpacer{},
									PushButton{
										Text: "New...",
										OnClicked: func() {
											NewVariable(mw, sysModel)
										},
									},
									PushButton{
										Text: "Edit...",
										OnClicked: func() {
											index := sysTableView.CurrentIndex()
											if index != -1 {
												EditVariable(mw, sysModel, sysModel.GetVariable(index).Name, sysModel.GetVariable(index).Value)
											}
										},
									},
									PushButton{
										Text: "Delete",
										OnClicked: func() {
											index := sysTableView.CurrentIndex()
											if index != -1 {
												DeleteVariable(mw, sysModel, sysModel.GetVariable(index).Name)
											}
										},
									},
								},
							},
						},
					},
				},
			},
			Composite{
				Layout: HBox{},
				Children: []Widget{
					HSpacer{},
					PushButton{
						Text: "OK",
						OnClicked: func() {
							if ApplyEnv(mw, usrModel, sysModel) {
								mw.Close()
							}
						},
					},
					PushButton{
						Text: "Cancel",
						OnClicked: func() {
							mw.Close()
						},
					},
				},
			},
		},
	}.Run()

}
コード例 #14
0
ファイル: server.go プロジェクト: Huangyan9188/pholcus
func serverWindow() {
	mw.Close()

	if err := (MainWindow{
		AssignTo: &mw,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   config.APP_NAME + "                                                          【 运行模式 -> 服务器 】",
		MinSize: Size{1100, 700},
		Layout:  VBox{ /*MarginsZero: true*/ },
		Children: []Widget{

			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 2},
				Children: []Widget{
					// 任务列表
					TableView{
						ColumnSpan:            1,
						MinSize:               Size{550, 350},
						AlternatingRowBGColor: walk.RGB(255, 255, 224),
						CheckBoxes:            true,
						ColumnsOrderable:      true,
						Columns: []TableViewColumn{
							{Title: "#", Width: 45},
							{Title: "任务", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
							{Title: "描述", Width: 370},
						},
						Model: spiderMenu,
					},

					VSplitter{
						ColumnSpan: 1,
						MinSize:    Size{550, 0},
						Children: []Widget{

							VSplitter{
								Children: []Widget{
									Label{
										Text: "自定义输入:(多任务之间以 | 隔开,选填)",
									},
									LineEdit{
										Text: Bind("Keywords"),
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*并发协程:(1~99999)",
									},
									NumberEdit{
										Value:    Bind("ThreadNum", Range{1, 99999}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "采集页数:(选填)",
									},
									NumberEdit{
										Value:    Bind("MaxPage"),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*分批输出大小:(1~5,000,000 条数据)",
									},
									NumberEdit{
										Value:    Bind("DockerCap", Range{1, 5000000}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*间隔基准:",
									},
									ComboBox{
										Value:         Bind("BaseSleeptime", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GuiOpt.SleepTime,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*随机延迟:",
									},
									ComboBox{
										Value:         Bind("RandomSleepPeriod", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GuiOpt.SleepTime,
									},
								},
							},

							RadioButtonGroupBox{
								ColumnSpan: 1,
								Title:      "*输出方式",
								Layout:     HBox{},
								DataMember: "OutType",
								Buttons: []RadioButton{
									{Text: GuiOpt.OutType[0].Key, Value: GuiOpt.OutType[0].String},
									{Text: GuiOpt.OutType[1].Key, Value: GuiOpt.OutType[1].String},
									{Text: GuiOpt.OutType[2].Key, Value: GuiOpt.OutType[2].String},
								},
							},
						},
					},
				},
			},

			Composite{
				Layout: HBox{},
				Children: []Widget{

					// 必填项错误检查
					LineErrorPresenter{
						AssignTo: &ep,
					},

					PushButton{
						MinSize:   Size{90, 0},
						Text:      serverBtnTxt(),
						AssignTo:  &toggleRunBtn,
						OnClicked: serverStart,
					},
				},
			},
		},
	}.Create()); err != nil {
		log.Fatal(err)
	}

	// 绑定log输出界面
	lv, err := NewLogView(mw)
	if err != nil {
		log.Fatal(err)
	}
	log.SetOutput(lv)

	if icon, err := walk.NewIconFromResource("ICON"); err == nil {
		mw.SetIcon(icon)
	}

	// 开启报告
	reporter.Log.Run()

	// 运行pholcus核心
	PholcusRun()

	// 运行窗体程序
	mw.Run()
}
コード例 #15
0
ファイル: server.go プロジェクト: ZenithDandelion/pholcus
func serverWindow() {
	mw.Close()

	if err := (MainWindow{
		AssignTo: &mw,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   config.FULL_NAME + "                                                          【 运行模式 -> 服务器 】",
		MinSize: Size{1100, 700},
		Layout:  VBox{MarginsZero: true},
		Children: []Widget{

			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 2},
				Children: []Widget{
					// 任务列表
					TableView{
						ColumnSpan:            1,
						MinSize:               Size{550, 450},
						AlternatingRowBGColor: walk.RGB(255, 255, 224),
						CheckBoxes:            true,
						ColumnsOrderable:      true,
						Columns: []TableViewColumn{
							{Title: "#", Width: 45},
							{Title: "任务", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
							{Title: "描述", Width: 370},
						},
						Model: spiderMenu,
					},

					VSplitter{
						ColumnSpan: 1,
						MinSize:    Size{550, 450},
						Children: []Widget{

							VSplitter{
								Children: []Widget{
									Label{
										Text: "自定义配置(多任务请分别多包一层“<>”)",
									},
									LineEdit{
										Text: Bind("Keyins"),
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*采集上限(默认限制URL数):",
									},
									NumberEdit{
										Value:    Bind("Limit"),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*并发协程:(1~99999)",
									},
									NumberEdit{
										Value:    Bind("ThreadNum", Range{1, 99999}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*分批输出大小:(1~5,000,000 条数据)",
									},
									NumberEdit{
										Value:    Bind("DockerCap", Range{1, 5000000}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*暂停时长参考:",
									},
									ComboBox{
										Value:         Bind("Pausetime", SelRequired{}),
										DisplayMember: "Key",
										BindingMember: "Int64",
										Model:         GuiOpt.Pausetime,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*代理IP更换频率:",
									},
									ComboBox{
										Value:         Bind("ProxyMinute", SelRequired{}),
										DisplayMember: "Key",
										BindingMember: "Int64",
										Model:         GuiOpt.ProxyMinute,
									},
								},
							},

							RadioButtonGroupBox{
								ColumnSpan: 1,
								Title:      "*输出方式",
								Layout:     HBox{},
								DataMember: "OutType",
								Buttons:    outputList,
							},
						},
					},
				},
			},

			Composite{
				Layout: HBox{},
				Children: []Widget{

					// 必填项错误检查
					LineErrorPresenter{
						AssignTo: &ep,
					},

					HSplitter{
						MaxSize: Size{220, 50},
						Children: []Widget{
							Label{
								Text: "继承并保存成功记录",
							},
							CheckBox{
								Checked: Bind("SuccessInherit"),
							},
						},
					},

					HSplitter{
						MaxSize: Size{220, 50},
						Children: []Widget{
							Label{
								Text: "继承并保存失败记录",
							},
							CheckBox{
								Checked: Bind("FailureInherit"),
							},
						},
					},

					PushButton{
						MinSize:   Size{90, 0},
						Text:      serverBtnTxt(),
						AssignTo:  &runStopBtn,
						OnClicked: serverStart,
					},
				},
			},
		},
	}.Create()); err != nil {
		panic(err)
	}

	setWindow()

	// 初始化应用
	Init()

	// 运行窗体程序
	mw.Run()
}
コード例 #16
0
ファイル: drawing.go プロジェクト: Ryanker/walk
func (mw *MyMainWindow) drawStuff(canvas *walk.Canvas, updateBounds walk.Rectangle) error {
	bmp, err := createBitmap()
	if err != nil {
		return err
	}
	defer bmp.Dispose()

	bounds := mw.paintWidget.ClientBounds()

	rectPen, err := walk.NewCosmeticPen(walk.PenSolid, walk.RGB(255, 0, 0))
	if err != nil {
		return err
	}
	defer rectPen.Dispose()

	if err := canvas.DrawRectangle(rectPen, bounds); err != nil {
		return err
	}

	ellipseBrush, err := walk.NewHatchBrush(walk.RGB(0, 255, 0), walk.HatchCross)
	if err != nil {
		return err
	}
	defer ellipseBrush.Dispose()

	if err := canvas.FillEllipse(ellipseBrush, bounds); err != nil {
		return err
	}

	linesBrush, err := walk.NewSolidColorBrush(walk.RGB(0, 0, 255))
	if err != nil {
		return err
	}
	defer linesBrush.Dispose()

	linesPen, err := walk.NewGeometricPen(walk.PenDash, 8, linesBrush)
	if err != nil {
		return err
	}
	defer linesPen.Dispose()

	if err := canvas.DrawLine(linesPen, walk.Point{bounds.X, bounds.Y}, walk.Point{bounds.Width, bounds.Height}); err != nil {
		return err
	}
	if err := canvas.DrawLine(linesPen, walk.Point{bounds.X, bounds.Height}, walk.Point{bounds.Width, bounds.Y}); err != nil {
		return err
	}

	points := make([]walk.Point, 10)
	dx := bounds.Width / (len(points) - 1)
	for i := range points {
		points[i].X = i * dx
		points[i].Y = int(float64(bounds.Height) / math.Pow(float64(bounds.Width/2), 2) * math.Pow(float64(i*dx-bounds.Width/2), 2))
	}
	if err := canvas.DrawPolyline(linesPen, points); err != nil {
		return err
	}

	bmpSize := bmp.Size()
	if err := canvas.DrawImage(bmp, walk.Point{(bounds.Width - bmpSize.Width) / 2, (bounds.Height - bmpSize.Height) / 2}); err != nil {
		return err
	}

	return nil
}
コード例 #17
0
ファイル: table.go プロジェクト: sunclx/walk
func main() {
	model := NewFooModel("img")
	foo := &TableViewColumnFormat{Title: "创建时间", Format: "2006-01-02", Width: 150}
	var tv *walk.TableView
	MainWindow{
		Title:  "TableView",
		Size:   Size{800, 600},
		Layout: VBox{},
		DataBinder: DataBinder{
			DataSource: foo,
			AutoSubmit: true,
			OnSubmitted: func() {
				fmt.Println(foo)
			},
		},
		Children: []Widget{
			Composite{
				Layout: HBox{},
				Children: []Widget{
					RadioButtonGroup{
						DataMember: "Alignment",
						Buttons: []RadioButton{
							RadioButton{
								Name:  "leftAlign",
								Text:  "左对齐",
								Value: AlignFar,
								OnClicked: func() {
									tv.Columns().Add(walk.NewTableViewColumn())
									model.PublishRowsReset()
								},
							},
							RadioButton{
								Name:  "leftAlign",
								Text:  "居中",
								Value: AlignCenter,
								OnClicked: func() {
									tv.Columns().At(4).SetAlignment(walk.AlignCenter)
									model.PublishRowsReset()
								},
							},
							RadioButton{
								Name:  "leftAlign",
								Text:  "右对齐",
								Value: AlignNear,
								OnClicked: func() {
									tv.Columns().At(4).SetAlignment(walk.AlignFar)
									//tv.Columns().Clear()
									model.PublishRowsReset()
								},
							},
						},
					},
				},
			},

			TableView{
				AssignTo:              &tv,
				AlternatingRowBGColor: walk.RGB(183, 208, 65),
				CheckBoxes:            true,
				ColumnsOrderable:      true,
				Columns: []TableViewColumn{
					{Title: "#"},
					{Title: "原文件名"},
					{Title: "类型"},
					{Title: "新文件名"},
					{Title: "创建时间", Format: "2006-01-02 15:04:05", Width: 150, Alignment: foo.Alignment, DataMember: "", Hidden: false, Precision: 2},
					{Title: "修改时间", Format: "2006-01-02 15:04:05", Width: 150, DataMember: "", Alignment: foo.Alignment},
				},
				Model: model,
			},
		},
	}.Run()
}
コード例 #18
0
ファイル: offline.go プロジェクト: jununfly/pholcus
func offlineWindow() {
	mw.Close()

	if err := (MainWindow{
		AssignTo: &mw,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   config.APP_FULL_NAME + "                                                          【 运行模式 ->  单机 】",
		MinSize: Size{1100, 700},
		Layout:  VBox{MarginsZero: true},
		Children: []Widget{

			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 2},
				Children: []Widget{
					// 任务列表
					TableView{
						ColumnSpan:            1,
						MinSize:               Size{550, 450},
						AlternatingRowBGColor: walk.RGB(255, 255, 224),
						CheckBoxes:            true,
						ColumnsOrderable:      true,
						Columns: []TableViewColumn{
							{Title: "#", Width: 45},
							{Title: "任务", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
							{Title: "描述", Width: 370},
						},
						Model: spiderMenu,
					},

					VSplitter{
						ColumnSpan: 1,
						MinSize:    Size{550, 450},
						Children: []Widget{

							VSplitter{
								Children: []Widget{
									Label{
										Text: "自定义输入:(多任务之间以 | 隔开,选填)",
									},
									LineEdit{
										Text: Bind("Keywords"),
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*并发协程:(1~99999)",
									},
									NumberEdit{
										Value:    Bind("ThreadNum", Range{1, 99999}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "最大采集页数:(选填)",
									},
									NumberEdit{
										Value:    Bind("MaxPage"),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*分批输出大小:(1~5,000,000 条数据)",
									},
									NumberEdit{
										Value:    Bind("DockerCap", Range{1, 5000000}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*间隔基准:",
									},
									ComboBox{
										Value:         Bind("BaseSleeptime", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GuiOpt.SleepTime,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*随机延迟:",
									},
									ComboBox{
										Value:         Bind("RandomSleepPeriod", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GuiOpt.SleepTime,
									},
								},
							},

							RadioButtonGroupBox{
								ColumnSpan: 1,
								Title:      "*输出方式",
								Layout:     HBox{},
								DataMember: "OutType",
								Buttons:    outputList,
							},
						},
					},
				},
			},

			Composite{
				Layout: HBox{},
				Children: []Widget{
					VSplitter{
						Children: []Widget{
							// 必填项错误检查
							LineErrorPresenter{
								AssignTo: &ep,
							},
						},
					},

					HSplitter{
						MaxSize: Size{150, 50},
						Children: []Widget{
							Label{
								Text: "继承历史去重样本",
							},
							CheckBox{
								Checked: Bind("InheritDeduplication"),
							},
						},
					},

					VSplitter{
						MaxSize: Size{90, 50},
						Children: []Widget{
							PushButton{
								Text:      "暂停/恢复",
								AssignTo:  &pauseRecoverBtn,
								OnClicked: offlinePauseRecover,
							},
						},
					},
					VSplitter{
						MaxSize: Size{90, 50},
						Children: []Widget{
							PushButton{
								Text:      "开始运行",
								AssignTo:  &runStopBtn,
								OnClicked: offlineRunStop,
							},
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		panic(err)
	}

	setWindow()

	pauseRecoverBtn.SetVisible(false)

	// 初始化应用
	Init()

	// 运行窗体程序
	mw.Run()
}
コード例 #19
0
ファイル: main.go プロジェクト: CodyGuo/Go-Cody
func main() {
	skinh.Attach()

	Input := new(Model)
	mw := new(MyMainWindow)

	date, _ := time.Parse("2006-02-03 03:04:05", "2016-01-01 08:08:08")

	if err := (MainWindow{
		AssignTo: &mw.MainWindow,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   "iMan - 测试程序",
		MinSize: Size{1100, 700},
		Layout:  VBox{},
		Children: []Widget{
			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 1},
				Children: []Widget{
					RadioButtonGroupBox{
						AssignTo:   &radioBtnGpBox,
						Title:      "注册模式",
						MinSize:    Size{0, 30},
						Layout:     HBox{},
						DataMember: "Int",
						Buttons: []RadioButton{
							{Text: iMode.RunMode[0].Key, Value: iMode.RunMode[0].Int},
							{Text: iMode.RunMode[1].Key, Value: iMode.RunMode[1].Int},
							{Text: iMode.RunMode[2].Key, Value: iMode.RunMode[2].Int},
						},
					},
				},
			},
			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 2},
				Children: []Widget{
					CheckBox{
						AssignTo:   &cBox1,
						Text:       "盒子",
						CheckState: walk.CheckUnchecked,
						Tristate:   true,
						OnClicked: func() {
							fmt.Println(cBox1.CheckState())
							if cBox1.CheckState() == 0 {
								mw.openAddd_Triggered("您关闭了盒子.")
							} else if cBox1.CheckState() == 1 {
								mw.openAddd_Triggered("您打开了盒子.")
							} else {
								mw.openAddd_Triggered("您的盒子是未知状态.")
							}
						},
						OnCheckedChanged: func() {
							mw.openAddd_Triggered("您修改了盒子的状态.")
						},
						OnCheckStateChanged: func() {
							mw.openAddd_Triggered("您的盒子状态被改变了...")
						},
						// CheckState: false,
					},

					DateEdit{
						AssignTo: &de1,
						// Format:   "Y-M-d H:m:s",
						Format:     "yyyy-MM-dd H:mm:ss",
						NoneOption: true,
						MinDate:    time.Now(),
						MaxDate:    time.Now().AddDate(1, 0, 0),
						Date:       date,
					},
					PushButton{
						AssignTo: &addIpBtn,
						Text:     "添加",
						OnClicked: func() {
							ok := mw.addAction_ServerIp()
							if ok == 0 {
								fmt.Println("添加服务器", "添加"+iplist.Ip+"成功.")
							}

							iplist.Ip = ""
							iplist.Remark = ""
						},
					},

					TableView{
						MinSize:                    Size{200, 100},
						MaxSize:                    Size{550, 450},
						AlternatingRowBGColor:      walk.RGB(255, 255, 224),
						CheckBoxes:                 true,
						ItemStateChangedEventDelay: 1,
						ColumnsOrderable:           false,
						ColumnsSizable:             false,
						SingleItemSelection:        false, // 单选
						LastColumnStretched:        false, // 显示最后一列
						Columns: []TableViewColumn{
							{Title: "序号"},
							{Title: "IP"},
							{Title: "备注"},
							{Title: "添加时间", Format: "2006-01-02 15:04:05", Width: 150},
						},

						Model: &model,
					},

					PushButton{
						AssignTo: &addIpBtn,
						Text:     "提交",
						MinSize:  Size{60, 80},
						MaxSize:  Size{100, 80},

						ToolTipText: "提示信息,请填写数字",
						OnClicked: func() {

							fmt.Println("-----ok----------")
							InputIp.ServerLists = model.GetChecked()
							var tmpListIp []string
							if len(InputIp.ServerLists) > 0 {
								fmt.Println("--------------------选中了哪个-----------")
								// fmt.Print(InputIp.ServerLists[0].Ip)
								for index, _ := range InputIp.ServerLists {
									tmpListIp = append(tmpListIp, InputIp.ServerLists[index].Ip)
									// if len(InputIp.ServerLists) == 1 {
									//     tmpListIp = InputIp.ServerLists[index].Ip
									// } else if len(InputIp.ServerLists) == 2 {
									//     tmpListIp = tmpListIp + " , " + InputIp.ServerLists[index].Ip
									// } else {
									//     tmpListIp = tmpListIp + " , " + InputIp.ServerLists[index].Ip
									// }

								}
								fmt.Println(tmpListIp)
								mw.openAddd_Triggered(strings.Join(tmpListIp, ", "))
							}
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		// log.Fatal(err)
		fmt.Println("错误来了:", err)
		log.Println(err)
	}

	// addIpBtn.SetMinMaxSize(walk.Size{30, 50}, walk.Size{50, 60})
	// mw.SetPersistent(true)
	mw.Run()
}
コード例 #20
0
ファイル: guimain.go プロジェクト: zydudu/pholcus
func Run() {
	var mw *walk.MainWindow
	var db *walk.DataBinder
	var ep walk.ErrorPresenter
	var spiderMenu = NewSpiderMenu(spider.Menu)

	if err := (MainWindow{
		AssignTo: &mw,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   config.APP_NAME,
		MinSize: Size{1100, 700},
		Layout:  VBox{},
		Children: []Widget{
			// 任务列表
			HSplitter{
				Children: []Widget{
					TableView{
						MinSize:               Size{550, 400},
						AlternatingRowBGColor: walk.RGB(255, 255, 224),
						CheckBoxes:            true,
						ColumnsOrderable:      true,
						Columns: []TableViewColumn{
							{Title: "#", Width: 45},
							{Title: "任务", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
							{Title: "描述", Width: 370},
						},
						Model: spiderMenu,
					},
					// 关键词
					VSplitter{
						MinSize: Size{550, 400},

						Children: []Widget{
							VSplitter{
								Children: []Widget{
									Label{
										Text: "关键词:(多任务之间以 | 隔开,选填)",
									},
									LineEdit{
										Text: Bind("Keywords"),
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "采集页数:(选填)",
									},
									NumberEdit{
										Value:    Bind("MaxPage"),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*并发协程:(1~99999)",
									},
									NumberEdit{
										Value:    Bind("ThreadNum", Range{1, 99999}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*分批输出大小:(1~5,000,000 条数据)",
									},
									NumberEdit{
										Value:    Bind("DockerCap", Range{1, 5000000}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*间隔基准:",
									},
									ComboBox{
										Value:         Bind("BaseSleeptime", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GUIOpt.SleepTime,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*随机延迟:",
									},
									ComboBox{
										Value:         Bind("RandomSleepPeriod", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GUIOpt.SleepTime,
									},
								},
							},

							RadioButtonGroupBox{
								ColumnSpan: 2,
								Title:      "*输出方式",
								Layout:     HBox{},
								DataMember: "OutType",
								Buttons: []RadioButton{
									{Text: GUIOpt.OutType[0].Key, Value: GUIOpt.OutType[0].String},
									{Text: GUIOpt.OutType[1].Key, Value: GUIOpt.OutType[1].String},
									{Text: GUIOpt.OutType[2].Key, Value: GUIOpt.OutType[2].String},
								},
							},
						},
					},
				},
			},

			Composite{
				Layout: HBox{},
				Children: []Widget{

					// 必填项错误检查
					LineErrorPresenter{
						AssignTo:   &ep,
						ColumnSpan: 2,
					},

					PushButton{
						Text:     "开始抓取",
						AssignTo: &toggleSpecialModePB,
						OnClicked: func() {
							if toggleSpecialModePB.Text() == "取消" {
								toggleSpecialModePB.SetEnabled(false)
								toggleSpecialModePB.SetText("取消中…")
								Stop()
							} else {
								if err := db.Submit(); err != nil {
									log.Print(err)
									return
								}
								Input.Spiders = spiderMenu.GetChecked()
								if len(Input.Spiders) == 0 {
									return
								}
								toggleSpecialModePB.SetText("取消")
								Start()
							}
						},
					},
				},
			},
		},
	}.Create()); err != nil {
		log.Fatal(err)
	}

	// 绑定log输出界面
	lv, err := NewLogView(mw)
	if err != nil {
		log.Fatal(err)
	}
	log.SetOutput(lv)

	if icon, err := walk.NewIconFromResource("ICON"); err == nil {
		mw.SetIcon(icon)
	}

	// 运行窗体程序
	mw.Run()
}
コード例 #21
0
ファイル: client.go プロジェクト: EMail2HF/pholcus
func clientWindow() {
	mw.Close()
	if err := (MainWindow{
		AssignTo: &mw,
		DataBinder: DataBinder{
			AssignTo:       &db,
			DataSource:     Input,
			ErrorPresenter: ErrorPresenterRef{&ep},
		},
		Title:   config.APP_NAME + "                                                          【 运行模式 -> 客户端 】",
		MinSize: Size{1100, 700},
		Layout:  VBox{MarginsZero: true},
		Children: []Widget{

			Composite{
				AssignTo: &setting,
				Layout:   Grid{Columns: 2},
				Children: []Widget{
					// 任务列表
					TableView{
						ColumnSpan:            1,
						MinSize:               Size{550, 450},
						AlternatingRowBGColor: walk.RGB(255, 255, 224),
						CheckBoxes:            true,
						ColumnsOrderable:      true,
						Columns: []TableViewColumn{
							{Title: "#", Width: 45},
							{Title: "任务", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
							{Title: "描述", Width: 370},
						},
						Model: spiderMenu,
					},

					VSplitter{
						ColumnSpan: 1,
						MinSize:    Size{550, 450},
						Children: []Widget{

							VSplitter{
								Children: []Widget{
									Label{
										Text: "自定义输入:(多任务之间以 | 隔开,选填)",
									},
									LineEdit{
										Text: Bind("Keywords"),
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*并发协程:(1~99999)",
									},
									NumberEdit{
										Value:    Bind("ThreadNum", Range{1, 99999}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "采集页数:(选填)",
									},
									NumberEdit{
										Value:    Bind("MaxPage"),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*分批输出大小:(1~5,000,000 条数据)",
									},
									NumberEdit{
										Value:    Bind("DockerCap", Range{1, 5000000}),
										Suffix:   "",
										Decimals: 0,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*间隔基准:",
									},
									ComboBox{
										Value:         Bind("BaseSleeptime", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GuiOpt.SleepTime,
									},
								},
							},

							VSplitter{
								Children: []Widget{
									Label{
										Text: "*随机延迟:",
									},
									ComboBox{
										Value:         Bind("RandomSleepPeriod", SelRequired{}),
										BindingMember: "Uint",
										DisplayMember: "Key",
										Model:         GuiOpt.SleepTime,
									},
								},
							},

							RadioButtonGroupBox{
								ColumnSpan: 1,
								Title:      "*输出方式",
								Layout:     HBox{},
								DataMember: "OutType",
								Buttons: []RadioButton{
									{Text: GuiOpt.OutType[0].Key, Value: GuiOpt.OutType[0].String},
									{Text: GuiOpt.OutType[1].Key, Value: GuiOpt.OutType[1].String},
									{Text: GuiOpt.OutType[2].Key, Value: GuiOpt.OutType[2].String},
									{Text: GuiOpt.OutType[3].Key, Value: GuiOpt.OutType[3].String},
								},
							},
						},
					},
				},
			},

			Composite{
				Layout: HBox{},
				Children: []Widget{

					// 必填项错误检查
					LineErrorPresenter{
						AssignTo: &ep,
					},

					PushButton{
						MinSize:  Size{110, 0},
						Text:     "断开服务器连接",
						AssignTo: &runStopBtn,
					},
				},
			},
		},
	}.Create()); err != nil {
		log.Fatal(err)
	}

	setWindow()

	// 禁用配置
	setting.SetEnabled(false)
	runStopBtn.SetEnabled(false)
	// 配置运行模式
	WTaskConf1()
	// 记录配置信息
	WTaskConf2()

	// 执行任务
	go LogicApp.Run()

	// 运行窗体程序
	mw.Run()
}