📄 oppview.cpp
字号:
// oppView.cpp : implementation of the COppView class
//
#include "string.h"
#include "stdafx.h"
#include "opp.h"
#include "program.h"
#include "worksdlg.h"
#include "pagedlg.h"
#include "movework.h"
#include "oppDoc.h"
#include "oppView.h"
#include "main.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
struct tSection{
int no;
int signal;
}Section[4] = {{1,0},{2,0},{3,0},{4,0}};
struct tWork_1{
char name;
int size;
}Work[3] = {{'A',6},{'B',25},{'C',36}};
struct tWork_2{
int name;
int size;
int sign;
}Worker[8] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
struct tPage{
int num;
int page;
int local;
int loop1;
int loop2;
}Page[8] = {{0,0,0,102,100},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}
,{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}};
struct tFrag{
int no;
int sign;
int x;
int y;
}Frag[64] = {{0,0,108,61},{1,0,128,61},{2,0,148,61},{3,0,168,61},{4,0,188,61},{5,0,208,61},{6,0,228,61},{7,0,248,61}
,{8,0,108,81},{9,0,128,81},{10,0,148,81},{11,0,168,81},{12,0,188,81},{13,0,208,81},{14,0,228,81},{15,0,248,81}
,{16,0,108,101},{17,0,128,101},{18,0,148,101},{19,0,168,101},{20,0,188,101},{21,0,208,101},{22,0,228,101},{23,0,248,101}
,{24,0,108,121},{25,0,128,121},{26,0,148,121},{27,0,168,121},{28,0,188,121},{29,0,208,121},{30,0,228,121},{31,0,248,121}
,{32,0,108,141},{33,0,128,141},{34,0,148,141},{35,0,168,141},{36,0,188,141},{37,0,208,141},{38,0,228,141},{39,0,248,141}
,{40,0,108,161},{41,0,128,161},{42,0,148,161},{43,0,168,161},{44,0,188,161},{45,0,208,161},{46,0,228,161},{47,0,248,161}
,{48,0,108,181},{49,0,128,181},{50,0,148,181},{51,0,168,181},{52,0,188,181},{53,0,208,181},{54,0,228,181},{55,0,248,181}
,{56,0,108,201},{57,0,128,201},{58,0,148,201},{59,0,168,201},{60,0,188,201},{61,0,208,201},{62,0,228,201},{63,0,248,201}
};
struct tMov{
int sign;
int name;
int size;
int begin;
int start;
}Mov[8] = {{0,0,0,16,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}
,{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}};
/////////////////////////////////////////////////////////////////////////////
// COppView
IMPLEMENT_DYNCREATE(COppView, CView)
BEGIN_MESSAGE_MAP(COppView, CView)
//{{AFX_MSG_MAP(COppView)
ON_COMMAND(ID_OPP_DO, OnOppDo)
ON_COMMAND(ID_OPP_UNDO, OnOppUndo)
ON_WM_KEYDOWN()
ON_WM_TIMER()
ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_DOMOV, OnDomov)
ON_COMMAND(ID_DOPAGE, OnDopage)
ON_COMMAND(ID_DOWORKS, OnDoworks)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COppView construction/destruction
COppView::COppView()
{
// TODO: add construction code here
sign_1 = 2; sign_2 = 0;
i_Status = 0;
i_Sign = 0;
status = 0;
start = 80;
sign = 0;
i_k = 0;
}
COppView::~COppView()
{
}
BOOL COppView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// COppView Drawing Portion
void COppView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
sign_1 = 2; sign_2 = 0;
i_Status = 0;
i_Sign = 0;
status = 0;
start = 80;
sign = 0;
i_k = 0;
Section[0].signal = 0;
Section[1].signal = 0;
Section[2].signal = 0;
Section[3].signal = 0;
loop_1 = 62; loop_2 = 60; //DoPage;
}
void COppView::OnDraw(CDC* pDC)
{
COppDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if(sign == 3){
ChartForm();
}
if(sign == 4){
SectionChart();
}
if(sign == 5){
MoveChart();
}
}
/////////////////////////////////////////////////////////////////////////////
// COppView diagnostics
#ifdef _DEBUG
void COppView::AssertValid() const
{
CView::AssertValid();
}
void COppView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
COppDoc* COppView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COppDoc)));
return (COppDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COppView Menu Portion
void COppView::OnOppDo()
{
// TODO: Add your command handler code here
CProGram dlg;
if(dlg.DoModal() == IDOK)
{
if(dlg.sign == 1) {
m_iTimer = SetTimer(ID_TIMER_MOV, 20, 0);
sign = 1;
i_x = 0;
i_y = 200;
}
if(dlg.sign == 2){
m_iTimer = KillTimer(ID_TIMER_MOV);
sign = 3;
ChartForm();
DoWorks();
}
if(dlg.sign == 3){
m_iTimer = KillTimer(ID_TIMER_MOV);
sign = 4;
SectionChart();
DoPage();
}
if(dlg.sign == 4){
m_iTimer = KillTimer(ID_TIMER_MOV);
sign = 5;
MoveChart();
MoveWork();
}
}
}
void COppView::OnOppUndo()
{
// TODO: Add your command handler code here
sign_1 = 2; sign_2 = 0;
i_Status = 0;
i_Sign = 0;
status = 0;
start = 80;
sign = 0;
i_k = 0;
Section[0].signal = 0;
Section[1].signal = 0;
Section[2].signal = 0;
Section[3].signal = 0;
loop_1 = 62; loop_2 = 60; //DoPage;
Invalidate(true);
}
////////////////////////////////////////////////////////////////////////////
// ToolBar Control Portion
void COppView::OnDomov()
{
// TODO: Add your command handler code here
MoveWork();
}
void COppView::OnDopage()
{
// TODO: Add your command handler code here
DoPage();
}
void COppView::OnDoworks()
{
// TODO: Add your command handler code here
DoWorks();
}
////////////////////////////////////////////////////////////////////////////
// KeyBoard And Mouse Control Portion
void COppView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if( nChar >= 0x30 && nChar <= 0x5A ){
sign = 2;
}
if( nChar == 0x70){
DoWorks();
}
if( nChar == 0x71){
DoPage();
}
if( nChar == 0X72){
MoveWork();
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void COppView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CView::OnRButtonDown(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
// Operate Portion
void COppView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(sign == 1){
CClientDC *pdc = new CClientDC(this);
CPen pen;
pen.CreatePen(PS_DOT,2,RGB(255,125,0));
CPen *oldpen = pdc->SelectObject(&pen);
int x = i_x;
int y = i_y;
if(nIDEvent==ID_TIMER_MOV){
pdc->SetPixel(x,y,RGB(255,125,0));
x++;
i_x = x;
}
pdc->SelectObject(oldpen);
}
if(sign == 2){
CClientDC *pdc = new CClientDC(this);
CPen pen;
pen.CreatePen(PS_DOT,2,RGB(255,125,0));
CPen *oldpen = pdc->SelectObject(&pen);
int i = i_x;
int j = 225;
if(nIDEvent==ID_TIMER_MOV){
pdc->SetPixel(i,j,RGB(0,125,255));
i+=2;
if(i_k >= 50){
sign = 1; i_k = 0;
}
i_x = i;
i_k++;
}
pdc->SelectObject(oldpen);
}
Invalidate (false);
CView::OnTimer(nIDEvent);
}
void COppView::DoWorks()
{
int i,j,name;
CWorksDlg works;
COppDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CString word; int k = 10;
CClientDC dc(this);
CPen pen;
CBrush brush;
pen.CreatePen(PS_SOLID, 1, RGB(0,125,255));
brush.CreateSolidBrush(RGB(255,255,255));
CPen *oldpen = dc.SelectObject(&pen);
dc.SetTextColor(RGB(0,125,255));
if(works.DoModal() == IDOK){
if(works.work == 1) {
word.Format("%c",k = Work[0].name);
dc.TextOut(625, 117, word);
dc.TextOut(530, 117, "已分配");
for(i = 1; i <= 25; i++){
dc.MoveTo(101, 80 + i); dc.LineTo(198, 80 + i);
}
}
if(works.work == 2) {
word.Format("%c",k = Work[1].name);
dc.TextOut(625, 147, word);
dc.TextOut(530, 147, "已分配");
for(i = 1; i <= 25; i++){
dc.MoveTo(101, 125 + i); dc.LineTo(198, 125 + i);
}
}
if(works.work == 3) {
word.Format("%c",k = Work[2].name);
dc.TextOut(625, 177, word);
dc.TextOut(530, 177, "已分配");
for(int i = 1; i <= 45; i++){
dc.MoveTo(101, 185 + i); dc.LineTo(198, 185 + i);
}
}
if(works.work == 4){
Worker[status].name = works.m_name;
Worker[status].size = works.m_size;
if(Worker[status].size > 0 && Worker[status].size <= 8){
if(Section[0].signal == 0){
word.Format("%d",k = Worker[status].name);
dc.TextOut(625, 117, word);
dc.TextOut(530, 117, "已分配");
for(i = 1; i <= 25; i++){
dc.MoveTo(101, 80 + i); dc.LineTo(198, 80 + i);
}
Worker[status].sign = 1;
Section[0].signal = 1;
status ++;
}
else{ MessageBox("分区已被占用!");}
}
if(Worker[status].size > 8 && Worker[status].size <= 32){
if(Section[1].signal == 0){
word.Format("%d",k = Worker[status].name);
dc.TextOut(625, 147, word);
dc.TextOut(530, 147, "已分配");
for(i = 1; i <= 25; i++){
dc.MoveTo(101, 125 + i); dc.LineTo(198, 125 + i);
}
Worker[status].sign = 2;
Section[1].signal = 1;
status ++;
}
else{ MessageBox("分区已被占用!");}
}
if(Worker[status].size > 32 && Worker[status].size <= 64){
if(Section[2].signal == 0){
word.Format("%d",k = Worker[status].name);
dc.TextOut(625, 177, word);
dc.TextOut(530, 177, "已分配");
for(int i = 1; i <= 45; i++){
dc.MoveTo(101, 185 + i); dc.LineTo(198, 185 + i);
}
Worker[status].sign = 3;
Section[2].signal = 1;
status ++;
}
else{ MessageBox("分区已被占用!");}
}
if(Worker[status].size > 64 && Worker[status].size <= 132){
if(Section[3].signal == 0){
word.Format("%d",k = Worker[status].name);
dc.TextOut(625, 207, word);
dc.TextOut(530, 207, "已分配");
for(int i = 1; i <= 75; i++){
dc.MoveTo(101, 275 + i); dc.LineTo(198, 275 + i);
}
Worker[status].sign = 4;
Section[3].signal = 1;
status ++;
}
else{ MessageBox("分区已被占用!");}
}
if(Work[status].size > 132 && Work[status].size <= 0){
MessageBox("输入操作有误,请重新输入!");
}
}
if(works.work == 5){
name = works.m_name;
for(j = 0; j<=4; j++){
if(name == Worker[j].name){
switch(Worker[j].sign)
{
case 1: FillPart_1(); Section[0].signal = 0; break;
case 2: FillPart_2(); Section[1].signal = 0; break;
case 3: FillPart_3(); Section[2].signal = 0; break;
case 4: FillPart_4(); Section[3].signal = 0; break;
}//break;
}//else{ MessageBox("你输入的作业不存在,请重新输入!"); break;}
}
}
}
else{
if(works.work == 1) {
FillPart_1();
}
if(works.work == 2) {
FillPart_2();
}
if(works.work == 3) {
FillPart_3();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -