0.3.11 Trying to write xml data. /JL
This commit is contained in:
24
color.go
24
color.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/lxn/walk"
|
||||
)
|
||||
@@ -86,7 +87,7 @@ func LoadBeads(mw *MyMainWindow) {
|
||||
se := new(Serie)
|
||||
se.Name = s.Name
|
||||
se.inStock = s.InStock
|
||||
se.onHand = s.OnHand
|
||||
se.onHand, _ = strconv.Atoi(s.OnHand)
|
||||
bc.Series = append(bc.Series, se)
|
||||
}
|
||||
bc.Brand = brand.BrandName
|
||||
@@ -139,10 +140,8 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
|
||||
}
|
||||
}
|
||||
val := mw.addBeads(name, data, color.ColorID, color.backgroundColor, ret)
|
||||
log.Println("Color ID: ", color.ColorID)
|
||||
if val == 1 {
|
||||
for _, b := range mw.beads {
|
||||
log.Println("Bead Color ID: ", b.ColorID)
|
||||
if b.ColorID == color.ColorID {
|
||||
for _, s := range b.Series {
|
||||
if s.Name == mw.serie_combo.Text() {
|
||||
@@ -152,6 +151,25 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, p := range mw.pallette.Brand {
|
||||
if p.BrandName == mw.brand_combo.Text() {
|
||||
for _, c := range p.Colors {
|
||||
if c.ColorIndex == color.ColorID {
|
||||
for _, s := range c.Series.Serie {
|
||||
if s.Name == mw.serie_combo.Text() {
|
||||
tmp, _ := strconv.Atoi(s.OnHand)
|
||||
tmp += ret.Number
|
||||
s.OnHand = strconv.Itoa(tmp)
|
||||
log.Println("Added ", ret.Number, " beads of ", name, " to ", mw.serie_combo.Text(), " (", s.OnHand, " on hand)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Println("Pallette updated: ", mw.pallette)
|
||||
log.Println("Saving palette file...")
|
||||
WritePaletteFile(mw)
|
||||
ShowBeads(mw, mw.serie_combo.Text())
|
||||
} else if val == 2 {
|
||||
log.Println("Canceled")
|
||||
|
||||
2
main.go
2
main.go
@@ -31,7 +31,7 @@ type MyMainWindow struct {
|
||||
|
||||
const (
|
||||
AppName string = "BeadImager"
|
||||
Version string = "0.3.10"
|
||||
Version string = "0.3.11"
|
||||
CopyRight string = "©2022 Jan Lerking"
|
||||
STD_MESS string = "Ready"
|
||||
LogFile string = "BeadImager.log"
|
||||
|
||||
11
pallette.go
11
pallette.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"encoding/xml"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -56,7 +57,7 @@ type (
|
||||
XMLName xml.Name `xml:"serie"`
|
||||
Name string `xml:"name,attr"`
|
||||
InStock bool `xml:"inStock"`
|
||||
OnHand int `xml:"onHand"`
|
||||
OnHand string `xml:"onHand"`
|
||||
}
|
||||
|
||||
Pegboards struct {
|
||||
@@ -225,3 +226,11 @@ func CheckPalletteFile() bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func WritePaletteFile(mw *MyMainWindow) {
|
||||
file, err := xml.MarshalIndent(mw.pallette, "", " ")
|
||||
if err != nil {
|
||||
log.Printf("Failed to marshal: %v", err)
|
||||
}
|
||||
_ = ioutil.WriteFile(UserPath+Sep+"pallette.xml", file, 0644)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user