Example #1
0
        public SearchStorageForm()
        {
            InitializeComponent();

            titleBarControl.Text = "Search Storage";
            DriveInfo[]    drives     = DriveInfo.GetDrives();
            CheckedListBox checkedBox = list_storage;

            for (int i = 0; i < drives.Length; i++)
            {
                DriveInfo drive = drives[i];

                if (drive.DriveType == DriveType.CDRom ||
                    drive.DriveType == DriveType.Network)
                {
                    // CDs cannot use NTFS
                    // and network I'm not even trying
                    continue;
                }

                SearchStorageInfo d = new SearchStorageInfo(drive);

                if (drive.IsReady)
                {
                    if (drive.DriveFormat != "NTFS")
                    {
                        // ignore non-NTFS drives
                        continue;
                    }

                    try {
                        long free  = drive.AvailableFreeSpace / 1024 / 1024 / 1024;
                        long total = drive.TotalSize / 1024 / 1024 / 1024;
                        long used  = total - free;

                        d.SetInfo(drive.Name + " " + used + " GB used");
                        checkedBox.Items.Add(d, true);
                    } catch {
                        // notify user of crash
                        d.SetInfo(drive.Name + " (Not authorized)");
                        checkedBox.Items.Add(d, CheckState.Indeterminate);
                    }
                }
                else
                {
                    // user might want to get that drive ready
                    d.SetInfo(drive.Name + " (Drive not ready)");
                    checkedBox.Items.Add(d, CheckState.Indeterminate);
                }
            }
        }
Example #2
0
        private void ScanGames_Click(object sender, EventArgs e)
        {
            MainForm.Instance.ChangeTitle("Scan Storage for Games", scanGames.Image);

            panel_disks.Visible          = true;
            panel_installedGames.Visible = false;
            panel_gameData.Visible       = false;

            list_storage.Controls.Clear();
            diskControls = new List <CheckedTextControl>();
            GC.Collect();

            DriveInfo[] drives = DriveInfo.GetDrives();
            for (int i = 0; i < drives.Length; i++)
            {
                DriveInfo drive = drives[i];

                if (drive.DriveType == DriveType.CDRom ||
                    drive.DriveType == DriveType.Network)
                {
                    // CDs cannot use NTFS
                    // and network I'm not even trying
                    continue;
                }

                SearchStorageInfo  d   = new SearchStorageInfo(drive);
                CheckedTextControl con = null;
                if (drive.IsReady)
                {
                    if (drive.DriveFormat != "NTFS")
                    {
                        // ignore non-NTFS drives
                        continue;
                    }

                    con            = new CheckedTextControl();
                    con.Width      = list_installedGames.Width;
                    con.Checked    = true;
                    con.SharedData = d;
                    list_storage.Controls.Add(con);
                    diskControls.Add(con);

                    Control sep = new Control();
                    sep.Height = 2;
                    list_storage.Controls.Add(sep);

                    try {
                        long free  = drive.AvailableFreeSpace / 1024 / 1024 / 1024;
                        long total = drive.TotalSize / 1024 / 1024 / 1024;
                        long used  = total - free;

                        d.SetInfo(drive.Name + " " + used + " GB used");
                        //checkedBox.Items.Add(d, true);
                    } catch {
                        // notify user of crash
                        d.SetInfo(drive.Name + " (Not authorized)");
                        //checkedBox.Items.Add(d, CheckState.Indeterminate);
                    }
                }
                else
                {
                    // user might want to get that drive ready
                    d.SetInfo(drive.Name + " (Drive not ready)");
                    //checkedBox.Items.Add(d, CheckState.Indeterminate);
                }

                if (con != null)
                {
                    con.UpdateTitleText(d.Info);
                }
            }

            DPI.DPIManager.ForceUpdate();
            DPI.DPIManager.ForceUpdate();
        }