0.3.0 Saving config on changes. /JL
This commit is contained in:
@@ -12,6 +12,27 @@ var (
|
|||||||
ConfigFile string = "BeadImager.conf"
|
ConfigFile string = "BeadImager.conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func SetConfigShowBeads(s string) {
|
||||||
|
log.Printf("Setting showbeads to: %s\n", s)
|
||||||
|
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
|
Config.Set("canvas", "showbeads", s)
|
||||||
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetConfigShowGrid(s string) {
|
||||||
|
log.Printf("Setting showgrid to: %s\n", s)
|
||||||
|
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
|
Config.Set("canvas", "showgrid", s)
|
||||||
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetConfigScale(s string) {
|
||||||
|
log.Printf("Setting scale to: %s\n", s)
|
||||||
|
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
|
Config.Set("canvas", "scale", s)
|
||||||
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
|
}
|
||||||
|
|
||||||
func ReadConfig() {
|
func ReadConfig() {
|
||||||
log.Printf("Reading config file: %s\n", ConfigFile)
|
log.Printf("Reading config file: %s\n", ConfigFile)
|
||||||
Config, _ = configparser.Parse(UserPath + Sep + ConfigFile)
|
Config, _ = configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
@@ -49,10 +70,3 @@ func CreateDefaultConfig() {
|
|||||||
Config.Set("canvas", "backgroundcolor", "#ffffff")
|
Config.Set("canvas", "backgroundcolor", "#ffffff")
|
||||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetConfigScale(s string) {
|
|
||||||
log.Printf("Setting scale to: %s\n", s)
|
|
||||||
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
|
||||||
Config.Set("canvas", "scale", s)
|
|
||||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type MyMainWindow struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AppName string = "BeadImager"
|
AppName string = "BeadImager"
|
||||||
Version string = "0.2.5"
|
Version string = "0.3.0"
|
||||||
CopyRight string = "©2022 Jan Lerking"
|
CopyRight string = "©2022 Jan Lerking"
|
||||||
STD_MESS string = "Ready"
|
STD_MESS string = "Ready"
|
||||||
LogFile string = "BeadImager.log"
|
LogFile string = "BeadImager.log"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ func CreateScaleProperties(mw *MyMainWindow) {
|
|||||||
nn := float64(slider.Value())
|
nn := float64(slider.Value())
|
||||||
log.Println("Setting scale number edit value to: ", nn)
|
log.Println("Setting scale number edit value to: ", nn)
|
||||||
sc.SetValue(nn)
|
sc.SetValue(nn)
|
||||||
|
SetConfigScale(fmt.Sprintf("%0.0f", nn))
|
||||||
})
|
})
|
||||||
sc.SetDecimals(0)
|
sc.SetDecimals(0)
|
||||||
sc.SetRange(10, 200)
|
sc.SetRange(10, 200)
|
||||||
@@ -114,6 +116,7 @@ func CreateScaleProperties(mw *MyMainWindow) {
|
|||||||
nn := float64(sc.Value())
|
nn := float64(sc.Value())
|
||||||
log.Println("Setting scale slider value to: ", nn)
|
log.Println("Setting scale slider value to: ", nn)
|
||||||
slider.SetValue(int(nn))
|
slider.SetValue(int(nn))
|
||||||
|
SetConfigScale(fmt.Sprintf("%0.0f", nn))
|
||||||
})
|
})
|
||||||
log.Println("Setting background color...")
|
log.Println("Setting background color...")
|
||||||
bg, _ := walk.NewSolidColorBrush(walk.RGB(255, 255, 255))
|
bg, _ := walk.NewSolidColorBrush(walk.RGB(255, 255, 255))
|
||||||
@@ -146,6 +149,14 @@ func CreateCanvasProperties(mw *MyMainWindow) {
|
|||||||
case "false":
|
case "false":
|
||||||
cb.SetChecked(false)
|
cb.SetChecked(false)
|
||||||
}
|
}
|
||||||
|
cb.CheckedChanged().Attach(func() {
|
||||||
|
log.Println("Grid checkbox changed")
|
||||||
|
if cb.Checked() {
|
||||||
|
SetConfigShowGrid("false")
|
||||||
|
} else {
|
||||||
|
SetConfigShowGrid("true")
|
||||||
|
}
|
||||||
|
})
|
||||||
log.Println("Grid checkbox created")
|
log.Println("Grid checkbox created")
|
||||||
walk.NewHSpacer(grcom)
|
walk.NewHSpacer(grcom)
|
||||||
log.Println("Creating grid color button")
|
log.Println("Creating grid color button")
|
||||||
@@ -163,6 +174,14 @@ func CreateCanvasProperties(mw *MyMainWindow) {
|
|||||||
case "false":
|
case "false":
|
||||||
cb.SetChecked(false)
|
cb.SetChecked(false)
|
||||||
}
|
}
|
||||||
|
cb.CheckedChanged().Attach(func() {
|
||||||
|
log.Println("Grid checkbox changed")
|
||||||
|
if !cb.Checked() {
|
||||||
|
SetConfigShowBeads("false")
|
||||||
|
} else {
|
||||||
|
SetConfigShowBeads("true")
|
||||||
|
}
|
||||||
|
})
|
||||||
log.Println("Pixels checkbox created")
|
log.Println("Pixels checkbox created")
|
||||||
log.Println("Creating canvas background color button")
|
log.Println("Creating canvas background color button")
|
||||||
grcolb, _ = walk.NewPushButton(mw.properties.propCanvas.property)
|
grcolb, _ = walk.NewPushButton(mw.properties.propCanvas.property)
|
||||||
|
|||||||
Reference in New Issue
Block a user