Ejemplo n.º 1
0
        /// <summary>
        /// Unload the selected drive from the program
        /// </summary>
        /// <param name="driveletter">The label of the selected drive</param>
        private void UnloadDevice(string driveletter)
        {
            usbDevice device = (usbDevice)fpanel1.Controls.Find(driveletter, true)[0];

            if (panel1.Controls.Contains(device))
            {
                panel1.Controls.Remove(device);
                device.Dispose();
                panel1.Refresh();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads a UsbDevice to the applications
        /// </summary>
        /// <param name="driveletter">The name of the drive</param>
        private void loadDevice(string driveletter)
        {
            try
            {
                usbDevice device = new usbDevice(driveletter, drives, serial);
                device.AllowDrop  = true;
                device.DragEnter += device_DragEnter;
                device.DragDrop  += device_DragDrop;
                device.Anchor     = AnchorStyles.Left;
                device.Name       = driveletter;
                int number = panel1.Controls.Count;

                // device.Location = new Point(2, number * 50);
                device.Margin = new System.Windows.Forms.Padding(5);
                //device.Width = 350;
                panel1.Controls.Add(device);
            }
            catch (Exception e)
            {
                Helper.WriteLog(e);
            }
        }
Ejemplo n.º 3
0
 public driveBrowser(Form2 frm)
 {
     InitializeComponent();
     panel = (FlowLayoutPanel)frm.Controls.Find("panel1", true)[0];
     foreach (Control ctrl in panel.Controls)
     {
         panel1.Controls.Add(ctrl);
     }
     if (DriveInformation.sdrv != "")
     {
         usbDevice device = (usbDevice)panel1.Controls.Find(DriveInformation.sdrv + ":\\", true)[0];
         device.BorderStyle = BorderStyle.FixedSingle;
         label2.Text        = DriveInformation.sdrv;
         checkDirectory(DriveInformation.sdrv + DriveInformation.sdrv_folder.Substring(1, DriveInformation.sdrv_folder.Length - 1));
     }
     textBox1.Text     = DriveInformation.sdrv_folder.Substring(3, DriveInformation.sdrv_folder.Length - 3);
     this.FormClosing += (s, a) => {
         foreach (Control ctrl in panel1.Controls)
         {
             panel.Controls.Add(ctrl);
         }
     };
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Unselect if the device is selected.
 /// </summary>
 /// <param name="device">The device that is to be unselected</param>
 public void deSelectDevice(usbDevice device)
 {
     device.BorderStyle=BorderStyle.None;
    // device.BackgroundImage = SmartSync.Properties.Resources.usbDevicebg;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Unselect if the device is selected.
 /// </summary>
 /// <param name="device">The device that is to be unselected</param>
 public void deSelectDevice(usbDevice device)
 {
     device.BorderStyle = BorderStyle.None;
     // device.BackgroundImage = SmartSync.Properties.Resources.usbDevicebg;
 }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Loads a UsbDevice to the applications
        /// </summary>
        /// <param name="driveletter">The name of the drive</param>
        private void loadDevice(string driveletter)
        {
            try
            {
                usbDevice device = new usbDevice(driveletter, drives, serial);
                device.AllowDrop = true;
                device.DragEnter += device_DragEnter;
                device.DragDrop += device_DragDrop;
                device.Anchor = AnchorStyles.Left;
                device.Name = driveletter;
                int number = panel1.Controls.Count;
                
               // device.Location = new Point(2, number * 50);
                device.Margin = new System.Windows.Forms.Padding(5);
                //device.Width = 350;
                panel1.Controls.Add(device);

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