⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 磁盘管理view.cpp

📁 用C++实现的模拟操作系统中磁盘管理的实现,代码通俗易懂!适合于初学者!
💻 CPP
字号:
// 磁盘管理View.cpp : implementation of the CMyView class
//

#include "stdafx.h"
#include "磁盘管理.h"

#include "磁盘管理Doc.h"
#include "磁盘管理View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyView

IMPLEMENT_DYNCREATE(CMyView, CView)

BEGIN_MESSAGE_MAP(CMyView, CView)
	//{{AFX_MSG_MAP(CMyView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction

CMyView::CMyView()
{
	// TODO: add construction code here

}

CMyView::~CMyView()
{
}

BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMyView drawing

void CMyView::OnDraw(CDC* pDC)
{
	CMyDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CString str;
	int i;
	int rx = 0;
	//int ry = 0;
	if(pDoc->showfree == 1)
	{
	    pDC->TextOut(0,0,"页号     起始块号    空闲块号      使用状态");
	    for(i=0;i< 10 ;i++)
		{
		    if(pDoc->Red == i)
			{
			    pDC->SetTextColor(RGB(255,0,0));
			    str.Format("%d",pDoc->DT[i].OrderNum);
		        pDC->TextOut(0,25*(i+1),str);
		        str.Format("%d",pDoc->DT[i].StarBlock);
		        pDC->TextOut(80,25*(i+1),str);
		        str.Format("%d",pDoc->DT[i].FreeBlocks);
		        pDC->TextOut(160,25*(i+1),str);
		        str.Format("%d",pDoc->DT[i].status);
		        pDC->TextOut(240,25*(i+1),str);
			    pDC->SetTextColor(RGB(0,0,0));
			}
		    else{

		        str.Format("%d",pDoc->DT[i].OrderNum);
		        pDC->TextOut(0,25*(i+1),str);
		        str.Format("%d",pDoc->DT[i].StarBlock);
		        pDC->TextOut(80,25*(i+1),str);
		        str.Format("%d",pDoc->DT[i].FreeBlocks);
		        pDC->TextOut(160,25*(i+1),str);
		        str.Format("%d",pDoc->DT[i].status);
		        pDC->TextOut(240,25*(i+1),str);
			}
		}
	    pDC->TextOut(0,25*(i+1),"柱面号:      磁道号:        物理记录号:      物理记录数:");
	    pDC->SetTextColor(RGB(255,0,0));
	    str.Format("%d",pDoc->disk.m_CylNum);
	    pDC->TextOut(60,25*(i+1),str);
	    str.Format("%d",pDoc->disk.m_DiskNum);
	    pDC->TextOut(140,25*(i+1),str);
	    str.Format("%d",pDoc->disk.m_PhyNum);
	    pDC->TextOut(270,25*(i+1),str);
	    str.Format("%d",pDoc->NeedBlock);
	    pDC->TextOut(390,25*(i+1),str);
	    pDC->SetTextColor(RGB(0,0,0));
	/*pDC->TextOut(400,0,"已经的存入文件:");
	pDC->SetTextColor(RGB(255,0,0));
	str.Format("柱面号:%d",pDoc->head->m_CylNum);
	pDC->TextOut(400,25,str);*/
	}
	if(pDoc->showbit == 1)
	{
		pDC->TextOut(0,0,"                  位示图");
		for(i=0;i<200;i++)
		{
			if(pDoc->bitred == i)
			{
				pDC->SetTextColor(RGB(255,1,74));
				str.Format("%d",pDoc->BitAry[i]);
				if(i%50 == 0)
				{
					rx = rx + 25 ;
				}
				pDC->TextOut(10*(i%50),rx,str);
				pDC->SetTextColor(RGB(0,0,0));
			}
			else
			{
				str.Format("%d",pDoc->BitAry[i]);
				if(i%50 == 0)
				{
					rx = rx + 25 ;
				}
				pDC->TextOut(10*(i%50),rx,str);
			}
		}
	}
	
}

/////////////////////////////////////////////////////////////////////////////
// CMyView printing

BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics

#ifdef _DEBUG
void CMyView::AssertValid() const
{
	CView::AssertValid();
}

void CMyView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
	return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -