Files
beadimager/main.go

128 lines
2.9 KiB
Go

package main
import (
"fmt"
"log"
"os"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
type MyMainWindow struct {
*walk.MainWindow
colors *walk.ScrollView
canvas *walk.ScrollView
properties *walk.ScrollView
pallette Pallette
beads []*BeadColor
}
const (
AppName string = "BeadImager"
Version string = "0.0.6"
CopyRight string = "©2022 Jan Lerking"
STD_MESS string = "Ready"
UserPath string = "C:\\Users\\janle\\BeadImager"
LogFile string = "BeadImager.log"
Sep string = "\\"
)
var LoggingFile *os.File
func InitLogFile() {
_, err := os.Stat(fmt.Sprintf(UserPath + Sep + LogFile))
if err == nil {
LoggingFile, err := os.OpenFile(fmt.Sprintf(UserPath+Sep+LogFile), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
log.SetOutput(LoggingFile)
} else {
if _, err := os.Stat(UserPath); err != nil {
os.Mkdir(UserPath, 0755)
}
_, err = os.Create(fmt.Sprintf(UserPath + Sep + LogFile))
if err != nil {
log.Fatal(err)
}
LoggingFile, err := os.OpenFile(fmt.Sprintf(UserPath+Sep+LogFile), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
log.SetOutput(LoggingFile)
}
log.Print("Logging initialized")
}
func main() {
InitLogFile()
walk.AppendToWalkInit(func() {
walk.FocusEffect, _ = walk.NewBorderGlowEffect(walk.RGB(0, 63, 255))
walk.InteractionEffect, _ = walk.NewDropShadowEffect(walk.RGB(63, 63, 63))
walk.ValidationErrorEffect, _ = walk.NewBorderGlowEffect(walk.RGB(255, 0, 0))
})
mw := &MyMainWindow{}
log.Println("MainWindow created")
CreatePallette(mw)
log.Println("Pallette created: ", mw.pallette)
//LoadBeads(mw)
//log.Println("Beads loaded: ", mw.beads)
brand_model := CreateBrandsList(mw)
pallette_combo := new(walk.ComboBox)
if _, err := (MainWindow{
AssignTo: &mw.MainWindow,
Title: AppName + " " + Version,
MinSize: Size{800, 600},
Layout: VBox{MarginsZero: true},
Children: []Widget{
Composite{
Layout: HBox{MarginsZero: true},
Children: []Widget{
Composite{
Layout: VBox{MarginsZero: true},
Children: []Widget{
Composite{
Layout: HBox{MarginsZero: true},
Children: []Widget{
Label{
Text: "Pallette:",
},
ComboBox{
AssignTo: &pallette_combo,
Model: brand_model,
OnCurrentIndexChanged: func() {
log.Println("Pallette changed to: ", pallette_combo.Text())
},
},
},
},
PushButton{
Text: "Edit Animal",
OnClicked: func() {},
},
ScrollView{
AssignTo: &mw.colors,
Layout: VBox{MarginsZero: true},
},
},
},
ScrollView{
AssignTo: &mw.canvas,
Layout: VBox{MarginsZero: true},
},
ScrollView{
AssignTo: &mw.properties,
Layout: VBox{MarginsZero: true},
},
},
},
},
}.Run()); err != nil {
log.Fatal(err)
}
}