📄 main_dlg.cpp
字号:
#include "stdafx.h"
// main_dlg.cpp
// note: for v1.6.3+, you should try to use the Resource Splitter
// comment this line, and uncomment the following one
#include "resource.h"
#include "main_dlg.h"
#include "para_empl.h"
#include "time.h"
using namespace win32::gui;
struct main_dlg_handler : event_handler<main_dlg_handler, main_dlg> {
handle_event on_calc() {
if(window()->item_num < 0)
{
msg_box( window(), "请先进行参数设置!" );
}
else{
//初始化算法参数
item_num = window()->get_item_num();
item_supp = window()->get_item_supp();
// 计算频繁项集
CAprioriSet* m_pSet = new CAprioriSet(item_num, item_supp);
start = clock();
item_set = m_pSet->getFreqItem();
stop = clock();
delete m_pSet;
window()->show_item(item_set);
time_used = ( stop - start )<<10/CLK_TCK;
msg_box ( window(), "耗时" + boost::lexical_cast<string>(time_used) + "毫秒,计算成功!" );
}
return command<ID_file_calc>().HANDLED_BY(&me::on_calc);
}
handle_event on_option() {
//parameter para;
item_num = 10;
item_supp = 0.2;
//para_empl pl( para );
create_modal_save_dlg ( ID_option, //<bolded_save_dlg>( ID_option, pl, null_wnd );
save_dlg::corresp()
.add_corresp( &item_num, ID_item_num )
.add_corresp( &item_supp, ID_item_supp),
null_wnd );
window()->item_num = item_num;
window()->item_supp = item_supp;
return command<ID_file_option>().HANDLED_BY(&me::on_option);
}
handle_event on_about() {
create_modal_dlg<dialog> ( window(), create_info().id(IDD_ABOUTBOX) ).wait();
return command<IDM_ABOUT>().HANDLED_BY(&me::on_about);
}
handle_event on_exit() {
PostQuitMessage(0);
return command<IDM_EXIT>().HANDLED_BY(&me::on_exit);
}
private:
clock_t start, stop;
double time_used;
int item_num;
double item_supp;
vector<ItemType> item_set;
};
main_dlg::main_dlg() {
item_num = -1;
item_supp = 0.2;
add_resizable_ctrl( ID_list_data, size_x | size_y );
child<list_ctrl>( ID_list_data)->add_col( lv_col().text("Item").width(100) );
child<list_ctrl>( ID_list_data)->add_col( lv_col().text("Count").width(100) );
}
main_dlg::~main_dlg() {
}
void main_dlg::show_item( vector<ItemType>& itemSet ) {
int idx = 0;
wnd<list_ctrl> aprioriItem = child<list_ctrl>(ID_list_data);
aprioriItem->del_all_items();
for( vector<ItemType>::iterator it = itemSet.begin(); it != itemSet.end(); it++)
{
//分隔不同级的频繁项集
if( it == itemSet.begin() || get<0>(*(it-1)) != get<0>(*it) )
{
aprioriItem->add_item( lv_item() );
aprioriItem->item( idx, 0, lv_item().text( "----------" ) );
aprioriItem->item( idx, 1, lv_item().text( "----------" ) );
++idx;
}
aprioriItem->add_item( lv_item() );
aprioriItem->item( idx, 0, lv_item().text( get<1>( *it ) ) );
aprioriItem->item( idx, 1, lv_item().text( boost::lexical_cast<string>( get<2>( *it ) ) ) );
++idx;
}
}
// note: for v1.6.3+, you should try to use the Resource Splitter
// comment this line, and uncomment the following one
int main_dlg::dialog_id() { return IDD_MAIN; }
// int main_dlg::dialog_id() { return dialog_id_; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -