0.2.1 Updated pegboard lists. /JL

This commit is contained in:
2022-12-18 22:04:22 +01:00
parent abb43aada8
commit 8e2bae5203
3 changed files with 46 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ import (
type (
BeadColor struct {
Color *walk.Composite
Checkbox *walk.CheckBox
backgroundColor walk.Brush
InfoTooltip *walk.ToolTip
@@ -98,6 +99,7 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, g
hb.SetMargins(walk.Margins{5, 0, 20, 0})
cm.SetLayout(hb)
color := new(BeadColor)
color.Color = cm
log.Println("Bead color struct: ", color)
color.SetBackgroundColor(walk.RGB(red, green, blue))
color.onHand = onhand

View File

@@ -24,13 +24,13 @@ type MyMainWindow struct {
serie_combo *walk.ComboBox
serie_model []string
pegboard_combo *walk.ComboBox
pegboard_model []string
Pegboards *Pegboards
properties *properties
}
const (
AppName string = "BeadImager"
Version string = "0.2.0"
Version string = "0.2.1"
CopyRight string = "©2022 Jan Lerking"
STD_MESS string = "Ready"
LogFile string = "BeadImager.log"

View File

@@ -53,13 +53,24 @@ type (
InStock bool `xml:"inStock"`
OnHand int `xml:"onHand"`
}
Pegboards struct {
Boards []Pegboard
}
Pegboard struct {
brand string
serie string
model []string
}
)
var (
serie_triggered bool = false
Serie_triggered bool = false
)
func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
mw.Pegboards = new(Pegboards)
mw.leftPanel, _ = walk.NewComposite(mw.content)
vb := walk.NewVBoxLayout()
mw.leftPanel.SetLayout(vb)
@@ -87,10 +98,20 @@ 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 {
mw.colors.Children().Clear()
LoadBeads(mw)
serie_triggered = true
if !Serie_triggered {
for _, color := range mw.beads {
if color.Series != mw.serie_combo.Text() {
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.SetModel(model.model)
}
}
Serie_triggered = true
}
})
comp, _ = walk.NewComposite(pallette_group)
@@ -99,23 +120,32 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
lbl, _ = walk.NewLabel(comp)
lbl.SetText("Pegboard:")
mw.pegboard_combo, _ = walk.NewComboBox(comp)
mw.pegboard_combo.SetModel(CreatePegboardsList(mw))
CreatePegboardsList(mw)
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)
}
}
mw.pegboard_combo.SetText(ConfigPegboard)
return pallette_group
}
func CreatePegboardsList(mw *MyMainWindow) []string {
pegboards := make([]string, 0)
func CreatePegboardsList(mw *MyMainWindow) {
var pb *Pegboard
for _, brand := range mw.pallette.Brand {
if brand.BrandName == mw.brand_combo.Text() {
for _, serie := range brand.Series {
pb = new(Pegboard)
pb.brand = brand.BrandName
pb.serie = serie.Serie
for _, pegboard := range brand.Pegboards {
if pegboard.Serie == mw.serie_combo.Text() {
pegboards = append(pegboards, pegboard.Type)
if pegboard.Serie == pb.serie {
pb.model = append(pb.model, pegboard.Type)
}
}
mw.Pegboards.Boards = append(mw.Pegboards.Boards, *pb)
}
}
return pegboards
log.Println("Pegboard: ", mw.Pegboards)
}
func CreateSeriesList(mw *MyMainWindow) []string {