0.3.12 Adding beads working. /JL
This commit is contained in:
18
color.go
18
color.go
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/lxn/walk"
|
||||
)
|
||||
@@ -87,7 +86,7 @@ func LoadBeads(mw *MyMainWindow) {
|
||||
se := new(Serie)
|
||||
se.Name = s.Name
|
||||
se.inStock = s.InStock
|
||||
se.onHand, _ = strconv.Atoi(s.OnHand)
|
||||
se.onHand = s.OnHand
|
||||
bc.Series = append(bc.Series, se)
|
||||
}
|
||||
bc.Brand = brand.BrandName
|
||||
@@ -151,22 +150,25 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, p := range mw.pallette.Brand {
|
||||
for ib, p := range mw.pallette.Brand {
|
||||
if p.BrandName == mw.brand_combo.Text() {
|
||||
for _, c := range p.Colors {
|
||||
for ic, c := range p.Colors {
|
||||
if c.ColorIndex == color.ColorID {
|
||||
for _, s := range c.Series.Serie {
|
||||
for is, 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)
|
||||
mw.pallette.Brand[ib].Colors[ic].Series.Serie[is].OnHand += ret.Number
|
||||
log.Println("Added ", ret.Number, " beads of ", name, " to ", mw.serie_combo.Text(), " (", s.OnHand, " on hand)")
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
//mw.pallette.Brand[0].Colors[0].Series.Serie[1].OnHand += ret.Number
|
||||
//log.Println("Onhand updated: ", mw.pallette.Brand[0].Colors[0].Series.Serie[1].OnHand)
|
||||
log.Println("Pallette updated: ", mw.pallette)
|
||||
log.Println("Saving palette file...")
|
||||
WritePaletteFile(mw)
|
||||
|
2
main.go
2
main.go
@@ -31,7 +31,7 @@ type MyMainWindow struct {
|
||||
|
||||
const (
|
||||
AppName string = "BeadImager"
|
||||
Version string = "0.3.11"
|
||||
Version string = "0.3.12"
|
||||
CopyRight string = "©2022 Jan Lerking"
|
||||
STD_MESS string = "Ready"
|
||||
LogFile string = "BeadImager.log"
|
||||
|
20
pallette.go
20
pallette.go
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
@@ -57,7 +56,7 @@ type (
|
||||
XMLName xml.Name `xml:"serie"`
|
||||
Name string `xml:"name,attr"`
|
||||
InStock bool `xml:"inStock"`
|
||||
OnHand string `xml:"onHand"`
|
||||
OnHand int `xml:"onHand"`
|
||||
}
|
||||
|
||||
Pegboards struct {
|
||||
@@ -175,7 +174,6 @@ func CreatePegboardsList(mw *MyMainWindow) {
|
||||
mw.Pegboards.Boards = append(mw.Pegboards.Boards, *pb)
|
||||
}
|
||||
}
|
||||
//log.Println("Pegboard: ", mw.Pegboards)
|
||||
}
|
||||
|
||||
func CreateSeriesList(mw *MyMainWindow) []string {
|
||||
@@ -199,22 +197,12 @@ func CreateBrandsList(mw *MyMainWindow) []string {
|
||||
}
|
||||
|
||||
func CreatePallette(mw *MyMainWindow) {
|
||||
// Open our xmlFile
|
||||
XMLFile, err := os.Open(UserPath + Sep + "pallette.xml")
|
||||
// if we os.Open returns an error then handle it
|
||||
XMLFile, err := ioutil.ReadFile(UserPath + Sep + "pallette.xml")
|
||||
if err != nil {
|
||||
log.Print("Failed to open pallette.xml")
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
log.Println("Successfully Opened pallette.xml")
|
||||
// defer the closing of our xmlFile so that we can parse it later on
|
||||
defer XMLFile.Close()
|
||||
|
||||
// read our opened xmlFile as a byte array.
|
||||
byteValue, _ := io.ReadAll(XMLFile)
|
||||
|
||||
er := xml.Unmarshal(byteValue, &mw.pallette)
|
||||
er := xml.Unmarshal(XMLFile, &mw.pallette)
|
||||
if er != nil {
|
||||
log.Printf("Failed to unmarshal: %v", er)
|
||||
}
|
||||
@@ -232,5 +220,5 @@ func WritePaletteFile(mw *MyMainWindow) {
|
||||
if err != nil {
|
||||
log.Printf("Failed to marshal: %v", err)
|
||||
}
|
||||
_ = ioutil.WriteFile(UserPath+Sep+"pallette.xml", file, 0644)
|
||||
_ = ioutil.WriteFile(UserPath+Sep+"pallette.xml", file, 0666)
|
||||
}
|
||||
|
@@ -271,7 +271,7 @@ func CreateCanvasProperties(mw *MyMainWindow) {
|
||||
}
|
||||
cb.CheckedChanged().Attach(func() {
|
||||
log.Println("Grid checkbox changed")
|
||||
if cb.Checked() {
|
||||
if !cb.Checked() {
|
||||
SetConfigShowGrid("false")
|
||||
} else {
|
||||
SetConfigShowGrid("true")
|
||||
|
Reference in New Issue
Block a user