Пример #1
0
 public void FileToItem(InterfaceSearchedFile file,ListViewItem itemFile)
 {
     if (file==null) return;
     if (itemFile.SubItems[0].Text!=file.Name) itemFile.SubItems[0].Text=file.Name;
     if (itemFile.SubItems[1].Text!=SizeToString(file.Size)) itemFile.SubItems[1].Text=SizeToString(file.Size);
     if (itemFile.SubItems[2].Text!=file.Avaibility.ToString()) itemFile.SubItems[2].Text=file.Avaibility.ToString();
     if (itemFile.SubItems[6].Text!="") itemFile.SubItems[6].Text="";
     if (itemFile.SubItems[3].Text!=file.Codec) itemFile.SubItems[3].Text=file.Codec;
     if (itemFile.SubItems[4].Text!=file.Length) itemFile.SubItems[4].Text=file.Length;
     if ((file.BitRate>0)&&(itemFile.SubItems[5].Text!=file.BitRate.ToString())) itemFile.SubItems[5].Text=file.BitRate.ToString();
     itemFile.Tag=file;
 }
Пример #2
0
        public InterfaceSearchedFile[] GetSearch(int SearchIndex)
        {
            if (apw)
            {
                if (SearchIndex<0) SearchIndex=CKernel.Searchs.Count-1;
                if ((CKernel.Searchs.Count==0)||(CKernel.Searchs.Count<=SearchIndex)) return null;
                CSearcher searcher=(CSearcher)CKernel.Searchs[SearchIndex];
                InterfaceSearchedFile[] filesFound=new InterfaceSearchedFile[searcher.Count];

                int i=0;
                lock (CKernel.Searchs[SearchIndex])
                {
                    foreach (CFileFound fileFound in searcher.Values)
                    {
                        filesFound[i]=FileFountToInterfaceFileFound(fileFound);
                        i++;
                    }
                }
                return filesFound;
            }
            else return null;
        }
Пример #3
0
 public void DownloadFile(InterfaceSearchedFile file, int SearchIndex)
 {
     if (apw)
     {
         DownloadElink("ed2k://|file|"+file.Name+"|"+file.Size.ToString()+"|"+file.strFileHash+"|/",false);
         //try to get soruces from the search results
         //lookup the result in the search result list
         if ((CKernel.Searchs.Count==0)||(CKernel.Searchs[SearchIndex]==null))
         {
             foreach (CSearcher searcher in CKernel.Searchs.Values)
             {
                 foreach (CFileFound fileFound in ((Hashtable)searcher.Clone()).Values)
                 {
                     if (fileFound.Hash==file.strFileHash)
                     {
                         fileFound.AddSourcesToFile();
                     }
                 }
             }
         }
         else
         {
             CSearcher searcher=(CSearcher)CKernel.Searchs[SearchIndex];
             foreach (CFileFound fileFound in ((Hashtable)searcher.Clone()).Values)
             {
                 if (fileFound.Hash==file.strFileHash)
                 {
                     if (fileFound.ResultState==Types.Constants.SearchResultState.New)
                         fileFound.ResultState=Types.Constants.SearchResultState.AlreadyDownloading;
                     fileFound.AddSourcesToFile();
                     CKernel.SearchFileModified(fileFound,SearchIndex);
                 }
             }
         }
     }
 }
Пример #4
0
 internal void SearchFileModified(InterfaceSearchedFile filefound, int searchID)
 {
     if (apw)
         if (filefound!=null) SubmitOnModifiedSearched(filefound,searchID);
 }
Пример #5
0
 internal void NewFileFound(InterfaceSearchedFile filefound, int searchID)
 {
     if (apw)
         if (filefound!=null) SubmitOnNewSearched(filefound,searchID);
 }
Пример #6
0
 internal InterfaceSearchedFile FileFountToInterfaceFileFound(CFileFound file)
 {
     if (apw)
     {
         InterfaceSearchedFile found= new InterfaceSearchedFile();
         found=new InterfaceSearchedFile();
         found.Name=file.Name;
         found.Size=file.Size;
         found.strFileHash=file.Hash;
         found.Avaibility=file.Avaibility;
         found.ResultState=file.ResultState;
         found.Codec=file.Codec;
         found.Length=file.Length;
         found.BitRate=file.BitRate;
         found.Completed=file.Complete;
         return found;
     }
     else return null;
 }
Пример #7
0
 private void m_OnNewSearched(InterfaceSearchedFile file, int searchID)
 {
     foreach (searchListView searchList in SearchesList.Values)
     {
         if ((int)searchList.Tag==searchID)
         {
             m_AddTotalResultsToTabPage(file,searchID,false,0);
             searchList.OnNewFile(file);
             break;
         }
     }
 }
