CCTRV 发表于 2011-5-2 13:31:49

Aero 界面展示 - SiteManage



研究了很久才知道如何只是顶部透明.
不过,顶部的Icon使用了偷懒的办法.那只是一张 png 图片而已.#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=icon.ico
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****

#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <fileListToArray.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WinAPIEx.au3>
#include <Process.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <File.au3>

;环境变量
Global $hImage, $hGraphic, $pngx, $pngy

;初始化变量
Global $7zexe, $7zFolder, $data
Global $ProjectFolder_Archive, $ProjectFolder_Move, $ProjectFolder_Now, $ProjectFolder_Project
Global $Server_Apache_Start, $Server_Apache_Stop, $Server_Choose, $Server_Nginx_Start, $Server_Nginx_Stop
Global $Server_Apache_Folder, $Server_Nginx_Folder
Global $SoftTitle
_AppStart()

$SoftTitle = "SiteManage";

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=d:\users\administrator\documents\autoit\foldercopy\foldercopy_gui.kxf
$Form = GUICreate("", 1049, 649, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "FormClose")
$Group1 = GUICtrlCreateGroup("程序源代码和项目", 400, 112, 641, 401)
$List1 = GUICtrlCreateList("", 416, 160, 258, 340, -1, 0)
$Button3 = GUICtrlCreateButton("链接", 688, 192, 75, 25)
GUICtrlSetOnEvent(-1, "Button3Click")
$Button4 = GUICtrlCreateButton("删除程序", 688, 341, 75, 25)
GUICtrlSetOnEvent(-1, "Button4Click")
$Button5 = GUICtrlCreateButton("压缩存档", 688, 372, 75, 25)
GUICtrlSetOnEvent(-1, "Button5Click")
$List3 = GUICtrlCreateList("", 776, 160, 250, 340, -1, 0)
$Label1 = GUICtrlCreateLabel("程序目录:", 416, 136, 55, 17)
$Label2 = GUICtrlCreateLabel("项目目录", 776, 136, 52, 17)
$Button7 = GUICtrlCreateButton("共同压缩", 688, 473, 75, 25)
GUICtrlSetOnEvent(-1, "Button7Click")
$Label3 = GUICtrlCreateLabel("Label3", 675, 418, 100, 1, $SS_BLACKRECT)
$Button9 = GUICtrlCreateButton("删除项目", 688, 440, 75, 25)
GUICtrlSetOnEvent(-1, "Button9Click")
$Button14 = GUICtrlCreateButton("解除链接", 688, 160, 75, 25)
GUICtrlSetOnEvent(-1, "Button14Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("服务器网站目录", 8, 112, 377, 530)
$List2 = GUICtrlCreateList("", 16, 136, 361, 497, BitOR($GUI_SS_DEFAULT_LIST, $WS_HSCROLL), 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("从存档中恢复", 400, 528, 425, 113)
$Combo1 = GUICtrlCreateCombo("", 416, 558, 393, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Button8 = GUICtrlCreateButton("仅程序恢复", 416, 600, 75, 25)
GUICtrlSetOnEvent(-1, "Button8Click")
$Button6 = GUICtrlCreateButton("共同恢复", 592, 600, 75, 25)
GUICtrlSetOnEvent(-1, "Button6Click")
$Button11 = GUICtrlCreateButton("仅项目恢复", 504, 600, 75, 25)
GUICtrlSetOnEvent(-1, "Button11Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("服务器程式", 840, 528, 201, 113)
$Radio1 = GUICtrlCreateRadio("Apache", 848, 560, 65, 17)
GUICtrlSetOnEvent(-1, "Radio1Click")
$Radio2 = GUICtrlCreateRadio("Nginx", 936, 560, 57, 17)
GUICtrlSetOnEvent(-1, "Radio2Click")
$Button12 = GUICtrlCreateButton("关闭服务器", 936, 600, 75, 25)
GUICtrlSetOnEvent(-1, "Button12Click")
$Button13 = GUICtrlCreateButton("开启(重启动)", 848, 600, 75, 25)
GUICtrlSetOnEvent(-1, "Button13Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button10 = GUICtrlCreateButton("刷新目录", 881, 73, 75, 25)
GUICtrlSetOnEvent(-1, "Button10Click")
$Button1 = GUICtrlCreateButton("打开目录", 964, 72, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button15 = GUICtrlCreateButton("Localhost", 798, 73, 75, 25)
GUICtrlSetOnEvent(-1, "Button15Click")
$Label4 = GUICtrlCreateLabel("State", 16, 76, 450, 17)
PngLoad(@ScriptDir & "\" & "Title" & ".png", 16, 8)
DwmDrawForm($Form)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_Refresh()

While 1
        Sleep(100)
WEnd

Func FormClose()
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_Shutdown()
        Exit
EndFunc   ;==>FormClose

Func Button3Click()
        ;链接
        $_tFolder = GUICtrlRead($List1)
        $f = $ProjectFolder_Move & $_tFolder & '\'
        _RunDOS("rd " & $ProjectFolder_Now)
        $c = 'mklink /d "' & $ProjectFolder_Now & '" "' & $f & '"'
        _RunDOS($c)
        _Refresh()
EndFunc   ;==>Button3Click

Func Button4Click()
        ;删除源代码
        FolderDel(1)
        _Refresh()
EndFunc   ;==>Button4Click

Func Button5Click()
        ;源代码压缩
        AddArchive(0)
        Button4Click()
        _Refresh()
EndFunc   ;==>Button5Click

Func Button1Click()
        ;打开目录
        ShellExecute($ProjectFolder_Now)
        _Refresh()
EndFunc   ;==>Button1Click

Func Button6Click()
        ;共同恢复(项目杂项和程序源代码都恢复)
        UnArchive(1)
        _Refresh()
EndFunc   ;==>Button6Click

Func Button7Click()
        ;共同压缩
        AddArchive(1)
        _Refresh()
EndFunc   ;==>Button7Click

Func Button8Click()
        ;仅程序恢复
        UnArchive(0)
        _Refresh()
EndFunc   ;==>Button8Click

Func Button9Click()
        ;删除项目
        FolderDel(3)
        _Refresh()
EndFunc   ;==>Button9Click

Func Button10Click()
        _Refresh()
EndFunc   ;==>Button10Click

Func Button14Click()
        ;解除链接
        _RunDOS("rd " & $ProjectFolder_Now)
        DirCreate($ProjectFolder_Now)
        _Refresh()
EndFunc   ;==>Button14Click

Func Button11Click()
        ;仅项目恢复
        _Refresh()
EndFunc   ;==>Button11Click

Func Button12Click()
        ;关闭服务器
        ShellExecuteWait($Server_Apache_Stop, "", $Server_Apache_Folder)
        ShellExecuteWait($Server_Nginx_Stop, "", $Server_Nginx_Folder)
        _Refresh()
EndFunc   ;==>Button12Click
Func Button13Click()
        ;开启(重启动) - 服务器
        If $Server_Choose = 0 Then
                ShellExecuteWait($Server_Nginx_Stop, "", $Server_Nginx_Folder)
                ShellExecuteWait($Server_Apache_Stop, "", $Server_Apache_Folder)
                ShellExecuteWait($Server_Apache_Start, "", $Server_Apache_Folder)
        Else
                ShellExecuteWait($Server_Apache_Stop, "", $Server_Apache_Folder)
                ShellExecuteWait($Server_Nginx_Stop, "", $Server_Nginx_Folder)
                ShellExecuteWait($Server_Nginx_Start, "", $Server_Nginx_Folder)
        EndIf
        _Refresh()
EndFunc   ;==>Button13Click
Func Radio1Click()
        ;选中 Apache
        SetIni('Server', 'Server', 0)
        _Refresh()
EndFunc   ;==>Radio1Click
Func Radio2Click()
        ;选中 Nginx
        SetIni('Server', 'Server', 1)
        _Refresh()
EndFunc   ;==>Radio2Click
Func Button15Click()
        ShellExecute("http://localhost")
EndFunc   ;==>Button15Click

;=========================================================================================================
;Model
;=========================================================================================================

Func _AppStart()
        $data = @YEAR & '-' & @MON & '-' & @MDAY
        $7zFolder = ReadIni('App', '7z', 'D:\Program Files\7-Zip\')
        $7zexe = $7zFolder & '7z.exe';
        $ProjectFolder_Now = ReadIni('Project', 'Now', 'D:\Users\WebSite\_Running\')
        $ProjectFolder_Archive = ReadIni('Project', 'Archive', 'D:\Users\WebSite\_Archive\')
        $ProjectFolder_Move = ReadIni('Project', 'Move', 'D:\Users\WebSite\_Move\')
        $ProjectFolder_Project = ReadIni('Project', 'Project', 'D:\Users\项目\')
        $Server_Choose = ReadIni('Server', 'Server', 0)
        $Server_Apache_Start = ReadIni('Server', 'Apache_Start', "D:\Users\WebSite\Apache\PnCmds\Start.cmd")
        $Server_Apache_Stop = ReadIni('Server', 'Apache_Stop', "D:\Users\WebSite\Apache\PnCmds\Stop.cmd")
        $Server_Nginx_Start = ReadIni('Server', 'Nginx_Start', "D:\Users\WebSite\Nginx\start.bat")
        $Server_Nginx_Stop = ReadIni('Server', 'Nginx_Stop', "D:\Users\WebSite\Nginx\stop.bat")
        $Server_Apache_Folder = ReadIni('Server', 'Apache_Folder', "D:\Users\WebSite\Apache\")
        $Server_Nginx_Folder = ReadIni('Server', 'Nginx_Folder', "D:\Users\WebSite\Nginx\")
EndFunc   ;==>_AppStart

Func _Refresh()
        Sleep(15)
        If $Server_Choose = 0 Then
                GUICtrlSetState($Radio1, $GUI_CHECKED)
                $Server_PID = ProcessExists("httpd.exe")
                $Server_State = "httpd.exe PID: " & $Server_PID
        Else
                GUICtrlSetState($Radio2, $GUI_CHECKED)
                $Server_PID = ProcessExists("nginx.exe")
                $Server_State = "nginx.exe PID: " & $Server_PID
        EndIf

        If $Server_PID <> 0 Then
                GUICtrlSetState($Button12, $GUI_ENABLE)
        Else
                GUICtrlSetState($Button12, $GUI_DISABLE)
        EndIf

        GUICtrlSetData($Label4, "服务器目录: " & _FindFolderDepict($ProjectFolder_Now) & " 服务器: " & $Server_State)

        Folder_Move_List()
        Folder_Now_List()
        Folder_Archive_List()
        Folder_Project_List()
EndFunc   ;==>_Refresh

Func Folder_Move_List()
        GUICtrlSetData($List1, "")
        $ProjectFolder_Move_Index_Array = _FileListToArray($ProjectFolder_Move, '*', 2)
        If $ProjectFolder_Move_Index_Array <> 0 Then
                $ProjectFolder_Move_Index_String = _ArrayToString($ProjectFolder_Move_Index_Array, '|', 1)
                GUICtrlSetData($List1, $ProjectFolder_Move_Index_String, $ProjectFolder_Move_Index_Array)
        EndIf
EndFunc   ;==>Folder_Move_List

Func Folder_Now_List()
        GUICtrlSetData($List2, "")
        $ProjectFolder_Now_Index_Array = myFileListToArray_DirSort($ProjectFolder_Now)
        If $ProjectFolder_Now_Index_Array <> 0 Then
                $ProjectFolder_Now_Index_String = _ArrayToString($ProjectFolder_Now_Index_Array, '|', 1)
                $ProjectFolder_Now_Index_String_A = StringReplace($ProjectFolder_Now_Index_String, $ProjectFolder_Now, ".\")
                GUICtrlSetData($List2, $ProjectFolder_Now_Index_String_A)
        EndIf
EndFunc   ;==>Folder_Now_List

Func Folder_Archive_List()
        GUICtrlSetData($Combo1, "")
        $ProjectFolder_Archive_Index_Array = _FileListToArray($ProjectFolder_Archive, '*.7z', 1)
        If $ProjectFolder_Archive_Index_Array <> 0 Then
                $ProjectFolder_Archive_Index_String = _ArrayToString($ProjectFolder_Archive_Index_Array, '|', 1)
                GUICtrlSetData($Combo1, $ProjectFolder_Archive_Index_String, $ProjectFolder_Archive_Index_Array)
        EndIf
EndFunc   ;==>Folder_Archive_List

Func Folder_Project_List()
        GUICtrlSetData($List3, "")
        $ProjectFolder_Project_Index_Array = _FileListToArray($ProjectFolder_Project, '*', 2)
        If $ProjectFolder_Project_Index_Array <> 0 Then
                $ProjectFolder_Project_Index_String = _ArrayToString($ProjectFolder_Project_Index_Array, '|', 1)
                GUICtrlSetData($List3, $ProjectFolder_Project_Index_String, $ProjectFolder_Project_Index_Array)
        EndIf
EndFunc   ;==>Folder_Project_List

Func MoveTo($depict)
        Tpp("正在处理")
        $d = $depict

        FileDelete($ProjectFolder_Now & "\*.FolderDepict")
        FileWrite($ProjectFolder_Now & "\" & $d & ".FolderDepict", "")

        $f = $ProjectFolder_Move & $data & '-' & $d & '\'
        DirCopy($ProjectFolder_Now, $f, 1)
        DirCreate($ProjectFolder_Now)
        Tff()
EndFunc   ;==>MoveTo

Func MoveBack($f)
        Tpp("正在处理")
        DirRemove($ProjectFolder_Now, 1)
        $f = $ProjectFolder_Move & $f & '\'
        DirCopy($f, $ProjectFolder_Now, 1)
        Tff()
EndFunc   ;==>MoveBack

Func UnArchive($isAll = 0)
        Tpp("正在处理")
        $_7z = GUICtrlRead($Combo1)
        $_7zReal = $ProjectFolder_Archive & $_7z
        $_7zNoExt = StringReplace($_7z, '.7z', '')
        If $_7z <> "" Then
                Un7z($_7zReal, $ProjectFolder_Move, $_7zNoExt & '\*')
                If $isAll = 1 Then Un7z_x($_7zReal, $ProjectFolder_Project & '\', $_7zNoExt & '')
        EndIf
        Tff()
EndFunc   ;==>UnArchive

Func AddArchive($isAll = 0)
        Tpp("正在处理")
        $_TergetName = GUICtrlRead($List1)
        Add7z($_TergetName, $ProjectFolder_Move & $_TergetName & '\')
        If ($isAll = 1) Then
                $_TergetProjectName = GUICtrlRead($List3)
                Add7z($_TergetName, $ProjectFolder_Project & $_TergetProjectName & '\')
        EndIf
        Tff()
EndFunc   ;==>AddArchive

Func Add7z($Name, $Folder)
        $t = $Folder
        $f = $ProjectFolder_Archive & $Name & '.7z'
        $c = '"' & $7zexe & '" a "' & $f & '" "' & $t & '"';
        RunWait($c, $7zFolder)
EndFunc   ;==>Add7z

Func Un7z($7zFile, $unFolder, $unTarget = '')
        $c = '"' & $7zexe & '" x "' & $7zFile & '" -o"' & $unFolder & '" "' & $unTarget & '"'
        RunWait($c, $7zFolder)
EndFunc   ;==>Un7z

Func Un7z_x($7zFile, $unFolder, $unTarget = '')
        $c = '"' & $7zexe & '" x "' & $7zFile & '" -o"' & $unFolder & '" -x!"' & $unTarget & '"'
        RunWait($c, $7zFolder)
EndFunc   ;==>Un7z_x

Func FolderDel($List)
        $a = MsgBox(1, $SoftTitle, '确认删除')
        If $a = 1 Then

                If $List = 1 Then
                        $_tFolder = GUICtrlRead($List1)
                        $f = $ProjectFolder_Move & $_tFolder & '\'
                Else
                        $_tFolder = GUICtrlRead($List3)
                        $f = $ProjectFolder_Project & $_tFolder & '\'
                EndIf

                DirRemove($f, 1)
        EndIf
EndFunc   ;==>FolderDel

Func _FindFolderDepict($Folder)
        ; 显示当前目录中所有文件的文件名
        $search = FileFindFirstFile($Folder & "*.FolderDepict")

        ; 检查搜索是否成功
        If $search = -1 Then
                Return "unknow"
        EndIf

        While 1
                $file = FileFindNextFile($search)
                If @error Then
                        ExitLoop
                EndIf

                If $file <> 1 Then
                        $file = StringReplace($file, ".FolderDepict", "")
                        Return $file
                EndIf
        WEnd

        ; 关闭搜索句柄
        FileClose($search)
EndFunc   ;==>_FindFolderDepict

Func _UIHIDE()
        GUISetState(@SW_HIDE, $Form)
EndFunc   ;==>_UIHIDE

Func _UISHOW()
        GUISetState(@SW_SHOW, $Form)
EndFunc   ;==>_UISHOW

Func Tpp($text)
        ToolTip($text, 50, 50, $SoftTitle, 1)
EndFunc   ;==>Tpp

Func Tff()
        ToolTip('处理完成', 50, 50, $SoftTitle, 1)
        Sleep(800)
        ToolTip("")
EndFunc   ;==>Tff

;界面
Func PngLoad($file, $x, $y)
        _GDIPlus_Startup()
        $pngx = $x
        $pngy = $y
        $hImage = _GDIPlus_ImageLoadFromFile($file)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form)
        GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
EndFunc   ;==>PngLoad

Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
        _WinAPI_RedrawWindow($Form, 0, 0, $RDW_UPDATENOW)
        _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, $pngx, $pngy)
        _WinAPI_RedrawWindow($Form, 0, 0, $RDW_VALIDATE)
        Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_PAINT

Func DwmDrawForm($Form)
        $top = 65
        If DwmIsCompositionEnabled() Then
                $tagMARGINSlphaKey = 0
                GUICtrlCreateGraphic(0, 0, 9999, $top)
                GUICtrlSetState(-1, $GUI_DISABLE)
                GUICtrlSetBkColor(-1, $tagMARGINSlphaKey)
                $MARGINS = DllStructCreate("int;int;int;int")
                DllStructSetData($MARGINS, 1, 0)
                DllStructSetData($MARGINS, 2, 0)
                DllStructSetData($MARGINS, 3, $top)
                DllStructSetData($MARGINS, 4, 0)
                _WinAPI_DwmExtendFrameIntoClientArea($Form, $MARGINS)
        Else
                ;MsgBox(0, $_Title, "没启用Aero不会看到透明效果")
                ;Exit
        EndIf
EndFunc   ;==>DwmDrawForm

Func DwmIsCompositionEnabled()
        $Struct = DllStructCreate("int")
        $result = DllCall("dwmapi.dll", "bool", "DwmIsCompositionEnabled", _
                        "ptr", DllStructGetPtr($Struct))
        Return DllStructGetData($Struct, 1)
EndFunc   ;==>DwmIsCompositionEnabled

Func ReadIni($a, $b, $c)
        Return IniRead(@ScriptDir & "\Set.ini", $a, $b, $c)
EndFunc   ;==>ReadIni

Func SetIni($a, $b, $c)
        $z = IniWrite(@ScriptDir & "\Set.ini", $a, $b, $c)
        If $z = 0 Then MsgBox(0, $SoftTitle, $z)
        _AppStart()
EndFunc   ;==>SetIni

kvisof 发表于 2011-5-2 13:47:40

厉害!!!请多多指教...

cxm23 发表于 2011-5-2 15:06:45


xp没效果,要WIN7 ?

这个程序是干啥用的?

wsfda 发表于 2011-5-2 16:30:24

严重的顶一把先...

wanghong01 发表于 2011-5-2 17:33:53

这个很好看的说

水木子 发表于 2011-5-2 18:07:21

缺少 fileListToArray.au3 库文件?

非典男人 发表于 2011-5-2 18:10:12

哥们 缺少 fileListToArray.au3 文件呀

chenronting 发表于 2011-5-2 20:19:41

哈, 是相当好看,只可惜没用WIN7

cbao123 发表于 2011-5-2 22:43:59

楼主绝顶牛人也!

devil3380 发表于 2011-5-3 11:04:15

看界面 真是漂亮的啊

dgnanhua 发表于 2011-5-3 13:09:18

看起业相当历害呵

cxm23 发表于 2011-5-3 14:44:21

{:face (382):}
什么皮肤?

mo_shaojie 发表于 2011-5-3 16:43:01

缺少几个文件,等于是无用产品.

kinghu318 发表于 2011-5-3 17:52:28

得通用才好。。。界面真的很好看

duyan 发表于 2011-5-3 21:24:08

居然有源码,太感谢了
页: [1] 2 3 4
查看完整版本: Aero 界面展示 - SiteManage