예제 #1
0
        /// <summary>Create and initialize the zoom bar control</summary>
        public eLePhantInspector()
        {
            // Prevent flicker with double buffering and all painting inside WM_PAINT
            SetStyle(ControlStyles.DoubleBuffer |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint, true);

            // Set initial state
            _borderWidth = 5;
            _barHeight = 29;
            _barSpacing = 3;
            _file = null;

            // recalculate the bars
            Recalculate();
        }
예제 #2
0
 internal void NewSharedFile(InterfaceFile file)
 {
     if (apw)
         if (file!=null) SubmitOnNewSharedFile(file);
 }
예제 #3
0
        internal InterfaceFile FileToInterfaceFile(CElement Element)
        {
            if (apw)
            {
                if (Element==null) return null;
                InterfaceFile response=new InterfaceFile();
                response.Name=Element.File.FileName;
                response.CompleteName=Element.File.CompleteName;
                response.Size=Element.File.FileSize;
                response.BytesDownloaded=Element.File.Transferred;
                response.RemainingBytes=Element.File.GetRemainingBytes();
                response.Status=(byte)Element.File.FileStatus;
                response.ChunksStatus=Element.File.ChunksStatus;
                response.UploadPriority=Element.File.UpPriority;
                response.DownloadPriority=Element.File.DownPriority;
                response.Gaps=Element.File.Gaps;
                response.RequestingBlocks=Element.File.RequestingBlocks;
                response.UploadChunksAvaibility=Element.Statistics.UploadAvaibility;
                if (response.ChunksStatus.Length==0)
                {
                    response.ChunksStatus=new byte[CHash.GetChunksCount(Element.File.FileSize)];
                    for (int i=0; i < response.ChunksStatus.Length; i++)
                    {
                        response.ChunksStatus[i]=(byte)Protocol.ChunkState.Empty;
                    }
                }
                response.MaxSources=Element.File.MaxSourcesInt;
                if (Element.SourcesList!=null)
                {
                    response.nSources=(ushort)Element.SourcesList.Count();
                    response.DownSpeed=Element.SourcesList.GetDownloadSpeed();
                    response.ChunksAvaibility=Element.SourcesList.GetChunksAvaibility();
                    response.nValidSources=Element.SourcesList.GetUsableClients();
                    response.nTransferringSources=Element.SourcesList.GetDownloadingClients();
                }
                else
                {
                    response.DownSpeed=0;
                    response.nSources=0;
                }
                response.strHash=CKernel.HashToString(Element.File.FileHash);

                if(response.Size!=0)
                    response.PercentCompleted=(decimal)(response.Size-response.RemainingBytes)/response.Size;
                else
                    response.PercentCompleted=0;

                response.CategoryID=Element.File.CategoryID;
                if (Element.File.FileStatus!=Protocol.FileState.Complete)
                    response.Category=CKernel.CategoriesList[Element.File.CategoryID];
                else
                    response.Category="";

                return response;
            }
            else return null;
        }
예제 #4
0
 public virtual void SubmitOnRemovedSharedFile(InterfaceFile file)
 {
     if (OnRemovedSharedFile!=null) OnRemovedSharedFile(file);
 }
예제 #5
0
 public virtual void SubmitOnNewFile(InterfaceFile file)
 {
     if (OnNewFile!=null) OnNewFile(file);
 }
예제 #6
0
 public void prueba(InterfaceFile file)
 {
     Console.WriteLine ("prueba");
 }
