public static void listdrives(DataGridView dataGridView1, CheckBox optimize, CheckBox optimizemft, CheckBox uncompress, string settingsfile) { DriveInfo[] driveInfo = DriveInfo.GetDrives().Where(x => x.IsReady).ToArray(); List <string> drives = new List <string>(); foreach (DriveInfo drive in driveInfo) { DriveType driveType = Native.GetDriveType(drive.Name); if ( driveType != DriveType.Fixed && driveType != DriveType.Removable && driveType != DriveType.RAMDisk ) { continue; } if (!is_virtual(drive.Name[0])) { drives.Add(drive.Name); } double driveSizeGB = Math.Round((double)drive.TotalSize / (1024 * 1024 * 1024), 2); double driveFreeSpaceGB = Math.Round((double)drive.AvailableFreeSpace / (1024 * 1024 * 1024), 2); double drivefreeSpacep = Math.Round((driveFreeSpaceGB / driveSizeGB) * 100, 2); if (drive.Name == "C:\\" && drivefreeSpacep < 35) { uncompress.CheckState = CheckState.Unchecked; uncompress.Enabled = false; PCS.IniWriteValue(settingsfile, "main", "uncompress", "False"); } dataGridView1.Rows.Add(true, drive.Name, driveFreeSpaceGB + " GB", drivefreeSpacep); } DiskDefragger.read_defragsettings(dataGridView1, optimize, optimizemft, uncompress, settingsfile, true); }
public static void analyse(System.Windows.Forms.DataVisualization.Charting.Chart chart1, System.Windows.Forms.DataVisualization.Charting.Series series1, DataGridView dataGridView1, CheckBox optimize, CheckBox optimizemft, CheckBox uncompress, Label label4, string settingsfile) { PCS pcs = new PCS(); log.WriteLog("Maintainer DiskDefrag analysis start"); DiskDefragger.read_defragsettings(dataGridView1, optimize, optimizemft, uncompress, settingsfile, true); for (int i = 0; i < dataGridView1.Rows.Count; i++) { string driveselection = dataGridView1[0, i].Value.ToString(); if (driveselection == "True") { string path = dataGridView1[1, i].Value.ToString().Substring(0, 2); PCS.process("cmd", "/C set UD_TIME_LIMIT=0h 30m && set UD_LOG_FILE_PATH=ud\\" + i.ToString() + ".log && ud\\udefrag.exe -a " + path, true); string fragmentedpercent = pcs.findword("ud\\" + i + ".log", "fragmentation is above the threshold:", 61); System.Threading.Thread.Sleep(1000); Global.fragmentedp[i] = fragmentedpercent.Substring(0, 5); } } string fragmentedf = pcs.findword("ud\\0.log", "fragmented files", 41); string fragmentedp = pcs.findword("ud\\0.log", "fragmentation is above the threshold:", 61); string compf = pcs.findword("ud\\0.log", "compressed files:", 41); string totalf = pcs.findword("ud\\0.log", "files total:", 41); double defragmentedfiles = Convert.ToDouble(totalf) - Convert.ToDouble(compf) + Convert.ToDouble(fragmentedf); label4.Text = "Fragmentation: " + fragmentedp.Substring(0, 7); series1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.DiagonalLeft; series1.ChartArea = "ChartArea1"; series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie; series1.Legend = "Legend1"; series1.Name = "Series1"; series1.Points.AddXY("Defragmented Files: " + defragmentedfiles, defragmentedfiles); series1.Points.AddXY("Fragmented Files: " + fragmentedf, Convert.ToDouble(fragmentedf)); series1.Points.AddXY("Compressed Files: " + compf, Convert.ToDouble(compf)); double fs = Convert.ToDouble(dataGridView1[3, 0].Value); double rs = 100 - fs; double fsp = Math.Round((fs * Convert.ToDouble(totalf)) / rs, 0); series1.Points.AddXY("Free Space: " + fs + "%", fsp); chart1.Series.Add(series1); chart1.Series[0]["PieLabelStyle"] = "Disabled"; }
private void DiskDefragList_Load(object sender, EventArgs e) { DiskDefragger.read_defragsettings(dataGridView1, checkBox1, checkBox2, checkBox3, "settings//defragsettings.ini", true); }