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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/lxn/walk"
|
"github.com/lxn/walk"
|
||||||
)
|
)
|
||||||
@@ -87,7 +86,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, _ = strconv.Atoi(s.OnHand)
|
se.onHand = s.OnHand
|
||||||
bc.Series = append(bc.Series, se)
|
bc.Series = append(bc.Series, se)
|
||||||
}
|
}
|
||||||
bc.Brand = brand.BrandName
|
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() {
|
if p.BrandName == mw.brand_combo.Text() {
|
||||||
for _, c := range p.Colors {
|
for ic, c := range p.Colors {
|
||||||
if c.ColorIndex == color.ColorID {
|
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() {
|
if s.Name == mw.serie_combo.Text() {
|
||||||
tmp, _ := strconv.Atoi(s.OnHand)
|
mw.pallette.Brand[ib].Colors[ic].Series.Serie[is].OnHand += ret.Number
|
||||||
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("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("Pallette updated: ", mw.pallette)
|
||||||
log.Println("Saving palette file...")
|
log.Println("Saving palette file...")
|
||||||
WritePaletteFile(mw)
|
WritePaletteFile(mw)
|
||||||
|
2
main.go
2
main.go
@@ -31,7 +31,7 @@ type MyMainWindow struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AppName string = "BeadImager"
|
AppName string = "BeadImager"
|
||||||
Version string = "0.3.11"
|
Version string = "0.3.12"
|
||||||
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"
|
||||||
|
20
pallette.go
20
pallette.go
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@@ -57,7 +56,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 string `xml:"onHand"`
|
OnHand int `xml:"onHand"`
|
||||||
}
|
}
|
||||||
|
|
||||||
Pegboards struct {
|
Pegboards struct {
|
||||||
@@ -175,7 +174,6 @@ func CreatePegboardsList(mw *MyMainWindow) {
|
|||||||
mw.Pegboards.Boards = append(mw.Pegboards.Boards, *pb)
|
mw.Pegboards.Boards = append(mw.Pegboards.Boards, *pb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//log.Println("Pegboard: ", mw.Pegboards)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateSeriesList(mw *MyMainWindow) []string {
|
func CreateSeriesList(mw *MyMainWindow) []string {
|
||||||
@@ -199,22 +197,12 @@ func CreateBrandsList(mw *MyMainWindow) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CreatePallette(mw *MyMainWindow) {
|
func CreatePallette(mw *MyMainWindow) {
|
||||||
// Open our xmlFile
|
XMLFile, err := ioutil.ReadFile(UserPath + Sep + "pallette.xml")
|
||||||
XMLFile, err := os.Open(UserPath + Sep + "pallette.xml")
|
|
||||||
// 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")
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
er := xml.Unmarshal(XMLFile, &mw.pallette)
|
||||||
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)
|
|
||||||
if er != nil {
|
if er != nil {
|
||||||
log.Printf("Failed to unmarshal: %v", er)
|
log.Printf("Failed to unmarshal: %v", er)
|
||||||
}
|
}
|
||||||
@@ -232,5 +220,5 @@ func WritePaletteFile(mw *MyMainWindow) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to marshal: %v", err)
|
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() {
|
cb.CheckedChanged().Attach(func() {
|
||||||
log.Println("Grid checkbox changed")
|
log.Println("Grid checkbox changed")
|
||||||
if cb.Checked() {
|
if !cb.Checked() {
|
||||||
SetConfigShowGrid("false")
|
SetConfigShowGrid("false")
|
||||||
} else {
|
} else {
|
||||||
SetConfigShowGrid("true")
|
SetConfigShowGrid("true")
|
||||||
|
Reference in New Issue
Block a user