Пример #1
0
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                //check if the device is registered already and if not, register it
                string[] dirs = new string[2];
                dirs[0] = (string)e.Data.GetData(typeof(string));
                if (!Directory.Exists(dirs[0]))
                {
                    return;
                }

                DriveInformation.sdrv_folder = (string)e.Data.GetData(typeof(string));

                if (selectedDrive != null)
                {
                    DriveInformation.sdrv = letter;
                }
                else
                {
                    DriveInformation.sdrv = "";
                }

                //load the dialog form to select the drive you want to synchronize and the folder you want to do that with
                driveBrowser browser = new driveBrowser(this);
                if (browser.ShowDialog().ToString() == "Cancel")
                {
                    return;
                }

                //progressbar.Visible = true;

                //retrieve the values set from the dialog
                string value = DriveInformation.sdrv_folder;
                //check if the device has been registered else register it
                RegisterDevice(DriveInformation.sdrv_serial);
                Drive drive = drives.Find(i => (i.serial) == DriveInformation.sdrv_serial);
                if (drive == null)
                {
                    return;
                }
                //progressbar.PerformStep();
                if (drive.source.Count > 0)
                {
                    //check if the folder has originally been synchronized
                    foreach (string[] s in drive.source)
                    {
                        if (s[0] == dirs[0])
                        {
                            dirs[1] = DriveInformation.sdrv_folder;

                            drives.Remove(drive);
                            drive.source.Remove(s);

                            if (drive.source != null)
                            {
                                drive.source.Add(dirs);
                            }
                            else
                            {
                                drive.source = new List <string[]>();
                                drive.source.Add(dirs);
                            }
                            drives.Add(drive);
                            FileDetailsMgmt.saveDrive(drives);
                            drives           = FileDetailsMgmt.getRegisteredDrives();
                            statuslabel.Text = "Folder added successfully";
                        }
                    }
                }
                else
                {
                    dirs[1] = DriveInformation.sdrv_folder;
                    drives.Remove(drive);
                    drive.autosync = true;
                    if (drive.source != null)
                    {
                        drive.source.Add(dirs);
                    }
                    else
                    {
                        drive.source = new List <string[]>();
                        drive.source.Add(dirs);
                    }
                    drives.Add(drive);
                    FileDetailsMgmt.saveDrive(drives);
                    drives           = FileDetailsMgmt.getRegisteredDrives();
                    statuslabel.Text = "Folder added successfully";
                }
            }
            catch (Exception ex) { Helper.WriteLog(ex); }
            finally
            {
                //progressbar.Visible = false;
            }
        }
Пример #2
0
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {

            try
            {
                //check if the device is registered already and if not, register it
                string[] dirs = new string[2];
                dirs[0] = (string)e.Data.GetData(typeof(string));
                if (!Directory.Exists(dirs[0])) return;

                DriveInformation.sdrv_folder = (string)e.Data.GetData(typeof(string));

                if (selectedDrive != null) DriveInformation.sdrv = letter;
                else DriveInformation.sdrv = "";

                //load the dialog form to select the drive you want to synchronize and the folder you want to do that with
                driveBrowser browser = new driveBrowser(this);
                if (browser.ShowDialog().ToString() == "Cancel") return;

                //progressbar.Visible = true;

                //retrieve the values set from the dialog
                string value = DriveInformation.sdrv_folder;
                //check if the device has been registered else register it
                RegisterDevice(DriveInformation.sdrv_serial);
                Drive drive = drives.Find(i => (i.serial) == DriveInformation.sdrv_serial);
                if (drive == null) return;
                //progressbar.PerformStep();
                if (drive.source.Count > 0)
                {
                    //check if the folder has originally been synchronized
                    foreach (string[] s in drive.source)
                    {
                        if (s[0] == dirs[0])
                        {

                            dirs[1] = DriveInformation.sdrv_folder;

                            drives.Remove(drive);
                            drive.source.Remove(s);

                            if (drive.source != null)
                                drive.source.Add(dirs);
                            else
                            {
                                drive.source = new List<string[]>();
                                drive.source.Add(dirs);
                            }
                            drives.Add(drive);
                            FileDetailsMgmt.saveDrive(drives);
                            drives = FileDetailsMgmt.getRegisteredDrives();
                            statuslabel.Text = "Folder added successfully";


                        }
                    }
                }
                else
                {


                    dirs[1] =  DriveInformation.sdrv_folder;
                    drives.Remove(drive);
                    drive.autosync = true;
                    if (drive.source != null)
                        drive.source.Add(dirs);
                    else
                    {

                        drive.source = new List<string[]>();
                        drive.source.Add(dirs);
                    }
                    drives.Add(drive);
                    FileDetailsMgmt.saveDrive(drives);
                    drives = FileDetailsMgmt.getRegisteredDrives();
                    statuslabel.Text = "Folder added successfully";

                }
            }
            catch (Exception ex) { Helper.WriteLog(ex); }
            finally
            {
                //progressbar.Visible = false;
            }

        }