예제 #7
0
        private void m_OnCancelFile()
        {
            if (SelectedItems.Count==0) return;

            try
            {
                int SelectedItem = SelectedItems.Count;
                InterfaceFile[] Items= new InterfaceFile[SelectedItem];

                for(int i=0;i!=SelectedItem;i++)
                {
                    Items[i] = (InterfaceFile)SelectedItems[i].Tag;
                }

                for(int i=0;i!=SelectedItem;i++)
                {
                    string message = String.Format(eLePhantForm.Globalization["MSG_DELETEFILE"],(Items[i].Name));
                    if (MessageBox.Show(message,"lphant",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)==DialogResult.Yes)
                    {
                        krnGateway.CancelFile(Items[i].strHash);
                    }
                }
            }
            catch(Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
예제 #8
0
        private void FileToItem(InterfaceFile file,ListViewItem itemFile)
        {
            if (file==null) return;
            if (itemFile.SubItems[0].Text!=file.Name) itemFile.SubItems[0].Text=file.Name;
                                                          //CNameCleaner.Clean(file.Name);
            if (itemFile.SubItems[1].Text!=SizeToString(file.Size)) itemFile.SubItems[1].Text=SizeToString(file.Size);
            if (itemFile.SubItems[2].Text!=SpeedToString(file.DownSpeed)) itemFile.SubItems[2].Text=SpeedToString(file.DownSpeed);
            if (itemFile.SubItems[3].Text!=SizeToString(file.BytesDownloaded)) itemFile.SubItems[3].Text=SizeToString(file.BytesDownloaded);

            if (itemFile.SubItems[4].Text!=SizeToString(file.RemainingBytes)) itemFile.SubItems[4].Text=SizeToString(file.RemainingBytes);
            if (itemFile.SubItems[5].Text!=Convert.ToString(file.nSources)) itemFile.SubItems[5].Text=Convert.ToString(file.nSources);
            if (itemFile.SubItems[6].Text!=Convert.ToString(file.nValidSources)) itemFile.SubItems[6].Text=Convert.ToString(file.nValidSources);
            if (itemFile.SubItems[7].Text!=Convert.ToString(file.nTransferringSources)) itemFile.SubItems[7].Text=Convert.ToString(file.nTransferringSources);
            if (itemFile.SubItems[8].Text!=StatusToString(file.Status)) itemFile.SubItems[8].Text=StatusToString(file.Status);
            if (itemFile.SubItems[9].Text!="") itemFile.SubItems[9].Text="";
            if (itemFile.SubItems[10].Text!=PriorityToString(file.DownloadPriority)) itemFile.SubItems[10].Text=PriorityToString(file.DownloadPriority);

            string estimatedTime="?";
            if (file.DownSpeed>0.3F)
            {
                TimeSpan ts=TimeSpan.FromSeconds(file.RemainingBytes/1024/file.DownSpeed);//new TimeSpan(0,0,file.RemainingBytes*1024/file.DownSpeed);
                if (ts.Days<=99)
                {
                    if (ts.Days>0)
                        estimatedTime=ts.Days+"d ";
                    else
                        estimatedTime="";
                    estimatedTime+=ts.Hours+"h "+ts.Minutes+"m";
                }
            }
            if (itemFile.SubItems[11].Text!=estimatedTime) itemFile.SubItems[11].Text=estimatedTime;

            if (itemFile.SubItems[12].Text!=file.Category) itemFile.SubItems[12].Text=file.Category;

            itemFile.ImageIndex=eLePhantForm.SystemIconsList.GetIconIndexOf(file.Name);
            itemFile.Tag=file;
        }
예제 #9
0
 private void showInfo(InterfaceFile file)
 {
     sFileDetails FileInfo	= (sFileDetails)krnGateway.GetFileDetails(file.strHash);
     this.tx_fileName.Text	= file.Name;
     this.tx_completeName.Text	= file.CompleteName;
     switch ((byte)FileInfo.Type)
     {
         case ((byte)Constants.FileType.Avi):
             FAviDetails.ShowData((Hashtable)FileInfo.ListDetails);
             FAviDetails.Show();
             break;
         default:
             FAviDetails.Hide();
             break;
     }
 }
예제 #10
0
        private void CalculateFilterSummary(InterfaceFile[] files)
        {
            ResetFiterSummary();
            string category;
            int i=0;
            bool isCategoryFiltered;
            InterfaceFile file;
            while (i<files.Length)
            {
                file=files[i];
                i++;
                if (file==null) continue;
                category="";
                switch(file.Status)
                {
                    case 0:
                    case 8:
                    case 9:
                        category="Started";
                        break;
                    case 1:
                    case 2:
                        category="Stopped";
                        break;
                }
                CFilterSummary filterSummary;

                isCategoryFiltered=false;
                if (CurrentCategoryFilter=="LBL_VIDEO")
                    isCategoryFiltered=(!CUtils.IsVideo(file.Name));
                else if (CurrentCategoryFilter=="LBL_AUDIO")
                    isCategoryFiltered=(!CUtils.IsAudio(file.Name));
                else if (CurrentCategoryFilter=="LBL_FILE")
                    isCategoryFiltered=(!CUtils.IsFile(file.Name));
                else isCategoryFiltered=((CurrentCategoryFilter.Length!=0)&&(CurrentCategoryFilter!=file.Category));

                if (!isCategoryFiltered)
                {
                    if (category.Length>0)
                    {
                        filterSummary=((CFilterSummary)FilterSummary[category]);
                        filterSummary.TotalSize+=file.Size/1024/1024;
                        filterSummary.Items++;
                    }

                    filterSummary=((CFilterSummary)FilterSummary["All"]);
                    filterSummary.TotalSize+=file.Size/1024/1024;
                    filterSummary.Items++;
                }
            }
            if (OnSummaryFilterChanged!=null) OnSummaryFilterChanged(this,null);
        }
예제 #11
0
 public void m_OnRemovedSharedFile(InterfaceFile file)
 {
     if (OnRemovedSharedFile!=null) OnRemovedSharedFile(file);
 }
예제 #12
0
 public void m_OnNewSharedFile(InterfaceFile file)
 {
     if (OnNewSharedFile!=null) OnNewSharedFile(file);
 }
예제 #13
0
        /// <summary>
        /// Paint a InterfaceFile chunk to any graphics
        /// </summary>
        /// <param name="file"></param>
        /// <param name="g"></param>
        /// <param name="rec"></param>
        /// <param name="PercentBar"></param>
        public static void DrawBar(InterfaceFile file, Graphics g, Rectangle rec, bool PercentBar, bool PercentNumber)
        {
            Rectangle barRect;
            Color end;
            LinearGradientBrush chunkBrush;

            // fill background with white
            //SolidBrush white = new SolidBrush(Color.White);
            //g.FillRectangle(white, rec);

            barRect = new Rectangle(rec.Left, rec.Top, rec.Width, rec.Height);
            //SolidBrush b = new SolidBrush(Color.Red);
            Color b=Color.Red;

            int xpos = barRect.Left;//this.HeaderLeft[column];
            //if (xpos==0) xpos = barRect.Left;

            int ChunkLength;
            for (int i = 0; i < file.ChunksStatus.Length; i++)
            {
                //ChunkLength=(int)Decimal.Round((decimal)(this.HeaderRight[column]-xpos)/(decimal)(file.ChunksStatus.Length-i),0);
                ChunkLength = (int)Decimal.Round((decimal)(barRect.Right-xpos)/(decimal)(file.ChunksStatus.Length-i),0);

                switch(file.ChunksStatus[i])
                {
                    case 3: //if completed : green else black
                        if(file.Status==9)
                            b=System.Drawing.Color.Green;//Color.FromArgb(82, 246, 91);
                        else
                            b=Color.Black;
                        break;
                    case 0: b=Color.Red;
                        break;
                    case 1: b=Color.Gray;
                        break;
                    case 2: b=Color.LightGray;
                        break;
                    default:b=Color.Red;
                        break;
                }
                if ((file.ChunksStatus[i]==0)&&(file.ChunksAvaibility!=null)&&(file.ChunksAvaibility[i]>0))
                {
                    int col=file.ChunksAvaibility[i]*4;
                    if (col>200) col=200;
                    col=Math.Abs(200-col);

                    b=Color.FromArgb(255,col,col,255);
                }

                try
                {
                    if (ChunkLength<=0) continue;
                    // calculate the new end color based on start color
                    end = ControlPaint.Dark(b, 0.3F);

                    // generate the linear brush
                    chunkBrush = new LinearGradientBrush(new Rectangle(xpos, barRect.Top, ChunkLength, barRect.Height), b, end, 90);

                    g.FillRectangle(chunkBrush, xpos, barRect.Top, ChunkLength, barRect.Height);
                }
                catch(Exception e)
                {
                    Debug.WriteLine(e.ToString());
                }
                xpos += ChunkLength;
            }

            decimal percent = file.PercentCompleted;

            if (PercentBar)
            {
                int CompleteChunkLength = (int)(percent*(rec.Right-rec.Left));
                Pen myProgressBarPen = new Pen(Color.FromArgb(82, 246, 91),2);
                g.DrawLine(myProgressBarPen,rec.Left,rec.Top+1,rec.Left+CompleteChunkLength,rec.Top+1);
            }

            if (PercentNumber)
            {
                g.DrawString(((byte)(percent*100)).ToString()+ " %",new System.Drawing.Font("Microsoft Sans Serif",7.25F,GraphicsUnit.Point),new SolidBrush(Color.White),barRect);
            }
        }
예제 #14
0
 internal void RemovedSharedFile(InterfaceFile file)
 {
     if (apw)
         if (file!=null) SubmitOnRemovedSharedFile(file);
 }
예제 #15
0
 private void m_OnNewShared(InterfaceFile shared)
 {
     ListViewItem ItemShared =new ListViewItem(new string[]{"","","",""});
     ItemShared.Tag=shared;
     SharedToItem(shared,ItemShared);
     Items.Add(ItemShared);
 }
예제 #16
0
 //        public sFileInfo GetFileInfo(string strFileHash)
 //        {
 //            sFileInfo response=new sFileInfo();
 //            if (apw)
 //            {
 //                CElement Element=(CElement)CKernel.FilesList[CKernel.StringToHash(strFileHash)];
 //                if (Element==null) return response;
 //                response=Element.File.GetInfo();
 //                return response;
 //            }
 //            else return response;
 //        }
 public InterfaceFile[] GetSharedFileList()
 {
     if (apw)
     {
         InterfaceFile[] response=new InterfaceFile[CKernel.FilesList.Count];
         int i=0;
         foreach (CElement Element in CKernel.FilesList.Values)
         {
             if (!Element.File.Empty)
             {
                 response[i]=new InterfaceFile();
                 response[i]=FileToInterfaceFile(Element);
                 i++;
             }
         }
         return response;
     }
     else return null;
 }
예제 #17
0
 private void m_OnRemovedSharedFile(InterfaceFile shared)
 {
     try
     {
         for (int i=0;i<this.Items.Count;i++)
         {
             if (shared.strHash==((InterfaceFile)Items[i].Tag).strHash)
             {
                 Items.RemoveAt(i);
             }
         }
     }
     catch{}
 }
예제 #18
0
 private void m_InvokeOnNewFile(InterfaceFile file)
 {
     if (this.InvokeRequired)
         this.BeginInvoke(new FileEvent(m_OnNewFile),new object[] {file});
     else
         m_OnNewFile(file);
 }
예제 #19
0
 private void SharedToItem(InterfaceFile shared,ListViewItem ItemShared)
 {
     if (shared==null) return;
     if (ItemShared.SubItems[0].Text!=shared.Name) ItemShared.SubItems[0].Text=shared.Name;
     if (ItemShared.SubItems[1].Text!=SizeToString(shared.Size)) ItemShared.SubItems[1].Text=SizeToString(shared.Size);
     if (ItemShared.SubItems[2].Text!=PriorityToString(shared.UploadPriority)) ItemShared.SubItems[2].Text=PriorityToString(shared.UploadPriority);
     ItemShared.Tag=shared;
     ItemShared.ImageIndex=eLePhantForm.SystemIconsList.GetIconIndexOf(shared.Name);
 }
예제 #20
0
        private void m_OnNewFile(InterfaceFile file)
        {
            ListViewItem itemFile=new ListViewItem(new string[]{"","","","","","","","","","","","",""});

            itemFile.Tag=file;
            FileToItem(file,itemFile);
            lock(this)
            {
                if ((!IsFiltered(file.Status))&&
                    (!IsCategoryFiltered(file.CategoryID,file.Name))) Items.Add(itemFile);
            }
        }
예제 #21
0
 private void m_RefreshStatistics(InterfaceFile file)
 {
     FileStatistics fstatistics=krnGateway.GetFileStatistics(file.strHash);
     labelSessionDownloadedRes.Text=eLePhantListView.SizeToString((uint)fstatistics.SessionDownload);
     labelSessionUploadedRes.Text=eLePhantListView.SizeToString((uint)fstatistics.SessionUpload);
     labelSessionRequestsRes.Text=fstatistics.SessionRequests.ToString();
     byte rating=0;
     string comment="";
     krnGateway.GetFileComment(file.strHash,ref comment,ref rating);
     this.textBoxComment.Text=comment;
 }