Sysmon: add a button to hide and show sensors (but it do not remember its state after app reopen)

git-svn-id: svn://kolibrios.org@9581 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2022-01-05 23:18:43 +00:00
parent 59d0c5206e
commit 512e7907ed
5 changed files with 52 additions and 31 deletions

View File

@ -135,6 +135,7 @@ void handle_param()
strcpy(#program_path+strrchr(#program_path,'/'), "EOLITE");
}
SetAppColors();
LoadIniSettings();
for (i=0; i<PANES_COUNT; i++) {
@ -190,7 +191,6 @@ void main()
load_dll(libini, #lib_init,1);
load_dll(libimg, #libimg_init,1);
SetAppColors();
handle_param();
SystemDiscs.Get();

View File

@ -229,7 +229,8 @@ void SetAppColors()
col.list_text_hidden = 0xA6A6B7;
col.list_vert_line = 0xDDD7CF;
col.lpanel = 0x00699C;
col.selec = col.selec_active = 0x92B1D9;
if (efm) EBX = 0x84BEFB; else EBX = 0x92B1D9;
col.selec = col.selec_active = EBX;
col.selec_text = 0x000000;
col.slider_bg_big = 0xCDCFCF;
col.odd_line = 0xF4F5F5;

View File

@ -2,4 +2,4 @@
@c-- /D=LANG_RUS sysmon.c
@rename sysmon.com sysmon
@del warning.txt
@pause
if not exist sysmon ( @pause )

View File

@ -2,4 +2,4 @@
@c-- /D=LANG_RUS sysmon.c
@rename sysmon.com sysmon
@del warning.txt
@pause
if not exist sysmon ( @pause )

View File

@ -1,10 +1,10 @@
/*
* System Monitor
* version 1.37
* version 1.4
* Author: Leency
*/
#define MEMSIZE 4096*30
#define MEMSIZE 1024*60
#define NO_DLL_INIT
//===================================================//
@ -42,7 +42,7 @@
#define T_DETAILS "<22>®¤à®¡­¥¥"
#define T_PROC_KILL "‘­ïâì § ¤ çã"
#define T_PROC_INFO "ˆ­ä®"
#define T_PROC_HEADER "<22>à®æ¥áá Ž‡“ Š¡ <EFBFBD> %"
#define T_PROC_HEADER "<22>à®æ¥áá Ž‡“ Š¡ <EFBFBD> %"
#define T_CPU_LOAD "‡ £à㧪  ¯à®æ¥áá®à  %i%% "
#define T_RAM_USAGE "<22> ¬ïâì Ž‡“: %i Œ¡ ᢮¡®¤­® ¨§ %i Œ¡"
#define T_RD_USAGE "‘¨á⥬­ë© ¤¨áª: %i Š¡ ᢮¡®¤­® ¨§ 1.4 Œ¡"
@ -53,7 +53,7 @@
#define T_DETAILS "Details"
#define T_PROC_KILL "Terminate"
#define T_PROC_INFO "Info"
#define T_PROC_HEADER "Process RAM KB CPU %"
#define T_PROC_HEADER "Process RAM KB CPU %"
#define T_CPU_LOAD "CPU load %i%% "
#define T_RAM_USAGE "RAM usage: %i MB free of %i MB"
#define T_RD_USAGE "System disk usage: %i MB free of 1.4 MB"
@ -61,10 +61,11 @@
#endif
enum {
BTN_ID_SHOW_SYSTEM_PROCESSES=200,
BTN_ID_PROC_KILL,
BTN_ID_PROC_INFO,
BTN_ID_MENU
BTN_SHOW_SYSTEM_PROCESSES=200,
BTN_PROC_KILL,
BTN_PROC_INFO,
BTN_MENU,
BTN_SHOWHIDE_SENSORS
};
//===================================================//
@ -87,21 +88,18 @@ proc_info Form;
int right_w;
bool show_sensors = true;
//===================================================//
// //
// CODE //
// //
//===================================================//
void load_lib()
{
load_dll(boxlib, #box_lib_init,0);
}
void main()
{
int btn;
load_lib();
load_dll(boxlib, #box_lib_init,0);
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop() switch(@WaitEventTimeout(50))
{
@ -121,27 +119,45 @@ void main()
if (show_system.click(btn)) {
SelectList_LineChanged();
}
if (BTN_ID_PROC_KILL == btn) {
if (BTN_PROC_KILL == btn) {
EventKillCurrentProcess();
}
if (BTN_ID_PROC_INFO == btn) {
if (BTN_PROC_INFO == btn) {
RunProgram("/sys/tinfo", itoa(GetProcessSlot(current_process_id)));
}
if (BTN_SHOWHIDE_SENSORS == btn) {
show_sensors ^= 1;
GOTO _DRAW_WINDOW;
}
break;
case evReDraw:
sc.get();
DefineAndDrawWindow(screen.width/2 - 350, 100, 700, 490, 0x33, sc.work, T_APP_TITLE,0);
_DRAW_WINDOW:
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window&ROLLED_UP) break;
if (Form.width < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; }
if (Form.height < 420) { MoveSize(OLD,OLD,OLD,420); break; }
if (show_sensors) {
if (Form.width < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; }
} else {
if (Form.width != RIGHT_X+5) { MoveSize(OLD,OLD,RIGHT_X+5,OLD); break; }
}
right_w = Form.cwidth - RIGHT_X - GAP;
right_w &= ~1; // make sure the number is even
WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER);
DefineButton(RIGHT_X-38,WIN_CONTENT_Y-25,18,18,BTN_SHOWHIDE_SENSORS,sc.work);
DrawRectangle3D(RIGHT_X-38,WIN_CONTENT_Y-25,19,18,sc.work_graph,sc.work_light);
PutPixel(RIGHT_X-38+19,WIN_CONTENT_Y-25,sc.work_light);
EDX = "<\0>";
EDX += show_sensors * 2;
WriteText(RIGHT_X-38+5,WIN_CONTENT_Y-25+2,0x90,sc.work_text, EDX);
//EBX += 5 << 16;
//$int 64
//bool burger_active = false;
//if (menu_id == OPEN_FILE) burger_active = true;
//DrawTopPanelButton(BTN_ID_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active);
//DrawTopPanelButton(BTN_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active);
SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W,
Form.cheight-BOTPANEL_H-WIN_CONTENT_Y);
@ -150,21 +166,25 @@ void main()
DrawBar(select_list.x-2, select_list.y+select_list.h+2,
select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work);
DrawCaptButton(PROCESS_LIST_W+GAP-110+18, select_list.y+select_list.h+5,
110,23,BTN_ID_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL);
110,23,BTN_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL);
DrawCaptButton(PROCESS_LIST_W+GAP-165+18, select_list.y+select_list.h+5,
46,23,BTN_ID_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO);
46,23,BTN_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO);
show_system.draw(GAP-1, select_list.y+select_list.h+10);
//WriteText(RIGHT_X, WIN_CONTENT_Y+25, 0x90, sc.work, "Update period: 5 seconds");
cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100);
ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23);
rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23);
if (show_sensors) {
cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100);
ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23);
rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23);
}
default:
MonitorCpu();
MonitorRam();
SelectList_LineChanged();
MonitorRd();
MonitorTmp();
if (show_sensors) {
MonitorCpu();
MonitorRam();
MonitorRd();
MonitorTmp();
}
}
}