0.3.10 Read from local pallette.xml working. /JL

This commit is contained in:
2022-12-22 22:07:07 +01:00
parent abc422f58b
commit 9d7c215ea9
4 changed files with 26 additions and 3 deletions

1
go.mod
View File

@@ -8,6 +8,7 @@ require (
github.com/akavel/rsrc v0.10.2 // indirect github.com/akavel/rsrc v0.10.2 // indirect
github.com/bigkevmcd/go-configparser v0.0.0-20221013105652-718c0b41a604 // indirect github.com/bigkevmcd/go-configparser v0.0.0-20221013105652-718c0b41a604 // indirect
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
github.com/otiai10/copy v1.9.0 // indirect
golang.org/x/sys v0.3.0 // indirect golang.org/x/sys v0.3.0 // indirect
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
) )

7
go.sum
View File

@@ -6,7 +6,14 @@ github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 h1:NVRJ0Uy0SOFcXSKLsS65Om
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc= github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/otiai10/copy v1.9.0 h1:7KFNiCgZ91Ru4qW4CWPf/7jqtxLagGRmIxWldPP9VY4=
github.com/otiai10/copy v1.9.0/go.mod h1:hsfX19wcn0UWIHUQ3/4fHuehhk2UyArQ9dVFAn3FczI=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.4.0/go.mod h1:gifjb2MYOoULtKLqUAEILUG/9KONW6f7YsJ6vQLTlFI=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc= gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc=

12
main.go
View File

@@ -6,6 +6,7 @@ import (
"os/user" "os/user"
"github.com/lxn/walk" "github.com/lxn/walk"
"github.com/otiai10/copy"
) )
type MyMainWindow struct { type MyMainWindow struct {
@@ -30,7 +31,7 @@ type MyMainWindow struct {
const ( const (
AppName string = "BeadImager" AppName string = "BeadImager"
Version string = "0.3.9" Version string = "0.3.10"
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"
@@ -82,7 +83,14 @@ func main() {
log.Println("Serie: ", ConfigSerie) log.Println("Serie: ", ConfigSerie)
log.Println("Pegboard: ", ConfigPegboard) log.Println("Pegboard: ", ConfigPegboard)
} }
if !CheckPalletteFile() {
// Copy files from network directory to local directory
err := copy.Copy("pallettes\\pallette.xml", UserPath+Sep+"pallette.xml")
if err != nil {
log.Fatal(err)
}
log.Println("Pallette file created")
}
walk.AppendToWalkInit(func() { walk.AppendToWalkInit(func() {
walk.FocusEffect, _ = walk.NewBorderGlowEffect(walk.RGB(0, 63, 255)) walk.FocusEffect, _ = walk.NewBorderGlowEffect(walk.RGB(0, 63, 255))
//walk.InteractionEffect, _ = walk.NewDropShadowEffect(walk.RGB(63, 63, 63)) //walk.InteractionEffect, _ = walk.NewDropShadowEffect(walk.RGB(63, 63, 63))

View File

@@ -199,7 +199,7 @@ func CreateBrandsList(mw *MyMainWindow) []string {
func CreatePallette(mw *MyMainWindow) { func CreatePallette(mw *MyMainWindow) {
// Open our xmlFile // Open our xmlFile
XMLFile, err := os.Open("pallettes\\pallette.xml") XMLFile, err := os.Open(UserPath + Sep + "pallette.xml")
// if we os.Open returns an error then handle it // if we os.Open returns an error then handle it
if err != nil { if err != nil {
log.Print("Failed to open pallette.xml") log.Print("Failed to open pallette.xml")
@@ -218,3 +218,10 @@ func CreatePallette(mw *MyMainWindow) {
log.Printf("Failed to unmarshal: %v", er) log.Printf("Failed to unmarshal: %v", er)
} }
} }
func CheckPalletteFile() bool {
if _, err := os.Stat(UserPath + Sep + "pallette.xml"); os.IsNotExist(err) {
return false
}
return true
}