0
已解决
v1.0.1更新日志:
解决了过多输入的问题,目前除打开文件夹和进入文件操作模式需要输入字符,其他全部用按键解决。
往期(v1.0.0)回顾(附使用说明):
https://wenda.codingtang.com/questions/10465/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<time.h>
#include<windows.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
struct xa{
string name;
int num,typ;
/*
typ=
-x 已被删除的文件
1 文件夹
2 文本文档
*/
}doc[256][256];
int check=1,top=1,i,j;
string x;
int file[256][256],filestd[256];
void color(int corcorcor){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),corcorcor);
}
string getTime()
{
time_t timep;
time (&timep);
char tmp[64];
strftime(tmp, sizeof(tmp), "系统时间:%Y年%m月%d日 %H时%M分%S秒",localtime(&timep) );
return tmp;
}
int kd(char ccc){
if(!KEY_DOWN(ccc)) return 0;
else return 1;
}
int shut_down(){
if(kd('M')){
system("cls");
cout<<"XA-codingtang v1.0.1 正在关机..."<<endl;
Sleep(3000);
check=0;
cout<<"关机完毕,欢迎下次使用。"<<endl;
}
}
void desktop(int cmmd){
while(!kd('M'))
{
system("cls");
color(9);
cout<<"操作系统:XA-codingtang v1.0.1"<<endl;
color(7);
for(i=1;i<=filestd[cmmd];i++){
if(1){
cout<<i<<" : "<<file[cmmd][i]<<endl;
}
}
cout<<"您已进入文件操作模式"<<endl<<"C-打开功能栏"<<endl;
Sleep(500);
if(kd('C'))
while(!kd('Q')){
system("cls");
cout<<"N-新建文件夹"<<endl<<"O-打开文件夹"<<endl<<"Q-退出功能区"<<endl<<"M-退至上一个文件夹"<<endl;
Sleep(500);
if(kd('N')){
system("cls");
cout<<">>XA系统 正在建立,请勿再按“N”键"<<endl;
Sleep(1000);
top++;
file[top][0]=cmmd;
filestd[cmmd]++;
file[cmmd][filestd[cmmd]]=top;
}
if(kd('O')){
system("cls");
for(i=1;i<=filestd[cmmd];i++){
if(1){
cout<<i<<" : "<<file[cmmd][i]<<endl;
}
}
cout<<"输入=0 - 退出"<<endl<<"第( )个文件夹:";
cin>>i;
if(i>0) desktop(file[cmmd][i]);
}
if(kd('M')){
system("cls");
cout<<">>XA系统 正在退出,请勿再按“M”键"<<endl;
Sleep(1000);
return ;
}
}
}
}
int main()
{
while(check){
color(9);
cout<<"操作系统:XA-codingtang v1.0.1"<<endl;
color(7);
string time=getTime();
cout<<time<<endl;
cout<<"Q-进入命令模式"<<endl;
Sleep(1000);
system("cls");
shut_down();
if(kd('Q')){
system("cls");
color(9);
cout<<"操作系统:XA-codingtang v1.0.1"<<endl;
color(7);
cout<<"您已进入命令模式"<<endl;
cout<<">>XA系统 提示:进入桌面(文件操作模式)输入“opendesktop”。"<<endl;
if(!check) break;
cin>>x;
if(x=="opendesktop")
desktop(1);
system("cls");
}
}
return 0;
}
恳请留下点赞、评论或关注!
您的鼓励是我们最大的动力!
沙宸安在2020-10-04 22:18:35追加了内容
谢谢!