Пример #8
0
 public uint OnUpdateFile(InterfaceSearchedFile file)
 {
     int i=0;
     try
     {
         ListViewItem iFile;
         do
         {
             iFile=Items[i];
             i++;
         }
         while ((((InterfaceSearchedFile)iFile.Tag).strFileHash!=file.strFileHash)&&(i<Items.Count));
         if (i-1<Items.Count)
         {
             uint diff = file.Avaibility-Convert.ToUInt32(iFile.SubItems[2].Text);
             FileToItem(file,iFile);
             return diff;
         }
         else
             return 0;
     }
     catch
     {
         return 0;
     }
 }
Пример #9
0
 private void m_InvokeOnNewSearched(InterfaceSearchedFile file, int searchID)
 {
     this.BeginInvoke(new SearchEvent(m_OnNewSearched),new object[] {file,searchID});
 }
Пример #10
0
        private void m_AddTotalResultsToTabPage(InterfaceSearchedFile file, int searchID,bool ondiff, uint diff)
        {
            try
            {
                if(!TotalResult.ContainsKey(searchID)) return;
                uint Total;

                foreach (Crownwood.Magic.Controls.TabPage TabPage in tabSearchs.TabPages)
                {
                    if ((int)TabPage.Tag==searchID)
                    {
                        if(ondiff)
                            Total = (uint)TotalResult[searchID]+diff;
                        else
                            Total = (uint)TotalResult[searchID]+file.Avaibility;

                        TotalResult[searchID] = Total;
                        TabPage.Title = TabTitle[searchID] + " (" +Total+")";
                    }
                }
            }
            catch(Exception Ex)
            {
                Debug.WriteLine(Ex.ToString());
            }
        }
Пример #11
0
 public void m_OnNewSearched(InterfaceSearchedFile file, int searchID)
 {
     if (OnNewSearched!=null) OnNewSearched(file,searchID);
 }
Пример #12
0
 public void DownloadFile(InterfaceSearchedFile fichero,int SearchIndex)
 {
     krnGateway.DownloadFile(fichero,SearchIndex);
     InterfaceFile[] files=krnGateway.GetDownloadFileList();
     CalculateFilterSummary(files);
 }
Пример #13
0
 private void m_OnNewSearched(InterfaceSearchedFile file, int searchID)
 {
     progressbar.Visible = true;
     stSearch.AppendValues(file.Name,file.Size.ToString(),file.Avaibility.ToString(),
                                 file.Codec,file.Length.ToString(),file.BitRate.ToString(),
                                 file.ResultState.ToString());
     /* Añadir cantidad de resultados */
 }
Пример #14
0
 private void m_InvokeOnNewSearched(InterfaceSearchedFile file, int searchID)
 {
     AsyncCallback callback=new AsyncCallback(MyCallback);
     SearchFileDelegate d=new SearchFileDelegate(m_OnNewSearched);
     d.BeginInvoke(file,searchID,callback,1);
 }
Пример #15
0
 public virtual void SubmitOnModifiedSearched(InterfaceSearchedFile file, int SearchIndex)
 {
     if (OnModifiedSearched!=null) OnModifiedSearched(file,SearchIndex);
 }
Пример #16
0
 private void m_OnModifiedSearched(InterfaceSearchedFile file, int searchID)
 {
     uint diff;
     foreach (searchListView searchList in SearchesList.Values)
     {
         if ((int)searchList.Tag==searchID)
         {
             diff=searchList.OnUpdateFile(file);
             m_AddTotalResultsToTabPage(file,searchID,true,diff);
         }
     }
 }
Пример #17
0
        internal static void SearchFileModified(CFileFound file, int SearchIndex)
        {
            InterfaceSearchedFile searchFile=new InterfaceSearchedFile();
            searchFile=InterfaceGateway[0].FileFountToInterfaceFileFound(file);

            for (int i=0;i<=InterfaceGateway.Length-1;i++)
            {
                if (CKernel.InterfaceGateway[i]!=null)
                {
                    InterfaceGateway[i].SearchFileModified(searchFile, SearchIndex);
                }
            }
        }
Пример #18
0
 public void OnNewFile(InterfaceSearchedFile file)
 {
     ListViewItem ItemFile =new ListViewItem(new string[]{"","","","","","",""});
     ItemFile.Tag=file;
     FileToItem(file,ItemFile);
     Items.Add(ItemFile);
     ItemFile.Tag=file;
 }