diff --git a/color.go b/color.go index 41a4d7c..ffd2705 100644 --- a/color.go +++ b/color.go @@ -17,8 +17,8 @@ type ( info *walk.ImageView warning *walk.ImageView Brand string - Series string - Weight int + Series []string + Weight []int Name string ColorID int Red byte @@ -62,12 +62,7 @@ func LoadBeads(mw *MyMainWindow) { log.Println("Loading bead: " + bead.ColorName + " ...") if !bead.Disabled { bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.OnHand, bead.Red, bead.Green, bead.Blue) - for _, series := range brand.Series { - if series.Serie == mw.serie_combo.Text() { - bc.Series = series.Serie - bc.Weight = series.Weight - } - } + bc.Series = bead.Series.Serie bc.Brand = brand.BrandName bc.Name = bead.ColorName bc.ColorID = bead.ColorIndex @@ -162,8 +157,3 @@ func (bc *BeadColor) SetInStock(inStock bool) { func (bc *BeadColor) GetColorID() int { return bc.ColorID } - -func (bc *BeadColor) AddOnHand(grams int) { - addbeads := grams / bc.Weight * 1000 - bc.onHand += int(addbeads) -} diff --git a/main.go b/main.go index 1c5294b..addd8c8 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ type MyMainWindow struct { const ( AppName string = "BeadImager" - Version string = "0.2.1" + Version string = "0.2.2" CopyRight string = "©2022 Jan Lerking" STD_MESS string = "Ready" LogFile string = "BeadImager.log" diff --git a/pallette.go b/pallette.go index 5d14eb5..8f52a6d 100644 --- a/pallette.go +++ b/pallette.go @@ -67,6 +67,7 @@ type ( var ( Serie_triggered bool = false + Disable bool ) func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox { @@ -98,20 +99,27 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox { mw.serie_combo.SetModel(CreateSeriesList(mw)) mw.serie_combo.SetText(ConfigSerie) mw.serie_combo.CurrentIndexChanged().Attach(func() { - if !Serie_triggered { - for _, color := range mw.beads { - if color.Series != mw.serie_combo.Text() { - color.Color.SetVisible(false) + 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 { - color.Color.SetVisible(true) + Disable = false } } - for _, model := range mw.Pegboards.Boards { - if model.brand == mw.brand_combo.Text() && model.serie == mw.serie_combo.Text() { - mw.pegboard_combo.SetModel(model.model) - } + if Disable { + color.Color.SetVisible(false) + } else { + color.Color.SetVisible(true) + } + } + for _, model := range mw.Pegboards.Boards { + if model.brand == mw.brand_combo.Text() && model.serie == mw.serie_combo.Text() { + mw.pegboard_combo.SetText("") + mw.pegboard_combo.SetModel(model.model) + log.Println("Pegboard model set to: ", model.model) } - Serie_triggered = true } }) comp, _ = walk.NewComposite(pallette_group)