整合各个模块。

This commit is contained in:
JZYFC 2021-12-23 17:21:04 +08:00
parent 05d7c34725
commit d341d17f12
12 changed files with 147 additions and 74 deletions

View File

@ -22,6 +22,10 @@ add_library(ZMLib "zm/delete.c" "zm/modify.c" zm/del_and_mod.h)
add_library(PSLib "note_by_ps/addnew.h" "note_by_ps/printall.h" "note_by_ps/printall.c"
"note_by_ps/addnew.c" "note_by_ps/test.c")
add_library(WDCLib note_by_WDC/search.h note_by_WDC/search.c)
add_library(HYLLib note/note.c
note/note.h
note/note_add.c
note/note_out.c)
add_executable(TeamProject
"console/ConsoleSettings.c" "console/ConsoleSettings.h"
@ -29,7 +33,8 @@ add_executable(TeamProject
note/note.h)
# hylTest
add_executable(hylTest note/note.h note/note.c note/note_add.c note/note_out.c)
add_executable(note note/text.c)
target_link_libraries(note HYLLib)
# jzyTest
add_executable(jzyTest note_by_jzy/menu.c note_by_jzy/menu.h main.c)
@ -43,4 +48,4 @@ target_link_libraries(jzyTest PSLib)
add_executable(psTest note_by_ps/addnew.c note_by_ps/test.c linked_list/struct_def.h inout/ddlinout.c inout/ddlinout.h note_by_ps/addnew.h note_by_ps/printall.h note_by_ps/printall.c console/ConsoleSettings.c console/ConsoleSettings.h)
# wdc_test
add_executable(wdcTest note_by_WDC/search.c note_by_WDC/test.c note_by_WDC/search.h note_by_ps/addnew.c note_by_ps/addnew.h inout/ddlinout.c inout/ddlinout.h console/ConsoleSettings.c console/ConsoleSettings.h)
add_executable(wdcTest note_by_WDC/search.c note_by_WDC/test.c note_by_WDC/search.h note_by_ps/addnew.c note_by_ps/addnew.h inout/ddlinout.c inout/ddlinout.h console/ConsoleSettings.c console/ConsoleSettings.h)

View File

@ -17,6 +17,7 @@
day_data data;
bool dataUsable = false;
bool isModify = false;
list_head currentHead;
// TODO: tab切换
//WNDPROC prevEditProc;
@ -176,6 +177,7 @@ LRESULT CALLBACK AddProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
EnumChildWindows(hWnd, EnumChildWndSetFont, (LPARAM) font);
EnableWindow(editBoxes[11], true);
if (isModify) {
WCHAR buf[5];
int *ptr = &(data.start_date.year);
@ -187,6 +189,7 @@ LRESULT CALLBACK AddProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
SetWindowText(editBoxes[10], data.todo);
swprintf(buf, 5, L"%d", data.number);
SetWindowText(editBoxes[11], buf);
EnableWindow(editBoxes[11], false);
}
break;
case WM_PAINT:
@ -244,6 +247,7 @@ LRESULT CALLBACK AddProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
swscanf(buf, L"%d", &(data.number));
if (GetWindowTextLength(editBoxes[10]) >= TODO_LENGTH) goto input_error;
if (!isModify && verify_id(currentHead, data) == false) goto input_error;
if (verify_time(data.start_date, data.due_date) == false) goto date_error;
GetWindowText(editBoxes[10], longBuf, TODO_LENGTH + 1);
@ -301,8 +305,9 @@ LRESULT CALLBACK AddProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
}
void open_add_window(HWND hWnd, bool is_modify) {
void open_add_window(HWND hWnd, bool is_modify, list_head head) {
currentHead = head;
isModify = is_modify;
EnableWindow(hWnd, false);

View File

@ -11,7 +11,7 @@
#include <stdio.h>
LRESULT CALLBACK AddProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void open_add_window(HWND hWnd, bool is_modify);
void open_add_window(HWND hWnd, bool is_modify, list_head head);
bool get_data(day_data *mDataPtr);
bool put_data(day_data mData);

View File

@ -6,6 +6,8 @@
#include "AddWnd.h"
#include "FontUtil.h"
#include "NoteWnd.h"
#include "../note_by_ps/addnew.h"
#include "../zm/del_and_mod.h"
#ifdef _UNICODE
#if defined _M_IX86
@ -47,6 +49,7 @@ void callRePaint(HWND hWnd, RECT *disp, TEXTMETRIC text_metric);
static list_head weekHead;
static list_head dayHead;
static bool is_update = false;
// TODO: TESTDATA
day_data current_data = {
@ -81,24 +84,26 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
list_head current;
static int currentListBox;
WCHAR initBuf[100];
switch (msg) {
case WM_CREATE:
font = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
// Add button
HWND hWndTestBtn = CreateWindowEx(
WS_EX_LEFT,
L"Button",
L"Test",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
24,
281,
144,
24,
hWnd,
(HMENU) ID_TEST_BTN, // 按钮ID
(HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
NULL
);
// Add buttons
// HWND hWndTestBtn = CreateWindowEx(
// WS_EX_LEFT,
// L"Button",
// L"Test",
// WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
// 24,
// 281,
// 144,
// 24,
// hWnd,
// (HMENU) ID_TEST_BTN, // 按钮ID
// (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
// NULL
// );
HWND hWndAddWeekBtn = CreateWindowEx(
WS_EX_LEFT,
@ -190,9 +195,9 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
L"Button",
L"打开笔记",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
188,
24,
281,
64,
144,
24,
hWnd,
(HMENU) ID_NOTE_BTN,
@ -244,7 +249,6 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
currentListBox = 0;
current = weekHead->next;
WCHAR initBuf[100];
while (current != NULL) {
swprintf(initBuf, 99, L"%s", current->data.todo);
int pos = (int) SendMessage(week_edit, LB_ADDSTRING, 0, (LPARAM) initBuf);
@ -288,6 +292,8 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Rectangle(hdc, sign.left, sign.top, sign.right, sign.bottom);
sign.left += 10;
DrawText(hdc, L"个性签名", -1, &sign, DT_LEFT | DT_VCENTER);
sign.top += text_metric.tmHeight + 6;
sign.bottom += text_metric.tmHeight + 6;
// 信息显示区
disp.left = 273;
@ -331,7 +337,23 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
EndPaint(hWnd, &ps);
if (is_update) {
SendMessage(week_edit, LB_RESETCONTENT, 0, 0);
SendMessage(day_edit, LB_RESETCONTENT, 0, 0);
current = weekHead->next;
while (current != NULL) {
swprintf(initBuf, 99, L"%s", current->data.todo);
int pos = (int) SendMessage(week_edit, LB_ADDSTRING, 0, (LPARAM) initBuf);
current = current->next;
}
current = dayHead->next;
while (current != NULL) {
swprintf(initBuf, 99, L"%s", current->data.todo);
int pos = (int) SendMessage(day_edit, LB_ADDSTRING, 0, (LPARAM) initBuf);
current = current->next;
}
is_update = false;
}
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
@ -345,31 +367,59 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
MessageBox(hWnd, wstr, L"Button clicked", MB_OK);
break;
case ID_ADD_WEEK_BTN:
case ID_ADD_DAY_BTN:
// 添加
open_add_window(hWnd, false);
// 添加周计划
open_add_window(hWnd, false, weekHead);
get_data(&current_data);
addnew(weekHead, current_data);
is_update = true;
callRePaint(hWnd, &disp, text_metric);
break;
case ID_ADD_DAY_BTN:
// 添加日计划
open_add_window(hWnd, false, dayHead);
get_data(&current_data);
addnew(dayHead, current_data);
is_update = true;
callRePaint(hWnd, &disp, text_metric);
break;
case ID_MODIFY_WEEK_BTN:
put_data(current_data);
open_add_window(hWnd, true, weekHead);
get_data(&current_data);
modifyNode(weekHead, current_data);
is_update = true;
callRePaint(hWnd, &disp, text_metric);
break;
case ID_MODIFY_DAY_BTN:
// 修改
put_data(current_data);
open_add_window(hWnd, true);
open_add_window(hWnd, true, dayHead);
get_data(&current_data);
modifyNode(dayHead, current_data);
is_update = true;
callRePaint(hWnd, &disp, text_metric);
break;
case ID_DELETE_WEEK_BTN:
// TODO: 删除消息框
deleteNode(weekHead, current_data);
is_update = true;
callRePaint(hWnd, &disp, text_metric);
break;
case ID_DELETE_DAY_BTN:
deleteNode(dayHead, current_data);
is_update = true;
callRePaint(hWnd, &disp, text_metric);
break;
case ID_NOTE_BTN:
open_note_window(hWnd);
case ID_NOTE_BTN:;
// open_note_window(hWnd);
FILE *file = NULL;
file = fopen("note.exe", "r");
if (file == NULL)
MessageBox(hWnd, L"笔记模块不存在", L"错误", MB_OK);
else system("start cmd /k note.exe");
break;
case ID_WEEK_LB:
switch (HIWORD(wParam)) {
case LBN_SELCHANGE:
case LBN_SELCHANGE:;
int i = (int) SendMessage(week_edit, LB_GETCURSEL, 0, 0);
if (i < 0) return 0;
current = weekHead->next;
@ -378,13 +428,14 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
current_data = current->data;
currentListBox = 0;
is_update = false;
callRePaint(hWnd, &disp, text_metric);
break;
}
break;
case ID_DAY_LB:
switch (HIWORD(wParam)) {
case LBN_SELCHANGE:
case LBN_SELCHANGE:;
int i = (int) SendMessage(day_edit, LB_GETCURSEL, 0, 0);
if (i < 0) return 0;
current = dayHead->next;
@ -393,6 +444,7 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
current_data = current->data;
currentListBox = 1;
is_update = false;
callRePaint(hWnd, &disp, text_metric);
break;
}

View File

@ -11,7 +11,7 @@
date read_date();
day_data read_info(void) {
day_data read_info(list_head head, bool is_add) {
wchar_t tmp;
day_data data;
int read_num;
@ -27,6 +27,9 @@ day_data read_info(void) {
restore_prev_color();
clear_input_stream();
goto reInputID;
} else if (is_add && !verify_id(head, data)) {
wprintf(L"id重复请重新输入\n");
goto reInputID;
}
reInputDate:
wprintf(L"请输入开始时间:\n");
@ -72,6 +75,15 @@ void clear_input_stream(void) {
while (wc != WEOF && wc != L'\n') wc = getwchar();
}
bool verify_id(list_head head, day_data data) {
head = head->next;
while (head != NULL) {
if (data.number == head->data.number) return false;
head = head->next;
}
return true;
}
bool verify_time(date start, date end) {
if (start.year < end.year) {
return true;

View File

@ -12,10 +12,11 @@
#include <time.h>
#include <stdbool.h>
day_data read_info(void);
day_data read_info(list_head head, bool is_add);
void clear_input_stream(void);
date read_date();
bool verify_time(date start, date end);
bool verify_id(list_head head, day_data data);
#endif //TEAMPROJECT_DDLINOUT_H

View File

@ -1,8 +1,8 @@
#include "note.c"
int main(){
//setlocale(LC_ALL," ");
setlocale(LC_ALL,"");
int flag=1;
system("chcp 65001");
// system("chcp 65001");
system("cls");
tag_head= init();
if(tag_head==NULL)return 0;

View File

@ -15,11 +15,12 @@ void search_start(list_head head,date start_date_s){
if(pointer->data.start_date.year == start_date_s.year && pointer->data.start_date.month == start_date_s.month && pointer->data.start_date.day == start_date_s.day){
wprintf(L"\n------------------------------\n");
wprintf(L"截至时间:%d,%d,%d\n",pointer->data.due_date.year,pointer->data.due_date.month,pointer->data.due_date.day);
wprintf(L"事件:%ls",pointer->data.todo);
wprintf(L"事件:%ls\n",pointer->data.todo);
wprintf(L"-------------------------------\n");
}
pointer = pointer->next;
}
system("pause");
}
void search_end(list_head head,date due_date_s){
@ -29,11 +30,12 @@ void search_end(list_head head,date due_date_s){
if(pointer->data.due_date.year == due_date_s.year && pointer->data.due_date.month == due_date_s.month && pointer->data.due_date.day == due_date_s.day){
wprintf(L"\n------------------------------\n");
wprintf(L"开始时间:%d,%d,%d\n",pointer->data.start_date.year,pointer->data.start_date.month,pointer->data.start_date.day);
wprintf(L"事件:%ls",pointer->data.todo);
wprintf(L"事件:%ls\n",pointer->data.todo);
wprintf(L"-------------------------------\n");
}
pointer = pointer->next;
}
system("pause");
}

View File

@ -96,19 +96,24 @@ void main_menu(void) {
case 1:
wprintf(L"请输入要更改的计划类型编号周计划为1日计划为2\n");
wscanf_s(L"%d", &input);
day_data dd;
if (input == 1) {
addnew(week_head);
dd = read_info(week_head, true);
addnew(week_head, dd);
} else if (input == 2) {
addnew(day_head);
dd = read_info(day_head, true);
addnew(day_head, dd);
} else goto input_err;
break;
case 2:
wprintf(L"请输入要更改的计划类型编号周计划为1日计划为2\n");
wscanf_s(L"%d", &input);
day_data data = read_info();
day_data data;
if (input == 1) {
data = read_info(week_head, false);
modifyNode(week_head, data);
} else if (input == 2) {
data = read_info(day_head, false);
modifyNode(day_head, data);
} else goto input_err;
break;
@ -135,9 +140,10 @@ void main_menu(void) {
} else if (input == 2) {
head_tmp = day_head;
} else goto input_err;
wprintf(L"请输入查找的数据查找计划开始日期为1查找计划结束日期为2\n");
wprintf(L"请输入查找的数据查找计划开始日期为1查找计划结束日期为2,忽略小时与分钟\n");
wscanf_s(L"%d", &input);
if (input != 1 && input != 2) goto input_err;
wprintf(L"请输入日期: \n");
date d = read_date();
if (input == 1) {
search_start(week_head, d);
@ -146,7 +152,11 @@ void main_menu(void) {
}
break;
case 5:
// TODO: 打开笔记本
FILE *file = NULL;
file = fopen("note.exe", "r");
if (file == NULL)
wprintf(L"笔记本模块不存在");
else system("start cmd /k note.exe");
break;
case 6:
wprintf(L"正在图形界面中操作。");

View File

@ -1,32 +1,21 @@
#include "addnew.h"
void addnew(list_head head){
void addnew(list_head head, day_data dd) {
linked_list *now;
linked_list *new_node =(linked_list*) malloc(sizeof(linked_list));
day_data dd = read_info();
linked_list *prev;
linked_list *new_node = (linked_list *) malloc(sizeof(linked_list));
new_node->data = dd;
new_node->next = NULL;
if(head->next=NULL){
head->next=new_node;
if (head->next == NULL) {
head->next = new_node;
}
for(now= head; (now->next)!=NULL; now = now->next){
if(new_node->data.due_date.year<=now->next->data.due_date.year){
if(new_node->data.due_date.month<=now->next->data.due_date.month){
if(new_node->data.due_date.day<=now->next->data.due_date.day){
if (new_node->data.due_date.hour <= now->next->data.due_date.hour) {
if (new_node->data.due_date.minute <= now->next->data.due_date.minute) {
new_node->next = now->next;
now->next = new_node;
}
}
}
}
}
}
if((now->next)==NULL)
now->next=new_node;
return;
prev = head;
for (now = head->next; now != NULL; now = now->next) {
if(verify_time(dd.start_date, now->data.start_date)) break;
prev = now;
}
new_node->next = prev->next;
prev->next = new_node;
}

View File

@ -5,5 +5,5 @@
#include "../linked_list/struct_def.h"
#include "../inout/ddlinout.h"
void addnew(list_head head);
void addnew(list_head head, day_data dd);
#endif//TEAMPROJECT_ADDNEW_H

View File

@ -2,19 +2,16 @@
void modifyNode(list_head head, day_data DATA) {
linked_list *p = head->next;
linked_list *pre = head->next;
while(p!=NULL){
if(p->data.number == DATA.number){
// if(p->data_data.number == DATA.number){ // DID YOU MEAN "data"
p->data = DATA;
// p->data_data = DATA; // DID YOU MEAN "data"
printf("The %dth task has been modified successfully!\n",DATA.number);
// printf("The %dth task has been modified successfully!\n",DATA.number);
return ;
}
pre = pre->next;
p = pre->next;
p = p->next;
}
printf("Sorry, we don't find this task, please check the number you input.");
return ;
// printf("Sorry, we don't find this task, please check the number you input.");
}