-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentStatus.cpp
107 lines (83 loc) · 2.5 KB
/
DocumentStatus.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// DocumentStatus.cpp : implementation file
//
#include "stdafx.h"
#include "3eExplorer.h"
#include "DocumentStatus.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDocumentStatus dialog
CDocumentStatus::CDocumentStatus(CWnd* pParent /*=NULL*/)
: CDialog(CDocumentStatus::IDD, pParent)
, m_pExplorerDoc(NULL)
{
//{{AFX_DATA_INIT(CDocumentStatus)
//}}AFX_DATA_INIT
}
void CDocumentStatus::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDocumentStatus)
DDX_Control(pDX, IDC_STATUS_LISTBOX, m_Listbox);
//}}AFX_DATA_MAP
SetStatusInformation();
}
BEGIN_MESSAGE_MAP(CDocumentStatus, CDialog)
//{{AFX_MSG_MAP(CDocumentStatus)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_FLUSH_CACHE, OnFlushCache)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDocumentStatus message handlers
int CDocumentStatus::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
if (NULL != m_pExplorerDoc)
{
SetWindowText(m_pExplorerDoc->GetRoot()->GetName().c_str());
}
return 0;
}
void CDocumentStatus::SetStatusInformation()
{
// remove the items from the listbox...
while (m_Listbox.GetCount())
{
m_Listbox.DeleteString(0);
}
if (NULL != m_pExplorerDoc)
{
m_Listbox.SetTabStops(100);
std::ostringstream ostr;
ostr << "Cylinders\t" << m_pExplorerDoc->GetRoot()->getCylinders();
m_Listbox.AddString(ostr.str().c_str());
ostr.str("");
ostr << "Heads/Tracks\t" << m_pExplorerDoc->GetRoot()->getHeads();
m_Listbox.AddString(ostr.str().c_str());
ostr.str("");
ostr << "Sectors\t" << m_pExplorerDoc->GetRoot()->getSectors();
m_Listbox.AddString(ostr.str().c_str());
ostr.str("");
ostr << "Sector Size\t" << m_pExplorerDoc->GetRoot()->getSectorSize();
m_Listbox.AddString(ostr.str().c_str());
ostr.str("");
ostr << "Sectors Cached\t" << m_pExplorerDoc->GetCacheSize();
m_Listbox.AddString(ostr.str().c_str());
ostr.str("");
ostr << "Cache Memory\t" << (m_pExplorerDoc->GetCacheSize() * m_pExplorerDoc->GetRoot()->getSectorSize()) << "b";
m_Listbox.AddString(ostr.str().c_str());
}
}
void CDocumentStatus::OnFlushCache()
{
if (NULL != m_pExplorerDoc)
{
m_pExplorerDoc->FlushCache();
SetStatusInformation();
}
}