0.0.7 Cleanup. /JL
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/lxn/walk"
|
"github.com/lxn/walk"
|
||||||
. "github.com/lxn/walk/declarative"
|
. "github.com/lxn/walk/declarative"
|
||||||
@@ -20,7 +18,7 @@ type MyMainWindow struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AppName string = "BeadImager"
|
AppName string = "BeadImager"
|
||||||
Version string = "0.0.6"
|
Version string = "0.0.7"
|
||||||
CopyRight string = "©2022 Jan Lerking"
|
CopyRight string = "©2022 Jan Lerking"
|
||||||
STD_MESS string = "Ready"
|
STD_MESS string = "Ready"
|
||||||
UserPath string = "C:\\Users\\janle\\BeadImager"
|
UserPath string = "C:\\Users\\janle\\BeadImager"
|
||||||
@@ -28,33 +26,6 @@ const (
|
|||||||
Sep string = "\\"
|
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() {
|
func main() {
|
||||||
InitLogFile()
|
InitLogFile()
|
||||||
|
|
||||||
@@ -72,6 +43,41 @@ func main() {
|
|||||||
brand_model := CreateBrandsList(mw)
|
brand_model := CreateBrandsList(mw)
|
||||||
pallette_combo := new(walk.ComboBox)
|
pallette_combo := new(walk.ComboBox)
|
||||||
|
|
||||||
|
DD_Pallette := 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())
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
serie_model := CreateSeriesList(mw)
|
||||||
|
serie_combo := new(walk.ComboBox)
|
||||||
|
|
||||||
|
DD_Serie := Composite{
|
||||||
|
Layout: HBox{MarginsZero: true},
|
||||||
|
Children: []Widget{
|
||||||
|
Label{
|
||||||
|
Text: "Serie:",
|
||||||
|
},
|
||||||
|
ComboBox{
|
||||||
|
AssignTo: &serie_combo,
|
||||||
|
Model: serie_model,
|
||||||
|
OnCurrentIndexChanged: func() {
|
||||||
|
log.Println("Serie changed to: ", serie_combo.Text())
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := (MainWindow{
|
if _, err := (MainWindow{
|
||||||
AssignTo: &mw.MainWindow,
|
AssignTo: &mw.MainWindow,
|
||||||
Title: AppName + " " + Version,
|
Title: AppName + " " + Version,
|
||||||
@@ -85,21 +91,8 @@ func main() {
|
|||||||
Composite{
|
Composite{
|
||||||
Layout: VBox{MarginsZero: true},
|
Layout: VBox{MarginsZero: true},
|
||||||
Children: []Widget{
|
Children: []Widget{
|
||||||
Composite{
|
DD_Pallette,
|
||||||
Layout: HBox{MarginsZero: true},
|
DD_Serie,
|
||||||
Children: []Widget{
|
|
||||||
Label{
|
|
||||||
Text: "Pallette:",
|
|
||||||
},
|
|
||||||
ComboBox{
|
|
||||||
AssignTo: &pallette_combo,
|
|
||||||
Model: brand_model,
|
|
||||||
OnCurrentIndexChanged: func() {
|
|
||||||
log.Println("Pallette changed to: ", pallette_combo.Text())
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
PushButton{
|
PushButton{
|
||||||
Text: "Edit Animal",
|
Text: "Edit Animal",
|
||||||
OnClicked: func() {},
|
OnClicked: func() {},
|
||||||
|
|||||||
+10
@@ -70,6 +70,16 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func CreateSeriesList(mw *MyMainWindow) []string {
|
||||||
|
series := make([]string, 0)
|
||||||
|
for _, brand := range mw.pallette.Brands.Brand {
|
||||||
|
for _, serie := range brand.Series.Serie {
|
||||||
|
series = append(series, serie.SerieName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return series
|
||||||
|
}
|
||||||
|
|
||||||
func CreateBrandsList(mw *MyMainWindow) []string {
|
func CreateBrandsList(mw *MyMainWindow) []string {
|
||||||
brands := make([]string, 0)
|
brands := make([]string, 0)
|
||||||
for _, brand := range mw.pallette.Brands.Brand {
|
for _, brand := range mw.pallette.Brands.Brand {
|
||||||
|
|||||||
Reference in New Issue
Block a user