From f7e0c48bdb46d952034a544326c6c65bbbe83ccd Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 20 Dec 2022 07:42:40 +0100 Subject: [PATCH] 0.3.1 Started working on dialogs. /JL --- dialog.go | 26 ++++++++++++++++++++++++++ main.go | 2 +- properties.go | 8 ++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 dialog.go diff --git a/dialog.go b/dialog.go new file mode 100644 index 0000000..6501c05 --- /dev/null +++ b/dialog.go @@ -0,0 +1,26 @@ +package main + +import ( + "log" + + "github.com/lxn/walk" +) + +func (mw *MyMainWindow) openImage() error { + dlg := new(walk.FileDialog) + + dlg.FilePath = UserPath + dlg.Filter = "Image Files (*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff)|*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff" + dlg.Title = "选择图片" + + if ok, err := dlg.ShowOpen(mw.MainWindow); err != nil { + return err + } else if !ok { + return nil + } + + prevFilePath := dlg.FilePath + log.Println("prevFilePath:", prevFilePath) + + return nil +} diff --git a/main.go b/main.go index 0d1307e..7dc18ff 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ type MyMainWindow struct { const ( AppName string = "BeadImager" - Version string = "0.3.0" + Version string = "0.3.1" CopyRight string = "©2022 Jan Lerking" STD_MESS string = "Ready" LogFile string = "BeadImager.log" diff --git a/properties.go b/properties.go index f0fdc72..dc34d61 100644 --- a/properties.go +++ b/properties.go @@ -163,6 +163,10 @@ func CreateCanvasProperties(mw *MyMainWindow) { grcolb, _ := walk.NewPushButton(grcom) cb.SetAlignment(walk.AlignHFarVNear) grcolb.SetText("Grid color") + grcolb.Clicked().Attach(func() { + log.Println("Grid color button clicked") + mw.openImage() + }) log.Println("Grid color button created") log.Println("Creating pixels checkbox") cb, _ = walk.NewCheckBox(mw.properties.propCanvas.property) @@ -187,6 +191,10 @@ func CreateCanvasProperties(mw *MyMainWindow) { grcolb, _ = walk.NewPushButton(mw.properties.propCanvas.property) grcolb.SetAlignment(walk.AlignHFarVNear) grcolb.SetText("Background color") + grcolb.Clicked().Attach(func() { + log.Println("Background color button clicked") + mw.openImage() + }) log.Println("Background color button created") bg, _ := walk.NewSolidColorBrush(walk.RGB(255, 255, 255)) mw.properties.propCanvas.property.SetBackground(bg)