0.2.3 Pallette updating working. /JL

This commit is contained in:
2022-12-19 12:40:10 +01:00
parent e325df9fbb
commit 46a9cbee3c
3 changed files with 33 additions and 42 deletions

View File

@@ -29,6 +29,18 @@ type (
}
)
func ShowBeads(mw *MyMainWindow, serie string) {
log.Println("Showing beads...")
for _, bead := range mw.beads {
bead.Color.SetVisible(false)
for _, s := range bead.Series {
if s == serie {
bead.Color.SetVisible(true)
}
}
}
}
func CreateBeadsGroup(mw *MyMainWindow) {
gb, _ := walk.NewGroupBox(mw.leftPanel)
gb.SetTitle("Beads")
@@ -46,38 +58,29 @@ func CreateBeadsGroup(mw *MyMainWindow) {
}
func LoadBeads(mw *MyMainWindow) {
var located bool
for _, brand := range mw.pallette.Brand {
if brand.BrandName == mw.brand_combo.Text() {
log.Println("Loading beads for brand: " + brand.BrandName + " ...")
log.Println("Loading beads for serie: " + mw.serie_combo.Text() + " ...")
for _, bead := range brand.Colors {
for _, serie := range bead.Series.Serie {
if serie == mw.serie_combo.Text() {
located = true
}
}
if located {
log.Println("Loading bead: " + bead.ColorName + " ...")
if !bead.Disabled {
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.OnHand, bead.Red, bead.Green, bead.Blue)
bc.Series = bead.Series.Serie
bc.Brand = brand.BrandName
bc.Name = bead.ColorName
bc.ColorID = bead.ColorIndex
bc.Red = bead.Red
bc.Green = bead.Green
bc.Blue = bead.Blue
bc.inStock = bead.InStock
mw.beads = append(mw.beads, bc)
if bead.OnHand <= 200 {
bc.warning.SetVisible(true)
bc.info.SetVisible(false)
} else {
bc.warning.SetVisible(false)
bc.info.SetVisible(true)
}
log.Println("Loading bead: " + bead.ColorName + " ...")
if !bead.Disabled {
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.OnHand, bead.Red, bead.Green, bead.Blue)
bc.Series = bead.Series.Serie
bc.Brand = brand.BrandName
bc.Name = bead.ColorName
bc.ColorID = bead.ColorIndex
bc.Red = bead.Red
bc.Green = bead.Green
bc.Blue = bead.Blue
bc.inStock = bead.InStock
mw.beads = append(mw.beads, bc)
if bead.OnHand <= 200 {
bc.warning.SetVisible(true)
bc.info.SetVisible(false)
} else {
bc.warning.SetVisible(false)
bc.info.SetVisible(true)
}
}
}

View File

@@ -30,7 +30,7 @@ type MyMainWindow struct {
const (
AppName string = "BeadImager"
Version string = "0.2.2"
Version string = "0.2.3"
CopyRight string = "©2022 Jan Lerking"
STD_MESS string = "Ready"
LogFile string = "BeadImager.log"

View File

@@ -100,20 +100,7 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
mw.serie_combo.SetText(ConfigSerie)
mw.serie_combo.CurrentIndexChanged().Attach(func() {
log.Println("Serie triggered: ", mw.serie_combo.Text())
for _, color := range mw.beads {
for _, serie := range color.Series {
if serie != mw.serie_combo.Text() {
Disable = true
} else {
Disable = false
}
}
if Disable {
color.Color.SetVisible(false)
} else {
color.Color.SetVisible(true)
}
}
ShowBeads(mw, mw.serie_combo.Text())
for _, model := range mw.Pegboards.Boards {
if model.brand == mw.brand_combo.Text() && model.serie == mw.serie_combo.Text() {
mw.pegboard_combo.SetText("")
@@ -135,6 +122,7 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
}
}
mw.pegboard_combo.SetText(ConfigPegboard)
ShowBeads(mw, mw.serie_combo.Text())
return pallette_group
}