0.3.11 Trying to write xml data. /JL
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/lxn/walk"
|
"github.com/lxn/walk"
|
||||||
)
|
)
|
||||||
@@ -86,7 +87,7 @@ func LoadBeads(mw *MyMainWindow) {
|
|||||||
se := new(Serie)
|
se := new(Serie)
|
||||||
se.Name = s.Name
|
se.Name = s.Name
|
||||||
se.inStock = s.InStock
|
se.inStock = s.InStock
|
||||||
se.onHand = s.OnHand
|
se.onHand, _ = strconv.Atoi(s.OnHand)
|
||||||
bc.Series = append(bc.Series, se)
|
bc.Series = append(bc.Series, se)
|
||||||
}
|
}
|
||||||
bc.Brand = brand.BrandName
|
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)
|
val := mw.addBeads(name, data, color.ColorID, color.backgroundColor, ret)
|
||||||
log.Println("Color ID: ", color.ColorID)
|
|
||||||
if val == 1 {
|
if val == 1 {
|
||||||
for _, b := range mw.beads {
|
for _, b := range mw.beads {
|
||||||
log.Println("Bead Color ID: ", b.ColorID)
|
|
||||||
if b.ColorID == color.ColorID {
|
if b.ColorID == color.ColorID {
|
||||||
for _, s := range b.Series {
|
for _, s := range b.Series {
|
||||||
if s.Name == mw.serie_combo.Text() {
|
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())
|
ShowBeads(mw, mw.serie_combo.Text())
|
||||||
} else if val == 2 {
|
} else if val == 2 {
|
||||||
log.Println("Canceled")
|
log.Println("Canceled")
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type MyMainWindow struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AppName string = "BeadImager"
|
AppName string = "BeadImager"
|
||||||
Version string = "0.3.10"
|
Version string = "0.3.11"
|
||||||
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"
|
||||||
|
|||||||
+10
-1
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ type (
|
|||||||
XMLName xml.Name `xml:"serie"`
|
XMLName xml.Name `xml:"serie"`
|
||||||
Name string `xml:"name,attr"`
|
Name string `xml:"name,attr"`
|
||||||
InStock bool `xml:"inStock"`
|
InStock bool `xml:"inStock"`
|
||||||
OnHand int `xml:"onHand"`
|
OnHand string `xml:"onHand"`
|
||||||
}
|
}
|
||||||
|
|
||||||
Pegboards struct {
|
Pegboards struct {
|
||||||
@@ -225,3 +226,11 @@ func CheckPalletteFile() bool {
|
|||||||
}
|
}
|
||||||
return true
|
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