1 #include "ReportDialog.h"
3 #include "Fraginator.h"
4 #include "DriveVolume.h"
5 #include "Defragment.h"
9 void SetReportInfo (HWND Dlg
, DefragReport
&Report
, uint32 BytesDivisor
, wchar_t *BytesUnits
, bool Fractional
)
15 memset (Text
, 0, sizeof (Text
));
18 SetDlgItemText (Dlg
, IDC_DRIVELETTER
, Report
.RootPath
.c_str());
21 SetDlgItemText (Dlg
, IDC_VOLUMELABEL
, Defrag
->GetVolume().GetVolumeInfo().Name
.c_str());
24 SetDlgItemText (Dlg
, IDC_VOLUMESERIAL
, Defrag
->GetVolume().GetVolumeInfo().Serial
.c_str());
27 SetDlgItemText (Dlg
, IDC_FILESYSTEM
, Defrag
->GetVolume().GetVolumeInfo().FileSystem
.c_str());
32 swprintf (Text
, L
"%.2f %s", (double)(signed)(Report
.DiskSizeBytes
/
33 (BytesDivisor
/ 1024)) / 1024.0, BytesUnits
);
37 AddCommas (Text
, Report
.DiskSizeBytes
/ BytesDivisor
);
39 wcscat (Text
, BytesUnits
);
42 SetDlgItemText (Dlg
, IDC_DISKSIZEBYTES
, Text
);
47 swprintf (Text
, L
"%.2f %s", (double)(signed)(Defrag
->GetVolume().GetVolumeInfo().FreeBytes
/
48 (BytesDivisor
/ 1024)) / 1024.0, BytesUnits
);
52 AddCommas (Text
, Defrag
->GetVolume().GetVolumeInfo().FreeBytes
/ BytesDivisor
);
54 wcscat (Text
, BytesUnits
);
56 SetDlgItemText (Dlg
, IDC_DISKFREEBYTES
, Text
);
59 AddCommas (Text
, Defrag
->GetVolume().GetVolumeInfo().ClusterCount
);
60 wcscat (Text
, L
" clusters");
61 SetDlgItemText (Dlg
, IDC_DISKSIZECLUSTERS
, Text
);
64 swprintf (Text
, L
"%u bytes", Defrag
->GetVolume().GetVolumeInfo().ClusterSize
);
65 SetDlgItemText (Dlg
, IDC_DISKCLUSTERSIZE
, Text
);
68 AddCommas (Text
, Report
.DirsCount
);
69 SetDlgItemText (Dlg
, IDC_DIRSCOUNT
, Text
);
72 AddCommas (Text
, Report
.FilesCount
);
73 SetDlgItemText (Dlg
, IDC_FILESCOUNT
, Text
);
76 swprintf (Text
, L
"(%.2f%%)", Report
.PercentFragged
);
77 AddCommas (Text2
, Report
.FraggedFiles
.size());
78 swprintf (Text3
, L
"%s %s", Text
, Text2
);
79 SetDlgItemText (Dlg
, IDC_FILESFRAGGED
, Text3
);
82 swprintf (Text
, L
"%.2f", Report
.AverageFragments
);
83 SetDlgItemText (Dlg
, IDC_AVERAGEFRAGS
, Text
);
88 swprintf (Text
, L
"%.2f %s", (double)(signed)(Report
.FilesSizeBytes
/
89 (BytesDivisor
/ 1024)) / 1024.0, BytesUnits
);
93 AddCommas (Text
, Report
.FilesSizeBytes
/ (uint64
)BytesDivisor
);
95 wcscat (Text
, BytesUnits
);
97 SetDlgItemText (Dlg
, IDC_FILESSIZEBYTES
, Text
);
102 swprintf (Text
, L
"%.2f %s", (double)(signed)((Report
.FilesSizeBytes
+ Report
.FilesSlackBytes
) /
103 (BytesDivisor
/ 1024)) / 1024.0, BytesUnits
);
107 AddCommas (Text
, (Report
.FilesSizeBytes
+ Report
.FilesSlackBytes
) / (uint64
)BytesDivisor
);
109 wcscat (Text
, BytesUnits
);
112 SetDlgItemText (Dlg
, IDC_FILESSIZEONDISK
, Text
);
117 swprintf (Text
, L
"%.2f %s", (double)(signed)(Report
.FilesSlackBytes
/
118 (BytesDivisor
/ 1024)) / 1024.0, BytesUnits
);
122 AddCommas (Text
, Report
.FilesSlackBytes
/ BytesDivisor
);
124 wcscat (Text
, BytesUnits
);
126 swprintf (Text2
, L
"(%.2f%%)", Report
.PercentSlack
);
127 swprintf (Text3
, L
"%s %s", Text2
, Text
);
128 SetDlgItemText (Dlg
, IDC_FILESSLACKBYTES
, Text3
);
131 bool PFRec
= false; // Recommend based off percent fragged files?
132 bool AFRec
= false; // Recommend based off average fragments per file?
134 if (Report
.PercentFragged
>= 5.0f
)
137 if (Report
.AverageFragments
>= 1.1f
)
140 wcscpy (Text
, L
"* ");
147 L
"%.2f%% of the files on this volume are fragmented. ",
148 Report
.PercentFragged
151 wcscat (Text
, Text2
);
159 L
"The average fragments per file (%.2f) indicates a high degree of fragmentation. ",
160 Report
.AverageFragments
163 wcscat (Text
, Text2
);
166 if (Report
.PercentFragged
< 5.0f
&& Report
.AverageFragments
< 1.1f
)
167 swprintf (Text
, L
"* No defragmentation is necessary at this point.");
169 if (Report
.PercentFragged
< 15.0f
&& Report
.AverageFragments
< 1.3f
)
170 wcscat (Text
, L
"It is recommended that you perform a Fast Defrag.");
172 wcscat (Text
, L
"It is recommended that you perform an Extensive Defrag.");
174 // Should we recommend a smaller cluster size?
175 if (Report
.PercentSlack
>= 10.0f
)
180 L
"\n* A large amount of disk space (%.2f%%) is being lost "
181 L
"due to a large (%u bytes) cluster size. It is recommended "
182 L
"that you use a disk utility such as Partition Magic to "
183 L
"reduce the cluster size of this volume.",
185 Defrag
->GetVolume().GetVolumeInfo().ClusterSize
188 wcscat (Text
, Text2
);
191 SetDlgItemText (Dlg
, IDC_RECOMMEND
, Text
);
197 INT_PTR CALLBACK
ReportDialogProc (HWND Dlg
, UINT Msg
, WPARAM WParam
, LPARAM LParam
)
202 SetReportInfo (Dlg
, Defrag
->GetDefragReport (), 1, L
"bytes", false);
206 switch (LOWORD(WParam
))
213 SetReportInfo (Dlg
, Defrag
->GetDefragReport (), 1024*1024*1024, L
"GB", true);
217 SetReportInfo (Dlg
, Defrag
->GetDefragReport (), 1024*1024, L
"MB", false);
221 SetReportInfo (Dlg
, Defrag
->GetDefragReport (), 1024, L
"KB", false);
225 SetReportInfo (Dlg
, Defrag
->GetDefragReport (), 1, L
"bytes", false);