Пример #3
0
        void device_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
                    foreach (string f in file)
                    {
                        string[] dirs = new string[2];
                        dirs[0] = f;
                        if (!Directory.Exists(dirs[0]))
                        {
                            return;
                        }
                        DriveInformation.sdrv_folder = f;
                        usbDevice dv = (usbDevice)sender;
                        DriveInformation.sdrv = dv.letter.Substring(0, 1);

                        //load the dialog form to select the drive you want to synchronize and the folder you want to do that with
                        driveBrowser browser = new driveBrowser(this);
                        if (browser.ShowDialog().ToString() == "Cancel")
                        {
                            return;
                        }

                        //retrieve the values set from the dialog
                        //check if the device has been registered else register it
                        RegisterDevice(DriveInformation.sdrv_serial);
                        Drive drive = drives.Find(i => (i.serial) == DriveInformation.sdrv_serial);
                        if (drive == null)
                        {
                            return;
                        }
                        if (drive.source.Count > 0)
                        {
                            //check if the folder has originally been synchronized
                            foreach (string[] s in drive.source)
                            {
                                if (s[0] == dirs[0])
                                {
                                    dirs[1] = DriveInformation.sdrv_folder;

                                    drives.Remove(drive);
                                    drive.source.Remove(s);

                                    if (drive.source != null)
                                    {
                                        drive.source.Add(dirs);
                                    }
                                    else
                                    {
                                        drive.source = new List <string[]>();
                                        drive.source.Add(dirs);
                                    }
                                    drives.Add(drive);
                                    FileDetailsMgmt.saveDrive(drives);
                                    drives           = FileDetailsMgmt.getRegisteredDrives();
                                    statuslabel.Text = "Folder added successfully";
                                }
                            }
                        }
                        else
                        {
                            dirs[1] = DriveInformation.sdrv + ":\\" + DriveInformation.sdrv_folder;
                            drives.Remove(drive);
                            drive.autosync = true;
                            if (drive.source != null)
                            {
                                drive.source.Add(dirs);
                            }
                            else
                            {
                                drive.source = new List <string[]>();
                                drive.source.Add(dirs);
                            }
                            drives.Add(drive);
                            FileDetailsMgmt.saveDrive(drives);
                            drives           = FileDetailsMgmt.getRegisteredDrives();
                            statuslabel.Text = "Folder added successfully";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.WriteLog(ex);
            }
        }
Пример #4
0
        void device_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
                    foreach (string f in file)
                    {

                        string[] dirs = new string[2];
                        dirs[0] = f;
                        if (!Directory.Exists(dirs[0])) return;
                        DriveInformation.sdrv_folder = f;
                        usbDevice dv = (usbDevice)sender;
                        DriveInformation.sdrv = dv.letter.Substring(0,1);
                        
                        //load the dialog form to select the drive you want to synchronize and the folder you want to do that with
                        driveBrowser browser = new driveBrowser(this);
                        if (browser.ShowDialog().ToString() == "Cancel") return;

                        //retrieve the values set from the dialog
                        //check if the device has been registered else register it
                        RegisterDevice(DriveInformation.sdrv_serial);
                        Drive drive = drives.Find(i => (i.serial) == DriveInformation.sdrv_serial);
                        if (drive == null) return;
                        if (drive.source.Count > 0)
                        {
                            //check if the folder has originally been synchronized
                            foreach (string[] s in drive.source)
                            {
                                if (s[0] == dirs[0])
                                {

                                    dirs[1] =DriveInformation.sdrv_folder;

                                    drives.Remove(drive);
                                    drive.source.Remove(s);

                                    if (drive.source != null)
                                        drive.source.Add(dirs);
                                    else
                                    {
                                        drive.source = new List<string[]>();
                                        drive.source.Add(dirs);
                                    }
                                    drives.Add(drive);
                                    FileDetailsMgmt.saveDrive(drives);
                                    drives = FileDetailsMgmt.getRegisteredDrives();
                                    statuslabel.Text = "Folder added successfully";


                                }
                            }
                        }
                        else
                        {


                            dirs[1] = DriveInformation.sdrv + ":\\" + DriveInformation.sdrv_folder;
                            drives.Remove(drive);
                            drive.autosync = true;
                            if (drive.source != null)
                                drive.source.Add(dirs);
                            else
                            {

                                drive.source = new List<string[]>();
                                drive.source.Add(dirs);
                            }
                            drives.Add(drive);
                            FileDetailsMgmt.saveDrive(drives);
                            drives = FileDetailsMgmt.getRegisteredDrives();
                            statuslabel.Text = "Folder added successfully";

                        }


                        

                    }


                }
            }
            catch (Exception ex)
            {
                Helper.WriteLog(ex);
            }
        }