Esempio n. 1
0
 public Clone(ParrotLibs.Drive Drive1, ParrotLibs.Drive Drive2)
 {
     InitializeComponent();
     this.Original    = Drive1;
     this.Destination = Drive2;
     this.Load       += new EventHandler(Clone_Load);
 }
Esempio n. 2
0
        public Drive_Properties(ParrotLibs.Drive FATXDrive)
        {
            InitializeComponent();

            mDrive            = FATXDrive;
            this.Load        += new EventHandler(Drive_Properties_Load);
            this.FormClosing += new FormClosingEventHandler(Drive_Properties_FormClosing);
        }
Esempio n. 3
0
        void LoadDeivce()
        {
            this.mWorker = new System.Threading.Thread((System.Threading.ThreadStart) delegate
            {
                try
                {
                    if (mDriveList != null)
                    {
                        for (int i = 0; i < mDriveList.Count; i++)
                        {
                            mDriveList[i].Close();
                        }
                    }

                    DriveList.Invoke((MethodInvoker) delegate
                    {
                        DriveList.Items.Clear();
                    });

                    l_Message.Invoke((MethodInvoker) delegate {
                        l_Message.Text = "正在加载驱动器...";
                    });

                    b_RefreshDrive.Invoke((MethodInvoker) delegate
                    {
                        b_RefreshDrive.Enabled = false;
                    });

                    mDriveList = ParrotLibs.StartHere.GetFATXDrives().ToList();
                    if (Properties.Settings.Default.RecentLoadFiles != null)
                    {
                        foreach (string sPathToFile in Properties.Settings.Default.RecentLoadFiles)
                        {
                            if (System.IO.File.Exists(sPathToFile))
                            {
                                try
                                {
                                    ParrotLibs.Drive sDrive = new ParrotLibs.Drive(sPathToFile);
                                    if (sDrive.IsFATXDrive())
                                    {
                                        mDriveList.Add(sDrive);
                                    }
                                }
                                catch (Exception e)
                                {
                                    if (!e.Message.Contains("being used"))
                                    {
                                        MessageBox.Show("An exception was thrown: " + e.Message + "\r\n\r\nStack Trace:\r\n" + e.StackTrace);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                        }
                    }

                    List <ListViewItem> sListView = new List <ListViewItem>();
                    for (int i = 0; i < mDriveList.Count; i++)
                    {
                        try
                        {
                            ListViewItem sDriveItem = new ListViewItem(mDriveList[i].Name);
                            if (mDriveList[i].DriveType == ParrotLibs.DriveType.HardDisk)
                            {
                                sDriveItem.ImageIndex = 0;
                                sDriveItem.SubItems.Add(mDriveList[i].DeviceIndex.ToString());
                            }
                            else if (mDriveList[i].DriveType == ParrotLibs.DriveType.USB)
                            {
                                sDriveItem.ImageIndex = 1;
                                sDriveItem.SubItems.Add(System.IO.Path.GetPathRoot(mDriveList[i].USBPaths[0]));
                            }
                            else
                            {
                                sDriveItem.ImageIndex = 2;
                                sDriveItem.SubItems.Add(System.IO.Path.GetFileName(mDriveList[i].FilePath));
                            }

                            sDriveItem.SubItems.Add(mDriveList[i].LengthFriendly);
                            sDriveItem.Tag = mDriveList[i];
                            sListView.Add(sDriveItem);
                        }
                        catch (Exception e)
                        {
                            if (!e.Message.Contains("being used"))
                            {
                                MessageBox.Show("An exception was thrown: " + e.Message + "\r\n\r\nStack Trace:\r\n" + e.StackTrace);
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }

                    DriveList.Invoke((MethodInvoker) delegate
                    {
                        DriveList.Items.AddRange(sListView.ToArray());
                    });

                    l_Message.Invoke((MethodInvoker) delegate
                    {
                        if (sListView.Count == 0)
                        {
                            l_Message.Text = "未发现驱动器...";
                        }
                        else
                        {
                            l_Message.Text = sListView.Count.ToString() + "个驱动器被加载!";
                        }
                    });
                    b_RefreshDrive.Invoke((MethodInvoker) delegate { b_RefreshDrive.Enabled = true; });
                }
                catch (Exception e)
                {
                    if (!e.Message.Contains("being used"))
                    {
                        MessageBox.Show("An exception was thrown: " + e.Message + "\r\n\r\nStack Trace:\r\n" + e.StackTrace);
                    }
                }
            });

            mWorker.Start();
        }