예제 #1
0
        private void CreatDowndLoadThread(object p)
        {
            FileInfoDataList SeleteInfo1 = (FileInfoDataList)p;

            if (SeleteInfo1 == null)
            {
                return;
            }
            #region MyRegion
            //if (SeleteInfo1.Hash.Length < 36)
            //{
            //    MessageBox.Show("根目录不能下载");
            //    return;
            //}
            #endregion

            if (SeleteInfo1.IsFolder == true)
            {
                MessageBox.Show("根目录不能下载");
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (ThreadStart) delegate
            {
                DownLoad d = new DownLoad();
                LoadInfo l = new LoadInfo();
                //l.name = @"DriverGenius2012";
                //l.type = "文件夹";
                d.RootDirectory = CurrentDownloadPath + @"\";
                l.name          = SeleteInfo1.Name;
                if (SeleteInfo1.Size == null)
                {
                    l.size = 0;
                }
                else
                {
                    l.size = (long)SeleteInfo1.Size;
                }
                l.type          = SeleteInfo1.Type;
                DownListInfo sm = d.CreatDownLoad(l);
                if (sm == null)
                {
                    return;
                }
                sm.ID    = d.ID = DownInfo.Count;
                sm.State = "下载";
                sm.Hash  = SeleteInfo.Hash;
                DownInfo.Add(sm);
                Down_d.Add(d);
                for (int i = 0; i < Down_d.Count; i++)
                {
                    Down_d[i].Maxseepd = Limit_DownLoad_Speed;
                    Down_d[i].Sum      = Down_d.Count;
                }
                d.Percentage += Refresh;
                //if (ShowSharefile == null)
                {
                    Task <int> task = _client.DownloadRequestAsync(SeleteInfo.Hash, d.Port);
                    task.ContinueWith(T =>
                    {
                    });
                }
                //else ShowSharefile.SendDirectoryName(@":\" + Directory + @"\" + l.name);
                Serialization(@"./config/ImportDownLoadInfo", DownInfo);
            });
        }