📄 mainframe.cpp
字号:
clearscreen(hOut,posq1,posq2);
break;
}
else
if(mouseclickl(hOut,hIn,d[2] ,mouseRec))
{
//添加删除文件函数
clearscreen(hOut,posq1,posq2);
if(t)
{
t=del(t);
clearscreen(hOut,posq1,posq2);
pal=false;
save=false;
break;
}
else
frame2(hOut,hIn,"家谱为空!!");
}
else
if(mouseclickl(hOut,hIn,d[3],mouseRec))
{ //修改函数
if(t)
{
button ww;
clearscreen(hOut,posq1,posq2);
COORD po1={22,13};
SetConsoleCursorPosition(hOut,po1);
cout<<" 单击要修改人或输入姓名";
COORD pos12={28,14};
button a,*pp;
ww.createbutton(pos12,"输入姓名",14,236,hOut);
pal=false;
save=false;
x=countnode(t);
pp=print1(t,pp,x,hOut);
for(;;)
{
char name[20];
int o=0;
ReadConsoleInput(hIn, &mouseRec, 1,&res);
mousemove1(hOut,hIn,ww,mouseRec);
for(int k=0;k<x;k++)
{
if(!pp[k].p)
pp[k].hidebutton(hOut,true);
mousemove1(hOut,hIn,pp[k],mouseRec);
}
if(mouseclickl(hOut,hIn,ww,mouseRec))
{
pos12.X+=8;
SetConsoleCursorPosition(hOut,pos12);
cin>>name;
bitnode*k;
k=search(t,name);
if(!k)
frame2(hOut,hIn,"此人不存在!");
else
xiugai(k,hOut);
o=1;
clearscreen(hOut,posq1,posq2);
}
for(int j=0;j<x;j++)
{
if(mouseclickl(hOut,hIn,pp[j],mouseRec))
{
for(int l=0;l<x;l++)
pp[l].hidebutton(hOut,false);
pal=false;
xiugai(search(t,pp[j].buttonname),hOut);
o=1;
clearscreen(hOut,posq1,posq2);
break;
}
}
if(o)break;
}
}
else
frame2(hOut,hIn,"家谱为空!!");
//修改
}
else
if(mouseclickl(hOut,hIn,d[4],mouseRec))
{
//保存函数
savefile(t);
save=true;
if(frame2(hOut,hIn,"文件已保存!"))
break;
}
else break;
}
}
if(mouseclickl(hOut,hIn,a,mouseRec)) //全屏切换
{
setmenu0(d,4,hOut);
tal=fullScreen(tal,a,hOut,hIn);
}
mousemove (hOut,hIn,a,mouseRec);
mousemove(hOut,hIn,c[0],mouseRec);
mousemove (hOut,hIn,b,mouseRec);
if(mouseclickl(hOut,hIn,b,mouseRec)) //退出按钮
{
setmenu0(d,4,hOut);
if(save)
{
if(frame1(hOut,hIn))
exit(0);
}
else
{
switch(frame3(hOut,hIn))
{
case 0:{savefile(t);exit(0);}
case 1:exit(0);
}
}
}
mousemove(hOut,hIn,g,mouseRec);
if(mouseclickl(hOut,hIn,g,mouseRec)||mouseclickl(hOut,hIn,h[2],mouseRec)) //返回
{
BOOL tall=true;
if(!save)
{
switch(frame3(hOut,hIn))
{
case 0: savefile(t);tall=true;break;
case 1:tall=true;break;
case 2: tall=false;break;
}
}
if(tall)
{
setmenu0(d,5,hOut); //文件菜单
setmenu0(e,4,hOut); //编辑菜单
setmenu0(f,3,hOut);
a.hidebutton(hOut,false);
b.hidebutton(hOut,false);
d[0].hidebutton(hOut,false);
e[0].hidebutton(hOut,false);
f[0].hidebutton(hOut,false);
g.hidebutton(hOut,false);
for(int j=0;j<8;j++)
h[j].hidebutton(hOut,false);
COORD p={1,12},poss={0,10},poss1={0,0},poss2={20,11};
COORD posa={50,5},pos1={10,15},posb={64,5};
SetConsoleTextAttribute(hOut,14); //设置窗口属性
SetConsoleCursorPosition(hOut,p); //设置光标的位置
FillConsoleOutputAttribute(hOut, 170, 199, poss, NULL);
FillConsoleOutputAttribute(hOut, 170, 199, poss1, NULL);
for(;poss1.Y<199;poss1.Y++)
{
if(poss2.Y<=poss1.Y)
{
FillConsoleOutputAttribute(hOut, 170, 1, poss2, NULL);
poss2.Y++;
}
FillConsoleOutputAttribute(hOut, 170, 1, poss1, NULL);
}
button a,b,d; //全屏按钮,退出按钮
COORD posd0={9,5};
a.createbutton(posa,"【全屏切换】",14,236,hOut);
b.createbutton(posb,"【 退 出 】",14,236,hOut);
d.createbutton(posd0,"【 文 件 】",14,236,hOut); //第一个菜单 新建菜单
//菜单可见性
button e[5]; //编辑菜单
COORD pose0={22,5};
e[0].createbutton(pose0,"【 编 辑 】",14,236,hOut);
button f; //帮助菜单
COORD posf0={36,5};
f.createbutton(posf0,"【 帮 助 】",14,236,hOut);
COORD p1={9,13};
button aa[7];
aa[0].createbutton(p1," 欢 ",14,236,hOut);
p1.Y=p1.Y+2;
aa[1].createbutton(p1," 迎 ",14,236,hOut);
p1.Y=p1.Y+2;
aa[2].createbutton(p1," 使 ",14,236,hOut);
p1.Y=p1.Y+2;
aa[3].createbutton(p1," 用 ",14,236,hOut);
p1.Y=p1.Y+2;
aa[4].createbutton(p1," 本 ",14,236,hOut);
p1.Y=p1.Y+2;
aa[5].createbutton(p1," 系 ",14,236,hOut);
p1.Y=p1.Y+2;
aa[6].createbutton(p1," 统 ",14,236,hOut);
p1.Y=p1.Y+2;
clearscreen(hOut,posq1,posq2);
//返回函数
return ;
}
}
if(mouseclickl(hOut,hIn,h[0],mouseRec))
{
//添加
clearscreen(hOut,posq1,posq2);
t=insert(t);
clearscreen(hOut,posq1,posq2);
pal=false;
save=false;
}
if(mouseclickl(hOut,hIn,h[1],mouseRec))
{
clearscreen(hOut,posq1,posq2);
if(t)
{
pal=false;
t=del(t);
COORD posz={22,16},posx={90,30};
clearscreen(hOut,posz,posx);
save=false;
clearscreen(hOut,posq1,posq2);
}
else
frame2(hOut,hIn,"家谱为空!!");
//删除
}
if(mouseclickl(hOut,hIn,h[3],mouseRec))
{
if(t)
{
button ww;
clearscreen(hOut,posq1,posq2);
COORD po1={22,13};
SetConsoleCursorPosition(hOut,po1);
cout<<" 单击要修改人或输入姓名";
COORD pos12={28,14};
button a,*pp;
ww.createbutton(pos12,"输入姓名",14,236,hOut);
pal=false;
save=false;
x=countnode(t);
pp=print1(t,pp,x,hOut);
for(;;)
{
char name[20];
int o=0;
ReadConsoleInput(hIn, &mouseRec, 1,&res);
mousemove1(hOut,hIn,ww,mouseRec);
mousemove(hOut,hIn,h[2],mouseRec);
mousemove(hOut,hIn,g,mouseRec);
if(mouseclickl(hOut,hIn,g,mouseRec)||mouseclickl(hOut,hIn,h[2],mouseRec))
{
clearscreen(hOut,posq1,posq2);
break;
}
for(int k=0;k<x;k++)
{
if(!pp[k].p)
pp[k].hidebutton(hOut,true);
mousemove1(hOut,hIn,pp[k],mouseRec);
}
if(mouseclickl(hOut,hIn,ww,mouseRec))
{
pos12.X+=8;
SetConsoleCursorPosition(hOut,pos12);
cin>>name;
bitnode*k;
k=search(t,name);
if(!k)
frame2(hOut,hIn,"此人不存在!");
else
xiugai(k,hOut);
o=1;
clearscreen(hOut,posq1,posq2);
}
for(int j=0;j<x;j++)
{
if(mouseclickl(hOut,hIn,pp[j],mouseRec))
{
for(int l=0;l<x;l++)
pp[l].hidebutton(hOut,false);
pal=false;
xiugai(search(t,pp[j].buttonname),hOut);
o=1;
clearscreen(hOut,posq1,posq2);
break;
}
}
if(o)break;
}
}
else
frame2(hOut,hIn,"家谱为空!!");
//修改
}
if(mouseclickl(hOut,hIn,h[4],mouseRec))
{
//查询
if(t)
{
button k[2];
COORD posk0={3,23};
k[0].createbutton(posk0,"按基本信息查询",14,236,hOut);
posk0.Y+=2;
k[1].createbutton(posk0,"按亲属关系查询",14,236,hOut);
for(;;)
{
ReadConsoleInput(hIn, &mouseRec, 1,&res);
pal=false;
clearscreen(hOut,posq1,posq2);
mousemove1(hOut,hIn,k[0],mouseRec);
mousemove1(hOut,hIn,k[1],mouseRec);
mousemove(hOut,hIn,h[2],mouseRec);
mousemove(hOut,hIn,g,mouseRec);
if(mouseclickl(hOut,hIn,g,mouseRec)||mouseclickl(hOut,hIn,h[2],mouseRec))
{
k[0].hidebutton(hOut,false);
k[1].hidebutton(hOut,false);
clearscreen(hOut,posq1,posq2);
break;
}
if(mouseclickl(hOut,hIn,k[0],mouseRec))
{
//添加基本信息查询函数
bitree a;//=new bitnode;
COORD pot={22,13};
SetConsoleCursorPosition(hOut,pot);
cout<<"不清楚的项可不填或填上###";
a=searchperson(hOut,t);
clearscreen(hOut,posq1,posq2);
COORD po2={40,13};
SetConsoleCursorPosition(hOut,po2);
cout<<"查询结果";
if(a)
{
if(!strcmp(a->a.parentname,"######"))
{
k[0].hidebutton(hOut,false);
k[1].hidebutton(hOut,false);
clearscreen(hOut,posq1,posq2);
break;
}
bitree c=a;
int xx=0;
button *aa;
COORD poi={22,14};
while(c)
{
c=c->lchild;
xx++;
}
aa=new button[xx];
int y=0;
while(a)
{
aa[y].createbutton(poi,a->a.name,14,236,hOut);
poi.X+=12;
y++;
if(!(y%5))
{
poi.X-=60;
poi.Y++;
}
a=a->lchild;
}
for(;;)
{
ReadConsoleInput(hIn, &mouseRec, 1,&res);
for(int i=0;i<xx;i++)
{
mousemove1(hOut,hIn,aa[i],mouseRec);
}
mousemove(hOut,hIn,h[2],mouseRec);
mousemove(hOut,hIn,g,mouseRec);
if(mouseclickl(hOut,hIn,g,mouseRec)||mouseclickl(hOut,hIn,h[2],mouseRec))
{
clearscreen(hOut,posq1,posq2);
break;
}
for(int j=0;j<xx;j++)
{
if(mouseclickl(hOut,hIn,aa[j],mouseRec))
{
posq1.Y+=6;
clearscreen(hOut,posq1,posq2);
coutnode(search(t,aa[j].buttonname),hOut);
posq1.Y-=6;
}
}
}
}
else
{
frame2(hOut,hIn," 查无此人!!");
clearscreen(hOut,posq1,posq2);
}
k[0].hidebutton(hOut,false);
k[1].hidebutton(hOut,false);
break;
}
if(mouseclickl(hOut,hIn,k[1],mouseRec))
{
//添加亲属关系查询函数
search1(t);
k[0].hidebutton(hOut,false);
k[1].hidebutton(hOut,false);
clearscreen(hOut,posq1,posq2);
break;
}
}
}
else
frame2(hOut,hIn,"家谱为空!!");
}
if(mouseclickl(hOut,hIn,h[5],mouseRec))
{
clearscreen(hOut,posq1,posq2);
if(t)
{
double age=0;
float stature=0;
int xx=0,yy=0,mannum=0;
int aa=8,bb=1;
int nn;
nn=countnode(t);
stat(t,age,stature,mannum,xx,yy,aa,bb);
COORD pol={23,14};
SetConsoleCursorPosition(hOut,pol);
cout<<" "<<t->a.name<<"家族的统计情况";
pol.Y+=2;
SetConsoleCursorPosition(hOut,pol);
cout<<"平均寿命:"<<age/yy;
pol.Y+=2;
SetConsoleCursorPosition(hOut,pol);
cout<<"平均身高:"<<stature/xx<<" cm";
pol.Y+=2;
SetConsoleCursorPosition(hOut,pol);
cout<<"男女比例:男"<<mannum<<" 女"<<nn-mannum;
pol.Y+=2;
SetConsoleCursorPosition(hOut,pol);
coutxueli(aa);
pol.Y+=2;
SetConsoleCursorPosition(hOut,pol);
coutxueli1(bb);
pol.Y+=2;
SetConsoleCursorPosition(hOut,pol);
cout<<"家族中人口:"<<nn;
pol.Y+=2;
pol.X+=15;
button ii;
ii.createbutton(pol,"【确定】",14,236,hOut);
for(;;)
{
ReadConsoleInput(hIn, &mouseRec, 1,&res);
mousemove(hOut,hIn,ii,mouseRec);
if(mouseclickl(hOut,hIn,ii,mouseRec))
{
ii.hidebutton(hOut,false);
clearscreen(hOut,posq1,posq2);
break;
}
}
}
else
frame2(hOut,hIn,"家谱为空!!");
pal=false;
//统计
}
if(mouseclickl(hOut,hIn,h[6],mouseRec))
{
clearscreen(hOut,posq1,posq2);
x=countnode(t);
pp=print1(t,pp,x,hOut);
pal=true;
//打印
}
if(mouseclickl(hOut,hIn,h[7],mouseRec))
{
savefile(t);
save=true;
if(frame2(hOut,hIn,"文件以保存!"))
;
//保存break;
}
}
return ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -