老师今年给我们出的题目要求做可视化界面,可恶的很啊,不过确实收获很多。
这次的程序分三个人一起写,难度也有的,互相认为对方的代码和shi一样。。。。
其余的操作和上次写的图书馆一样,但多了图片的处理和可视化界面的操作。这次的可视化界面是用ege写的
很简单,很方便,但功能却生硬的多。
一、要求:
二、流程图:
三、数据表:
四、分析设计:
#include<graphics.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<Windows.h>
#include<time.h>
int user;
struct diary{
char year[11];
char month[11];
char day[11];
char weekday[11];
char weather[11];
char name[21];
int num;
struct diary *next;
};
struct image{
char name[21];
int num;
char IMAGE[100][31];
struct image *next;
};
mouse_msg msg = {
0};
char text[200010];
char book[100000];
//----------------
void mainmenu();//主界面;
void point();//测试位置;
void over();//结束
void login();//登陆;
void setpass();//设置密码;
//------------------
void findiary(); //查找日记;
void datefind();//日期查找;
void weatherfind();//天气查找;
void namefind();//标题查找;
void opendiary(char *name);//打开日记;
void openimage(char *name,int num);//打开图片; //缩放功能不好;
//-------------------
int cont();//目录计数;
//-------------------
void lookthrogh();//日记浏览;
//---------------------
void Remove(); //删除日记;
void addiary();//添加日记;
void copytext(char *address,char *name);//复制文本;
//---------------------
void improve();//查找替换;
void Print2(char* s,char* show);
void point(char* s,char* show);
void strrpe(char *str,char *old,char *now);
void Print2(char* s,char* show);
//---------------------
int cont()
{
FILE *fp=fopen("list.txt","r");
char year[11],month[11],day[11],week[11],weather[11],name[11];
int sum=0,index;
while(!feof(fp))
{
sum++;
fscanf(fp,"%s%s%s%s%s%s%d",year,month,day,week,weather,name,&index);
}
fclose(fp);
return sum-1;
}
//-------------------------------------------------------------------------------------------------
void point()
{
initgraph(640,640);
PIMAGE src;
src=newimage();
getimage(src,"12.png");
setfont(30, 0, "宋体");
setbkmode(TRANSPARENT);
setcolor(EGERGB(0xff,0xff,0xff));
while(1)
{
while (mousemsg()) msg = getmouse();
cleardevice();//清屏;
putimage(0,0,src);
xyprintf(0, 560, "x=%d y=%d",msg.x, msg.y, msg.wheel);
xyprintf(0, 580, "move=%d down=%d up=%d",(int)msg.is_move(), (int)msg.is_down(),
(int)msg.is_up());
xyprintf(0, 600, "left=%d mid=%d right=%d",(int)msg.is_left(),(int)msg.is_mid(),
(int)msg.is_right());
xyprintf(0, 620, "wheel=%d wheel rotate=%d",(int)msg.is_wheel(), msg.wheel);
}
return ;
}
//--------------------------------------------------------------------------------------------------
void findiary()
{
setfont(30, 0, "幼圆");
setbkmode(TRANSPARENT);
setcolor(EGERGB(0,0,0));
cleardevice();
PIMAGE src1;
src1=newimage();
getimage(src1,"4.png");
while(1)
{
while (mousemsg()) msg = getmouse();
cleardevice();
putimage(0,0,src1);//设置背景 ;
if((msg.x>30&&msg.x<200)&&(msg.y>77&&msg.y<152)&&(int)msg.is_left()==1)/*按日期查找;*/ datefind();
else if((msg.x>30&&msg.x<200)&&(msg.y>210&&msg.y<270)&&(int)msg.is_left()==1) /*按天气查找*/ weatherfind();
else if((msg.x>25&&msg.x<200)&&(msg.y>330&&msg.y<395)&&(int)msg.is_left()==1)/*按标题查找;*/ namefind();
else if((msg.x>46&&msg.x<156)&&(msg.y>428&&msg.y<490)&&(int)msg.is_left()==1)/*return ; */ return ;
}
return ;
}
void datefind()
{
cleardevice();
PIMAGE src2;
src2=newimage();
getimage(src2,"5.png");
putimage(0,0,src2);
FILE *fp=fopen("list.txt","r");
struct diary *head=NULL,*p,*q;//建立链表;
for(int i=1;i<=cont()&&!feof(fp);i++)
{
p=(struct diary*)malloc(sizeof(struct diary));
fscanf(fp,"%s%s%s%s%s%s%d",p->year,p->month,p->day,p->weather,p->weekday,p->name,&p->num);
p->next=NULL;
if(head==NULL) head=p;
else q->next=p;
q=p;
}
fclose(fp);
cleardevice();
setfont(20, 0, "幼圆");
setbkmode(TRANSPARENT);
putimage(0,0,src2);
setcolor(EGERGB(0x45,0x80,0xff));
char xx[21],year[11],month[11],day[11];
inputbox_getline("输入", "请按年+空格+月+空格+日的形式输入",xx,31);
p=head;
while(p!=NULL)
{
char time[21];
strcpy(time,p->year);strcat(time," ");strcat(time,p->month);strcat(time," ");strcat(time,p->day);
if(strcmp(time,xx)==0)
{
//Sleep(1000);
while(1)
{
msg = getmouse();
cleardevice();
putimage(0,0,src2);
xyprintf(0,100,"%s年 %s月 %s日 %s %s %s",p->year,p->month,p->day,p->weekday,p->weather,p->name);
setfont(30,0,"幼圆");
xyprintf(0,200,"是否打开日记");
outtextxy(0,250,"yes no");
if((msg.x>0&&msg.x<40)&&(msg.y>261&&msg.y<277)&&(int)msg.is_left()==1)
{
cleardevice();
putimage(0,0,src2);
openimage(p->name,p->num);
opendiary(p->name);
outtextxy(0,420,"点击此处返回...");
while(1)
{
msg=getmouse();
if((msg.x>0&&msg.x<180)&&(msg.y>420&&msg.y<440)&&(int)msg.is_left()==1) return ;
}
}
else if((msg.x>77&&msg.x<102)&&(msg.y>261&&msg.y<277)&&(int)msg.is_left()==1) return ;
}
}
p=p->next;
}
setfont(30, 0, "幼圆");
xyprintf(0,400,"没找到哟,小老弟,按任意键返回...");
outtextxy(0,420,"点击此处返回...");
while(1)
{
msg=getmouse();
if((msg.x>0&&msg.x<180)&&(msg.y>420&&msg.y<440)&&(int)msg.is_left()==1) return ;
}
return ;
}
void weatherfind()
{
cleardevice();
PIMAGE src2;
src2=newimage();
getimage(src2,"5.png");
putimage(0