Enumeration
#Window_0
#image
#next
#open
#Ima
#File_path
#List
#min
#oma
#text
#text2
#avto
#ico
#tray
#menu
#Fr_3D
EndEnumeration
UsePNGImageDecoder()
UseJPEGImageDecoder()
Global Rep.s, NbSongs, File.s, Nasd.s, SongPlaying, Wal.s, rez
Procedure Direct() ; сканирование папки
NbSongs = 0
SetGadgetText(#File_path, GetPathPart(Rep))
ClearGadgetItems(#List)
If ExamineDirectory(0, GetPathPart(Rep), "*.*")
Repeat
FileType = NextDirectoryEntry(0)
If FileType
FileName.s = DirectoryEntryName(0)
If FileName.s <> "." And FileName.s <> ".."
Ext$ = LCase(Right(FileName.s,4))
If Ext$ = ".png" Or Ext$ = ".jpg" Or Ext$ = ".jpg"
AddGadgetItem(#List, -1, FileName.s)
NbSongs = NbSongs + 1
EndIf
EndIf
EndIf
SetGadgetState(#List, SongPlaying )
Until FileType = 0
EndIf
EndProcedure
Procedure wallpaper() ; смена обоев
File.s = GetGadgetText(#File_path)+GetGadgetText(#List) ; получаем путь из суммы директории и имени с плей листа
LoadImage(#oma, File.s)
x_min.f=ImageWidth (#oma) ; ширина картинки
y_min.f=ImageHeight(#oma) ; высота картинки
rez_min=(160/x_min)*y_min
SetGadgetState(#min, ResizeImage(#oma, 160, rez_min) )
x.f= GetSystemMetrics_(#SM_CXSCREEN) ; ширина монитора
y.f=GetSystemMetrics_(#SM_CYSCREEN) ; высота монитора
LoadImage(#Ima, File.s)
x_im.f=ImageWidth (#Ima) ; ширина картинки
y_im.f=ImageHeight(#Ima) ; высота картинки
rez=(x/x_im)*y_im
If x_min.f< x.f
If CreateImage(#image, x, rez)
StartDrawing(ImageOutput(#image))
DrawImage(ImageID(#Ima), 0, 0, x, rez)
StopDrawing()
#file = "oooo.bmp"
SaveImage(#image, #file, #PB_ImagePlugin_BMP)
SystemParametersInfo_(#SPI_SETDESKWALLPAPER, 0, #file, #SPIF_UPDATEINIFILE)
EndIf
Else
SystemParametersInfo_(#SPI_SETDESKWALLPAPER, 0, File.s, #SPIF_UPDATEINIFILE)
EndIf
; DeleteFile("oooo.bmp")
EndProcedure
Procedure Avto() ; авто просмотр
If GetGadgetState(#avto) And Rep <> ""
SongPlaying = GetGadgetState(#List)+ 1
If SongPlaying < NbSongs
SetGadgetState(#List, SongPlaying )
EndIf
wallpaper()
EndIf
EndProcedure
Procedure Min() ; миниатюра
File.s = GetGadgetText(#File_path)+GetGadgetText(#List) ; получаем путь из суммы директории и имени с плей листа
Debug File.s
If File <> ""
LoadImage(#oma, File.s)
x_min.f=ImageWidth (#oma) ; ширина картинки
y_min.f=ImageHeight(#oma) ; высота картинки
rez_min=(160/x_min)*y_min
SetGadgetState(#min, ResizeImage(#oma, 160, rez_min) )
SetGadgetText(#text2, Str(x_min)+ " x "+ Str(y_min))
ResizeGadget(#Fr_3D, 195, 30, 170, rez_min+15)
EndIf
EndProcedure
CatchImage(#min,?Im1, ?Im1End -?Im1 )
CatchImage(#ico,?Im2, ?Im2End -?Im2 )
If OpenWindow (#Window_0,0,0,380,210,"Смена обоев рабочего стола",#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) ;|#PB_Window_Invisible #PB_Window_MinimizeGadget|
ButtonGadget(#next,210,5,80,20,"Следующий")
ButtonGadget(#open, 50,5,80,20,"Открыть")
ListViewGadget(#List, 10, 30, 170, 170)
Frame3DGadget(#Fr_3D, 195, 30, 170, 115, "")
ImageGadget(#min,200,40,160,100,ImageID(#min))
TextGadget(#text, 200,170,160,15,"Предварительный просмотор")
TextGadget(#text2,200,190,160,15,"",#PB_Text_Center)
CheckBoxGadget(#avto,320,5,40,20,"Авто")
SetGadgetState(#avto, 0)
TextGadget(#File_path,0,0,0,0,"Путь")
;------------Чтение пути-----------------------------
If OpenPreferences("wolp.pcs")
Rep.s = ReadPreferenceString("Путь", "Нет")
Poz.s = ReadPreferenceString("Позиция", "Нет")
Wal.s = ReadPreferenceString("Обои", "Нет")
ClosePreferences()
EndIf
SongPlaying = Val(Poz.s)
Direct()
Min()
wallpaper()
;----------------------------------------------------
If CreatePopupMenu(#menu)
MenuItem(0, "Скрыть")
MenuBar()
;MenuItem(1, "Показать")
MenuItem(2, "Выход")
EndIf
AddSysTrayIcon(#tray, WindowID(#Window_0), ImageID(#ico))
SetTimer_(WindowID(#Window_0),Event,10000,@Avto())
EndIf
Repeat
Event = WaitWindowEvent()
Window = EventWindow()
Gadget = EventGadget()
mx.l = WindowMouseX(#Window_0) ; координаты x
my.l = WindowMouseY(#Window_0) ; координаты y
If ((mx > 200 And mx < 360) And (my > 40 And my < 140))
SetCursor_(LoadCursor_(0,#IDC_HAND)) ; курсор рука
EndIf
Select Event
Case #PB_Event_SysTray
Select EventType()
Case #PB_EventType_LeftClick
HideWindow(#Window_0,0)
Case #PB_EventType_RightClick
DisplayPopupMenu(#menu, WindowID(#Window_0))
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 0
HideWindow(#Window_0,1)
Case 1
;HideWindow(#Window_0,0)
Case 2
Event = #PB_Event_CloseWindow
EndSelect
Case #WM_LBUTTONDBLCLK ; обработка события на двойной клик
If Gadget = #List Or Gadget = #min
; SetCursor_(LoadCursor_(0,#IDC_HAND)) ; курсор рука
File.s = GetGadgetText(#File_path)+GetGadgetText(#List)
Wal.s = File.s
wallpaper()
EndIf
Case #PB_Event_Gadget
Select EventGadget()
Case #next
If Rep <> ""
SongPlaying = GetGadgetState(#List)+ 1
If SongPlaying < NbSongs
SetGadgetState(#List, SongPlaying )
EndIf
wallpaper()
EndIf
Case #open
Rep.s = OpenFileRequester("","","*.*|*.*",0)
Direct()
;---Совпадение списка и открыт. картинки-------------------
Nasd.s= GetFilePart(Rep.s) ; извлекаем имя
For n=0 To 1000
SetGadgetState(#List, n)
If Nasd.s =GetGadgetText(#List)
SetGadgetState(#List, n)
Break
EndIf
Next
Min()
Case #List
Min()
EndSelect
EndSelect
Select message
Case #WM_KEYDOWN
If Rep <> ""
SongPlaying = GetGadgetState(#List)+ 1
If SongPlaying < NbSongs
SetGadgetState(#List, SongPlaying )
EndIf
wallpaper()
EndIf
EndSelect
If Event = #PB_Event_CloseWindow
;{----Запись параметров перед выходом-----------
OpenPreferences("wolp.pcs")
WritePreferenceString("Путь",File.s)
WritePreferenceString("Позиция",Str(GetGadgetState(#List)))
WritePreferenceString("Обои",Wal.s)
ClosePreferences()
;}---------------------------------------------
Break
EndIf
ForEver
DataSection
Im1:
IncludeBinary "wal.png"
Im1End:
Im2:
IncludeBinary "иконка.ico"
Im2End:
EndDataSection