0.2.4 Updated pallette. /JL
This commit is contained in:
70
color.go
70
color.go
@@ -17,15 +17,19 @@ type (
|
||||
info *walk.ImageView
|
||||
warning *walk.ImageView
|
||||
Brand string
|
||||
Series []string
|
||||
Series []*Serie
|
||||
Weight []int
|
||||
Name string
|
||||
ColorID int
|
||||
Red byte
|
||||
Green byte
|
||||
Blue byte
|
||||
inStock bool
|
||||
onHand int
|
||||
}
|
||||
|
||||
Serie struct {
|
||||
Name string
|
||||
inStock bool
|
||||
onHand int
|
||||
}
|
||||
)
|
||||
|
||||
@@ -34,7 +38,7 @@ func ShowBeads(mw *MyMainWindow, serie string) {
|
||||
for _, bead := range mw.beads {
|
||||
bead.Color.SetVisible(false)
|
||||
for _, s := range bead.Series {
|
||||
if s == serie {
|
||||
if s.Name == serie {
|
||||
bead.Color.SetVisible(true)
|
||||
}
|
||||
}
|
||||
@@ -65,30 +69,37 @@ func LoadBeads(mw *MyMainWindow) {
|
||||
for _, bead := range brand.Colors {
|
||||
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 := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue)
|
||||
for _, s := range bead.Series.Serie {
|
||||
se := new(Serie)
|
||||
se.Name = s.Name
|
||||
se.inStock = s.InStock
|
||||
se.onHand = s.OnHand
|
||||
bc.Series = append(bc.Series, se)
|
||||
bc.InfoTooltip.SetText(bc.info, "Approx. "+fmt.Sprint(se.onHand)+" left on hand")
|
||||
bc.WarningTooltip.SetText(bc.warning, "Only "+fmt.Sprint(se.onHand)+" left on hand")
|
||||
if se.onHand <= 200 {
|
||||
bc.warning.SetVisible(true)
|
||||
bc.info.SetVisible(false)
|
||||
} else {
|
||||
bc.warning.SetVisible(false)
|
||||
bc.info.SetVisible(true)
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, green byte, blue byte) *BeadColor {
|
||||
func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, blue byte) *BeadColor {
|
||||
var err error
|
||||
log.Println("Creating bead color: " + name + " ...")
|
||||
cm, _ := walk.NewComposite(mw.colors)
|
||||
@@ -100,7 +111,6 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, g
|
||||
color.Color = cm
|
||||
log.Println("Bead color struct: ", color)
|
||||
color.SetBackgroundColor(walk.RGB(red, green, blue))
|
||||
color.onHand = onhand
|
||||
log.Println("Creating checkbox")
|
||||
color.Checkbox, err = walk.NewCheckBox(cm)
|
||||
if err != nil {
|
||||
@@ -120,7 +130,6 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, g
|
||||
color.InfoTooltip.SetInfoTitle(name + " - " + fmt.Sprint(id))
|
||||
color.info.SetImage(walk.IconInformation())
|
||||
color.InfoTooltip.AddTool(color.info)
|
||||
color.InfoTooltip.SetText(color.info, "Approx. "+fmt.Sprint(color.onHand)+" left on hand")
|
||||
color.info.SetVisible(false)
|
||||
color.warning, err = walk.NewImageView(cm)
|
||||
if err != nil {
|
||||
@@ -131,7 +140,6 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, g
|
||||
color.WarningTooltip.SetWarningTitle(name + " - " + fmt.Sprint(id))
|
||||
color.warning.SetImage(walk.IconWarning())
|
||||
color.WarningTooltip.AddTool(color.warning)
|
||||
color.WarningTooltip.SetText(color.warning, "Only "+fmt.Sprint(color.onHand)+" left on hand")
|
||||
color.warning.SetVisible(false)
|
||||
|
||||
lbl, _ := walk.NewLabel(cm)
|
||||
@@ -145,16 +153,30 @@ func (bc *BeadColor) SetBackgroundColor(col walk.Color) {
|
||||
bc.backgroundColor, _ = walk.NewSolidColorBrush(col)
|
||||
}
|
||||
|
||||
func (bc *BeadColor) GetOnHand() int {
|
||||
return bc.onHand
|
||||
func (bc *BeadColor) GetOnHand(serie string) int {
|
||||
for _, s := range bc.Series {
|
||||
if s.Name == serie {
|
||||
return s.onHand
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (bc *BeadColor) GetInStock() bool {
|
||||
return bc.inStock
|
||||
func (bc *BeadColor) GetInStock(serie string) bool {
|
||||
for _, s := range bc.Series {
|
||||
if s.Name == serie {
|
||||
return s.inStock
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (bc *BeadColor) SetInStock(inStock bool) {
|
||||
bc.inStock = inStock
|
||||
func (bc *BeadColor) SetInStock(serie string, inStock bool) {
|
||||
for _, s := range bc.Series {
|
||||
if s.Name == serie {
|
||||
s.inStock = inStock
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (bc *BeadColor) GetColorID() int {
|
||||
|
||||
2
main.go
2
main.go
@@ -30,7 +30,7 @@ type MyMainWindow struct {
|
||||
|
||||
const (
|
||||
AppName string = "BeadImager"
|
||||
Version string = "0.2.3"
|
||||
Version string = "0.2.4"
|
||||
CopyRight string = "©2022 Jan Lerking"
|
||||
STD_MESS string = "Ready"
|
||||
LogFile string = "BeadImager.log"
|
||||
|
||||
@@ -36,7 +36,12 @@ type (
|
||||
Colorstruct struct {
|
||||
Series struct {
|
||||
XMLName xml.Name `xml:"series"`
|
||||
Serie []string `xml:"serie"`
|
||||
Serie []struct {
|
||||
XMLName xml.Name `xml:"serie"`
|
||||
Name string `xml:"name,attr"`
|
||||
InStock bool `xml:"inStock"`
|
||||
OnHand int `xml:"onHand"`
|
||||
}
|
||||
}
|
||||
ColorIndex int `xml:"colorIndex,attr"`
|
||||
ColorName string `xml:"colorname"`
|
||||
@@ -50,8 +55,6 @@ type (
|
||||
IsNeutral bool `xml:"isNeutral"`
|
||||
IsGrayscale bool `xml:"isGrayscale"`
|
||||
Disabled bool `xml:"disabled"`
|
||||
InStock bool `xml:"inStock"`
|
||||
OnHand int `xml:"onHand"`
|
||||
}
|
||||
|
||||
Pegboards struct {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user