0.0.4 added logging. /JL

This commit is contained in:
2022-12-09 14:30:18 +01:00
parent 48bd14cf42
commit a8ee74b373
+64 -6
View File
@@ -1,7 +1,9 @@
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"
@@ -9,18 +11,59 @@ import (
type MyMainWindow struct { type MyMainWindow struct {
*walk.MainWindow *walk.MainWindow
te *walk.TextEdit colors *walk.ScrollView
canvas *walk.ScrollView
properties *walk.ScrollView
} }
const ( const (
AppName string = "BeadImager" AppName string = "BeadImager"
Version string = "0.0.3" Version string = "0.0.4"
CopyRight string = "©2022 Jan Lerking" CopyRight string = "©2022 Jan Lerking"
STD_MESS string = "Ready" 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() { 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{} mw := &MyMainWindow{}
log.Println("MainWindow created")
//ss := mw.MainWindow.MaxSize()
//log.Println(ss)
if _, err := (MainWindow{ if _, err := (MainWindow{
AssignTo: &mw.MainWindow, AssignTo: &mw.MainWindow,
@@ -29,14 +72,29 @@ func main() {
Layout: VBox{MarginsZero: true}, Layout: VBox{MarginsZero: true},
Children: []Widget{ Children: []Widget{
HSplitter{ Composite{
Layout: HBox{MarginsZero: true},
Children: []Widget{
Composite{
Layout: VBox{MarginsZero: true},
Children: []Widget{ Children: []Widget{
PushButton{ PushButton{
Text: "Edit Animal", Text: "Edit Animal",
OnClicked: func() {},
}, },
TextEdit{ ScrollView{
AssignTo: &mw.te, AssignTo: &mw.colors,
ReadOnly: true, Layout: VBox{MarginsZero: true},
},
},
},
ScrollView{
AssignTo: &mw.canvas,
Layout: VBox{MarginsZero: true},
},
ScrollView{
AssignTo: &mw.properties,
Layout: VBox{MarginsZero: true},
}, },
}, },
}, },