// Copyright 2011 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
	"github.com/lxn/walk"
	"AD-Control/public"
)
func userInit(){
	public.SendServerExec(public.Msg_Exec_Update)

	public.SendServerReport("Start User")

}

func menuInit(ni * walk.NotifyIcon){
	menuInitPower(ni)
	menuInitSoftwareInstall(ni)
	menuInitUserTools(ni)
	menuInitFileShares(ni)
	menuInitOther(ni)

}
func main() {
	// flag 初始化
	if public.FlagInit() {return}
	
	// 用户初始化
	userInit()

	// 程序初始化
	mw,err := walk.NewMainWindow()
	if err != nil {
		public.PrintLog(err)
	}

	icon, err := walk.Resources.Icon(`AD-Control.ico`)
	if err != nil {
		public.PrintLog(err)
	}

	// 后台图标应用初始化
	ni, err := walk.NewNotifyIcon(mw)
	if err != nil {
		public.PrintLog(err)
	}
	defer ni.Dispose()

	// Set the icon and a tool tip text.
	if err := ni.SetIcon(icon); err != nil {
		public.PrintLog(err)
	}
	if err := ni.SetToolTip("Click for info or use the context menu to exit."); err != nil {
		public.PrintLog(err)
	}
	menuInit(ni)

	// The notify icon is hidden initially, so we have to make it visible.
	if err := ni.SetVisible(true); err != nil {
		public.PrintLog(err)
	}
	
	// 循环 运行窗体
	mw.Run()
}

