Skip to content

Commit

Permalink
Finished keywords filter
Browse files Browse the repository at this point in the history
Signed-off-by: 邓佳佳 <[email protected]>
  • Loading branch information
nmgwddj committed Oct 22, 2018
1 parent 19ca4e2 commit f146bcb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
11 changes: 11 additions & 0 deletions bin/themes/default/main_form/log_file_session_box.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
<Window>
<VBox>
<HBox name="keywords_filter" width="stretch" height="auto" bkcolor="white" padding="0,0,0,8">
<Button name="start_capture" width="28" height="28" valign="center" tooltiptext="开始监控文件" margin="0,0,5" visible="false"
forenormalimage="start_capture.png"
hotimage="../public/button/icon_hover.png"
pushedimage="../public/button/icon_pushed.png"
disabledimage="start_capture.png" />
<Button name="stop_capture" width="28" height="28" valign="center" tooltiptext="暂停监控文件" margin="0,0,5" visible="false"
forenormalimage="stop_capture.png"
hotimage="../public/button/icon_hover.png"
pushedimage="../public/button/icon_pushed.png"
disabledimage="stop_capture.png" />
<Control class="splitline_ver_level1" margin="5,0,10" visible="false"/>
<HListBox name="keyword_list" width="auto"></HListBox>
<Control />
<HBox width="auto" height="auto" valign="center">
Expand Down
Binary file added bin/themes/default/main_form/start_capture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/themes/default/main_form/stop_capture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions src/gui/main_form/log_file_session_box/log_file_session_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ void LogFileSessionBox::InitControl(const std::wstring& file_path, ListBox* log_
GlobalManager::FillBoxWithCache(this, L"main_form/log_file_session_box.xml");

this->AttachBubbledEvent(kEventClick, nbase::Bind(&LogFileSessionBox::OnClicked, this, std::placeholders::_1));
this->AttachBubbledEvent(kEventReturn, nbase::Bind(&LogFileSessionBox::OnKeyDown, this, std::placeholders::_1));
this->AttachBubbledEvent(kEventReturn, nbase::Bind(&LogFileSessionBox::OnReturnKeyDown, this, std::placeholders::_1));

keyword_list_ = dynamic_cast<ListBox*>(FindSubControl(L"keyword_list"));
keyword_input_ = dynamic_cast<RichEdit*>(FindSubControl(L"keyword_input"));
keyword_add_ = dynamic_cast<Button*>(FindSubControl(L"keyword_add"));
log_content_ = dynamic_cast<RichEdit*>(FindSubControl(L"log_content"));
start_capture_ = dynamic_cast<Button*>(FindSubControl(L"start_capture"));
stop_capture_ = dynamic_cast<Button*>(FindSubControl(L"stop_capture"));

log_instance_.reset(new FileInstance(file_path.c_str()));
}
Expand Down Expand Up @@ -58,11 +60,23 @@ bool LogFileSessionBox::OnClicked(EventArgs* msg)
{
AddKeyword();
}
else if (name == L"start_capture")
{
StartCapture();
stop_capture_->SetVisible(true);
start_capture_->SetVisible(false);
}
else if (name == L"stop_capture")
{
StopCapture();
start_capture_->SetVisible(true);
stop_capture_->SetVisible(false);
}

return true;
}

bool LogFileSessionBox::OnKeyDown(EventArgs* msg)
bool LogFileSessionBox::OnReturnKeyDown(EventArgs* msg)
{
std::wstring name = msg->pSender->GetName();
if (name == L"keyword_input")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LogFileSessionBox : public VBox
void RemoveKeyword(KeywordItem* keyword_item);

bool OnClicked(EventArgs* msg);
bool OnKeyDown(EventArgs* msg);
bool OnReturnKeyDown(EventArgs* msg);
void OnFileChangedCallback(const std::wstring& log_file, const std::string& data, bool append = true);

static const LPCTSTR kFindString;
Expand All @@ -34,6 +34,8 @@ class LogFileSessionBox : public VBox
RichEdit* log_content_ = nullptr;
ListBox* keyword_list_ = nullptr;
Button* keyword_add_ = nullptr;
Button* start_capture_ = nullptr;
Button* stop_capture_ = nullptr;

// data
std::shared_ptr<FileInstance> log_instance_; // Îļþ״̬¹ÜÀí
Expand Down
2 changes: 1 addition & 1 deletion src/module/file_manager/file_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void FileInstance::CaptureFileThread()
{
// 等待文件大小变更的事件
DWORD wait = WaitForSingleObject(find_handle_, INFINITE);
if (wait == WAIT_OBJECT_0 && find_handle_)
if (wait == WAIT_OBJECT_0)
{
if (!FindNextChangeNotification(find_handle_))
{
Expand Down

0 comments on commit f146bcb

Please sign in to comment.