Ejemplo n.º 1
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            List <SearchStorageInfo> drivesToSearch = new List <SearchStorageInfo>();

            for (int i = 0; i < diskControls.Count; i++)
            {
                CheckedTextControl checkedSto = diskControls[i];
                if (checkedSto.Checked)
                {
                    drivesToSearch.Add((SearchStorageInfo)checkedSto.SharedData);
                }
            }

            btn_search.Text    = "Scanning...";
            btn_search.Enabled = false;

            ThreadPool.QueueUserWorkItem(ScanDrivesThread, drivesToSearch);
        }
Ejemplo n.º 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();
        }