EnableExplicit Procedure ListIcon_GetItem_ImageNumber(GadgetID, Item) ; Получение индекса иконки (в ImageList) пункта ListIcon'а. Protected pitem.LV_ITEM pitem\mask = #LVIF_IMAGE pitem\iItem = Item SendMessage_(GadgetID, #LVM_GETITEM, 0, @pitem) ProcedureReturn pitem\iImage EndProcedure Procedure ListIcon_SetItem_ImageNumber(GadgetID, Item, Number.w) ; Установка новой иконки (в ImageList) пункта ListIcon'а. Protected hImageList, pitem.LV_ITEM If Number< -1 : Number=-1 : EndIf pitem\mask = #LVIF_IMAGE pitem\iItem = Item pitem\iImage = Number SendMessage_(GadgetID, #LVM_SETITEM, 0, @pitem) EndProcedure Procedure ListIconFiles_SetItemImage(GadgetID, Item, Part.s, hImageList) Static NewList Part_IconID.GetIcon_Extension() Protected ImList_Image, IconID If GadgetID And Item>=0 And Part<>"" And hImageList ImList_Image=-1 Part=LCase(Part) ForEach Part_IconID() If Part=Part_IconID()\Part ; Данные о расширенни найдены ImList_Image = Part_IconID()\IconID EndIf Next If ImList_Image=-1 IconID = GetIcon_Extension(Part) If IconID ImList_Image = ImageList_ReplaceIcon_(hImageList, -1, IconID) If ImList_Image>-1 If AddElement(Part_IconID()) Part_IconID()\Part=Part Part_IconID()\IconID=ImList_Image EndIf EndIf EndIf EndIf If ImList_Image>-1 If ListIcon_GetItem_ImageNumber(GadgetID, Item)<>ImList_Image ListIcon_SetItem_ImageNumber(GadgetID, Item, ImList_Image) EndIf EndIf EndIf EndProcedure Procedure.b PanelInfo_DrawImage_Accessibly(Image, NoPeer.b, Array MapPiece.a(1), CountPiece.l) ; Прорисовка рисунка "Доступно" на вкладке "Общая информация", панели. Protected Result.b, ImW, ImH, TempL.l Protected TempF.f, CountF.f, Pos.f, i, x Result = #False If IsImage(Image) ImW = ImageWidth(Image) ImH = ImageHeight(Image) If StartDrawing(ImageOutput(Image)) DrawingMode(#PB_2DDrawing_Outlined) Box(0,0,ImW, ImH, RGB(120, 120, 120)) ImW-2 DrawingMode(#PB_2DDrawing_Default) If NoPeer=#True ; Нет поров - фон красный. TempL = RGB(255, 192, 191) Else ; Пиры есть - фон серый. TempL = RGB(240, 240, 240) EndIf ImH-2 Box(1,1,ImW, ImH, TempL) If NoPeer<>-1 TempL = 0 If CountPiece>=ImW-2 ; Число частей равно или больше размера рисунка. TempF = (ImW)/CountPiece CountF = 0 For i=1 To ImW x = 0 Repeat CountF+TempF If TempL<=CountPiece If Torrent_GetArray_MapPiece(MapPiece(), TempL)=0 x = 1 EndIf Else x=1 EndIf TempL + 1 Until CountF>=i If x=0 Line(i,1,1, ImH, $48864D) EndIf Next i Else ; Число частейменьше размера рисунка. If CountPiece>0 TempF = (ImW)/CountPiece Pos = 0 While Pos+TempF0 Box(Round(Pos, #PB_Round_Up), 1, Round(TempF, #PB_Round_Up), ImH, $48864D) EndIf Pos+TempF TempL + 1 Wend EndIf EndIf EndIf StopDrawing() Result = #True EndIf EndIf ProcedureReturn Result EndProcedure Procedure.b PanelInfo_DrawImage_Load(Image, PercentLoad.w, Array MapPiece.a(1), CountPiece.l) ; Прорисовка рисунка "Загружено" на вкладке "Общая информация", панели. Protected Result.b, SizeArray, ImW, ImH, i, TempF.f Protected x, z, TempL.l, CountF.f, Pos.f Result = #False If PercentLoad>=0 SizeArray = ArraySize(MapPiece()) Else SizeArray = 0 EndIf If SizeArray>=0 And IsImage(Image) ImW = ImageWidth(Image) ImH = ImageHeight(Image) If StartDrawing(ImageOutput(Image)) DrawingMode(#PB_2DDrawing_Outlined) Box(0,0,ImW, ImH, RGB(120, 120, 120)) ImW-2 DrawingMode(#PB_2DDrawing_Default) Box(1,1,ImW, ImH-2, RGB(240, 240, 240)) If PercentLoad>=0 TempL = 0 If CountPiece>=ImW-2 ; Число частей равно или больше размера рисунка. TempF = (ImW)/CountPiece CountF = 0 For i=1 To ImW x = 0 Repeat CountF+TempF If TempL<=CountPiece If Torrent_GetArray_MapPiece(MapPiece(), TempL)=0 x = 1 EndIf Else x=1 EndIf TempL + 1 Until CountF>=i If x=0 Line(i,1,1, 17, $48864D) EndIf Next i Else ; Число частейменьше размера рисунка. If CountPiece>0 TempF = (ImW)/CountPiece Pos = 0 While Pos+TempF0 Box(Round(Pos, #PB_Round_Up), 1, Round(TempF, #PB_Round_Up), 17, $48864D) EndIf Pos+TempF TempL + 1 Wend EndIf EndIf If PercentLoad>1000 : PercentLoad=1000 : EndIf Line(1,18,ImW, 1, RGB(80, 80, 200)) TempF=PercentLoad/(1000/ImW) Box(1,19,TempF, 4, RGB(95, 250, 200)) EndIf StopDrawing() Result = #True EndIf EndIf ProcedureReturn Result EndProcedure Procedure PanelInfo_DrawImage(*DrawInfo.OutData_Panel_Info_MiscInfo, UpdateImage.b, Update.a) Protected TempB.b, PercentLoad.w, ImageWidth.w Protected x, Pos.RECT, TempF.f, i, NoPeer.b Static Image_Load_Width.w, Dim TempPiece.a(0), Dim AccessiblyPiece.a(0), InNum_Load.a, InNum_Accessibly.a ImageWidth = G_ProgramMiscInfo\Panel_Info_MiscInfo_ImageWidth-138 TempB=#False If (Image_Load_Width<>ImageWidth And ImageWidth>0) Or IsImage(#MainWin_Panel_Info_Image_Temp)=0 If CreateImage(#MainWin_Panel_Info_Image_Temp, ImageWidth, 24, 24)=0 ProcedureReturn 0 EndIf EndIf If *DrawInfo And Update If *DrawInfo\CurrentFileSize>0 If *DrawInfo\All_Size / *DrawInfo\CurrentFileSize >0 TempF = 1000 / (*DrawInfo\All_Size / *DrawInfo\CurrentFileSize) Else TempF = 1000 EndIf Else TempF = 0 EndIf If ((ArraySize(*DrawInfo\MapPiece()) <> ArraySize(TempPiece()) Or Image_Load_Width<>ImageWidth)) And ImageWidth>0 ;Or UpdateImage If ArraySize(*DrawInfo\MapPiece()) <> ArraySize(TempPiece()) CopyArray(*DrawInfo\MapPiece(), TempPiece()) EndIf TempB=PanelInfo_DrawImage_Load(#MainWin_Panel_Info_Image_Temp, TempF, *DrawInfo\MapPiece(), *DrawInfo\CountPiece) Else If Image_Load_Width=ImageWidth And ArraySize(*DrawInfo\MapPiece()) = ArraySize(TempPiece()) x=ArraySize(TempPiece())-1 For i=0 To x If *DrawInfo\MapPiece(i)<>TempPiece(i) CopyArray(*DrawInfo\MapPiece(), TempPiece()) TempB=1 Break EndIf Next i Else TempB=1 If ArraySize(*DrawInfo\MapPiece()) <> ArraySize(TempPiece()) CopyArray(*DrawInfo\MapPiece(), TempPiece()) EndIf EndIf If TempB=1 TempB=PanelInfo_DrawImage_Load(#MainWin_Panel_Info_Image_Temp, TempF, *DrawInfo\MapPiece(), *DrawInfo\CountPiece) EndIf EndIf Else ; Внимание. Указатель на массив невалидный! If ArraySize(TempPiece())>0 Or UpdateImage TempB=PanelInfo_DrawImage_Load(#MainWin_Panel_Info_Image_Temp, -1, *DrawInfo\MapPiece(), 0) ReDim TempPiece(0) TempPiece(0) = 0 EndIf EndIf If TempB = #True If InNum_Load=0 i=#MainWin_Panel_Info_Image_Load_1 InNum_Load=1 Else i=#MainWin_Panel_Info_Image_Load_2 InNum_Load=0 EndIf CopyImage(#MainWin_Panel_Info_Image_Temp, i) SetGadgetState(#MainWin_Panel_Info_MiscInfo_Load, ImageID(i)) EndIf TempB = #False If *DrawInfo And Update If (*DrawInfo\TorrentStatus=#TorrentStatus_Load Or *DrawInfo\TorrentStatus=#TorrentStatus_Seed Or *DrawInfo\TorrentStatus=#TorrentStatus_Pause) And *DrawInfo\Network_IO\ActivePeers+*DrawInfo\Network_IO\Seeds <=0 NoPeer=#True Else NoPeer=#False EndIf If ((ArraySize(*DrawInfo\AccessiblyPiece()) <> ArraySize(AccessiblyPiece()) Or Image_Load_Width<>ImageWidth)) And ImageWidth>0 If ArraySize(*DrawInfo\AccessiblyPiece()) <> ArraySize(AccessiblyPiece()) CopyArray(*DrawInfo\AccessiblyPiece(), AccessiblyPiece()) EndIf TempB=PanelInfo_DrawImage_Accessibly(#MainWin_Panel_Info_Image_Temp, NoPeer, *DrawInfo\AccessiblyPiece(), *DrawInfo\CountPiece) Else If Image_Load_Width=ImageWidth And ArraySize(*DrawInfo\AccessiblyPiece()) = ArraySize(AccessiblyPiece()) x=ArraySize(AccessiblyPiece())-1 For i=0 To x If *DrawInfo\AccessiblyPiece(i)<>AccessiblyPiece(i) CopyArray(*DrawInfo\AccessiblyPiece(), AccessiblyPiece()) TempB=1 Break EndIf Next i Else TempB=1 If ArraySize(*DrawInfo\AccessiblyPiece()) <> ArraySize(AccessiblyPiece()) CopyArray(*DrawInfo\AccessiblyPiece(), AccessiblyPiece()) EndIf EndIf If TempB=1 TempB=PanelInfo_DrawImage_Accessibly(#MainWin_Panel_Info_Image_Temp, NoPeer, *DrawInfo\AccessiblyPiece(), *DrawInfo\CountPiece) EndIf EndIf Else ; Внимание. Указатель на массив невалидный! If ArraySize(AccessiblyPiece())>0 Or UpdateImage TempB=PanelInfo_DrawImage_Accessibly(#MainWin_Panel_Info_Image_Temp, -1, *DrawInfo\AccessiblyPiece(), 0) ReDim AccessiblyPiece(0) AccessiblyPiece(0) = 0 EndIf EndIf If TempB = #True If InNum_Accessibly=0 i=#MainWin_Panel_Info_Image_Accessibly_1 InNum_Accessibly=1 Else i=#MainWin_Panel_Info_Image_Accessibly_2 InNum_Accessibly=0 EndIf CopyImage(#MainWin_Panel_Info_Image_Temp, i) SetGadgetState(#MainWin_Panel_Info_MiscInfo_Accessibly, ImageID(i)) EndIf RedrawWindow_(GadgetID(#MainWin_Panel_Info_MiscInfo_Load), 0, 0, #RDW_UPDATENOW) RedrawWindow_(GadgetID(#MainWin_Panel_Info_MiscInfo_Accessibly), 0, 0, #RDW_UPDATENOW) If ImageWidth>0 Image_Load_Width = ImageWidth EndIf EndProcedure Procedure.s ActiveTimeSec(Time.l) Protected Result.s, x, Temp x = 0 Result = "" If Time>=0 If Time>=31556926 ; Больше или равно год. Temp = Round(Time/31556926, #PB_Round_Down) If Temp>0 x+1 Result + Str(Temp)+" Год " Time = Time % 31556926 EndIf EndIf Temp = Round(Time/604800, #PB_Round_Down) If Temp>0 Or x=1 ; Больше или равно одной неделе. x+1 Result + Str(Temp)+" нед. " Time = Time % 604800 EndIf If x<2 Temp = Round(Time/86400, #PB_Round_Down) If Temp>0 Or x=1 ; Больше или равно одни сутки. x+1 Result + Str(Temp)+" дн. " Time = Time % 86400 EndIf EndIf If x<2 Temp = Round(Time/3600, #PB_Round_Down) If Temp>0 Or x=1 x+1 Result + Str(Temp)+" ч. " Time = Time % 3600 EndIf EndIf If x<2 Temp = Round(Time/60, #PB_Round_Down) If Temp>0 Or x=1 x+1 Result + Str(Temp)+" мин. " Time = Time % 60 EndIf EndIf If x<2 And Time>=0 Result + Str(Time)+ " сек." EndIf Else Result = Chr($221E) EndIf ProcedureReturn Result EndProcedure Procedure.s OutText_TorrentStatusText(Status.b) Protected Result.s If G_ProgramMiscInfo\Torrent_All_Pause = #True And (Status = #TorrentStatus_Load Or Status = #TorrentStatus_Seed) ;Status = #TorrentStatus_Pause Result="Пауза (All)" Else Select Status Case #TorrentStatus_Add Result="Добавление" Case #TorrentStatus_Load Result="Загружается" Case #TorrentStatus_Seed Result="Раздаётся" Case #TorrentStatus_Pause Result="Пауза" Case #TorrentStatus_Stop Result="Остановлен" Case #TorrentStatus_Error Result="Ошибка." Default Result="" EndSelect EndIf ProcedureReturn Result EndProcedure Procedure OutText_TableTorrent(Pos, *OutText.OutTextTableTorrent) ; Вывод текста в таблицу с торрентами. Protected String.s;, TorrentIcon If Pos<0 Or Pos > CountGadgetItems(#MainWin_ListIcon_Torrent)-1 ProcedureReturn 0 EndIf ; Надпись "Торрент". String = *OutText\TorrentName If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Name)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Name) EndIf ; Надпись "Состояние". String = OutText_TorrentStatusText(*OutText\TorrentStatus) If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Status)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Status) EndIf ; Надпись "Объем торрента". String = ConvertByte_ToString(*OutText\All_Size, 2) If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Size)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Size) EndIf ; Надпись "Сиды". String = Str(*OutText\Seeds)+" ("+Str(*OutText\AllSeeds)+")" If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Seed)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Seed) EndIf ; Надпись "Пиры". String = Str(*OutText\ActivePeers)+" ("+Str(*OutText\AllPeers)+")" If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Peer)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Peer) EndIf ; Надпись "Прием". If *OutText\InSpeed>0 String = ConvertByte_ToString(*OutText\InSpeed, 2)+"/с" Else String = "" EndIf If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_InSpeed)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_InSpeed) EndIf ; Надпись "Отдача". If *OutText\OutSpeed>0 String = ConvertByte_ToString(*OutText\OutSpeed, 2)+"/с" Else String = "" EndIf If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_OutSpeed)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_OutSpeed) EndIf ; Надпись "Время". If *OutText\TorrentStatus<>#TorrentStatus_Seed If *OutText\RemainsTime>=-1 And (*OutText\TorrentStatus<>#TorrentStatus_Stop Or *OutText\TorrentStatus<>#TorrentStatus_Error) String = ActiveTimeSec(*OutText\RemainsTime) Else String = "" EndIf Else String = "—" EndIf If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Time)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Time) EndIf ; Надпись "Отдано". String = ConvertByte_ToString(*OutText\SendBytes, 2) If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Diven)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Diven) EndIf ; Надпись "Метка". String = *OutText\Label If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Label)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Label) EndIf ; Надпись "Доступно". String = StrF(*OutText\Available, 3) If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Available)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Available) EndIf ; Надпись "Коэффициент раздачи". String = StrF(*OutText\RatioDistribution, 3) If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Distribution)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Distribution) EndIf ; Надпись "Дата добавления". String = FormatDate("%dd.%mm.%yyyy %hh:%ii", *OutText\AddDate) If GetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, #MainWin_ListIcon_Torrent_Date)<>String SetGadgetItemText(#MainWin_ListIcon_Torrent, Pos, String, #MainWin_ListIcon_Torrent_Date) EndIf EndProcedure Procedure Update_TableTorrent(INFO_Hash.s, Pos=-1, NoTableLock=0) ; Вывод текста в таблицу с торрентами. Protected ListPos=0, x.b=0 Protected OutText.OutTextTableTorrent, y=0 If INFO_Hash<>"" ; Если указана хеш-сумма. If Test_LockMutex(G_TorrentList\Mutex, 50) ForEach G_TorrentList\TorrentList() If G_TorrentList\TorrentList()\TorrentFile\INFO_Hash = INFO_Hash y = 1 Pos = ListPos Break EndIf ListPos + 1 Next x = 1 EndIf Else ; Если сумма не указана, то предполагается что список заперт Mutex'ом и текущий элемент уже выбран. y = 1 EndIf If y = 1 OutText\TorrentName = G_TorrentList\TorrentList()\TorrentName OutText\TorrentStatus = G_TorrentList\TorrentList()\TorrentStatus OutText\All_Size = G_TorrentList\TorrentList()\TorrentFile\All_Size OutText\Seeds = G_TorrentList\TorrentList()\Network_IO\Seeds OutText\AllSeeds = G_TorrentList\TorrentList()\Network_IO\AllSeeds OutText\ActivePeers = G_TorrentList\TorrentList()\Network_IO\ActivePeers OutText\AllPeers = G_TorrentList\TorrentList()\Network_IO\AllPeers OutText\InSpeed = G_TorrentList\TorrentList()\Network_IO\InSpeed OutText\OutSpeed = G_TorrentList\TorrentList()\Network_IO\OutSpeed OutText\RemainsTime = G_TorrentList\TorrentList()\Network_IO\RemainsTime OutText\SendBytes = G_TorrentList\TorrentList()\Network_IO\SendBytes OutText\Label = G_TorrentList\TorrentList()\Label OutText\Available = G_TorrentList\TorrentList()\Network_IO\Available OutText\RatioDistribution = G_TorrentList\TorrentList()\Network_IO\RatioDistribution OutText\AddDate = G_TorrentList\TorrentList()\AddDate If INFO_Hash<>"" Or x = 1 UnlockMutex(G_TorrentList\Mutex) EndIf If Pos>=0 If NoTableLock<>1 If Test_LockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex, 50)<>#True NoTableLock=1 EndIf EndIf OutText_TableTorrent(Pos, @OutText) If NoTableLock<>1 UnlockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex) EndIf EndIf ProcedureReturn EndIf If INFO_Hash<>"" And x = 1 UnlockMutex(G_TorrentList\Mutex) EndIf EndProcedure Procedure Out_Update_TableTorrent_All(List TableTorrent.OutTextTableTorrent()) ; Обгновление всей таблицы с торрантами. Вызывается раз в секунуд. Protected CountItem, x, i, s If Test_LockMutex(G_TorrentList\Mutex_Table, 20) = #True ForEach G_TorrentList\Table() ForEach TableTorrent() If G_TorrentList\Table()\INFO_Hash = TableTorrent()\INFO_Hash ;If TableTorrent()\Percent <> G_TorrentList\Table()\Percent TableTorrent()\Percent = G_TorrentList\Table()\Percent ;EndIf EndIf Next Next UnlockMutex(G_TorrentList\Mutex_Table) If Test_LockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex, 20) = #True CountItem = CountGadgetItems(#MainWin_ListIcon_Torrent)-1 ; Число торрентов в таблице If CountItem>=0 i=0 ForEach TableTorrent() If i>CountItem Break EndIf OutText_TableTorrent(i, @TableTorrent()) i + 1 Next EndIf UnlockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex) EndIf EndIf ClearList(TableTorrent()) EndProcedure Procedure Out_CopyData_TableTorrent(List TableTorrent.OutTextTableTorrent()) ; Копирование данных, выводимых в таблицу торрентов. Protected TempF.f ClearList(TableTorrent()) ForEach G_TorrentList\TorrentList() If AddElement(TableTorrent()) TableTorrent()\TorrentName = G_TorrentList\TorrentList()\TorrentName TableTorrent()\TorrentStatus = G_TorrentList\TorrentList()\TorrentStatus TableTorrent()\All_Size = G_TorrentList\TorrentList()\TorrentFile\All_Size TableTorrent()\Seeds = G_TorrentList\TorrentList()\Network_IO\Seeds TableTorrent()\AllSeeds = G_TorrentList\TorrentList()\Network_IO\AllSeeds TableTorrent()\ActivePeers = G_TorrentList\TorrentList()\Network_IO\ActivePeers TableTorrent()\AllPeers = G_TorrentList\TorrentList()\Network_IO\AllPeers TableTorrent()\InSpeed = G_TorrentList\TorrentList()\Average_InSpeed TableTorrent()\OutSpeed = G_TorrentList\TorrentList()\Average_OutSpeed TableTorrent()\RemainsTime = G_TorrentList\TorrentList()\Network_IO\RemainsTime TableTorrent()\SendBytes = G_TorrentList\TorrentList()\Network_IO\SendBytes TableTorrent()\Label = G_TorrentList\TorrentList()\Label TableTorrent()\Available = G_TorrentList\TorrentList()\Network_IO\Available TableTorrent()\RatioDistribution = G_TorrentList\TorrentList()\Network_IO\RatioDistribution TableTorrent()\AddDate = G_TorrentList\TorrentList()\AddDate TableTorrent()\INFO_Hash = G_TorrentList\TorrentList()\TorrentFile\INFO_Hash EndIf Next EndProcedure Procedure Out_Panel_MiscInfo(*TorrentInfo.OutData_Panel_Info_MiscInfo, Update.a) ; Вывд текста на панели "Общая информация". Protected i, String.s, TempL, Size, x, z If *TorrentInfo<>0 And Update String = StrF(*TorrentInfo\Network_IO\Available, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Text_Accessibly)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Text_Accessibly, String) EndIf String = DelNull(StrF(*TorrentInfo\Percent, 2))+" %" If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Text_Load)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Text_Load, String) EndIf ; Надпись "Прошло". String = ActiveTimeSec(*TorrentInfo\ActiveTimeSec) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Passed)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Passed, String) EndIf ; Надпись "Загружено". String = ConvertByte_ToString(*TorrentInfo\Network_IO\ReceiveBytes, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Load)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Load, String) EndIf ; Надпись "Вх. скорость". String = ConvertByte_ToString(*TorrentInfo\Network_IO\InSpeed, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_InSpeed)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_InSpeed, String) EndIf ; Надпись "Лимит приёма". String = ConvertByte_ToString(*TorrentInfo\Network_IO\Limit_In, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_InLimit)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_InLimit, String) EndIf ; Надпись "Состояние". String = OutText_TorrentStatusText(*TorrentInfo\TorrentStatus) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Status)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Status, String) EndIf ;Надпись "Осталось". If *TorrentInfo\Network_IO\RemainsTime>0 String = ActiveTimeSec(*TorrentInfo\Network_IO\RemainsTime) Else String = "" EndIf If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Remains)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Remains, String) EndIf ; Надпись "Передано". String = ConvertByte_ToString(*TorrentInfo\Network_IO\SendBytes, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Transmit)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Transmit, String) EndIf ; Надпись "Скорость отдачи". String = ConvertByte_ToString(*TorrentInfo\Network_IO\OutSpeed, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_OutSpeed)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_OutSpeed, String) EndIf ; Надпись "Лимит отдачи". String = ConvertByte_ToString(*TorrentInfo\Network_IO\Limit_Out, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_OutLimit)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_OutLimit, String) EndIf ; Надпись "Лишнее". String = ConvertByte_ToString(*TorrentInfo\Network_IO\Excess, 2) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Excess)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Excess, String) EndIf ; Надпись "Сиды". String = Str(*TorrentInfo\Network_IO\Seeds) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Seeds)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Seeds, String) EndIf ; Надпись "Активные пиры". String = Str(*TorrentInfo\Network_IO\ActivePeers) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_ActivePeers)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_ActivePeers, String) EndIf ; Надпись "Коэфф. раздачи". String = StrF(*TorrentInfo\Network_IO\RatioDistribution, 3) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_RatioDistribution)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_RatioDistribution, String) EndIf ; Надпись "Путь к файлам". String = *TorrentInfo\Path If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Path)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Path, String) EndIf ; Надпись "Общий объём". String = ConvertByte_ToString(*TorrentInfo\All_Size, 3)+" ("+ConvertByte_ToString(*TorrentInfo\CurrentFileSize, 3)+" присутствует)" If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_AllSize)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_AllSize, String) EndIf ; Надпись "Части". TempL=0 Size = ArraySize(*TorrentInfo\MapPiece())-1 For i=0 To Size z = *TorrentInfo\MapPiece(i) For x=1 To 8 If z & 1 TempL + 1 EndIf z>>1 Next x Next i String = Str(*TorrentInfo\CountPiece)+" x "+ConvertByte_ToString(*TorrentInfo\piece_length, 2)+" ("+Str(TempL)+" присутствует)" If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Piece)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Piece, String) EndIf ; Надпись "Создано". String = FormatDate("%dd.%mm.%yyyy %hh:%ii", *TorrentInfo\AddDate) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Create)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Create, String) EndIf ; Надпись "Хеш-сумма". String = UCase(*TorrentInfo\INFO_Hash) If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Hash)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Hash, String) EndIf ; Надпись "Описание". String = *TorrentInfo\comment If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Info)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Info, String) EndIf ; Надпись "Публикатор". String = *TorrentInfo\Publisher If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Publisher)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Publisher, String) EndIf ; Надпись "Адрес публикатора". String = *TorrentInfo\Publisher_Url If GetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Publisher_Url)<>String SetGadgetText(#MainWin_Panel_Info_MiscInfo_Scroll_Text_Publisher_Url, String) EndIf Else SetGadgetText(#MainWin_Panel_Info_MiscInfo_Text_Accessibly,"") SetGadgetText(#MainWin_Panel_Info_MiscInfo_Text_Load,"") For i=#MainWin_Panel_Info_MiscInfo_Scroll_Text_Passed To #MainWin_Panel_Info_MiscInfo_Scroll_Text_Publisher_Url SetGadgetText(i,"") Next i EndIf EndProcedure Procedure Out_Panel_Tracker(*Tracker.OutData_Panel_Info_TrackerInfo, Pos, UpdateList.a) ; Вывод данных в теблицу "Трекеры", панели информации. Protected CountList, CountItem, i, String.s Protected Update.b, Gadget, TrackerStatus.s, UpdTracker.s Protected header, Temp Static OldPos If *Tracker And Pos>=0 And UpdateList Update = #False CountList = ListSize(*Tracker\TrackerList()) CountItem = CountGadgetItems(#MainWin_Panel_Info_ListIcon_Tracker) Gadget = GadgetID(#MainWin_Panel_Info_ListIcon_Tracker) If CountList>CountItem ; В списке больше элементов, чем в таблице. SendMessage_(Gadget, #WM_SETREDRAW, #False, 0) Update = #True Temp = CountList-1 For i=CountItem To Temp AddGadgetItem(#MainWin_Panel_Info_ListIcon_Tracker, i, "") Next i ElseIf CountListString SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, String, #MainWin_Panel_Info_ListIcon_Tracker_Name) EndIf If *Tracker\TrackerList()\ErrorString="" TrackerStatus="Работает" Else TrackerStatus=*Tracker\TrackerList()\ErrorString EndIf If *Tracker\TorrentStatus <> #TorrentStatus_Stop And *Tracker\TorrentStatus <> #TorrentStatus_Error If *Tracker\TrackerList()\UpdateTime UpdTracker = ActiveTimeSec(*Tracker\TrackerList()\UpdateTime) Else If *Tracker\TorrentStatus = #TorrentStatus_Load Or *Tracker\TorrentStatus = #TorrentStatus_Seed UpdTracker = "Обновление...." Else UpdTracker = "" EndIf TrackerStatus="" EndIf Else UpdTracker = "" TrackerStatus="" EndIf If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, #MainWin_Panel_Info_ListIcon_Tracker_Status)<>TrackerStatus SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, TrackerStatus, #MainWin_Panel_Info_ListIcon_Tracker_Status) EndIf If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, #MainWin_Panel_Info_ListIcon_Tracker_Update)<>UpdTracker SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, UpdTracker, #MainWin_Panel_Info_ListIcon_Tracker_Update) EndIf If UpdTracker<>"" Or TrackerStatus<>"" String = Str(*Tracker\TrackerList()\Complete) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, #MainWin_Panel_Info_ListIcon_Tracker_Seed)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, String, #MainWin_Panel_Info_ListIcon_Tracker_Seed) EndIf String = Str(*Tracker\TrackerList()\Incomplete) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, #MainWin_Panel_Info_ListIcon_Tracker_Peer)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, String, #MainWin_Panel_Info_ListIcon_Tracker_Peer) EndIf Else If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, #MainWin_Panel_Info_ListIcon_Tracker_Seed)<>"" SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, "", #MainWin_Panel_Info_ListIcon_Tracker_Seed) EndIf If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, #MainWin_Panel_Info_ListIcon_Tracker_Peer)<>"" SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Tracker, i, "", #MainWin_Panel_Info_ListIcon_Tracker_Peer) EndIf EndIf i+1 Next If Update = #True SendMessage_(Gadget, #WM_SETREDRAW, #True, 0) InvalidateRect_(Gadget, 0, 0) header = SendMessage_(Gadget, #LVM_GETHEADER, 0, 0) InvalidateRect_(header, 0, 1) EndIf Else If CountGadgetItems(#MainWin_Panel_Info_ListIcon_Tracker)>0 ClearGadgetItems(#MainWin_Panel_Info_ListIcon_Tracker) EndIf EndIf OldPos=Pos EndProcedure Procedure Out_Panel_Peer(*PeerInfo.OutData_Panel_Info_PeerInfo, Pos, UpdateList.a) ; Вывод данных в теблицу "Пиры", панели информации. Protected Update.a, NewFlag.a, CountList, CountItem Protected i, Gadget, Temp, String.s If *PeerInfo And Pos>=0 And UpdateList Update = #False NewFlag = #False CountList = ListSize(*PeerInfo\Peer()) CountItem = CountGadgetItems(#MainWin_Panel_Info_ListIcon_Peer) Gadget = GadgetID(#MainWin_Panel_Info_ListIcon_Peer) If CountList>CountItem ; В списке больше элементов, чем в таблице. SendMessage_(Gadget, #WM_SETREDRAW, #False, 0) Update = #True Temp = CountList-1 For i=CountItem To Temp AddGadgetItem(#MainWin_Panel_Info_ListIcon_Peer, i, "") Next i ElseIf CountList*PeerInfo\Peer()\NumFlag ListIcon_SetItem_ImageNumber(Gadget, i, *PeerInfo\Peer()\NumFlag) EndIf String = *PeerInfo\Peer()\PeerAddress If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_IP)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_IP) EndIf String = *PeerInfo\Peer()\Local If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_Local)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_Local) EndIf String = *PeerInfo\Peer()\Client If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_ClientName)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_ClientName) EndIf String = *PeerInfo\Peer()\PeerFlags If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_Flags)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_Flags) EndIf String = *PeerInfo\Peer()\Request If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_Request)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_Request) EndIf String = StrF(*PeerInfo\Peer()\Percent / 10, 1) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_Percent)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_Percent) EndIf String = ConvertByte_ToString(*PeerInfo\Peer()\InBytes, 2)+"/с" If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_In)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_In) EndIf String = ConvertByte_ToString(*PeerInfo\Peer()\OutBytes, 2)+"/с" If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_Out)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_Out) EndIf String = ConvertByte_ToString(*PeerInfo\Peer()\All_Upload, 2) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_Upload)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_Upload) EndIf String = ConvertByte_ToString(*PeerInfo\Peer()\All_Download, 2) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_Download)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_Download) EndIf If *PeerInfo\Peer()\In_Speed_Peer>0 String = ConvertByte_ToString(*PeerInfo\Peer()\In_Speed_Peer, 2)+"/с" Else String = "" EndIf If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, #MainWin_Panel_Info_ListIcon_Peer_SpeedPeer)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Peer, i, String, #MainWin_Panel_Info_ListIcon_Peer_SpeedPeer) EndIf i+1 Next If Update = #True SendMessage_(Gadget, #WM_SETREDRAW, #True, 0) InvalidateRect_(Gadget, 0, 0) Temp = SendMessage_(Gadget, #LVM_GETHEADER, 0, 0) InvalidateRect_(Temp, 0, 1) ElseIf NewFlag=#True InvalidateRect_(Gadget, 0, 0) EndIf Else If CountGadgetItems(#MainWin_Panel_Info_ListIcon_Peer)>0 ClearGadgetItems(#MainWin_Panel_Info_ListIcon_Peer) EndIf EndIf EndProcedure Procedure Out_Panel_Files_CopyPieceInfo(Array Piece.a(1), ArraySize.l, Item.l, PieceStart.l, PieceEnd.l, *Count_Piece.Long) Protected *Point, MemPos, Byte.a, TempA.a Protected i, Shift.a, CountPiece, Index Protected Mask.a, x If ArraySize>0 CountPiece = PieceEnd-PieceStart If CountPiece<=0 : CountPiece=1 : EndIf MemPos=0 *Point = GetGadgetItemData(#MainWin_Panel_Info_ListIcon_Files, Item) If *Point If PeekL(*Point)<>CountPiece FreeMemory(*Point) *Point=0 EndIf EndIf If *Point=0 *Point=AllocateMemory(CountPiece/8+8) EndIf If *Point PokeL(*Point, CountPiece) MemPos+4 Shift = PieceStart % 8 Index = PieceStart / 8 Mask = 8-Shift If PieceEnd>ArraySize*8 : PieceEnd=ArraySize*8 : EndIf If Shift = 0 ; Точно делится на 8. CopyMemory(@Piece()+Index, *Point+MemPos, PieceEnd/8-Index+1) Else ; Надо двигать биты. For i=PieceStart To PieceEnd Step 8 If Index>ArraySize : Break : EndIf Byte = Piece(Index) Byte>>Shift TempA = Piece(Index+1) TempA< CountPiece Break 2 EndIf If Byte&1 *Count_Piece\l + 1 EndIf Byte>>1 Next x Next i EndIf EndIf EndProcedure Procedure Out_Panel_Files(*FileInfo.Sub_TorrentInfo_TorrentList_MapFile, Pos, UpdateList.a) ; Вывод данных в теблицу "Файлы", панели информации. Protected Update.a, NewFlag.a, CountArray, CountItem Protected i, Gadget, Temp, String.s Protected *Point, SizeArray_Piece, TempF.f Static OldPos If *FileInfo And Pos>=0 And UpdateList If Test_LockMutex(G_ProgramMiscInfo\ListIcon_Files_Mutex, 100) Update = #False NewFlag = #False CountArray = ArraySize(*FileInfo\MapFiles()) CountItem = CountGadgetItems(#MainWin_Panel_Info_ListIcon_Files) SizeArray_Piece = ArraySize(*FileInfo\MapPiece()) Gadget = GadgetID(#MainWin_Panel_Info_ListIcon_Files) If CountArray>CountItem ; В списке больше элементов, чем в таблице. SendMessage_(Gadget, #WM_SETREDRAW, #False, 0) Update = #True Temp = CountArray-1 For i=CountItem To Temp AddGadgetItem(#MainWin_Panel_Info_ListIcon_Files, i, "") Next i ElseIf CountArray"" ListIconFiles_SetItemImage(Gadget, i, String, G_ProgramMiscInfo\hImageList_ListIcon_Files) Else ListIcon_SetItem_ImageNumber(Gadget, i, -1) EndIf String = *FileInfo\MapFiles(i)\FileName If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, #MainWin_Panel_Info_ListIcon_Files_Name)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, String, #MainWin_Panel_Info_ListIcon_Files_Name) EndIf String = Str(i+1) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, #MainWin_Panel_Info_ListIcon_Files_Number)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, String, #MainWin_Panel_Info_ListIcon_Files_Number) EndIf String = ConvertByte_ToString(*FileInfo\MapFiles(i)\SizeFile, 2) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, #MainWin_Panel_Info_ListIcon_Files_Size)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, String, #MainWin_Panel_Info_ListIcon_Files_Size) EndIf If *FileInfo\MapFiles(i)\RealFileSize=-1 Temp = 1 : Else : Temp = 0 EndIf String = ConvertByte_ToString(*FileInfo\MapFiles(i)\RealFileSize+Temp, 2) If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, #MainWin_Panel_Info_ListIcon_Files_Download)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, String, #MainWin_Panel_Info_ListIcon_Files_Download) EndIf If *FileInfo\MapFiles(i)\RealFileSize>0 TempF=(*FileInfo\MapFiles(i)\SizeFile / *FileInfo\MapFiles(i)\RealFileSize) If TempF>0 String = StrF((1000/TempF)/10, 1) Else String = "0.0" EndIf Else If *FileInfo\MapFiles(i)\SizeFile=0 String = "100.0" Else String = "0.0" EndIf EndIf If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, #MainWin_Panel_Info_ListIcon_Files_Percent)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, String, #MainWin_Panel_Info_ListIcon_Files_Percent) EndIf Temp=*FileInfo\MapFiles(i)\PieceEnd-*FileInfo\MapFiles(i)\PieceStart If Temp=<0 : Temp=1 : EndIf String = Str(Count_Piece(i)\l)+" ("+Str(Temp)+")" If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, #MainWin_Panel_Info_ListIcon_Files_CountPiece)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, String, #MainWin_Panel_Info_ListIcon_Files_CountPiece) EndIf Select *FileInfo\MapFiles(i)\Priorityt Case #PriorityFiles_Normal ; Нормальный приоритет. String = "Нормальный" Case #PriorityFiles_Min ; Низкий приоритет. String = "Высокий" Case #PriorityFiles_Max ; Высокий приоритет. String = "Низкий" Case #PriorityFiles_NoFile ; Пропуск файла (не загружать файл). String = "Пропуск файла" Default String = "" EndSelect If GetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, #MainWin_Panel_Info_ListIcon_Files_Priority)<>String SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Files, i, String, #MainWin_Panel_Info_ListIcon_Files_Priority) EndIf SetGadgetData(#MainWin_Panel_Info_ListIcon_Files, 10) Next i If Update = #True SendMessage_(Gadget, #WM_SETREDRAW, #True, 0) InvalidateRect_(Gadget, 0, 0) Temp = SendMessage_(Gadget, #LVM_GETHEADER, 0, 0) InvalidateRect_(Temp, 0, 0) EndIf EndIf Else Temp=CountGadgetItems(#MainWin_Panel_Info_ListIcon_Files) If Temp>0 Temp-1 If Test_LockMutex(G_ProgramMiscInfo\ListIcon_Files_Mutex, 400) For i=0 To Temp *Point = GetGadgetItemData(#MainWin_Panel_Info_ListIcon_Files, i) If *Point SetGadgetItemData(#MainWin_Panel_Info_ListIcon_Files, i, 0) FreeMemory(*Point) EndIf Next UnlockMutex(G_ProgramMiscInfo\ListIcon_Files_Mutex) ClearGadgetItems(#MainWin_Panel_Info_ListIcon_Files) EndIf EndIf EndIf If OldPos <> Pos PostMessage_(GadgetID(#MainWin_Panel_Info_ListIcon_Files), #LVM_UPDATE, 0, 0) EndIf OldPos = Pos EndProcedure Procedure Out_Panel_Pieces(List PieceInfo.Sub_TorrentInfo_TorrentList_BlockInfo(), Pos, UpdateList.a) ; Вывод данных в теблицу "Части", панели информации. Protected Update.a, NewFlag.a, CountList, CountItem Protected i, Gadget, Temp, String.s Protected *Point, CountBlock.l Static OldPos If Pos>=0 And UpdateList If Test_LockMutex(G_ProgramMiscInfo\ListIcon_Piece_Mutex, 100) Update = #False NewFlag = #False CountList = ListSize(PieceInfo()) CountItem = CountGadgetItems(#MainWin_Panel_Info_ListIcon_Piece) Gadget = GadgetID(#MainWin_Panel_Info_ListIcon_Piece) If CountList>CountItem ; В списке больше элементов, чем в таблице. SendMessage_(Gadget, #WM_SETREDRAW, #False, 0) Update = #True Temp = CountList ; -1 For i=CountItem To Temp AddGadgetItem(#MainWin_Panel_Info_ListIcon_Piece, i, "") Next i ElseIf CountListCountBlock FreeMemory(*Point) *Point=0 EndIf EndIf If *Point=0 *Point=AllocateMemory(CountBlock+4) EndIf If *Point PokeL(*Point, CountBlock) CopyMemory(@PieceInfo()\BlockInfo(), *Point+4, CountBlock) EndIf SetGadgetItemData(#MainWin_Panel_Info_ListIcon_Piece, i, *Point) i+1 Next UnlockMutex(G_ProgramMiscInfo\ListIcon_Piece_Mutex) If Update = #False SendMessage_(Gadget, #WM_SETREDRAW, #True, 0) EndIf CountItem=0 ;: CountBlock-1 ForEach PieceInfo() Temp=0 CountBlock = PieceInfo()\CountBlock-1 For i=0 To CountBlock If PieceInfo()\BlockInfo(i)=2 Temp+1 EndIf Next i SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Piece, CountItem , Str(PieceInfo()\Piece), #MainWin_Panel_Info_ListIcon_Piece_Number) SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Piece, CountItem , ConvertByte_ToString(PieceInfo()\Size, 2), #MainWin_Panel_Info_ListIcon_Piece_Size) SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Piece, CountItem , Str(PieceInfo()\CountBlock), #MainWin_Panel_Info_ListIcon_Piece_Block) SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Piece, CountItem , Str(Temp), #MainWin_Panel_Info_ListIcon_Piece_End) SetGadgetItemText(#MainWin_Panel_Info_ListIcon_Piece, CountItem , Str(PieceInfo()\CountAvailable), #MainWin_Panel_Info_ListIcon_Piece_Available) CountItem+1 Next If Update = #True SendMessage_(Gadget, #WM_SETREDRAW, #True, 0) InvalidateRect_(Gadget, 0, 0) Temp = SendMessage_(Gadget, #LVM_GETHEADER, 0, 0) InvalidateRect_(Temp, 0, 0) EndIf EndIf Else Temp=CountGadgetItems(#MainWin_Panel_Info_ListIcon_Piece) If Temp>0 Temp-1 If Test_LockMutex(G_ProgramMiscInfo\ListIcon_Piece_Mutex, 400) For i=0 To Temp *Point = GetGadgetItemData(#MainWin_Panel_Info_ListIcon_Piece, i) If *Point SetGadgetItemData(#MainWin_Panel_Info_ListIcon_Piece, i, 0) FreeMemory(*Point) EndIf Next UnlockMutex(G_ProgramMiscInfo\ListIcon_Piece_Mutex) ClearGadgetItems(#MainWin_Panel_Info_ListIcon_Piece) EndIf EndIf EndIf If OldPos <> Pos PostMessage_(GadgetID(#MainWin_Panel_Info_ListIcon_Piece), #LVM_UPDATE, 0, 0) EndIf OldPos = Pos EndProcedure Procedure Out_Panel_Info_SpeedGraph_Draw(x.a, y.a, w.u, h.u, MaxSpeed.l, Speed_CoboBox.a, Max, StepTime) ; Прорисовка графика скорости. Protected Size, Width.u, Height.u Protected X_Correct.f, OldPos.f, Pos.f Protected OldY, Speed.l, S_Speed.q, Temp, TempF.f Protected Count, All_Count, Y_Pos, VirtualPixel;, StartElement Width = w-x Height = h-y-1 X_Correct = (w-4)/Max VirtualPixel = Max/100 FrontColor(RGB(62, 88, 220)) ; Цвет графика входящей скорости. Size = ListSize(G_TorrentList\Info\Speed\Speed_In()) If Size>0 If Size>Max Temp = Max Temp+VirtualPixel ;+VirtualPixel-2;+1Round(X_Correct,#PB_Round_Up) If Temp>=Size Temp = Size-2 EndIf Else Temp = Size-1 EndIf Count=0 If Temp>0 OldY = h-1 : OldPos=w+x-2-(X_Correct*Temp)+Count: Pos = w+x-2-(X_Correct*Temp)+Count : S_Speed = 0 Count = 0 : All_Count = 0 ;: Debug Count;OldPos SelectElement(G_TorrentList\Info\Speed\Speed_In(), Temp) While PreviousElement(G_TorrentList\Info\Speed\Speed_In()) <> 0 Speed = G_TorrentList\Info\Speed\Speed_In() S_Speed + Speed Count + 1 All_Count + 1 Pos+X_Correct If Count>=VirtualPixel ;And Draw_StartPosPos ;Pos-OldPos>=1 Temp = S_Speed/Count Y_Pos = Round((MaxSpeed-Temp)/(MaxSpeed/(Height))+y, #PB_Round_Up) If OldPosw+x-2;All_Count>=Max Break EndIf Wend EndIf EndIf FrontColor(RGB(194, 69, 128)) ; Цвет графика изходящей скорости. Size = ListSize(G_TorrentList\Info\Speed\Speed_Out()) If Size>0 If Size>Max Temp = Max Temp+VirtualPixel ;+VirtualPixel-2;+1Round(X_Correct,#PB_Round_Up) If Temp>=Size Temp = Size-2 EndIf Else Temp = Size-1 EndIf Count=0 If Temp>0 OldY = h-1 : OldPos=w+x-2-(X_Correct*Temp)+Count: Pos = w+x-2-(X_Correct*Temp)+Count : S_Speed = 0 Count = 0 : All_Count = 0 ;: Debug Count;OldPos SelectElement(G_TorrentList\Info\Speed\Speed_Out(), Temp) While PreviousElement(G_TorrentList\Info\Speed\Speed_Out()) <> 0 Speed = G_TorrentList\Info\Speed\Speed_Out() S_Speed + Speed Count + 1 All_Count + 1 Pos+X_Correct If Count>=VirtualPixel ;And Draw_StartPosPos ;Pos-OldPos>=1 Temp = S_Speed/Count Y_Pos = Round((MaxSpeed-Temp)/(MaxSpeed/(Height))+y, #PB_Round_Up) If OldPosw+x-2 Break EndIf Wend EndIf EndIf EndProcedure Procedure Out_Panel_Info_SpeedGraph() ; Отображение графика на вкладке "Скорость" панели информации. Static SizeW.w, SizeH.w;, Protected x, ImageWidth.w, ImageHeight.w Protected Temp_1, Temp_2, TextWidth.w, TextHeight.w Protected Text.s, i, TempF.f, Pos.f Protected Text_1.s, Text_2.s Protected MaxSpeed.l, Speed_CoboBox.a, Max, StepTime, Image Static ImNum.a If ImNum=0 Image=#MainWin_Panel_Info_Image_SpeedGraph_1 Else Image=#MainWin_Panel_Info_Image_SpeedGraph_2 EndIf ImageWidth = G_ProgramMiscInfo\Panel_Info_MiscInfo_ImageWidth-4 ImageHeight = G_ProgramMiscInfo\Panel_Info_MiscInfo_ImageHeight-30 Speed_CoboBox = G_ProgramMiscInfo\Setting\Speed_CoboBoxState If SizeW<>ImageWidth Or SizeH<>ImageHeight Or IsImage(#MainWin_Panel_Info_Image_SpeedGraph_Temp)=0 If CreateImage(#MainWin_Panel_Info_Image_SpeedGraph_Temp, ImageWidth, ImageHeight) = 0 ProcedureReturn 0 EndIf SizeW=ImageWidth : SizeH=ImageHeight EndIf Select Speed_CoboBox Case 0 : Text_1 = "10 секунд." Max = 10*10 : StepTime=1 Case 1 : Text_1 = "1 минута." Max = 10*60 : StepTime=5 Case 2 : Text_1 = "5 минут." Max = 5*60*10 : StepTime=30 Case 3 : Text_1 = "1 час." Max = 60*60*10 : StepTime=5*60 EndSelect i=0 MaxSpeed=0 ; Выясняем максимальную скорость за всё время наблидения (10 часов максимум). ForEach G_TorrentList\Info\Speed\Speed_In() If MaxSpeedMax Break EndIf i+1 Next i=0 ForEach G_TorrentList\Info\Speed\Speed_Out() If MaxSpeedMax Break EndIf i+1 Next If MaxSpeed<1000 MaxSpeed=1024 Else MaxSpeed+MaxSpeed/40 EndIf If StartDrawing(ImageOutput(#MainWin_Panel_Info_Image_SpeedGraph_Temp)) Box(0,0,ImageWidth,ImageHeight,RGB(19, 78, 60)) DrawingFont(G_ProgramMiscInfo\Font_SpeedGraph) DrawingMode(#PB_2DDrawing_Transparent) FrontColor(RGB(229, 254, 234)) ; Цвет текста и линий. TextHeight = TextHeight("aAр8") Temp_2 = MaxSpeed For i=1 To 4 If Temp_2/1024 < 1000 Text = Str(Temp_2/1024) Break EndIf Temp_2/1024 Next i TextWidth = TextWidth(Text) DrawText(30-TextWidth-2, 8, Text) Select i Case 1 Text_2 = "КБ" Case 2 Text_2 = "МБ" Case 3 Text_2 = "ГБ" Case 4 Text_2 = "ТБ" EndSelect Temp_1 = ImageWidth-40 Temp_2 = ImageHeight-4-TextHeight Line(30,10,Temp_1, 1) ; Верхняя линия. Line(30,Temp_2, Temp_1, 1) ; Нижнаяя линия. Line(30,10,1, Temp_2-10) ; Левая линия Line(Temp_1+30-1,10,1, Temp_2-10) ; Правая линия. DrawText(30,Temp_2,"Шаг сетки: "+Text_1) Text = Text_2+"/с" TextWidth = TextWidth(Text) DrawRotatedText(24-TextHeight, (Temp_2+10)/2+TextWidth/2, Text, 90) Text = "0" TextWidth = TextWidth(Text) DrawText(30-TextWidth-2, Temp_2-TextHeight, Text) FrontColor(RGB(38, 120, 90)) ; Цвет сетки. TempF=(Temp_1-30)/9.3333 ; Вертикальные линии сетки. Pos = 30+TempF Repeat x=Temp_2-4 For i=11 To x Step 8 Line(Pos, i, 1, 4) Next i x = (Temp_2-i)%8 If x>0 And x =< 4 Line(Pos, Temp_2-x, 1, x) EndIf Pos + TempF Until Pos>= Temp_1 TempF=(Temp_2-10)/4 ; Горизонтальные лини сетки. Pos = 10+TempF Repeat x=Temp_1+24 For i=31 To x Step 8 Line(i, Pos, 4, 1) Next i x = (Temp_1-i)%8+4 If x>0 And x =< 4 Line(Temp_1-x+28, Pos, x, 1) EndIf Pos + TempF Until Pos>= Temp_2 Out_Panel_Info_SpeedGraph_Draw(30, 10, Temp_1, Temp_2, MaxSpeed, Speed_CoboBox, Max, StepTime) ; Прорисовка графика скорости. StopDrawing() x = CopyImage(#MainWin_Panel_Info_Image_SpeedGraph_Temp, Image) SetGadgetState(#MainWin_Panel_Info_Speed_ImageGraph, x) EndIf EndProcedure Procedure Out_CopyData_Panel_Info_MiscInfo(*MiscInfo.OutData_Panel_Info_MiscInfo) If *MiscInfo CopyStructure(G_TorrentList\TorrentList()\Network_IO, *MiscInfo\Network_IO, Sub_TorrentInfo_TorrentList_Network_IO) *MiscInfo\Network_IO\InSpeed = G_TorrentList\TorrentList()\Average_InSpeed *MiscInfo\Network_IO\OutSpeed = G_TorrentList\TorrentList()\Average_OutSpeed CopyArray(G_TorrentList\TorrentList()\Torrent\MapFile\MapPiece(), *MiscInfo\MapPiece()) CopyArray(G_TorrentList\TorrentList()\Network\AccessiblyPiece(), *MiscInfo\AccessiblyPiece()) *MiscInfo\Percent = 100 /(G_TorrentList\TorrentList()\Torrent\Torrent_FileSize / G_TorrentList\TorrentList()\Torrent\CurrentFileSize) *MiscInfo\ActiveTimeSec = G_TorrentList\TorrentList()\ActiveTimeSec *MiscInfo\AddDate = G_TorrentList\TorrentList()\AddDate *MiscInfo\TorrentStatus = G_TorrentList\TorrentList()\TorrentStatus *MiscInfo\All_Size = G_TorrentList\TorrentList()\TorrentFile\All_Size *MiscInfo\Comment = G_TorrentList\TorrentList()\TorrentFile\comment *MiscInfo\CountPiece = G_TorrentList\TorrentList()\Torrent\CountPiece *MiscInfo\INFO_Hash = G_TorrentList\TorrentList()\TorrentFile\INFO_Hash *MiscInfo\Path = G_TorrentList\TorrentList()\Torrent\Path *MiscInfo\piece_length = G_TorrentList\TorrentList()\TorrentFile\piece_length *MiscInfo\Publisher = G_TorrentList\TorrentList()\TorrentFile\Publisher *MiscInfo\Publisher_Url = G_TorrentList\TorrentList()\TorrentFile\Publisher_Url *MiscInfo\CurrentFileSize = G_TorrentList\TorrentList()\Torrent\CurrentFileSize EndIf EndProcedure Procedure Out_CopyData_Panel_Info_Tracker(*TrackerInfo.OutData_Panel_Info_TrackerInfo) If *TrackerInfo ForEach G_TorrentList\TorrentList()\Network\Tracker() If AddElement(*TrackerInfo\TrackerList()) *TrackerInfo\TrackerList()\Address = G_TorrentList\TorrentList()\Network\Tracker()\Address *TrackerInfo\TrackerList()\Complete = G_TorrentList\TorrentList()\Network\Tracker()\Complete *TrackerInfo\TrackerList()\ErrorString = G_TorrentList\TorrentList()\Network\Tracker()\ErrorString *TrackerInfo\TrackerList()\Incomplete = G_TorrentList\TorrentList()\Network\Tracker()\Incomplete *TrackerInfo\TrackerList()\UpdateTime = G_TorrentList\TorrentList()\Network\Tracker()\UpdateTime EndIf Next *TrackerInfo\TorrentStatus = G_TorrentList\TorrentList()\TorrentStatus EndIf EndProcedure Procedure Out_CopyData_Panel_Info_Peer(*PeerInfo.OutData_Panel_Info_PeerInfo) Protected NewList TaskList.ProgramStatus_Network_DomainsPeer() Protected PeerAddress.s, x.a, Info.Peer_Handshake Protected Flag.w If *PeerInfo ForEach G_TorrentList\TorrentList()\Network\PeerList() If G_TorrentList\TorrentList()\Network\PeerList()\Active = #True ; С этим пиром происходит обмен даными и его необходимо отобразить в таблице. If AddElement(*PeerInfo\Peer()) If G_ProgramMiscInfo\Setting\ShowDomainsName ; Разрешено отображение доменного имени. If G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Domains<>"" PeerAddress = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Domains Flag = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Flag Else PeerAddress = G_TorrentList\TorrentList()\Network\PeerList()\IP$ Flag=-1 If AddElement(TaskList()) TaskList()\INFO_Hash = G_TorrentList\TorrentList()\TorrentFile\INFO_Hash TaskList()\IP_Peer = PeerAddress TaskList()\IP = G_TorrentList\TorrentList()\Network\PeerList()\IP TaskList()\Active = 0 EndIf EndIf Else PeerAddress = G_TorrentList\TorrentList()\Network\PeerList()\IP$ Flag=-1 EndIf *PeerInfo\Peer()\PeerAddress = PeerAddress *PeerInfo\Peer()\NumFlag = Flag *PeerInfo\Peer()\Local = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Local *PeerInfo\Peer()\Client = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Client *PeerInfo\Peer()\PeerFlags = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\PeerFlags *PeerInfo\Peer()\Request = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Request *PeerInfo\Peer()\Percent = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\Percent *PeerInfo\Peer()\InBytes = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\InBytes *PeerInfo\Peer()\OutBytes = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\OutBytes *PeerInfo\Peer()\All_Upload = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\All_Upload *PeerInfo\Peer()\All_Download = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\All_Download *PeerInfo\Peer()\In_Speed_Peer = G_TorrentList\TorrentList()\Network\PeerList()\Out_Table\In_Speed_Peer EndIf EndIf Next If G_ProgramMiscInfo\Setting\ShowDomainsName ; Разрешено отображение доменного имени. If ListSize(TaskList())>0 ; Если задания, получения доменого имни и флага пира. If Test_LockMutex(G_ProgramMiscInfo\Network\DomainsPeer_Mutex, 100) = #True ForEach TaskList() x=#False ForEach G_ProgramMiscInfo\Network\DomainsPeer_TaskList() If G_ProgramMiscInfo\Network\DomainsPeer_TaskList()\INFO_Hash = TaskList()\INFO_Hash And G_ProgramMiscInfo\Network\DomainsPeer_TaskList()\IP_Peer = TaskList()\IP_Peer x=#True ; Такое задание есть в списке и нет смысла его дублировать. Break EndIf Next If x=#False If AddElement(G_ProgramMiscInfo\Network\DomainsPeer_TaskList()) CopyStructure(TaskList(), G_ProgramMiscInfo\Network\DomainsPeer_TaskList(), ProgramStatus_Network_DomainsPeer) EndIf EndIf Next UnlockMutex(G_ProgramMiscInfo\Network\DomainsPeer_Mutex) SignalSemaphore(G_ProgramMiscInfo\Network\DomainsPeer_Semaphore) EndIf EndIf EndIf EndIf EndProcedure Procedure OutText_Update_Speed() ; Обновление данных о скорости. G_TorrentList\Info\Speed\All_InBytes + G_TorrentList\Info\Speed\InSpeed G_TorrentList\Info\Speed\All_OutBytes + G_TorrentList\Info\Speed\OutSpeed G_TorrentList\Info\Speed\In_Speed + G_TorrentList\Info\Speed\InSpeed G_TorrentList\Info\Speed\Out_Speed + G_TorrentList\Info\Speed\OutSpeed FirstElement(G_TorrentList\Info\Speed\Speed_In()) If InsertElement(G_TorrentList\Info\Speed\Speed_In()) G_TorrentList\Info\Speed\Speed_In() = G_TorrentList\Info\Speed\Average_InSpeed ;G_TorrentList\Info\Speed\InSpeed EndIf If ListSize(G_TorrentList\Info\Speed\Speed_In())>=36000 ; 10 часов. If LastElement(G_TorrentList\Info\Speed\Speed_In()) DeleteElement(G_TorrentList\Info\Speed\Speed_In()) EndIf EndIf FirstElement(G_TorrentList\Info\Speed\Speed_Out()) If InsertElement(G_TorrentList\Info\Speed\Speed_Out()) G_TorrentList\Info\Speed\Speed_Out() = G_TorrentList\Info\Speed\Average_OutSpeed ;G_TorrentList\Info\Speed\OutSpeed EndIf If ListSize(G_TorrentList\Info\Speed\Speed_Out())>=36000 ; 10 часов. If LastElement(G_TorrentList\Info\Speed\Speed_Out()) DeleteElement(G_TorrentList\Info\Speed\Speed_Out()) EndIf EndIf EndProcedure Procedure OutText_Core(SemaphoreState.b) Protected Update.a, x, TempS.s, Panel_Info_Page Protected List_Torrent_Pos.l, Size.l Protected NewList TableTorrent.OutTextTableTorrent() Protected Panel_MiscInfo.OutData_Panel_Info_MiscInfo Protected Panel_TrackerInfo.OutData_Panel_Info_TrackerInfo Protected Panel_PeerInfo.OutData_Panel_Info_PeerInfo Protected Panel_FileInfo.Sub_TorrentInfo_TorrentList_MapFile Protected NewList Panel_PieceInfo.Sub_TorrentInfo_TorrentList_BlockInfo() List_Torrent_Pos = G_ProgramMiscInfo\List_Torrent_Pos Panel_Info_Page = G_ProgramMiscInfo\Panel_Info_Page If SemaphoreState<>2 Or (Panel_Info_Page=0 Or Panel_Info_Page=5) ;Debug SemaphoreState If Test_LockMutex(G_TorrentList\Mutex, 200) = #True If SemaphoreState=0 Out_CopyData_TableTorrent(TableTorrent()) EndIf Update = 0 Size = ListSize(G_TorrentList\TorrentList()) If Size>0 If List_Torrent_Pos>=0 And List_Torrent_Pos2 Out_Panel_MiscInfo(@Panel_MiscInfo, Update) EndIf PanelInfo_DrawImage(@Panel_MiscInfo, SemaphoreState, Update) ClearStructure(@Panel_MiscInfo, OutData_Panel_Info_MiscInfo) Case 1 ; Трекеры. Out_Panel_Tracker(@Panel_TrackerInfo, List_Torrent_Pos, Update) ClearStructure(@Panel_TrackerInfo, OutData_Panel_Info_TrackerInfo) Case 2 ; Пиры. Out_Panel_Peer(@Panel_PeerInfo, List_Torrent_Pos, Update) ClearStructure(@Panel_PeerInfo, OutData_Panel_Info_PeerInfo) Case 3 ; Файлы. Out_Panel_Files(@Panel_FileInfo, List_Torrent_Pos, Update) ClearStructure(@Panel_FileInfo, Sub_TorrentInfo_TorrentList_MapFile) Case 4 ; Части. Out_Panel_Pieces(Panel_PieceInfo(), List_Torrent_Pos, Update) ; Вывод данных в теблицу "Части", панели информации. ClearList(Panel_PieceInfo()) Case 5 ; Скорость. Out_Panel_Info_SpeedGraph() EndSelect EndIf EndIf EndProcedure Procedure Out_Tray() ; Вывод подстазки в трее. Protected x.b=0, Message.s, Temp Protected Title.s, Icon.l Static OldMessage.s, BalloonTimer.a If Test_TrayIcon(#SysTrayID, WindowID(#MainWin))=0 ; Не обнаружена иконка в трее G_ProgramMiscInfo\TrayInfo\Balloon_Visible = #False G_ProgramMiscInfo\TrayInfo\Balloon_Old_Visible=#False : BalloonTimer=0 If AddSysTrayIcon(#SysTrayID, WindowID(#MainWin), ImageID(#MainWin_TrayIcon)) x=1 : OldMessage = "" EndIf Else x=1 EndIf If x=1 Message=#MessageName+Chr(10) Message +"Входящая скорость: "+ConvertByte_ToString(G_TorrentList\Info\Speed\Average_InSpeed, 2)+"/c; исходящая: "+ConvertByte_ToString(G_TorrentList\Info\Speed\Average_OutSpeed, 2) If OldMessage <> Message SysTrayIconToolTip(#SysTrayID, Message) OldMessage = Message EndIf If G_ProgramSetting\Misc\BalloonTray If G_ProgramMiscInfo\TrayInfo\Balloon_Visible = #False ; Всплывающее окно не отображатемя. If G_ProgramMiscInfo\TrayInfo\Balloon_Old_Visible=#False x=0 Message="" : Title="" LockMutex(G_ProgramMiscInfo\TrayInfo\Balloon_Mutex) If ListSize(G_ProgramMiscInfo\TrayInfo\BalloonList())>0 FirstElement(G_ProgramMiscInfo\TrayInfo\BalloonList()) Title = G_ProgramMiscInfo\TrayInfo\BalloonList()\Title Message = G_ProgramMiscInfo\TrayInfo\BalloonList()\Message Icon = G_ProgramMiscInfo\TrayInfo\BalloonList()\Icon DeleteElement(G_ProgramMiscInfo\TrayInfo\BalloonList(), 1) x=1 EndIf UnlockMutex(G_ProgramMiscInfo\TrayInfo\Balloon_Mutex) If x=1 And Message<>"" SysTray_IconBalloon(#SysTrayID, WindowID(#MainWin), Title, Message, 20000, Icon) G_ProgramMiscInfo\TrayInfo\Balloon_Old_Visible=#True EndIf BalloonTimer=0 Else Goto Out_Tray_m1 EndIf Else G_ProgramMiscInfo\TrayInfo\Balloon_Old_Visible=#False Out_Tray_m1: BalloonTimer+1 If BalloonTimer>60 ; Не может всплывающее окно отображаться больше минуты, значит глюк. G_ProgramMiscInfo\TrayInfo\Balloon_Visible = #False BalloonTimer=0 G_ProgramMiscInfo\TrayInfo\Balloon_Old_Visible=#False EndIf EndIf EndIf EndIf EndProcedure Procedure Out_AddMessageTray_Balloon(Title.s, Message.s, Icon.l) ; Добавление сообщеия в очередь вывода сообщений во всплывающих окнах в трее. If G_ProgramSetting\Misc\BalloonTray If Message<>"" LockMutex(G_ProgramMiscInfo\TrayInfo\Balloon_Mutex) If ListSize(G_ProgramMiscInfo\TrayInfo\BalloonList())<=20 ; Ограничение на очередь соощений, чтобы не завалило ими. LastElement(G_ProgramMiscInfo\TrayInfo\BalloonList()) ; Добавление в конец очереди сообщений. If AddElement(G_ProgramMiscInfo\TrayInfo\BalloonList()) G_ProgramMiscInfo\TrayInfo\BalloonList()\Title = Title G_ProgramMiscInfo\TrayInfo\BalloonList()\Message = Message G_ProgramMiscInfo\TrayInfo\BalloonList()\Icon = Icon EndIf EndIf UnlockMutex(G_ProgramMiscInfo\TrayInfo\Balloon_Mutex) EndIf EndIf EndProcedure Procedure Out_StatusBar() ; Вывод данных в строку состояния. Protected Port_IconState.a, hToolTip.i, IconID ;Protected Protected Window_ID, Gadget_ID Static ToolTip_Text.s, CurrentIcon.i Static Icon_ToolTip, Title_ToolTip.s StatusBarText(#MainWin_StatusBar, #MainWin_StatusBar_PeerProc, DelNull(StrF(G_TorrentList\Info\PeerProc_Percent/10, 1))+" %", #PB_StatusBar_Center) StatusBarText(#MainWin_StatusBar, #MainWin_StatusBar_InSpeed, "Вх. скорость: "+DelNull(ConvertByte_ToString(G_TorrentList\Info\Speed\Average_InSpeed, 1))+"/c Всего: "+DelNull(ConvertByte_ToString(G_TorrentList\Info\Speed\In_Speed, 1))) StatusBarText(#MainWin_StatusBar, #MainWin_StatusBar_OutSpeed, "Исх. скорость: "+DelNull(ConvertByte_ToString(G_TorrentList\Info\Speed\Average_OutSpeed, 1))+"/c Всего: "+DelNull(ConvertByte_ToString(G_TorrentList\Info\Speed\Out_Speed, 1))) Port_IconState = G_TorrentList\Info\PortIconState hToolTip = G_TorrentList\Info\hToolTip_PortIcon Window_ID = WindowID(#MainWin) Gadget_ID = GadgetID(#MainWin_StatusBar_ImageGadget_Port) If hToolTip If CurrentIcon<>Port_IconState CurrentIcon=Port_IconState Select Port_IconState Case #PortIconState_No_InConnect ; Иконка "Нет входящих соединений". IconID=ImageID(#MainWin_Panel_Info_Icon_Log_Warning) ToolTip_Text = "Нет входящих соединений, "+Chr(10)+"проверьте настройки сети." Title_ToolTip="Нет вх. соединений." Icon_ToolTip=#NIIF_WARNING Case #PortIconState_Yes_InConnect ; Иконка "Есть входящие соединения". IconID=ImageID(#MainWin_StatusBar_Icon_Port_OK) ToolTip_Text = "Есть входящие соединения." Title_ToolTip="ОК." Icon_ToolTip=#NIIF_INFO Case #PortIconState_ErrCreateServer ; Иконка "Ошибка создания сервера". IconID=ImageID(#MainWin_Panel_Info_Icon_ErrCreateServer) ToolTip_Text = "Ошибка при запуске сервера. "+Chr(10)+"Возможно занят порт "+Str(G_ProgramSetting\Lan\Port)+"." Title_ToolTip="Ошибка запуска сервера." Icon_ToolTip=#NIIF_ERROR Default IconID=ImageID(#MainWin_Panel_Info_Icon_No) ToolTip_Text = "" Title_ToolTip="" Icon_ToolTip=#NIIF_NONE EndSelect SetGadgetState(#MainWin_StatusBar_ImageGadget_Port, IconID) ToolTip_Change(hToolTip, Window_ID, Gadget_ID, ToolTip_Text, Title_ToolTip, Icon_ToolTip) EndIf If CurrentIcon If ToolTip_Text<>"" If IsMouseOver(GadgetID(#MainWin_StatusBar_ImageGadget_Port)) ToolTip_Change(hToolTip, Window_ID, Gadget_ID, ToolTip_Text, Title_ToolTip, Icon_ToolTip) EndIf EndIf EndIf EndIf EndProcedure ; - меняет иконки в ListIconGadget. Procedure SetIcon_TorrentListIcon(Gadget, Item, State) Protected pitem.LV_ITEM State - #MainWin_TorrentIcon_down If State>=0 And State<8 pitem\mask = #LVIF_IMAGE pitem\iItem = Item pitem\iImage = G_ProgramMiscInfo\Torrent_ImageList[State] SendMessage_(GadgetID(Gadget), #LVM_SETITEM, 0, @pitem) EndIf EndProcedure Procedure Out_TorrentList_AllPause() ; Смена иконок при включении и отключении паузы для всех торрентов. Protected x, i, Count, NewList S_Torrent.POINT() Protected NewList TableTorrent.OutTextTableTorrent() If Test_LockMutex(G_TorrentList\Mutex, 800) = #True ForEach G_TorrentList\TorrentList() If AddElement(S_Torrent()) S_Torrent()\x = G_TorrentList\TorrentList()\TorrentStatus S_Torrent()\y = G_TorrentList\TorrentList()\Network\Error_Tracker EndIf Next UnlockMutex(G_TorrentList\Mutex) Else ProcedureReturn EndIf If Test_LockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex, 400) = #True Count = CountGadgetItems(#MainWin_ListIcon_Torrent)-1 x=ListSize(S_Torrent()) For i=0 To Count If i<=x SelectElement(S_Torrent(), i) If S_Torrent()\x = #TorrentStatus_Load Or S_Torrent()\x = #TorrentStatus_Seed If G_ProgramMiscInfo\Torrent_All_Pause=#True SetIcon_TorrentListIcon(#MainWin_ListIcon_Torrent, i, #MainWin_TorrentIcon_Pause) Else If S_Torrent()\x = #TorrentStatus_Load If S_Torrent()\y = 1 ; Ошибка при конектре к трекеру. SetIcon_TorrentListIcon(#MainWin_ListIcon_Torrent, i, #MainWin_TorrentIcon_red_down) ; Красный значок. Else SetIcon_TorrentListIcon(#MainWin_ListIcon_Torrent, i, #MainWin_TorrentIcon_down) EndIf Else If S_Torrent()\y = 1 ; Ошибка при конектре к трекеру. SetIcon_TorrentListIcon(#MainWin_ListIcon_Torrent, i, #MainWin_TorrentIcon_red_up) ; Красный значок. Else SetIcon_TorrentListIcon(#MainWin_ListIcon_Torrent, i, #MainWin_TorrentIcon_up) EndIf EndIf EndIf EndIf Else Break EndIf Next i UnlockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex) If Test_LockMutex(G_TorrentList\Mutex, 100) = #True Out_CopyData_TableTorrent(TableTorrent()) UnlockMutex(G_TorrentList\Mutex) Out_Update_TableTorrent_All(TableTorrent()) EndIf PostMessage_(G_ProgramMiscInfo\hTorrentListIcon, #WM_PAINT, 0, 0) EndIf EndProcedure Procedure Table_ActiveItem_GetLabel(List Label.String_2()) ; Чтение меток с выделеных торентов в списке (таблице). Protected x, i, Count, SizeList Protected NewList Status.a() ClearList(Label()) If Test_LockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex, 400)=#True Count = CountGadgetItems(#MainWin_ListIcon_Torrent) For i=0 To Count If GetGadgetItemState(#MainWin_ListIcon_Torrent, i) & #PB_ListIcon_Selected If AddElement(Status()) Status() = i EndIf EndIf Next i UnlockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex) If Test_LockMutex(G_TorrentList\Mutex, 400)=#True SizeList = ListSize(G_TorrentList\TorrentList()) ForEach Status() i = Status() If i<=SizeList SelectElement(G_TorrentList\TorrentList(), i) If AddElement(Label()) Label()\String_1 = G_TorrentList\TorrentList()\TorrentFile\INFO_Hash Label()\String_2 = G_TorrentList\TorrentList()\Label EndIf EndIf Next UnlockMutex(G_TorrentList\Mutex) EndIf EndIf EndProcedure Procedure Table_ActiveItem_SetLabel(List Label.String_2(), NewLabel.s) ; Присваивание метки заданным торрентам. Protected INFO_Hash.s, x Protected NewList TableTorrent.OutTextTableTorrent() If ListSize(Label())>0 If Test_LockMutex(G_TorrentList\Mutex, 400) = #True ForEach Label() INFO_Hash = Label()\String_1 x=0 ForEach G_TorrentList\TorrentList() If G_TorrentList\TorrentList()\TorrentFile\INFO_Hash = INFO_Hash G_TorrentList\TorrentList()\Label = NewLabel Break EndIf x+1 Next Next ; Вывод текста в таблицу с торрентами. Out_CopyData_TableTorrent(TableTorrent()) UnlockMutex(G_TorrentList\Mutex) Out_Update_TableTorrent_All(TableTorrent()) EndIf EndIf EndProcedure Procedure Table_Refresh_Torrent() ; Повторный запрос трекеру (обновить трекер). Protected x, i, Count, SizeList Protected NewList Status.a() If Test_LockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex, 400)=#True Count = CountGadgetItems(#MainWin_ListIcon_Torrent) For i=0 To Count If GetGadgetItemState(#MainWin_ListIcon_Torrent, i) & #PB_ListIcon_Selected If AddElement(Status()) Status() = i EndIf EndIf Next i UnlockMutex(G_ProgramMiscInfo\TorrentListIcon_Mutex) If Test_LockMutex(G_TorrentList\Mutex, 400)=#True SizeList = ListSize(G_TorrentList\TorrentList()) ForEach Status() i = Status() If i<=SizeList SelectElement(G_TorrentList\TorrentList(), i) x = G_TorrentList\TorrentList()\TorrentStatus If x = #TorrentStatus_Load Or x = #TorrentStatus_Seed ForEach G_TorrentList\TorrentList()\Network\Tracker() If G_TorrentList\TorrentList()\Network\Tracker()\UpdateTime>2 G_TorrentList\TorrentList()\Network\Tracker()\UpdateTime = 2 EndIf Next EndIf EndIf Next UnlockMutex(G_TorrentList\Mutex) EndIf EndIf EndProcedure DisableExplicit ; IDE Options = PureBasic 5.11 (Windows - x86) ; Folding = ------ ; EnableXP