Procedure CreateTorrentCB(File.s, Pos.f) Static Old_File.s, Old_Pos Protected Count, Temp If Old_File <> File Old_File = File If Len(File) > 40 Count = CountString(File, "\") If Count > 2 Temp=FindString(File, "\", 1) If Temp > 0 Temp = FindString(File, "\", Temp+1) If Temp > 0 File.s = Left(File, Temp)+"...\"+GetFilePart(File) EndIf EndIf EndIf EndIf If IsGadget(#CreateTorrent_CurrentFile) SetGadgetText(#CreateTorrent_CurrentFile, File) EndIf EndIf If Round(Pos,#PB_Round_Down) <> Old_Pos Old_Pos = Pos ;Round(Pos,#PB_Round_Up) If IsGadget(#CreateTorrent_ProgressBar) SetGadgetState(#CreateTorrent_ProgressBar, Old_Pos) EndIf EndIf EndProcedure Procedure Open_CreateTorrent_Win(*x) Protected Event, Path.s, String.s, Dir.s Protected Torrent.TorrentFiles_CreateInfo Protected Temp, i, S_Temp.s, ActiveGadget If OpenWindow(#CreateTorrent_Win, 277, 288, 384, 374, "Создание торрента.", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_WindowCentered | #PB_Window_Invisible, WindowID(#MainWin)) TextGadget(#CreateTorrent_Text_0, 10, 10, 200, 15, "Путь к файлам:") OptionGadget(#CreateTorrent_Radio_File, 220, 10, 65, 15, "Файл") OptionGadget(#CreateTorrent_Radio_Dir, 295, 10, 75, 15, "Папка") StringGadget(#CreateTorrent_String_Path, 10, 30, 335, 20, "", #PB_String_ReadOnly) ButtonGadget(#CreateTorrent_Button_Path, 350, 30, 30, 20, "...") TextGadget(#CreateTorrent_Text_5, 10, 65, 335, 15, "Торрент файл:") StringGadget(#CreateTorrent_String_TorrentFile, 10, 85, 335, 20, "", #PB_String_ReadOnly) ButtonGadget(#CreateTorrent_Button_TorrentFile, 350, 85, 30, 20, "...") CompilerIf #PB_Compiler_Version<520 Frame3DGadget(#CreateTorrent_Frame3D_0, 15, 120, 355, 205, "Свойства торрента") CompilerElse FrameGadget(#CreateTorrent_Frame3D_0, 15, 120, 355, 205, "Свойства торрента") CompilerEndIf TextGadget(#CreateTorrent_Text_1, 25, 140, 335, 15, "Трекеры:") StringGadget(#CreateTorrent_String_Tracker, 25, 160, 335, 74, "", #ES_MULTILINE|#WS_VSCROLL|#ES_AUTOVSCROLL) TextGadget(#CreateTorrent_Text_2, 25, 245, 330, 15, "Комментарий:") StringGadget(#CreateTorrent_String_Comment, 25, 265, 335, 20, "") TextGadget(#CreateTorrent_Text_3, 165, 300, 110, 15, "Размер частей:", #PB_Text_Right) CheckBoxGadget(#CreateTorrent_CheckBox_Private, 25, 300, 120, 15, "Частный торрент") ComboBoxGadget(#CreateTorrent_Combo_Piece, 280, 295, 80, 22) ProgressBarGadget(#CreateTorrent_ProgressBar, 15, 350, 265, 15, 0, 100, #PB_ProgressBar_Smooth) ButtonGadget(#CreateTorrent_Button_Start, 295, 340, 75, 25, "Создать") TextGadget(#CreateTorrent_CurrentFile, 15, 335, 265, 15, "") SetWindowLongPtr_(GadgetID(#CreateTorrent_CurrentFile),#GWL_STYLE, GetWindowLongPtr_(GadgetID(#CreateTorrent_CurrentFile),#GWL_STYLE)|#SS_LEFTNOWORDWRAP) SetGadgetState(#CreateTorrent_Radio_File, 1) AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "Авто") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "16 КБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "32 КБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "64 КБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "128 КБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "256 КБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "512 КБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "1 МБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "2 МБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "4 МБ") AddGadgetItem(#CreateTorrent_Combo_Piece, -1, "8 МБ") SetGadgetState(#CreateTorrent_Combo_Piece, 0) SendMessage_(WindowID(#CreateTorrent_Win),#WM_SETICON,#False,ImageID(#MainWin_ToolBar_Icon_CreateTorrent)) SetActiveGadget(#CreateTorrent_Radio_File) SendMessage_(WindowID(#CreateTorrent_Win), #WM_UPDATEUISTATE, $30002,0) HideWindow(#CreateTorrent_Win, 0) Thread_ID = 0 Repeat Event = WaitWindowEvent() If Event = #PB_Event_Gadget And Thread_ID=0 Select EventGadget() Case #CreateTorrent_Button_Path If FileSize(G_ProgramMiscInfo\Setting\TorrentDirPath)= -2 Dir = G_ProgramMiscInfo\Setting\TorrentDirPath Else Dir = "" EndIf If GetGadgetState(#CreateTorrent_Radio_File) ; Файл Path = OpenFileRequester("",Dir,"Все файлы|*.*",0) If Path<>"" And FileSize(Path)>0 SetGadgetText(#CreateTorrent_String_Path, Path) Path = GetPathPart(Path) If Path<>"" And FileSize(Path)= -2 G_ProgramMiscInfo\Setting\TorrentDirPath = Path EndIf EndIf Else ; Папка Path = PathRequester("Укажите путь к папке с файлами торрента.",Dir) If Path<>"" And FileSize(Path)= -2 SetGadgetText(#CreateTorrent_String_Path, Path) G_ProgramMiscInfo\Setting\TorrentDirPath = Path EndIf EndIf Case #CreateTorrent_Button_TorrentFile If FileSize(G_ProgramMiscInfo\Setting\TorrentFilePath)= -2 Dir = G_ProgramMiscInfo\Setting\TorrentFilePath Else Dir = "" EndIf Path = SaveFileRequester("",Dir,"Торрент-файлы (*.torrent)|*.torrent|Все файлы|*.*",0) If Path<>"" And SelectedFilePattern()>-1 If SelectedFilePattern() = 0 And GetExtensionPart(Path)="" : Path+".torrent" : EndIf SetGadgetText(#CreateTorrent_String_TorrentFile, Path) Path = GetPathPart(Path) If Path<>"" And FileSize(Path)= -2 G_ProgramMiscInfo\Setting\TorrentFilePath = Path EndIf EndIf Case #CreateTorrent_Radio_File, #CreateTorrent_Radio_Dir SetGadgetText(#CreateTorrent_String_Path, "") Case #CreateTorrent_Button_Start SetGadgetState(#CreateTorrent_ProgressBar, 0) ClearStructure(@Torrent, TorrentFiles_CreateInfo) NewList Torrent\announce() Torrent\Path = GetGadgetText(#CreateTorrent_String_Path) Torrent\FileName = GetGadgetText(#CreateTorrent_String_TorrentFile) If Torrent\Path<>"" And Torrent\FileName<>"" String=GetGadgetText(#CreateTorrent_String_Tracker) If String<>"" String = ReplaceString(String, Chr(13), Chr(10)) String = ReplaceString(String, Chr(10)+Chr(10), Chr(10)) If String<>"" String + Chr(10) Temp = CountString(String, Chr(10)) For i=1 To Temp S_Temp = StringField(String, i, Chr(10)) If S_Temp<>"" S_Temp=Trim(S_Temp) S_Temp=RemoveString(S_Temp, Chr(9)) If S_Temp<>"" If AddElement(Torrent\announce()) Torrent\announce() = S_Temp Else MessageRequester(#MessageName+" - создание торрента.", "Ошибка выделения памяти!", #MB_OK|#MB_ICONERROR) Break EndIf EndIf EndIf Next i EndIf EndIf String="" : S_Temp="" Torrent\BreakThread = 0 ; Признак того, что не нужно прерывать создание торрент-файла. Torrent\ClientName = #ProgName+"__"+#ProgVersion Torrent\comment = GetGadgetText(#CreateTorrent_String_Comment) Torrent\Directory = GetGadgetState(#CreateTorrent_Radio_Dir) & 1 Torrent\ErrorCode = 0 Torrent\ErrorString = "" Torrent\Result = 0 Temp = GetGadgetState(#CreateTorrent_Combo_Piece) If Temp>0 And Temp<12 Torrent\pieceLength = 16384 << (Temp-1) Else Torrent\pieceLength = 0 EndIf Torrent\PiecesCB = @CreateTorrentCB() Torrent\private = GetGadgetState(#CreateTorrent_CheckBox_Private) & 1 Torrent\ProgName = #MessageName+" - создание торрента." Thread_ID = CreateThread(@TorrentFiles_CreateTorrent(), @Torrent) If Thread_ID AddWindowTimer(#CreateTorrent_Win, #CreateTorrent_Timer, 400) Else MessageRequester(#MessageName+" - создание торрента.", "Ошибка при создании потока.", #MB_OK|#MB_ICONWARNING) EndIf Else MessageRequester(#MessageName+" - создание торрента.", "Укажите путь к файлам.", #MB_OK|#MB_ICONWARNING) EndIf EndSelect ElseIf Event = #PB_Event_CloseWindow If Thread_ID <> 0 And IsThread(Thread_ID) If MessageRequester(#MessageName+" - создание торрента.", "Торрент файл в процессе создания."+Chr(10)+"Прервать?", #MB_YESNO|#MB_ICONQUESTION|#MB_DEFBUTTON2) = #IDYES Torrent\BreakThread = 1 ; Прерываем создание файла. RemoveWindowTimer(#CreateTorrent_Win, #CreateTorrent_Timer) For i=1 To 100 Delay(100) WindowEvent() If IsThread(Thread_ID)=0 Break EndIf Next i If IsThread(Thread_ID) KillThread(Thread_ID) EndIf Thread_ID = 0 If FileSize(Torrent\FileName)>=0 DeleteFile(Torrent\FileName) EndIf SetGadgetText(#CreateTorrent_CurrentFile, "") SetGadgetState(#CreateTorrent_ProgressBar, 0) MessageRequester(#MessageName+" - создание торрента.", "Торрент файл не был создан - прервано по запросу пользователя.", #MB_OK|#MB_ICONWARNING) EndIf Else Break EndIf ElseIf Event = #PB_Event_Timer If EventTimer() = #CreateTorrent_Timer If IsThread(Thread_ID) = 0 ; Поток завершился. RemoveWindowTimer(#CreateTorrent_Win, #CreateTorrent_Timer) Thread_ID = 0 If Torrent\Result = 1 And Torrent\ErrorCode=0 MessageRequester(#MessageName+" - создание торрента.", "Торрент-файл успешно создан.", #MB_OK|#MB_ICONINFORMATION) ElseIf Torrent\ErrorCode>0 TorrentFiles_CreateTorrent_ShowError(Torrent\ErrorCode, Torrent\ErrorString, #MessageName) EndIf EndIf EndIf ElseIf Event = #WM_KEYDOWN ActiveGadget = GetActiveGadget() If ActiveGadget = #CreateTorrent_Radio_File If EventwParam() = 39 SetGadgetState(#CreateTorrent_Radio_Dir, #True) SetActiveGadget(#CreateTorrent_Radio_Dir) SetGadgetText(#CreateTorrent_String_Path, "") EndIf ElseIf ActiveGadget = #CreateTorrent_Radio_Dir If EventwParam() = 37 SetGadgetState(#CreateTorrent_Radio_File, #True) SetActiveGadget(#CreateTorrent_Radio_File) SetGadgetText(#CreateTorrent_String_Path, "") EndIf EndIf EndIf ForEver CloseWindow(#CreateTorrent_Win) Else MessageRequester(#MessageName, "Ошибка при создании окна", #MB_OK|#MB_ICONWARNING) EndIf EndProcedure Procedure Open_LoadTorrent_Win(*x.String) Protected Window, Event, Torrent_FileSize.q Protected StringGadget_Path, ButtonGadget_Path Protected CheckBoxGadget_StartTorrent, CheckBoxGadget_NoHash Protected ComboBoxGadget_Label, TreeGadget_File Protected ButtonGadget_AllFile, ButtonGadget_NoFile Protected TextGadget_Date, TextGadget_Size Protected TextGadget_Name, TextGadget_Comment Protected ButtonGadget_OK, ButtonGadget_Cancel Protected FileName.s, Torrent.TorrentFiles_TorrentInfo Protected TorrentState, String.s, x, TorrentName.s Protected WinName.s, GMT, tzi.TIME_ZONE_INFORMATION Protected NewList Label.s(), lpFreeBytesAvailable.q Protected *Mem, y = 0 , *DataTorrentFile, DataTorrent_Size.l Protected Pos = 0, ErrMutex.Ascii Protected WinPopup, WP_ProgressBar, WP_Button, WP_Text TorrentState = 0 DataTorrent_Size = 0 *DataTorrentFile = 0 If *x = 0 : ProcedureReturn : EndIf FileName = *x\s ;PeekS() ClearStructure(*x, String) FreeMemory(*x) *x=0 If FileSize(FileName)<=0 : ProcedureReturn : EndIf If TorrentFiles_LoadTorrentFile(FileName, @Torrent, @*DataTorrentFile, @DataTorrent_Size) <> #True TorrentFiles_LoadTorrentFile_ShowEror(Torrent\ErrorCode, Torrent\ErrorString, #MessageName) ProcedureReturn EndIf If *DataTorrentFile = 0 MessageRequester(#MessageName, "Ошибка при доступе к торрент-файлу!"+Chr(10)+FileName, #MB_OK|#MB_ICONWARNING) ProcedureReturn EndIf If Torrent\TypeDir = #True WinName = Torrent\CurrentDir_Name Else SelectElement(Torrent\files(),0) WinName = Torrent\files()\path() EndIf If WinName<>"" : WinName+" - " : EndIf LockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) ; Проверяем обрабатывается ли торрент программой, т. е. открыт ли он сейчас. If ListSize(G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList())>0 String=LCase(Torrent\INFO_Hash) ForEach G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() If LCase(G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList()) = String UnlockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) MessageRequester(WinName+"добавление торрента.", "Выбранный торрент-файл уже обрабатывается программой!", #MB_OK|#MB_ICONWARNING) If *DataTorrentFile FreeMemory(*DataTorrentFile) *DataTorrentFile = 0 EndIf ProcedureReturn EndIf Next EndIf AddElement(G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList()) G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() = Torrent\INFO_Hash UnlockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) LockMutex(G_TorrentList\Mutex) ; Проверяем, есть ли этот торрент в списке торрентов программмы. If ListSize(G_TorrentList\TorrentList())>0 String=LCase(Torrent\INFO_Hash) ForEach G_TorrentList\TorrentList() If LCase(G_TorrentList\TorrentList()\TorrentFile\INFO_Hash) = String UnlockMutex(G_TorrentList\Mutex) If MessageRequester(WinName+"добавление торрента.", "Торрент уже зарегистрирован в программе."+Chr(10)+"Добавить список трекеров?", #MB_YESNO|#MB_ICONQUESTION) = #IDYES ; Здесь должен быть код добавления списка трекеров в торрент. Torrent_AddTrackerList(String, @Torrent) EndIf LockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) ; Удаляем информацию об обработке прораммой файла торрента. ForEach G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() If G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() = Torrent\INFO_Hash DeleteElement(G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList()) Break EndIf Next UnlockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) If *DataTorrentFile FreeMemory(*DataTorrentFile) *DataTorrentFile = 0 EndIf ProcedureReturn EndIf Next EndIf UnlockMutex(G_TorrentList\Mutex) TorrentName ="" If Torrent\TypeDir = #True ; Торрент в папке. WinName = Torrent\CurrentDir_Name TorrentName = WinName If WinName<>"" : WinName+" - " : EndIf SizeList = ListSize(Torrent\files()) If SizeList>200 If MessageRequester(WinName+"добавление торрента.", "В торренте много файлов ("+Str(SizeList)+") и их обработка может занять продолжительное время."+Chr(10)+"Продолжить?", #MB_YESNO|#MB_ICONQUESTION|#MB_DEFBUTTON2) = #IDNO LockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) ForEach G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() If G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() = Torrent\INFO_Hash DeleteElement(G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList()) Break EndIf Next UnlockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) If *DataTorrentFile FreeMemory(*DataTorrentFile) *DataTorrentFile = 0 EndIf ProcedureReturn Else DisableDebugger WinPopup = OpenWindow(#PB_Any, 0, 0, 370, 50, "добавление торрента.", #PB_Window_SystemMenu|#PB_Window_TitleBar | #PB_Window_WindowCentered, WindowID(#MainWin)) EnableDebugger If WinPopup WP_Text = TextGadget(#PB_Any, 10, 4, 350, 16, "Обработка торрента - "+Chr(34)+Torrent\CurrentDir_Name+Chr(34), #SS_LEFTNOWORDWRAP) WP_ProgressBar = ProgressBarGadget(#PB_Any, 10,24, 270, 16, 0, SizeList, #PB_ProgressBar_Smooth) WP_Button = ButtonGadget(#PB_Any, 290, 20, 70, 22, "Отмена") EndIf EndIf EndIf Else ; Торрент в файле. SelectElement(Torrent\files(),0) WinName = Torrent\files()\path() TorrentName = WinName If WinName<>"" : WinName+" - " : EndIf EndIf DisableDebugger Window = OpenWindow(#PB_Any, 262, 198, 373, 388, WinName+"добавление торрента.", #PB_Window_SystemMenu | #PB_Window_Invisible | #PB_Window_TitleBar | #PB_Window_ScreenCentered);#PB_Window_WindowCentered, WindowID(#MainWin)) EnableDebugger If Window TextGadget(#PB_Any, 10, 10, 320, 15, "Путь к месту сохранения файлов:") StringGadget_Path = StringGadget(#PB_Any, 10, 25, 320, 20, "") ButtonGadget_Path = ButtonGadget(#PB_Any, 335, 24, 30, 22, "...") CheckBoxGadget_StartTorrent = CheckBoxGadget(#PB_Any, 10, 55, 135, 15, "Запустить торрент") CheckBoxGadget_NoHash = CheckBoxGadget(#PB_Any, 10, 75, 135, 15, "Без проверки хеша") TextGadget(#PB_Any, 144, 56, 70, 15, "Метка:", #PB_Text_Right) ComboBoxGadget_Label = ComboBoxGadget(#PB_Any, 220, 50, 110, 22, #PB_ComboBox_Editable) CompilerIf #PB_Compiler_Version<520 Frame3DGadget(#PB_Any, 20, 100, 335, 245, "Файлы торрента") CompilerElse FrameGadget(#PB_Any, 20, 100, 335, 245, "Файлы торрента") CompilerEndIf TreeGadget_File = TreeGadget(#PB_Any, 30, 120, 310, 125, #PB_Tree_AlwaysShowSelection) ;#PB_Tree_CheckBoxes| ButtonGadget_AllFile = ButtonGadget(#PB_Any, 260, 250, 85, 22, "Выбрать всё") : DisableGadget(ButtonGadget_AllFile, 1) ButtonGadget_NoFile = ButtonGadget(#PB_Any, 260, 274, 85, 22, "Снять отметки") : DisableGadget(ButtonGadget_NoFile, 1) TextGadget(#PB_Any, 30, 260, 70, 15, "Дата:") TextGadget_Date = TextGadget(#PB_Any, 105, 260, 150, 15, "", #SS_LEFTNOWORDWRAP) TextGadget(#PB_Any, 30, 280, 70, 15, "Размер:") TextGadget_Size = TextGadget(#PB_Any, 105, 280, 150, 15, ConvertByte_ToString(Torrent\All_Size, 3), #SS_LEFTNOWORDWRAP) TextGadget(#PB_Any, 30, 300, 70, 15, "Имя:") TextGadget_Name = TextGadget(#PB_Any, 105, 300, 240, 15, Torrent\CurrentDir_Name, #SS_LEFTNOWORDWRAP) TextGadget(#PB_Any, 30, 320, 70, 15, "Описание:") TextGadget_Comment = TextGadget(#PB_Any, 105, 320, 240, 15, Torrent\comment, #SS_LEFTNOWORDWRAP) ButtonGadget_OK = ButtonGadget(#PB_Any, 195, 355, 70, 24, "OK") ButtonGadget_Cancel = ButtonGadget(#PB_Any, 285, 355, 70, 24, "Отмена") SetGadgetColor(TextGadget_Date, #PB_Gadget_FrontColor, $C70238) SetGadgetColor(TextGadget_Size, #PB_Gadget_FrontColor, $C70238) SetGadgetColor(TextGadget_Name, #PB_Gadget_FrontColor, $C70238) SetGadgetColor(TextGadget_Comment, #PB_Gadget_FrontColor, $C70238) SetGadgetState(CheckBoxGadget_StartTorrent, 1) String = "" If FileSize(G_ProgramMiscInfo\Setting\TorrentSavePath)=-2 String = G_ProgramMiscInfo\Setting\TorrentSavePath Else If FileSize(G_ProgramMiscInfo\ProgFilePath + #DirTorrentFiles)=-2 String = G_ProgramMiscInfo\ProgFilePath + #DirTorrentFiles Else String = G_ProgramMiscInfo\ProgFilePath EndIf EndIf If Right(String,1)<>"\" : String+"\" : EndIf G_ProgramMiscInfo\Setting\TorrentSavePath = String If Torrent\TypeDir = #True ; Торрент в папке. If TorrentName<>"" If Len(String) TorrentName+"\" String + TorrentName EndIf EndIf If Right(String,1)<>"\" : String+"\" : EndIf Else ; Торрент в виде одного файла. String + TorrentName EndIf SetGadgetText(StringGadget_Path, String) If Torrent\creation_date>0 If GetTimeZoneInformation_(@tzi) = 2 ; значит время летнее GMT = tzi\Bias/(-60)+1 ; Например в Лондоне 12 часов, в Москве 15, разница tzi\Bias = 12-15 = -180 минут Else GMT = tzi\Bias/(-60) ; Иначе - стандартное время EndIf SetGadgetText(TextGadget_Date, FormatDate("%dd.%mm.%yyyy %hh:%ii", AddDate(Torrent\creation_date, #PB_Date_Hour,GMT))) EndIf If Torrent\TypeDir = #True ; Торрент в папке. ProgressPos = 0 ForEach Torrent\files() If WP_ProgressBar And IsGadget(WP_ProgressBar) SetGadgetState(WP_ProgressBar, ProgressPos) ProgressPos + 1 EndIf For x = 1 To 10 DisableDebugger Event = WindowEvent() EnableDebugger If (Event = #PB_Event_CloseWindow And EventWindow() = WinPopup) Or (Event = #PB_Event_Gadget And EventGadget() = WP_Button) If MessageRequester(WinName+"добавление торрента.", "Прервать обработку торрента"+Chr(10)+Chr(34)+Torrent\CurrentDir_Name+Chr(34)+"?", #MB_YESNO|#MB_ICONQUESTION|#MB_DEFBUTTON2) = #IDYES If WinPopup And IsWindow(WinPopup) CloseWindow(WinPopup) EndIf If Window And IsWindow(Window) CloseWindow(Window) EndIf LockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) ForEach G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() If G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() = Torrent\INFO_Hash DeleteElement(G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList()) Break EndIf Next UnlockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) If *DataTorrentFile FreeMemory(*DataTorrentFile) *DataTorrentFile = 0 EndIf ProcedureReturn EndIf EndIf Next x x=0 : y = 0 : Pos = 0 SizeList = ListSize(Torrent\files()\path()) - 1 If SizeList>=0 ForEach Torrent\files()\path() CountGadget = CountGadgetItems(TreeGadget_File)-1 String = Torrent\files()\path() If y = 0 For i=0 To CountGadget If GetGadgetItemAttribute(TreeGadget_File, i, #PB_Tree_SubLevel) = x If GetGadgetItemText(TreeGadget_File, i) = String ; Найдено в дереве. y=2 Pos = i Break EndIf EndIf Next i If y=2 y = 0 x+1 Continue ElseIf i>CountGadget y=1 EndIf EndIf If y = 1 Or CountGadget<0; Не найдено в гаджете. If SizeList=0 And x = 0 AddGadgetItem(TreeGadget_File, -1, String, GetIcon_Extension(GetExtensionPart(String)), x) Else If xCountGadget Or GetGadgetItemAttribute(TreeGadget_File, i, #PB_Tree_SubLevel) <> x AddGadgetItem(TreeGadget_File, i+x-1, String, GetIcon_Extension(GetExtensionPart(String)), x) Break EndIf Until i>CountGadget EndIf EndIf EndIf x + 1 Next EndIf Next If WinPopup And IsWindow(WinPopup) CloseWindow(WinPopup) WinPopup = 0 : WP_ProgressBar = 0 EndIf Else ; Торрент в виде одного файла. SelectElement(Torrent\files()\path(), 0) String = Torrent\files()\path() AddGadgetItem(TreeGadget_File, -1, String, GetIcon_Extension(GetExtensionPart(String)), 0) EndIf CountGadget = CountGadgetItems(TreeGadget_File)-1 For i=0 To CountGadget Flag = GetGadgetItemState(TreeGadget_File, i) Flag | #PB_Tree_Checked SetGadgetItemState(TreeGadget_File, i, Flag) Next i Copy_Label(Label()) ; Создание списка уникальных меток торрентов. ForEach Label() AddGadgetItem(ComboBoxGadget_Label, -1, Label()) Next SendMessage_(WindowID(Window),#WM_SETICON,#False,ImageID(#MainWin_ToolBar_Icon_AddTorrent)) HideWindow(Window, 0) SetActiveGadget(ButtonGadget_Path) SendMessage_(WindowID(Window), #WM_UPDATEUISTATE, $30002,0) TorrentState = 0 Repeat DisableDebugger Event = WaitWindowEvent() EnableDebugger If Event = #PB_Event_Gadget Gadget = EventGadget() Select Gadget Case ButtonGadget_Path If Torrent\TypeDir = #True ; Торрент в папке. String = PathRequester("Выберите место расположения файлов", G_ProgramMiscInfo\Setting\TorrentSavePath) If String<>"" If FileSize(String) = -2 G_ProgramMiscInfo\Setting\TorrentSavePath = String EndIf If Len(String) TorrentName+"\" String + TorrentName EndIf If Right(String,1)<>"\" : String+"\" : EndIf SetGadgetText(StringGadget_Path, String) EndIf Else ; Торрент в виде одного файла. String = SaveFileRequester("", GetGadgetText(StringGadget_Path), "Все файлы|*.*", 0) If String<>"" And SelectedFilePattern()>=0 SetGadgetText(StringGadget_Path, String) String = GetPathPart(String) If FileSize(String) = -2 G_ProgramMiscInfo\Setting\TorrentSavePath = String EndIf EndIf EndIf Case TreeGadget_File Type = EventType() If Type = #PB_EventType_Change ;Debug GetGadgetState(TreeGadget_File) EndIf Case ButtonGadget_AllFile, ButtonGadget_NoFile CountGadget = CountGadgetItems(TreeGadget_File)-1 For i=0 To CountGadget Flag = GetGadgetItemState(TreeGadget_File, i) If Gadget = ButtonGadget_AllFile Flag | #PB_Tree_Checked Else Flag & ~#PB_Tree_Checked EndIf SetGadgetItemState(TreeGadget_File, i, Flag) Next i Case ButtonGadget_OK String = GetGadgetText(StringGadget_Path) If String<>"" x=0 If Torrent\TypeDir = #True ;And String<>"" If Right(String,1)<>"\" : String+"\" : EndIf Pos = FindString(String, "\", 1) If Pos>0 If FindString(String, "\", Pos+1)>Pos+1 x=1 EndIf EndIf Else x=1 EndIf If x=1 x=0 Count = CountString(String, "\") For i=2 To Count TempS.s = StringField(String, i, "\") If CheckFilename(TempS) = 0 x = 1 EndIf Next i If x=0 And (Torrent\TypeDir = #True Or CheckFilename(GetFilePart(String)) <> 0) TempS = Left(String, 3) y = GetDriveType_(@TempS) If y=#DRIVE_CDROM MessageRequester(#MessageName+" "+WinName+"добавление торрента.", "На CD/DVD нельзя сохранять файлы!", #MB_OK|#MB_ICONWARNING) ElseIf y=#DRIVE_NO_ROOT_DIR MessageRequester(#MessageName+" "+WinName+"добавление торрента.", "Не найден диск!", #MB_OK|#MB_ICONWARNING) Else lpFreeBytesAvailable = 0 If GetDiskFreeSpaceEx_(@TempS, @lpFreeBytesAvailable,0,0) = 0 x=GetLastError_() TempS = "" If x *Mem = AllocateMemory(1024) If *Mem FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, x, 0, *Mem, 1024, 0) TempS = PeekS(*Mem) FreeMemory(*Mem) If TempS<>"" : TempS = Chr(10)+Chr(10)+TempS : EndIf EndIf EndIf MessageRequester(#MessageName+" "+WinName+"добавление торрента.", "Ошибка при определении свободного места на диске!"+TempS, #MB_OK|#MB_ICONERROR) Else Torrent_FileSize = Torrent\All_Size ; ВРЕМЕННО. На самом деле должен бть размер только тех файлов, которые были выбраны. If lpFreeBytesAvailable > Torrent_FileSize HideWindow(Window, 1) : ErrMutex\a = #False If Torrent_AddTorrent(String, GetGadgetText(ComboBoxGadget_Label), GetGadgetState(CheckBoxGadget_NoHash), GetGadgetState(CheckBoxGadget_StartTorrent), Torrent_FileSize, @Torrent, #MessageName+" "+WinName+"добавление торрента.", *DataTorrentFile, DataTorrent_Size, @ErrMutex)<>#True ; Добавление нового торрента в список. MessageRequester(#MessageName+" "+WinName+"добавление торрента.", "Произошла ошибка при добавлении торрента!", #MB_OK|#MB_ICONWARNING) EndIf If ErrMutex\a=#True And G_ProgramSetting\Misc\BalloonTray=#True ; Произошла ошибка и разрешены всплывающие подсказки над треем. SysTray_IconBalloon(#SysTrayID, WindowID(#MainWin), "Добавление торрента.", "Произошла ошибка при захвате мьютекса.", 20000, 3) EndIf Break Else TempS = "На выбранном диске недостаточно свободного места для всех файлов!"+Chr(10) TempS + "Требуется - "+ConvertByte_ToString(Torrent_FileSize, 3)+Chr(10) TempS + "Доступно - "+ConvertByte_ToString(lpFreeBytesAvailable, 3) MessageRequester(#MessageName+" "+WinName+"добавление торрента.", TempS, #MB_OK|#MB_ICONWARNING) EndIf EndIf EndIf Else MessageRequester(#MessageName+" "+WinName+"добавление торрента.", "В пути к файлам присутствуют запрещенные символы!", #MB_OK|#MB_ICONWARNING) EndIf Else MessageRequester(#MessageName+" "+WinName+"добавление торрента.", "Некорректный путь к папке!"+Chr(10)+"Выберите другую папку.", #MB_OK|#MB_ICONWARNING) EndIf Else MessageRequester(WinName+"добавление торрента.", "Не выбрана директория сохранения файлов торрента!", #MB_OK|#MB_ICONWARNING) EndIf Case ButtonGadget_Cancel TorrentState = 0 Break EndSelect EndIf Until Event = #PB_Event_CloseWindow And EventWindow() = Window CloseWindow(Window) Else MessageRequester(#MessageName+" "+WinName+"добавление торрента.", "Ошибка при создании окна", #MB_OK|#MB_ICONWARNING) EndIf If *DataTorrentFile FreeMemory(*DataTorrentFile) *DataTorrentFile = 0 EndIf LockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) ForEach G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() If G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList() = Torrent\INFO_Hash DeleteElement(G_ProgramMiscInfo\LoadTorrent\Hash_TorrentList()) Break EndIf Next UnlockMutex(G_ProgramMiscInfo\LoadTorrent\Mutex) EndProcedure Procedure Window_LabelTorrent_ComboBox_CB(hWnd, Msg, wParam, lParam) Protected *Proc *Proc = GetWindowLongPtr_(hWnd,#GWL_USERDATA) If (Msg = #WM_KEYDOWN Or Msg = #WM_KEYUP Or Msg = 258) And wParam=13 PostMessage_(WindowID(#Window_LabelTorrent), Msg, wParam, lParam) Msg = 0 : wParam = 0 : lParam = 0 EndIf ProcedureReturn CallWindowProc_(*Proc, hWnd, Msg, wParam, lParam) EndProcedure Procedure Window_LabelTorrent() Protected NewList Label.s() If OpenWindow(#Window_LabelTorrent, 0, 0, 269, 101, " Выбор метки торрента.", #PB_Window_SystemMenu | #PB_Window_Tool | #PB_Window_Invisible|#PB_Window_WindowCentered , WindowID(#MainWin)) TextGadget(#Window_LabelTorrent_Text, 10, 10, 250, 16, "Выберите метку для торрента.") x=ComboBoxGadget(#Window_LabelTorrent_ComboBox, 10, 30, 250, 22, #PB_ComboBox_Editable) ButtonGadget(#Window_LabelTorrent_Button_OK, 50, 65, 70, 24, "ОК", #PB_Button_Default) ButtonGadget(#Window_LabelTorrent_Button_Cancel, 145, 65, 70, 24, "Отмена") Copy_Label(Label()) ; Создание списка уникальных меток торрентов. ForEach Label() AddGadgetItem(#Window_LabelTorrent_ComboBox, -1, Label()) Next Table_ActiveItem_GetLabel(G_ProgramMiscInfo\Label()) If ListSize(G_ProgramMiscInfo\Label())>0 ForEach G_ProgramMiscInfo\Label() If G_ProgramMiscInfo\Label()\String_2<>"" SetGadgetText(#Window_LabelTorrent_ComboBox, G_ProgramMiscInfo\Label()\String_2) EndIf Next EndIf x=ChildWindowFromPoint_(x, 10|(10<<32)) SetWindowLongPtr_(x, #GWL_USERDATA, SetWindowLong_(x, #GWL_WNDPROC,@Window_LabelTorrent_ComboBox_CB())) SetActiveGadget(#Window_LabelTorrent_ComboBox) SendMessage_(WindowID(#Window_LabelTorrent), #WM_UPDATEUISTATE, $30002,0) HideWindow(#Window_LabelTorrent, #False) DisableWindow(#MainWin, #True) SetActiveWindow(#Window_LabelTorrent) EndIf EndProcedure Procedure Window_LabelTorrent_Event(Event) If Event = #PB_Event_CloseWindow Or (Event = #PB_Event_Gadget And EventGadget() = #Window_LabelTorrent_Button_Cancel) CloseWindow(#Window_LabelTorrent) DisableWindow(#MainWin, #False) ElseIf (Event = #PB_Event_Gadget And EventGadget() = #Window_LabelTorrent_Button_OK) Or (Event = #WM_KEYDOWN And EventwParam()=13) Table_ActiveItem_SetLabel(G_ProgramMiscInfo\Label(), GetGadgetText(#Window_LabelTorrent_ComboBox)) CloseWindow(#Window_LabelTorrent) DisableWindow(#MainWin, #False) EndIf EndProcedure Procedure Window_AddPeer_Create() If OpenWindow(#Window_AddPeer, 399, 240, 302, 89, "Добавление пира", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_WindowCentered, WindowID(#MainWin)) TextGadget(#PB_Any, 5, 20, 30, 15, "IP:", #PB_Text_Right) IPAddressGadget(#Window_AddPeer_IPAddress, 40, 15, 135, 20) TextGadget(#PB_Any, 185, 20, 55, 15, "Порт:", #PB_Text_Right) StringGadget(#Window_AddPeer_String_Port, 245, 15, 50, 20, "", #PB_String_Numeric) ButtonGadget(#Window_AddPeer_Button_OK, 75, 55, 70, 25, "OK") ButtonGadget(#Window_AddPeer_Button_Cancel, 170, 55, 70, 25, "Отмена") SendMessage_(GadgetID(#Window_AddPeer_String_Port), #EM_SETLIMITTEXT, 5, 0) DisableWindow(#MainWin, #True) EndIf EndProcedure Procedure Window_AddPeer_Event(Event) Protected AddIP.s, Port.l, x.b If Event = #PB_Event_CloseWindow Or (Event = #PB_Event_Gadget And EventGadget() = #Window_AddPeer_Button_Cancel) CloseWindow(#Window_AddPeer) DisableWindow(#MainWin, #False) G_TorrentList\Info\AddPeer_INFO_Hash="" ElseIf Event = #PB_Event_Gadget And EventGadget() = #Window_AddPeer_Button_OK If GetGadgetState(#Window_AddPeer_IPAddress)<>0 AddIP=GetGadgetText(#Window_AddPeer_IPAddress) Port = Val(GetGadgetText(#Window_AddPeer_String_Port)) If Port>0 And Port < 65536 x=#False If G_TorrentList\Info\AddPeer_INFO_Hash If Test_LockMutex(G_TorrentList\Mutex, 800) ForEach G_TorrentList\TorrentList() If G_TorrentList\TorrentList()\TorrentFile\INFO_Hash = G_TorrentList\Info\AddPeer_INFO_Hash ForEach G_TorrentList\TorrentList()\Network\PeerList() If G_TorrentList\TorrentList()\Network\PeerList()\IP$ = AddIP And G_TorrentList\TorrentList()\Network\PeerList()\Port = Port x=#True Break EndIf Next If x=#False If AddElement(G_TorrentList\TorrentList()\Network\PeerList()) G_TorrentList\TorrentList()\Network\PeerList()\Peer_id = "" G_TorrentList\TorrentList()\Network\PeerList()\IP$ = AddIP G_TorrentList\TorrentList()\Network\PeerList()\IP = ip2int(AddIP) G_TorrentList\TorrentList()\Network\PeerList()\Port = Port G_TorrentList\TorrentList()\Network\PeerList()\NumTracker = -1 G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Domains = "" G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Flag = -1 G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Local = "" EndIf EndIf EndIf Next UnlockMutex(G_TorrentList\Mutex) EndIf If x=#True MessageRequester("Добавление пира", "Добавляемый пир уже есть в списке.", #MB_OK|#MB_ICONWARNING) EndIf EndIf If x=#False CloseWindow(#Window_AddPeer) DisableWindow(#MainWin, #False) G_TorrentList\Info\AddPeer_INFO_Hash="" EndIf Else MessageRequester("Добавление пира", "Укажите корректный номер порта пира.", #MB_OK|#MB_ICONWARNING) EndIf Else MessageRequester("Добавление пира", "Укажите IP адрес пира.", #MB_OK|#MB_ICONWARNING) EndIf EndIf EndProcedure Procedure MainWindow_Create() Protected ErrString.s, IconSize.w, hWnd_Proc, x Protected hTB, hWnd, SizeR.RECT, i Protected ListViewSpalte.LV_COLUMN, hListView Protected Flag, Win.WINDOWPLACEMENT, R.RECT ListViewSpalte\mask = #LVCF_FMT ListViewSpalte\fmt = #LVCFMT_RIGHT ErrString = "Ошибка при создании " ExamineDesktops() If G_ProgramMiscInfo\Setting\MainWinX<-200 G_ProgramMiscInfo\Setting\MainWinX = 100 EndIf If G_ProgramMiscInfo\Setting\MainWinY<-20 G_ProgramMiscInfo\Setting\MainWinY = 100 EndIf If G_ProgramMiscInfo\Setting\MainWinW<520 Or G_ProgramMiscInfo\Setting\MainWinW>DesktopWidth(0) G_ProgramMiscInfo\Setting\MainWinW = 520 EndIf If G_ProgramMiscInfo\Setting\MainWinH<300 Or G_ProgramMiscInfo\Setting\MainWinH>DesktopHeight(0) G_ProgramMiscInfo\Setting\MainWinH = 300 EndIf Flag = 0 If G_ProgramMiscInfo\Setting\MainWinState &#WPF_RESTORETOMAXIMIZED Flag = #PB_Window_Maximize ;#WS_MAXIMIZE EndIf CompilerIf #Debug_Mode = #True hWnd = OpenWindow(#MainWin, G_ProgramMiscInfo\Setting\MainWinX, G_ProgramMiscInfo\Setting\MainWinY, G_ProgramMiscInfo\Setting\MainWinW, G_ProgramMiscInfo\Setting\MainWinH, #MessageName+" Включен отладочный режим!", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_Invisible|#PB_Window_TitleBar|Flag) CompilerElse hWnd = OpenWindow(#MainWin, G_ProgramMiscInfo\Setting\MainWinX, G_ProgramMiscInfo\Setting\MainWinY, G_ProgramMiscInfo\Setting\MainWinW, G_ProgramMiscInfo\Setting\MainWinH, #MessageName, #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_Invisible|#PB_Window_TitleBar|Flag) CompilerEndIf ;hWnd = NewOpenWindow(#MainWin, G_ProgramMiscInfo\Setting\MainWinX, G_ProgramMiscInfo\Setting\MainWinY, G_ProgramMiscInfo\Setting\MainWinW, G_ProgramMiscInfo\Setting\MainWinH, #MessageName, #WS_MINIMIZEBOX|#WS_MAXIMIZEBOX|#WS_SIZEBOX|#WS_CAPTION|#WS_SYSMENU|Flag) If hWnd ;UseGadgetList(hWnd) EnableWindowDrop(#MainWin, #PB_Drop_Files, #PB_Drag_Link) SmartWindowRefresh(#MainWin, 1) WindowBounds(#MainWin, 520, 300, 8000, 8000) Win\Length = SizeOf(WINDOWPLACEMENT) GetWindowPlacement_(hWnd, @Win) Win\flags = G_ProgramMiscInfo\Setting\MainWinState Win\ptMaxPosition\x = 0 Win\ptMaxPosition\y = 0 Win\rcNormalPosition\left = G_ProgramMiscInfo\Setting\MainWinX Win\rcNormalPosition\top = G_ProgramMiscInfo\Setting\MainWinY Win\rcNormalPosition\right = G_ProgramMiscInfo\Setting\MainWinW + G_ProgramMiscInfo\Setting\MainWinX Win\rcNormalPosition\bottom = G_ProgramMiscInfo\Setting\MainWinH + G_ProgramMiscInfo\Setting\MainWinY Win\showCmd = #SW_HIDE SetWindowPlacement_(hWnd, @Win) ; If CreateMenu(#MainMenu, hWnd) MenuTitle("Файл") MenuItem(#MainMenu_LoadTorrent, "Добавить торрент"+Chr(9)+"Ctrl+A") MenuItem(#MainMenu_CreateTorrent, "Создать торрент"+Chr(9)+"Ctrl+N") MenuBar() MenuItem(#MainMenu_Exit, "Выход") MenuTitle("Настройка") MenuItem(#MainMenu_Pref, "Настройки"+Chr(9)+"Ctrl+P") MenuTitle("Помощь") MenuItem(#MainMenu_About, "О программе"+Chr(9)+"F1") Else MessageRequester(#MessageName, ErrString+"главного меню!", #MB_OK|#MB_ICONERROR) End EndIf AddKeyboardShortcut(#MainWin, #PB_Shortcut_Control|#PB_Shortcut_A, #MainMenu_LoadTorrent) AddKeyboardShortcut(#MainWin, #PB_Shortcut_Control|#PB_Shortcut_N, #MainMenu_CreateTorrent) AddKeyboardShortcut(#MainWin, #PB_Shortcut_Control|#PB_Shortcut_P, #MainMenu_Pref) AddKeyboardShortcut(#MainWin, #PB_Shortcut_F1, #MainMenu_About) hTB = CreateToolBar(#MainToolBar, hWnd) If hTB SetWindowLongPtr_(hTB, #GWL_STYLE,GetWindowLongPtr_(hTB, #GWL_STYLE)|#CCS_NOPARENTALIGN|#CCS_TOP|#CCS_NODIVIDER) IconSize = 24 SendMessage_(hTB, #TB_SETBITMAPSIZE, 0, IconSize | (IconSize << 16)) ImageList_SetIconSize_(SendMessage_(hTB, #TB_GETIMAGELIST, 0, 0) , IconSize , IconSize) IconSize+4 SendMessage_(hTB, #TB_SETBUTTONSIZE, 0, IconSize | (IconSize << 16)) SendMessage_(hTB, #TB_AUTOSIZE, 0, 0) ToolBarImageButton(#MainMenu_LoadTorrent, ImageID(#MainWin_ToolBar_Icon_AddTorrent)) ToolBarToolTip(#MainToolBar, #MainMenu_LoadTorrent, "Добавить торрент") ToolBarImageButton(#MainMenu_CreateTorrent, ImageID(#MainWin_ToolBar_Icon_CreateTorrent)) ToolBarToolTip(#MainToolBar, #MainMenu_CreateTorrent, "Создать торрент") ToolBarSeparator() ToolBarImageButton(#MainMenu_Pref, ImageID(#MainWin_ToolBar_Icon_Setting)) ToolBarToolTip(#MainToolBar, #MainMenu_Pref, "Настройки программы") ToolBarSeparator() ToolBarImageButton(#MainMenu_Torrent_Start, ImageID(#MainWin_ToolBar_Icon_Torrent_Start)) ToolBarToolTip(#MainToolBar, #MainMenu_Torrent_Start, "Запустить") ToolBarImageButton(#MainMenu_Torrent_Pause, ImageID(#MainWin_ToolBar_Icon_Torrent_Pause)) ToolBarToolTip(#MainToolBar, #MainMenu_Torrent_Pause, "Пауза") ToolBarImageButton(#MainMenu_Torrent_Stop, ImageID(#MainWin_ToolBar_Icon_Torrent_Stop)) ToolBarToolTip(#MainToolBar, #MainMenu_Torrent_Stop, "Остановить") ToolBarSeparator() ToolBarImageButton(#MainMenu_DeleteTorrent, ImageID(#MainWin_ToolBar_Icon_Torrent_Delete)) ToolBarToolTip(#MainToolBar, #MainMenu_DeleteTorrent, "Удалить торрент из списка") G_ProgramMiscInfo\hRebar=CreateRebar(hWnd, hTB) Else MessageRequester(#MessageName, ErrString+"панели инструментов!", #MB_OK|#MB_ICONERROR) End EndIf hSB=CreateStatusBar(#MainWin_StatusBar, hWnd) If hTB SetWindowLongPtr_(hSB, #GWL_STYLE,GetWindowLongPtr_(hSB, #GWL_STYLE)|#SBT_TOOLTIPS) AddStatusBarField(50) ; Вывод текущей загрузки в процентах (0-100%) потока обмена данными с пирами. AddStatusBarField(26) AddStatusBarField(#PB_Ignore) AddStatusBarField(#PB_Ignore) AddStatusBarField(#PB_Ignore) x=UseGadgetList(hSB) ImageGadget(#MainWin_StatusBar_ImageGadget_Port,54, 4, 16, 16, 0) G_TorrentList\Info\hToolTip_PortIcon=CreateToolTip(WindowID(#MainWin), GadgetID(#MainWin_StatusBar_ImageGadget_Port), "", "", 0) UseGadgetList(x) Else MessageRequester(#MessageName, ErrString+"строки состояния!", #MB_OK|#MB_ICONERROR) End EndIf ;StatusBarImage(#MainWin_StatusBar, #MainWin_StatusBar_PortIcon, ImageID(#MainWin_Panel_Info_Icon_Log)) ;SendMessage_(hSB, #SB_SETTIPTEXT, #MainWin_StatusBar_PortIcon, @"Подсказка") hListView = ListIconGadget(#MainWin_ListIcon_Torrent, 0, 0, 100, 200, "Торрент", 200, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_MultiSelect|#PB_ListIcon_HeaderDragDrop|#LVS_NOSORTHEADER) G_ProgramMiscInfo\hTorrentListIcon = hListView SetGadgetFont(#MainWin_ListIcon_Torrent, FontID(#MainWin_Panel_Info_Font_Scroll_Text)) hImageList = SendMessage_(hListView, #LVM_GETIMAGELIST, #LVSIL_SMALL, 0) If hImageList = 0 hImageList = ImageList_Create_(16, 16, #ILC_COLOR32 | #ILC_MASK, 10, 2) SendMessage_(hListView, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImageList) EndIf G_ProgramMiscInfo\hImageList_TorrentListIcon = hImageList For i=#MainWin_TorrentIcon_down To #MainWin_TorrentIcon_New G_ProgramMiscInfo\Torrent_ImageList[i-#MainWin_TorrentIcon_down] = ImageList_ReplaceIcon_(hImageList, -1, ImageID(i)) Next i SendMessage_(hListView, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Status, "Состояние", 80) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Size, "Объём", 70) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Progress, "Прогресс", 70) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Seed, "Сиды", 50) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Peer, "Пиры", 50) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_InSpeed, "Прием", 70) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_OutSpeed, "Отдача", 70) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Time, "Время", 70) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Diven, "Отдано", 58) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Label, "Метка", 70) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Available, "Доступно", 70) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Distribution, "Коэфф.", 58) AddGadgetColumn(#MainWin_ListIcon_Torrent, #MainWin_ListIcon_Torrent_Date, "Дата добавления", 110) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Size, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Seed, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Peer, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_InSpeed, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_OutSpeed, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Time, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Diven, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Available, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Distribution, @ListViewSpalte) ListViewSpalte\fmt = #LVCFMT_CENTER SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Progress, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_ListIcon_Torrent_Date, @ListViewSpalte) ListViewSpalte\fmt = #LVCFMT_RIGHT For i=1 To 14 If G_ProgramMiscInfo\Setting\TorrentListIcon_Width[i-1] >= 4 SetGadgetItemAttribute(#MainWin_ListIcon_Torrent, 0, #PB_ListIcon_ColumnWidth, G_ProgramMiscInfo\Setting\TorrentListIcon_Width[i-1], i-1) EndIf Next i SendMessage_(hListView,#LVM_SETCOLUMNORDERARRAY,14, @G_ProgramMiscInfo\Setting\TorrentListIcon_ORDERARRAY[0]) G_ProgramMiscInfo\hHeader_TorrentListIcon = SendMessage_(hListView, #LVM_GETHEADER, 0, 0) Create_Gadget(#MainWin_Panel_Info, "SysTabControl32", "", #WS_CHILD|#WS_VISIBLE|#WS_CLIPCHILDREN|#TCS_TABS|#WS_TABSTOP|#TCS_TOOLTIPS, 0,0,100,100,#WS_EX_CONTROLPARENT) x=SplitterGadget(#MainWin_Splitter_Vertikal, 2, ToolBarHeight(#MainToolBar), WindowWidth(#MainWin)-4, WindowHeight(#MainWin)-MenuHeight()-ToolBarHeight(#MainToolBar)-StatusBarHeight(#MainWin_StatusBar), #MainWin_ListIcon_Torrent, #MainWin_Panel_Info, #PB_Splitter_SecondFixed) SetGadgetAttribute(#MainWin_Splitter_Vertikal, #PB_Splitter_FirstMinimumSize, 100) SetGadgetAttribute(#MainWin_Splitter_Vertikal, #PB_Splitter_SecondMinimumSize, 100) If G_ProgramMiscInfo\Setting\SplitterPos<100 G_ProgramMiscInfo\Setting\SplitterPos = 150 EndIf SetGadgetState(#MainWin_Splitter_Vertikal, G_ProgramMiscInfo\Setting\SplitterPos) ; hPanel=GadgetID(#MainWin_Panel_Info) G_ProgramMiscInfo\PanelInfo\hPanel = hPanel UseGadgetList(hPanel) TabControl_AddTab(hPanel, 0, "Общая информация", ImageID(#MainWin_Panel_Info_Icon_Info)) G_ProgramMiscInfo\PanelInfo\Page_hWnd[0]= CreateWindowEx_(0, "#32770", "", #WS_CHILD|#WS_VISIBLE, 10, 10, 100, 100, hPanel, 0, 0, 0) G_ProgramMiscInfo\PanelInfo\CountPage + 1 TabControl_AddTab(hPanel, 1, "Трекеры", ImageID(#MainWin_Panel_Info_Icon_Tracker)) G_ProgramMiscInfo\PanelInfo\Page_hWnd[1] = ListIconGadget(#MainWin_Panel_Info_ListIcon_Tracker, 0, 0, 200, 100, "Объект", 200, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_HeaderDragDrop|#LVS_NOSORTHEADER) : HideGadget(#MainWin_Panel_Info_ListIcon_Tracker,1) G_ProgramMiscInfo\PanelInfo\CountPage + 1 SendMessage_(GadgetID(#MainWin_Panel_Info_ListIcon_Tracker), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES) TabControl_AddTab(hPanel, 2, "Пиры", ImageID(#MainWin_Panel_Info_Icon_Peer)) G_ProgramMiscInfo\PanelInfo\Page_hWnd[2] = ListIconGadget(#MainWin_Panel_Info_ListIcon_Peer, 0, 0, 200, 100, "IP — адрес", 120, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_HeaderDragDrop|#LVS_NOSORTHEADER) : HideGadget(#MainWin_Panel_Info_ListIcon_Peer,1) G_ProgramMiscInfo\PanelInfo\CountPage + 1 SendMessage_(GadgetID(#MainWin_Panel_Info_ListIcon_Peer), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES) TabControl_AddTab(hPanel, 3, "Файлы", ImageID(#MainWin_Panel_Info_Icon_Files)) G_ProgramMiscInfo\PanelInfo\Page_hWnd[3] = ListIconGadget(#MainWin_Panel_Info_ListIcon_Files, 0, 0, 200, 100, "Имя файла", 180, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_HeaderDragDrop|#LVS_NOSORTHEADER) : HideGadget(#MainWin_Panel_Info_ListIcon_Files,1) G_ProgramMiscInfo\PanelInfo\CountPage + 1 SendMessage_(GadgetID(#MainWin_Panel_Info_ListIcon_Files), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES) TabControl_AddTab(hPanel, 4, "Части", ImageID(#MainWin_Panel_Info_Icon_Piece)) G_ProgramMiscInfo\PanelInfo\Page_hWnd[4] = ListIconGadget(#MainWin_Panel_Info_ListIcon_Piece, 0, 0, 200, 100, "Номер части", 90, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_HeaderDragDrop|#LVS_NOSORTHEADER) : HideGadget(#MainWin_Panel_Info_ListIcon_piece,1) G_ProgramMiscInfo\PanelInfo\CountPage + 1 SendMessage_(GadgetID(#MainWin_Panel_Info_ListIcon_Piece), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES, #LVS_EX_LABELTIP|#LVS_EX_GRIDLINES) TabControl_AddTab(hPanel, 5, "Скорость", ImageID(#MainWin_Panel_Info_Icon_Speed)) G_ProgramMiscInfo\PanelInfo\Page_hWnd[5] = CreateWindowEx_(0, "#32770", "", #WS_CHILD, 10, 10, 100, 100, hPanel, 0, 0, 0) G_ProgramMiscInfo\PanelInfo\CountPage + 1 TabControl_AddTab(hPanel, 6, "Лог", ImageID(#MainWin_Panel_Info_Icon_Log)) G_ProgramMiscInfo\PanelInfo\Page_hWnd[6] = ListIconGadget(#MainWin_Panel_Info_ListIcon_Log, 10, 10, 100, 100,"", 100, #PB_ListIcon_FullRowSelect|#LVS_NOCOLUMNHEADER); G_ProgramMiscInfo\PanelInfo\CountPage + 1 SendMessage_(G_ProgramMiscInfo\PanelInfo\Page_hWnd[6], #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_LABELTIP, #LVS_EX_LABELTIP) SetGadgetFont(#MainWin_Panel_Info_ListIcon_Tracker, FontID(#MainWin_Panel_Info_Font_Scroll_Text)) SetGadgetFont(#MainWin_Panel_Info_ListIcon_Peer, FontID(#MainWin_Panel_Info_Font_Scroll_Text)) SetGadgetFont(#MainWin_Panel_Info_ListIcon_Files, FontID(#MainWin_Panel_Info_Font_Scroll_Text)) SetGadgetFont(#MainWin_Panel_Info_ListIcon_Piece, FontID(#MainWin_Panel_Info_Font_Scroll_Text)) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Tracker, #MainWin_Panel_Info_ListIcon_Tracker_Status, "Статус", 120) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Tracker, #MainWin_Panel_Info_ListIcon_Tracker_Update, "До обновления", 120) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Tracker, #MainWin_Panel_Info_ListIcon_Tracker_Seed, "Сиды", 70) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Tracker, #MainWin_Panel_Info_ListIcon_Tracker_Peer, "Пиры", 70) hListView = GadgetID(#MainWin_Panel_Info_ListIcon_Tracker) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Tracker_Seed, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Tracker_Peer, @ListViewSpalte) For i=0 To 4 If G_ProgramMiscInfo\Setting\ListIcon_Tracker_Width[i] >= 4 SetGadgetItemAttribute(#MainWin_Panel_Info_ListIcon_Tracker, 0, #PB_ListIcon_ColumnWidth, G_ProgramMiscInfo\Setting\ListIcon_Tracker_Width[i], i) EndIf Next i SendMessage_(hListView,#LVM_SETCOLUMNORDERARRAY,5, @G_ProgramMiscInfo\Setting\ListIcon_Tracker_ORDERARRAY[0]) hImageList = SendMessage_(hListView, #LVM_GETIMAGELIST, #LVSIL_SMALL, 0) If hImageList ImageList_Destroy_(hImageList) EndIf hImageList = ImageList_Create_(2, 16, #ILC_COLOR32 | #ILC_MASK, 2, 2) SendMessage_(hListView, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImageList) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_ClientName, "Клиент", 90) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_Local, "Локализация", 90) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_Flags, "Флаги", 58) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_Request, "Запросы", 70) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_Percent, "%", 40) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_In, "Приём", 70) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_Out, "Отдача", 70) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_Upload, "Отдано", 70) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_Download, "Получено", 70) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Peer, #MainWin_Panel_Info_ListIcon_Peer_SpeedPeer, "Скорость пира", 100) hListView = GadgetID(#MainWin_Panel_Info_ListIcon_Peer) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_Flags, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_Request, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_Percent, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_In, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_Out, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_Upload, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_Download, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Peer_SpeedPeer, @ListViewSpalte) For i=0 To 10 If G_ProgramMiscInfo\Setting\ListIcon_Peer_Width[i] >= 4 SetGadgetItemAttribute(#MainWin_Panel_Info_ListIcon_Peer, 0, #PB_ListIcon_ColumnWidth, G_ProgramMiscInfo\Setting\ListIcon_Peer_Width[i], i) EndIf Next i SendMessage_(hListView,#LVM_SETCOLUMNORDERARRAY,11, @G_ProgramMiscInfo\Setting\ListIcon_Peer_ORDERARRAY[0]) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Files, #MainWin_Panel_Info_ListIcon_Files_Size, "Объем", 58) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Files, #MainWin_Panel_Info_ListIcon_Files_Number, "№", 40) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Files, #MainWin_Panel_Info_ListIcon_Files_Download, "Загружено", 80) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Files, #MainWin_Panel_Info_ListIcon_Files_Percent, "%", 70) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Files, #MainWin_Panel_Info_ListIcon_Files_CountPiece, "Число частей", 100) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Files, #MainWin_Panel_Info_ListIcon_Files_Piece, "Части файла", 100) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Files, #MainWin_Panel_Info_ListIcon_Files_Priority, "Приоритет", 80) hListView = GadgetID(#MainWin_Panel_Info_ListIcon_Files) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Files_Number, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Files_Size, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Files_Download, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Files_Percent, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN,#MainWin_Panel_Info_ListIcon_Files_CountPiece, @ListViewSpalte) ListViewSpalte\fmt = #LVCFMT_CENTER SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Files_Piece, @ListViewSpalte) ListViewSpalte\fmt = #LVCFMT_RIGHT For i=0 To 7 If G_ProgramMiscInfo\Setting\ListIcon_Files_Width[i] >= 4 SetGadgetItemAttribute(#MainWin_Panel_Info_ListIcon_Files, 0, #PB_ListIcon_ColumnWidth, G_ProgramMiscInfo\Setting\ListIcon_Files_Width[i], i) EndIf Next i SendMessage_(hListView,#LVM_SETCOLUMNORDERARRAY,8, @G_ProgramMiscInfo\Setting\ListIcon_Files_ORDERARRAY[0]) hImageList = SendMessage_(hListView, #LVM_GETIMAGELIST, #LVSIL_SMALL, 0) If hImageList = 0 hImageList = ImageList_Create_(16, 16, #ILC_COLOR32 | #ILC_MASK, 40, 10) SendMessage_(hListView, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImageList) EndIf G_ProgramMiscInfo\hImageList_ListIcon_Files = hImageList AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Piece, #MainWin_Panel_Info_ListIcon_Piece_Size, "Размер", 58) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Piece, #MainWin_Panel_Info_ListIcon_Piece_Block, "Блоков", 80) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Piece, #MainWin_Panel_Info_ListIcon_Piece_ProgressBar, "Состояние загрузки блоков", 180) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Piece, #MainWin_Panel_Info_ListIcon_Piece_End, "Завершено", 80) AddGadgetColumn(#MainWin_Panel_Info_ListIcon_Piece, #MainWin_Panel_Info_ListIcon_Piece_Available, "Доступно", 80) hListView = GadgetID(#MainWin_Panel_Info_ListIcon_Piece) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Piece_Size, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Piece_Block, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Piece_End, @ListViewSpalte) SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Piece_Available, @ListViewSpalte) ListViewSpalte\fmt = #LVCFMT_CENTER SendMessage_(hListView, #LVM_SETCOLUMN, #MainWin_Panel_Info_ListIcon_Piece_ProgressBar, @ListViewSpalte) For i=0 To 5;6 If G_ProgramMiscInfo\Setting\ListIcon_Piece_Width[i] >= 4 SetGadgetItemAttribute(#MainWin_Panel_Info_ListIcon_Piece, 0, #PB_ListIcon_ColumnWidth, G_ProgramMiscInfo\Setting\ListIcon_Piece_Width[i], i) EndIf Next i SendMessage_(hListView,#LVM_SETCOLUMNORDERARRAY,6, @G_ProgramMiscInfo\Setting\ListIcon_Piece_ORDERARRAY[0]) hImageList = SendMessage_(hListView, #LVM_GETIMAGELIST, #LVSIL_SMALL, 0) If hImageList ImageList_Destroy_(hImageList) EndIf hImageList = ImageList_Create_(2, 16, #ILC_COLOR32 | #ILC_MASK, 2, 2) SendMessage_(hListView, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImageList) If G_ProgramMiscInfo\OS_Version>#PB_OS_Windows_2000 SetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\Page_hWnd[0],#GWL_EXSTYLE,GetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\Page_hWnd[0],#GWL_EXSTYLE)|#WS_EX_COMPOSITED) SetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\Page_hWnd[5],#GWL_EXSTYLE,GetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\Page_hWnd[5],#GWL_EXSTYLE)|#WS_EX_COMPOSITED) SetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\Page_hWnd[6],#GWL_EXSTYLE,GetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\Page_hWnd[6],#GWL_EXSTYLE)|#WS_EX_COMPOSITED) EndIf hListView = GadgetID(#MainWin_Panel_Info_ListIcon_Peer) hImageList = SendMessage_(hListView, #LVM_GETIMAGELIST, #LVSIL_SMALL, 0) If hImageList = 0 ; no image list, create one hImageList = ImageList_Create_(16, 16, #ILC_COLOR32 | #ILC_MASK, 120, 2) SendMessage_(hListView, #LVM_SETIMAGELIST, #LVSIL_SMALL, hImageList) EndIf ; ********** Добавление гаджетов на вкладку "Общая информация" панели. ********** UseGadgetList(G_ProgramMiscInfo\PanelInfo\Page_hWnd[0]) TextGadget(#MainWin_Panel_Info_MiscInfo_Text_1, 2, 8, 80, 20, "Доступно:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Text_2, 2, 34, 80, 20, "Загружено:", #SS_LEFTNOWORDWRAP) x=ImageGadget(#MainWin_Panel_Info_MiscInfo_Accessibly, 84, 4, 300, 24,0) SetWindowLongPtr_(x,#GWL_EXSTYLE,GetWindowLongPtr_(x,#GWL_EXSTYLE)|#WS_EX_TRANSPARENT) x=ImageGadget(#MainWin_Panel_Info_MiscInfo_Load, 84, 30, 300, 24,0) SetWindowLongPtr_(x,#GWL_EXSTYLE,GetWindowLongPtr_(x,#GWL_EXSTYLE)|#WS_EX_TRANSPARENT) TextGadget(#MainWin_Panel_Info_MiscInfo_Text_Accessibly, 200, 12, 44, 20, "", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Text_Load, 200, 38, 44, 20, "", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Back, 0,0,302,404,"") ; Подложка скролла. x = CreateWindowChild_Panel_Info_Back_MiscInfo(2,58,200,100, G_ProgramMiscInfo\PanelInfo\Page_hWnd[0]) G_ProgramMiscInfo\PanelInfo\hMiscInfo_Scroll = x x = GadgetID(#MainWin_Panel_Info_MiscInfo_Scroll_Back) SetParent_(x, G_ProgramMiscInfo\PanelInfo\hMiscInfo_Scroll) UseGadgetList(x) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_1, 2,2,284,18,"Состояние торрента.",#PB_Text_Center) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_2, 8,30,88,18,"Прошло:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_3, 8,50,88,18,"Загружено:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_4, 8,70,88,18,"Вх. скорость:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_5, 8,90,88,18,"Лимит приёма:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_6, 8,110,88,18,"Состояние:", #SS_LEFTNOWORDWRAP) x=30 For i=#MainWin_Panel_Info_MiscInfo_Scroll_Text_Passed To #MainWin_Panel_Info_MiscInfo_Scroll_Text_Status TextGadget(i,98,x,120,18,"", #SS_LEFTNOWORDWRAP) ; Отображение результата в полях "Прошло", "Загружено", "Вх. скорость", "Лимит приёма" и "Состояние". x+20 Next i TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_7, 2,140, 284, 18, "Torrent-файл.", #PB_Text_Center) If IsFont(#MainWin_Panel_Info_Font_Scroll) SetGadgetFont(#MainWin_Panel_Info_MiscInfo_Scroll_Text_1, FontID(#MainWin_Panel_Info_Font_Scroll)) SetGadgetFont(#MainWin_Panel_Info_MiscInfo_Scroll_Text_7, FontID(#MainWin_Panel_Info_Font_Scroll)) EndIf TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_8, 8,170,110,18,"Путь к файлам:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_9, 8,190,110,18,"Общий объём:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_10, 8,210,110,18,"Части:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_11, 8,230,110,18,"Создано:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_12, 8,250,110,18,"Хеш-сумма:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_14, 8,270,110,18,"Описание:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_15, 8,290,110,18,"Издатель:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_16, 8,310,110,18,"Адрес издателя:", #SS_LEFTNOWORDWRAP) x=170 For i=#MainWin_Panel_Info_MiscInfo_Scroll_Text_Path To #MainWin_Panel_Info_MiscInfo_Scroll_Text_Publisher_Url TextGadget(i,120,x,420,18,"", #SS_LEFTNOWORDWRAP|#SS_NOPREFIX) ; Отображение результата в полях "Путь к файлам", "Общий объём", "Создано", "Хеш-сумма", "Описание" и "Части", "Публикатор", "Адрес публикатора". x+20 Next i TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_17, 220,30,88,18,"Осталось:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_18, 220,50,88,18,"Передано:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_19, 220,70,88,18,"Скор. отдачи:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_20, 220,90,88,18,"Лимит отдачи:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_21, 220,110,88,18,"Лишнее:", #SS_LEFTNOWORDWRAP) x=30 For i=#MainWin_Panel_Info_MiscInfo_Scroll_Text_Remains To #MainWin_Panel_Info_MiscInfo_Scroll_Text_Excess TextGadget(i,310,x,120,18,"", #SS_LEFTNOWORDWRAP) ; Отображение результата в полях "Осталось", "Передано", "Скор. отдачи", "Лимит отлачи" и "Лишнее". x+20 Next i TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_22, 432,30,100,18,"Активные сиды:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_23, 432,50,100,18,"Активные пиры:", #SS_LEFTNOWORDWRAP) TextGadget(#MainWin_Panel_Info_MiscInfo_Scroll_Text_24, 432,70,100,18,"Коэфф. раздачи:", #SS_LEFTNOWORDWRAP) x=30 For i=#MainWin_Panel_Info_MiscInfo_Scroll_Text_Seeds To #MainWin_Panel_Info_MiscInfo_Scroll_Text_RatioDistribution TextGadget(i,534,x,200,18,"", #SS_LEFTNOWORDWRAP) ; Отображение результата в полях "Сиды", "Активные пиры" и "Коэфф. раздачи". x+20 Next i x = FontID(#MainWin_Panel_Info_Font_Scroll_Text) For i=#MainWin_Panel_Info_MiscInfo_Scroll_Text_2 To #MainWin_Panel_Info_MiscInfo_Scroll_Text_Publisher_Url If i<>#MainWin_Panel_Info_MiscInfo_Scroll_Text_7 ;And i<>#MainWin_Panel_Info_MiscInfo_Scroll_Text_Path And i<>#MainWin_Panel_Info_MiscInfo_Scroll_Text_Info SetGadgetFont(i, x) EndIf Next i ; ********** Добавление гаджетов на вкладку "Скорость" панели. ********** UseGadgetList(G_ProgramMiscInfo\PanelInfo\Page_hWnd[5]) TextGadget(#MainWin_Panel_Info_Speed_Text_SelectTime, 4,8,120,18,"Период обновления:", #SS_LEFTNOWORDWRAP) ComboBoxGadget(#MainWin_Panel_Info_Speed_CoboBox_SelectTime, 128, 4, 120, 22) : DisableGadget(#MainWin_Panel_Info_Speed_CoboBox_SelectTime, 1) AddGadgetItem(#MainWin_Panel_Info_Speed_CoboBox_SelectTime, -1, "1 секунда") AddGadgetItem(#MainWin_Panel_Info_Speed_CoboBox_SelectTime, -1, "5 секунд") AddGadgetItem(#MainWin_Panel_Info_Speed_CoboBox_SelectTime, -1, "30 секунд") AddGadgetItem(#MainWin_Panel_Info_Speed_CoboBox_SelectTime, -1, "5 минут") SetGadgetState(#MainWin_Panel_Info_Speed_CoboBox_SelectTime, G_ProgramMiscInfo\Setting\Speed_CoboBoxState) ImageGadget(#MainWin_Panel_Info_Speed_ImageGraph, 2, 28, 100,100,0) UseGadgetList(WindowID(#MainWin)) G_ProgramMiscInfo\PanelInfo\OldFunc = GetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\hPanel, #GWL_WNDPROC) SetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\hPanel,#GWL_USERDATA, @G_ProgramMiscInfo\PanelInfo) SetWindowLongPtr_(G_ProgramMiscInfo\PanelInfo\hPanel, #GWL_WNDPROC, @Systabcontrol32_CB()) *Proc = GetWindowLongPtr_(G_ProgramMiscInfo\hTorrentListIcon, #GWL_WNDPROC) SetWindowLongPtr_(G_ProgramMiscInfo\hTorrentListIcon,#GWL_USERDATA, *Proc) SetWindowLongPtr_(G_ProgramMiscInfo\hTorrentListIcon, #GWL_WNDPROC, @MainWin_All_ListIcon_CB()) For i=1 To 6 If i<>5 hListView = G_ProgramMiscInfo\PanelInfo\Page_hWnd[i] *Proc = GetWindowLongPtr_(hListView, #GWL_WNDPROC) SetWindowLongPtr_(hListView,#GWL_USERDATA, *Proc) SetWindowLongPtr_(hListView, #GWL_WNDPROC, @MainWin_All_ListIcon_CB()) EndIf Next i hWnd_Proc = G_ProgramMiscInfo\PanelInfo\Page_hWnd[0] *Proc = GetWindowLongPtr_(hWnd_Proc, #GWL_WNDPROC) SetWindowLongPtr_(hWnd_Proc,#GWL_USERDATA, *Proc) SetWindowLongPtr_(hWnd_Proc, #GWL_WNDPROC, @MainWindow_PanelInfo_StaticPage_MiscInfo_CB()) hWnd_Proc = G_ProgramMiscInfo\PanelInfo\Page_hWnd[5] *Proc = GetWindowLongPtr_(hWnd_Proc, #GWL_WNDPROC) SetWindowLongPtr_(hWnd_Proc,#GWL_USERDATA, *Proc) SetWindowLongPtr_(hWnd_Proc, #GWL_WNDPROC, @MainWindow_PanelInfo_StaticPage_Speed_CB()) hWnd_Proc = GadgetID(#MainWin_Panel_Info_MiscInfo_Scroll_Back) *Proc = GetWindowLongPtr_(hWnd_Proc, #GWL_WNDPROC) SetWindowLongPtr_(hWnd_Proc,#GWL_USERDATA, *Proc) SetWindowLongPtr_(hWnd_Proc, #GWL_WNDPROC, @MainWindow_PanelInfo_Back_Scroll_CB()) GetWindowRect_(G_ProgramMiscInfo\hRebar, @SizeR) ResizeGadget(#MainWin_Splitter_Vertikal, #PB_Ignore, SizeR\bottom - SizeR\top, WindowWidth(#MainWin)-4, WindowHeight(#MainWin)-MenuHeight()-ToolBarHeight(#MainToolBar)-StatusBarHeight(#MainWin_StatusBar)) If G_ProgramMiscInfo\Setting\TabPos<0 Or G_ProgramMiscInfo\Setting\TabPos>6 : G_ProgramMiscInfo\Setting\TabPos=0 : EndIf TabControl_SetPage(G_ProgramMiscInfo\PanelInfo\hPanel, G_ProgramMiscInfo\Setting\TabPos , @G_ProgramMiscInfo\PanelInfo) SetWindowCallback(@MainWin_Callbackproc(), #MainWin) FillMemory(@SizeR, SizeOf(SizeR), 0) FillMemory(@R, SizeOf(R), 0) SendMessage_(G_ProgramMiscInfo\PanelInfo\hPanel, #TCM_ADJUSTRECT, 0, @r) GetClientRect_(G_ProgramMiscInfo\PanelInfo\hPanel, @SizeR) SizeR\left + r\left/2 SizeR\top + r\top SizeR\right - r\left-r\left/2 SizeR\bottom + r\bottom ; -r\top G_ProgramMiscInfo\Panel_Info_MiscInfo_ImageWidth = SizeR\right - SizeR\left+2 PanelInfo_DrawImage(0, 1, 0) G_ProgramMiscInfo\Panel_Info_MiscInfo_ImageHeight = SizeR\bottom - SizeR\top SetActiveGadget(#MainWin_ListIcon_Torrent) SendMessage_(WindowID(#MainWin), #WM_UPDATEUISTATE, $30002,0) Else MessageRequester(#MessageName, ErrString+"главного окна!", #MB_OK|#MB_ICONERROR) End EndIf EndProcedure Declare SettingWindow_Create() Procedure MainWindow_Event(Event) Protected SizeR.RECT, x Protected WinWidth, WinHeight Protected Gadget, P_ItemWidth, P_ItemHeight Protected Menu, Result, File.s, i, Files$ Protected TorrentInfo.Sub_TorrentInfo_TorrentList Protected Cursor.POINT, Handle, EventType Protected NewList Label.String_2() Protected *LoadFile.String Result = #False If Event = #PB_Event_SizeWindow WinWidth = WindowWidth(#MainWin) WinHeight = WindowHeight(#MainWin) If G_ProgramMiscInfo\hRebar GetWindowRect_(G_ProgramMiscInfo\hRebar, @SizeR) SetWindowPos_(G_ProgramMiscInfo\hRebar, #HWND_NOTOPMOST, 0, 0, WinWidth, SizeR\bottom - SizeR\top, #SWP_NOACTIVATE|#SWP_NOMOVE|#SWP_NOZORDER) EndIf ResizeGadget(#MainWin_Splitter_Vertikal, #PB_Ignore, SizeR\bottom - SizeR\top, WinWidth-4, WinHeight-MenuHeight()-ToolBarHeight(#MainToolBar)-StatusBarHeight(#MainWin_StatusBar)) RedrawWindow_(WindowID(#MainWin), 0, 0, #RDW_ALLCHILDREN|#RDW_UPDATENOW) ElseIf Event = #PB_Event_Gadget Gadget = EventGadget() Select Gadget Case #MainWin_Splitter_Vertikal RedrawWindow_(GadgetID(#MainWin_Panel_Info), 0, 0, #RDW_ALLCHILDREN|#RDW_UPDATENOW) RedrawWindow_(GadgetID(#MainWin_ListIcon_Torrent), 0, 0, #RDW_UPDATENOW) Case #MainWin_Panel_Info_ListIcon_Log If EventType()=#PB_EventType_LeftDoubleClick x=GetGadgetState(#MainWin_Panel_Info_ListIcon_Log) If x>=0 File = GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Log, x, 0) If File SetClipboardText(Trim(File)) EndIf EndIf EndIf Case #MainWin_ListIcon_Torrent EventType = EventType() G_ProgramMiscInfo\List_Torrent_Pos = GetGadgetState(#MainWin_ListIcon_Torrent) If EventType = #PB_EventType_Change SignalSemaphore(G_ProgramMiscInfo\Panel_Info_Semaphore) EndIf If EventType = #PB_EventType_LeftDoubleClick lv = GadgetID(#MainWin_ListIcon_Torrent) lvi.lvhittestinfo GetCursorPos_(@lvi\pt) GetWindowRect_(lv,@lvpos.rect) lvi\pt\x-lvpos\left lvi\pt\y-lvpos\top SendMessage_(lv, #LVM_SUBITEMHITTEST, 0, @lvi) If lvi\isubitem = 0 SetWindowLongPtr_(lv,#GWL_STYLE, GetWindowLongPtr_(lv,#GWL_STYLE)|#LVS_EDITLABELS) editcontrol = SendMessage_(lv,#LVM_EDITLABEL,lvi\iitem,0) EndIf EndIf If EventType = #PB_EventType_RightClick If G_ProgramMiscInfo\List_Torrent_Pos>=0 DisplayPopupMenu(#TorrentPopupMemu, WindowID(#MainWin)) EndIf EndIf Case #MainWin_Panel_Info_ListIcon_Peer ; Список пиров. If EventType() = #PB_EventType_RightClick G_TorrentList\Info\AddPeer_INFO_Hash="" If G_ProgramMiscInfo\List_Torrent_Pos>=0 DisableMenuItem(#PeerListMemu, #PeerListMemu_AddPeer, 0) Else DisableMenuItem(#PeerListMemu, #PeerListMemu_AddPeer, 1) EndIf DisplayPopupMenu(#PeerListMemu, WindowID(#MainWin)) EndIf Case #MainWin_StatusBar_ImageGadget_Port ; Иконка в строке состояния, показывающая открыт ли порт. If EventType()=#PB_EventType_LeftDoubleClick RunProgram("http://www.2ip.ru/check-port/?port="+Str(G_ProgramSetting\Lan\Port)) EndIf Case #MainWin_Panel_Info_Speed_CoboBox_SelectTime EndSelect ElseIf Event = #PB_Event_Menu Menu = EventMenu() Select Menu Case #MainMenu_LoadTorrent File = OpenFileRequester("",G_ProgramMiscInfo\Setting\TorrentFilePath,"Торрент-файлы (*.torrent)|*.torrent|Все файлы|*.*", 0, #PB_Requester_MultiSelection) If File<>"" If FileSize(GetPathPart(File))= -2 G_ProgramMiscInfo\Setting\TorrentFilePath = GetPathPart(File) EndIf While File<>"" And FileSize(File)>0 *LoadFile = AllocateMemory(SizeOf(String)) If *LoadFile InitializeStructure(*LoadFile, String) *LoadFile\s = File x=CreateThread(@Open_LoadTorrent_Win(), *LoadFile) If x ThreadPriority(x, 8) Else ClearStructure(*LoadFile, String) FreeMemory(*LoadFile) EndIf EndIf File = NextSelectedFileName() Wend EndIf Case #MainMenu_CreateTorrent ; Пункт главного меню "Создать торрент" If IsWindow(#CreateTorrent_Win) HideWindow(#CreateTorrent_Win, 0) SetActiveWindow(#CreateTorrent_Win) Else x=CreateThread(@Open_CreateTorrent_Win(), 0) If x ThreadPriority(x, 8) EndIf EndIf Case #MainMenu_Exit Result = #True Case #MainMenu_Pref If IsWindow(#Setting_Win)=0 SettingWindow_Create() Else SetActiveWindow(#Setting_Win) EndIf Case #TrayMenu_Show_HideWindow If IsWindowVisible_(WindowID(#MainWin)) ; Если окно было видимым, HideWindow(#MainWin, #True) ; Скрываем его. G_ProgramMiscInfo\Setting\MainWinVisible = #False Else ; Окно невидимое. HideWindow(#MainWin, #False) Set_ForegroundWindow(WindowID(#MainWin)) G_ProgramMiscInfo\Setting\MainWinVisible = #True EndIf Case #MainMenu_Torrent_Start Torrent_SetStatus(#TorrentStatus_M_Start) Case #MainMenu_Torrent_Pause Torrent_SetStatus(#TorrentStatus_Pause) Case #MainMenu_Torrent_Stop Torrent_SetStatus(#TorrentStatus_Stop) Case #MainMenu_DeleteTorrent, #TorrentPopupMemu_DeleteTorrent_And_Files Torrent_DeleteTorrent(Menu) Case #MainMenu_About ; на PureBasic MessageRequester( "О программе", #MessageName+" - Торрент-клиент предназначенный для работы"+Chr(10)+"со съемных носителей, например, флешки."+Chr(10)+Chr(10)+"Автор программы - Высочанский Пётр."+Chr(10)+"E-mail: pbtorrent@yandex.ru", #MB_OK|#MB_ICONINFORMATION) Case #TorrentPopupMemu_OpenDirTorrent ; Открыть папку торрента. If G_ProgramMiscInfo\List_Torrent_Pos>=0 And G_ProgramMiscInfo\List_Torrent_Pos"" If FileSize(File)=-2 RunProgram(File) Else MessageRequester(#MessageName, "Папка не найдена!"+Chr(10)+File, #MB_ICONWARNING) EndIf EndIf EndIf Case #TrayMenu_PauseAllTorrent x = GetMenuItemState(#TrayMenu, #TrayMenu_PauseAllTorrent) x!1 SetMenuItemState(#TrayMenu, #TrayMenu_PauseAllTorrent, x) G_ProgramMiscInfo\Torrent_All_Pause = x Out_TorrentList_AllPause() Case #TorrentPopupMemu_Label_New ; Новая метка Window_LabelTorrent() Case #TorrentPopupMemu_Label_Del ; Удаление метки Table_ActiveItem_GetLabel(Label()) Table_ActiveItem_SetLabel(Label(), "") Case #TorrentPopupMemu_Label_xx To #TorrentPopupMemu_Label_xx+50 ; В меню выбрана метка. Table_ActiveItem_GetLabel(Label()) Table_ActiveItem_SetLabel(Label(), GetMenuItemText(#TorrentPopupMemu, Menu)) Case #TorrentPopupMemu_Refresh_Torrent ; Повторный запрос трекеру (обновить трекер). Table_Refresh_Torrent() ; Повторный запрос трекеру (обновить трекер). Case #PeerListMemu_AddPeer ; Добавить пира в торент. G_TorrentList\Info\AddPeer_INFO_Hash="" If G_ProgramMiscInfo\List_Torrent_Pos>=0 x=#False If Test_LockMutex(G_TorrentList\Mutex, 800)=#True If G_ProgramMiscInfo\List_Torrent_Pos < ListSize(G_TorrentList\TorrentList()) SelectElement(G_TorrentList\TorrentList(), G_ProgramMiscInfo\List_Torrent_Pos) If G_TorrentList\TorrentList()\TorrentStatus=#TorrentStatus_Load Or G_TorrentList\TorrentList()\TorrentStatus=#TorrentStatus_Seed Or G_TorrentList\TorrentList()\TorrentStatus=#TorrentStatus_Pause G_TorrentList\Info\AddPeer_INFO_Hash = G_TorrentList\TorrentList()\TorrentFile\INFO_Hash Else x=#True EndIf EndIf UnlockMutex(G_TorrentList\Mutex) If x=#False If G_TorrentList\Info\AddPeer_INFO_Hash Window_AddPeer_Create() EndIf Else MessageRequester("Добавление пира", "Добавить пира можно только в активный торрент.", #MB_OK|#MB_ICONWARNING) EndIf EndIf EndIf Case #PeerListMemu_ShowDomainsName ; Доменное имя (отображать его в таблице или нет) G_ProgramMiscInfo\Setting\ShowDomainsName = GetMenuItemState(#PeerListMemu, #PeerListMemu_ShowDomainsName) ! 1 SetMenuItemState(#PeerListMemu, #PeerListMemu_ShowDomainsName, G_ProgramMiscInfo\Setting\ShowDomainsName) EndSelect ElseIf Event = #PB_Event_WindowDrop If EventDropType() = #PB_Drop_Files Files$ = EventDropFiles() Count = CountString(Files$, Chr(10)) + 1 For i = 1 To Count *LoadFile = AllocateMemory(SizeOf(String)) If *LoadFile InitializeStructure(*LoadFile, String) *LoadFile\s = StringField(Files$, i, Chr(10)) If FileSize(*LoadFile\s)>0 x=CreateThread(@Open_LoadTorrent_Win(), *LoadFile) If x ThreadPriority(x, 8) Else ClearStructure(*LoadFile, String) FreeMemory(*LoadFile) EndIf EndIf EndIf Next i EndIf ElseIf Event = #PB_Event_MinimizeWindow If G_ProgramSetting\Misc\MinimazeTray = 1 HideWindow(#MainWin, #True) G_ProgramMiscInfo\Setting\MainWinVisible = #False EndIf ElseIf Event = #PB_Event_SysTray EventType = EventType() If EventType = #PB_EventType_LeftDoubleClick If G_ProgramSetting\Misc\HideShowTray = 1 If IsWindowVisible_(WindowID(#MainWin)) ; Если окно было видимым, HideWindow(#MainWin, #True) ; Скрываем его. G_ProgramMiscInfo\Setting\MainWinVisible = #False Else ; Окно невидимое. HideWindow(#MainWin, #False) Set_ForegroundWindow(WindowID(#MainWin)) G_ProgramMiscInfo\Setting\MainWinVisible = #True EndIf EndIf EndIf ElseIf Event = #WM_MOUSEWHEEL GetCursorPos_(Cursor) Handle = WindowFromPoint_(Cursor\X|(Cursor\Y<<32)) If Handle = G_ProgramMiscInfo\hTorrentListIcon Or Handle =G_ProgramMiscInfo\PanelInfo\hMiscInfo_Scroll SendMessage_(Handle, #WM_MOUSEWHEEL, EventwParam(), EventlParam()) Else For i=1 To 6 If i<>5 If Handle = G_ProgramMiscInfo\PanelInfo\Page_hWnd[i] SendMessage_(Handle, #WM_MOUSEWHEEL, EventwParam(), EventlParam()) Break EndIf EndIf Next i EndIf ElseIf Event = #PB_Event_CloseWindow If G_ProgramSetting\Misc\CloseTray=1 HideWindow(#MainWin, #True) G_ProgramMiscInfo\Setting\MainWinVisible = #False Else Result = #True EndIf EndIf ProcedureReturn Result EndProcedure Procedure SettingWindow_SetParameter() SetGadgetState(#Setting_Win_Misc_Check_MinimazeTray, G_ProgramSetting\Misc\MinimazeTray) SetGadgetState(#Setting_Win_Misc_Check_CloseTray, G_ProgramSetting\Misc\CloseTray) SetGadgetState(#Setting_Win_Misc_Check_BalloonTray, G_ProgramSetting\Misc\BalloonTray) SetGadgetState(#Setting_Win_Misc_Check_HideShowTray, G_ProgramSetting\Misc\HideShowTray) SetGadgetState(#Setting_Win_Lan_Spin_Port, G_ProgramSetting\Lan\Port) SetGadgetState(#Setting_Win_Lan_Check_RandomPort, G_ProgramSetting\Lan\RandomPort) If G_ProgramSetting\Lan\RandomPort = 1 DisableGadget(#Setting_Win_Lan_Spin_Port, 1) EndIf SetGadgetState(#Setting_Win_Lan_Spin_MaxConnect, G_ProgramSetting\Lan\MaxConnect) SetGadgetState(#Setting_Win_Lan_Spin_MaxPeer, G_ProgramSetting\Lan\MaxPeer) SetGadgetState(#Setting_Win_Lan_Spin_SlotTorrent, G_ProgramSetting\Lan\SlotTorrent) SetGadgetState(#Setting_Win_Torrent_Spin_MaxActiveTorrent, G_ProgramSetting\Torrent\MaxActiveTorrent) SetGadgetState(#Setting_Win_Torrent_Spin_MaxLoad, G_ProgramSetting\Torrent\MaxLoad) SetGadgetState(#Setting_Win_Torrent_Check_SerialLoadPiece, G_ProgramSetting\Torrent\Serial_LoadPiece) If G_ProgramSetting\TreePos<0 Or G_ProgramSetting\TreePos>3 G_ProgramSetting\TreePos=0 EndIf SetGadgetState(#Setting_Win_TreeSelector, G_ProgramSetting\TreePos) HideGadget(#Setting_Win_Container_Misc+G_ProgramSetting\TreePos, 0) EndProcedure Procedure SettingWindow_GetParameter() Protected x G_ProgramSetting\Misc\MinimazeTray = GetGadgetState(#Setting_Win_Misc_Check_MinimazeTray) G_ProgramSetting\Misc\CloseTray = GetGadgetState(#Setting_Win_Misc_Check_CloseTray) x = GetGadgetState(#Setting_Win_Misc_Check_BalloonTray) If x <>G_ProgramSetting\Misc\BalloonTray G_ProgramSetting\Misc\BalloonTray = x ;If x=0 ; Были запрещены всплывающие окна в трее. G_ProgramMiscInfo\TrayInfo\Balloon_Visible = #False G_ProgramMiscInfo\TrayInfo\Balloon_Old_Visible = #False LockMutex(G_ProgramMiscInfo\TrayInfo\Balloon_Mutex) If ListSize(G_ProgramMiscInfo\TrayInfo\BalloonList())>0 ClearList(G_ProgramMiscInfo\TrayInfo\BalloonList()) EndIf UnlockMutex(G_ProgramMiscInfo\TrayInfo\Balloon_Mutex) ;EndIf EndIf G_ProgramSetting\Misc\HideShowTray = GetGadgetState(#Setting_Win_Misc_Check_HideShowTray) x = GetGadgetState(#Setting_Win_Lan_Spin_Port) If x <>G_ProgramSetting\Lan\Port G_ProgramSetting\Lan\Port = x Start_Server(2) SetGadgetState(#Setting_Win_Lan_Spin_Port, x) EndIf G_ProgramSetting\Lan\RandomPort = GetGadgetState(#Setting_Win_Lan_Check_RandomPort) G_ProgramSetting\Lan\MaxConnect = GetGadgetState(#Setting_Win_Lan_Spin_MaxConnect) G_ProgramSetting\Lan\MaxPeer = GetGadgetState(#Setting_Win_Lan_Spin_MaxPeer) G_ProgramSetting\Lan\SlotTorrent = GetGadgetState(#Setting_Win_Lan_Spin_SlotTorrent) G_ProgramSetting\Torrent\MaxActiveTorrent = GetGadgetState(#Setting_Win_Torrent_Spin_MaxActiveTorrent) G_ProgramSetting\Torrent\MaxLoad = GetGadgetState(#Setting_Win_Torrent_Spin_MaxLoad) G_ProgramSetting\Torrent\Serial_LoadPiece=GetGadgetState(#Setting_Win_Torrent_Check_SerialLoadPiece) G_ProgramSetting\TreePos = GetGadgetState(#Setting_Win_TreeSelector) EndProcedure Procedure SettingWindow_Create() Protected x If OpenWindow(#Setting_Win, 0, 0, 540, 400, #ProgName+" - настройки программы.", #PB_Window_SystemMenu|#PB_Window_Invisible|#PB_Window_TitleBar|#PB_Window_WindowCentered, WindowID(#MainWin)) TreeGadget(#Setting_Win_TreeSelector, 4,10,124,338, #PB_Tree_AlwaysShowSelection) AddGadgetItem(#Setting_Win_TreeSelector, -1, "Разное",0,0) AddGadgetItem(#Setting_Win_TreeSelector, -1, "Сеть",0,0) AddGadgetItem(#Setting_Win_TreeSelector, -1, "Торренты",0,0) ContainerGadget(#Setting_Win_Container_Misc, 132, 10, 404, 340) : HideGadget(#Setting_Win_Container_Misc, #True);, #PB_Container_Flat x = TextGadget(#PB_Any, 2, 0, 398, 16, "Разное", #PB_Text_Center) SetGadgetColor(x,#PB_Gadget_BackColor, $48864D) SetGadgetColor(x,#PB_Gadget_FrontColor, $FFFFFF) SetGadgetFont(x, FontID(#MainWin_Panel_Info_Font_Scroll)) CompilerIf #PB_Compiler_Version<520 Frame3DGadget(#PB_Any, 2, 24, 398, 58, "Системный трей") CompilerElse FrameGadget(#PB_Any, 2, 24, 398, 58, "Системный трей") CompilerEndIf CheckBoxGadget(#Setting_Win_Misc_Check_MinimazeTray, 16, 40, 190, 16, "Сворачивать в трей") GadgetToolTip(#Setting_Win_Misc_Check_MinimazeTray, "При сворачивании главного окна, убирать кнопку программы с панели задач") CheckBoxGadget(#Setting_Win_Misc_Check_CloseTray, 210, 40, 184, 16, "Закрывать в трей") GadgetToolTip(#Setting_Win_Misc_Check_CloseTray, "При закрытии главного окна, не завершать работу программы") CheckBoxGadget(#Setting_Win_Misc_Check_BalloonTray, 16, 58, 190, 16, "Всплывающие уведомления") GadgetToolTip(#Setting_Win_Misc_Check_BalloonTray, "Всплывающие окна, типа 'Balloon Tip'") CheckBoxGadget(#Setting_Win_Misc_Check_HideShowTray, 210, 58, 184, 16, "Активировать двойным кликом") GadgetToolTip(#Setting_Win_Misc_Check_HideShowTray, "Сворачивать и разворачивать главное окно программы при двойном клике ЛКМ по значку в трее") CloseGadgetList() ContainerGadget(#Setting_Win_Container_Lan, 132, 10, 404, 340) : HideGadget(#Setting_Win_Container_Lan, #True) x = TextGadget(#PB_Any, 2, 0, 398, 16, "Сеть", #PB_Text_Center) SetGadgetColor(x,#PB_Gadget_BackColor, $48864D) SetGadgetColor(x,#PB_Gadget_FrontColor, $FFFFFF) SetGadgetFont(x, FontID(#MainWin_Panel_Info_Font_Scroll)) CompilerIf #PB_Compiler_Version<520 Frame3DGadget(#PB_Any, 2, 30, 398, 34,"",#PB_Frame3D_Single) CompilerElse FrameGadget(#PB_Any, 2, 30, 398, 34,"",#PB_Frame_Single) CompilerEndIf TextGadget(#PB_Any, 8, 42, 198, 16, "Порт для входящих соединений:",#SS_LEFTNOWORDWRAP) x=SpinGadget(#Setting_Win_Lan_Spin_Port, 210, 38, 50, 20, 1000, 65535, #PB_Spin_Numeric) GadgetToolTip(#Setting_Win_Lan_Spin_Port, "Этот порт будет использоваться для входящих соединений других торрент-клиентов") SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#ES_NUMBER) CheckBoxGadget(#Setting_Win_Lan_Check_RandomPort, 270, 42, 124, 16, "Случайный порт") GadgetToolTip(#Setting_Win_Lan_Check_RandomPort, "Случайный выбор порта при запуске программы") CompilerIf #PB_Compiler_Version<520 Frame3DGadget(#PB_Any, 2, 70, 398, 94,"Соединения") CompilerElse FrameGadget(#PB_Any, 2, 70, 398, 94,"Соединения") CompilerEndIf TextGadget(#PB_Any, 8, 92, 328, 16, "Максимальное количество соединений:",#SS_LEFTNOWORDWRAP) x=SpinGadget(#Setting_Win_Lan_Spin_MaxConnect, 340, 88, 50, 20, 1, 1000, #PB_Spin_Numeric) SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#ES_NUMBER) TextGadget(#PB_Any, 8, 116, 328, 16, "Максимум соединений на торрент:",#SS_LEFTNOWORDWRAP) ; активныхпиров x=SpinGadget(#Setting_Win_Lan_Spin_MaxPeer, 340, 112, 50, 20, 1, 100, #PB_Spin_Numeric) SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#ES_NUMBER) TextGadget(#PB_Any, 8, 140, 328, 16, "Число слотов раздачи для торрента:",#SS_LEFTNOWORDWRAP) x=SpinGadget(#Setting_Win_Lan_Spin_SlotTorrent, 340, 135, 50, 20, 1, 20, #PB_Spin_Numeric) SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#ES_NUMBER) CloseGadgetList() ContainerGadget(#Setting_Win_Container_Torrent, 132, 10, 404, 340) : HideGadget(#Setting_Win_Container_Torrent, #True) x = TextGadget(#PB_Any, 2, 0, 398, 16, "Торренты", #PB_Text_Center) SetGadgetColor(x,#PB_Gadget_BackColor, $48864D) SetGadgetColor(x,#PB_Gadget_FrontColor, $FFFFFF) SetGadgetFont(x, FontID(#MainWin_Panel_Info_Font_Scroll)) CompilerIf #PB_Compiler_Version<520 Frame3DGadget(#PB_Any, 2, 30, 398, 58,"",#PB_Frame3D_Single) CompilerElse FrameGadget(#PB_Any, 2, 30, 398, 58,"",#PB_Frame_Single) CompilerEndIf TextGadget(#PB_Any, 8, 42, 328, 16, "Максимум активных торрентов:",#SS_LEFTNOWORDWRAP) x=SpinGadget(#Setting_Win_Torrent_Spin_MaxActiveTorrent, 340, 38, 50, 20, 1, 200, #PB_Spin_Numeric) : DisableGadget(#Setting_Win_Torrent_Spin_MaxActiveTorrent, #True) SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#ES_NUMBER) TextGadget(#PB_Any, 8, 68, 328, 16, "Максимум одновременных загрузок:",#SS_LEFTNOWORDWRAP) x=SpinGadget(#Setting_Win_Torrent_Spin_MaxLoad, 340, 62, 50, 20, 1, 100, #PB_Spin_Numeric) : DisableGadget(#Setting_Win_Torrent_Spin_MaxLoad, #True) SetWindowLongPtr_(x,#GWL_STYLE,GetWindowLongPtr_(x,#GWL_STYLE)|#ES_NUMBER) CheckBoxGadget(#Setting_Win_Torrent_Check_SerialLoadPiece, 4, 100, 350, 16, "Последовательная загрузка частей (не рекомендуется)") CloseGadgetList() If CreateImage(#Setting_Win_Image_LineGadget, 540, 2) If StartDrawing(ImageOutput(#Setting_Win_Image_LineGadget)) Line(0,0,540, 1, $808080) Line(0,1,540, 1, $FFFFFF) StopDrawing() ImageGadget(#Setting_Win_LineGagdet, 0, 358, 540, 2, ImageID(#Setting_Win_Image_LineGadget)) EndIf EndIf ButtonGadget(#Setting_Win_Button_OK, 230, 368, 80, 24, "OK") ButtonGadget(#Setting_Win_Button_Cancel, 320, 368, 80, 24, "Отмена") ButtonGadget(#Setting_Win_Button_Apply, 410, 368, 80, 24, "Применить") SettingWindow_SetParameter() SendMessage_(WindowID(#Setting_Win),#WM_SETICON,#False,ImageID(#MainWin_ToolBar_Icon_Setting)) SetActiveGadget(#Setting_Win_TreeSelector) SendMessage_(WindowID(#Setting_Win), #WM_UPDATEUISTATE, $30002,0) HideWindow(#Setting_Win, #False) EndIf EndProcedure Procedure SettingWindow_Event(Event) Protected Gadget, Temp Static TreePos.b If Event = #PB_Event_CloseWindow Or (Event = #PB_Event_Gadget And EventGadget() = #Setting_Win_Button_Cancel) CloseWindow(#Setting_Win) If IsImage(#Setting_Win_Image_LineGadget) : FreeImage(#Setting_Win_Image_LineGadget) : EndIf TreePos=-1 ElseIf Event = #PB_Event_Gadget Gadget = EventGadget() Select Gadget Case #Setting_Win_TreeSelector If EventType()=#PB_EventType_Change If TreePos=-1 TreePos=G_ProgramSetting\TreePos EndIf Temp = GetGadgetState(#Setting_Win_TreeSelector) If TreePos<>Temp If IsGadget(Temp+#Setting_Win_Container_Misc) : HideGadget(Temp+#Setting_Win_Container_Misc, #False): EndIf If IsGadget(TreePos+#Setting_Win_Container_Misc) : HideGadget(TreePos+#Setting_Win_Container_Misc, #True): EndIf TreePos=Temp EndIf EndIf Case #Setting_Win_Lan_Check_RandomPort Temp = GetGadgetState(#Setting_Win_Lan_Check_RandomPort) DisableGadget(#Setting_Win_Lan_Spin_Port, Temp) Case #Setting_Win_Torrent_Check_SerialLoadPiece Temp = GetGadgetState(#Setting_Win_Torrent_Check_SerialLoadPiece) If Temp=1 And G_ProgramSetting\Torrent\Serial_LoadPiece=0 If MessageRequester(#ProgName+" - настройки программы.", "ВНИМАНИЕ!"+Chr(10)+"Последовательная загрузка частей"+Chr(10)+"может негативно сказаться на процессе"+Chr(10)+"обмена данными!"+Chr(10)+Chr(10)+"Активировать последовательную загрузку частей?", #MB_YESNO|#MB_ICONWARNING|#MB_DEFBUTTON2) = #IDNO SetGadgetState(#Setting_Win_Torrent_Check_SerialLoadPiece, 0) EndIf EndIf Case #Setting_Win_Button_OK, #Setting_Win_Button_Apply SettingWindow_GetParameter() Save_Setting() If Gadget = #Setting_Win_Button_OK CloseWindow(#Setting_Win) If IsImage(#Setting_Win_Image_LineGadget) : FreeImage(#Setting_Win_Image_LineGadget) : EndIf TreePos=-1 EndIf EndSelect EndIf EndProcedure ; IDE Options = PureBasic 5.11 (Windows - x86) ; Folding = --- ; EnableXP