Skip to content

Commit ca190d0

Browse files
committed
Enable routing option, remove button, misc state management
1 parent ce9f98e commit ca190d0

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

SarAsio/configui.cpp

+37-2
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,23 @@ INT_PTR ApplicationsPropertySheetPage::dialogProc(
456456
break;
457457
case WM_COMMAND:
458458
switch (LOWORD(wparam)) {
459+
case 1200: // _enableRouting
460+
_config.enableApplicationRouting =
461+
Button_GetCheck(_enableRouting) == BST_CHECKED;
462+
refreshControls();
463+
changed();
464+
break;
459465
case 1203: // _addButton
460466
if (HIWORD(wparam) == BN_CLICKED) {
461467
onAddApplication();
462468
}
463469

470+
break;
471+
case 1204: // _removeButton
472+
if (HIWORD(wparam) == BN_CLICKED) {
473+
onRemoveApplication();
474+
}
475+
464476
break;
465477
}
466478

@@ -503,10 +515,16 @@ void ApplicationsPropertySheetPage::initControls()
503515
ListView_InsertColumn(_listView, 2, &col);
504516
ListView_SetExtendedListViewStyle(_listView, LVS_EX_FULLROWSELECT);
505517

506-
refreshApplicationList();
518+
refreshControls();
507519
updateEnabled();
508520
}
509521

522+
void ApplicationsPropertySheetPage::refreshControls()
523+
{
524+
Button_SetCheck(_enableRouting, _config.enableApplicationRouting);
525+
refreshApplicationList();
526+
}
527+
510528
void ApplicationsPropertySheetPage::refreshApplicationList()
511529
{
512530
ListView_DeleteAllItems(_listView);
@@ -536,15 +554,18 @@ void ApplicationsPropertySheetPage::refreshApplicationList()
536554

537555
void ApplicationsPropertySheetPage::updateEnabled()
538556
{
557+
EnableWindow(_listView, _config.enableApplicationRouting);
558+
Button_Enable(_addButton, _config.enableApplicationRouting);
539559
Button_Enable(_removeButton,
560+
_config.enableApplicationRouting &&
540561
ListView_GetSelectedCount(_listView) > 0);
541562
}
542563

543564
void ApplicationsPropertySheetPage::onOpenApplication()
544565
{
545566
auto index = ListView_GetNextItem(_listView, -1, LVNI_SELECTED);
546567

547-
if (index < 0 || index >= _config.applications.size()) {
568+
if (index < 0 || index >= (int)_config.applications.size()) {
548569
return;
549570
}
550571

@@ -558,6 +579,20 @@ void ApplicationsPropertySheetPage::onOpenApplication()
558579
}
559580
}
560581

582+
void ApplicationsPropertySheetPage::onRemoveApplication()
583+
{
584+
auto index = ListView_GetNextItem(_listView, -1, LVNI_SELECTED);
585+
586+
if (index < 0 || index >= (int)_config.endpoints.size()) {
587+
return;
588+
}
589+
590+
_config.applications.erase(_config.applications.begin() + index);
591+
refreshApplicationList();
592+
updateEnabled();
593+
changed();
594+
}
595+
561596
void ApplicationsPropertySheetPage::onAddApplication()
562597
{
563598
ApplicationConfigDialog dlg(_config, ApplicationConfig());

SarAsio/configui.h

+2
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ struct ApplicationsPropertySheetPage: public PropertySheetPage
117117

118118
private:
119119
void initControls();
120+
void refreshControls();
120121
void refreshApplicationList();
121122
void updateEnabled();
122123
void onOpenApplication();
123124
void onAddApplication();
125+
void onRemoveApplication();
124126

125127
DriverConfig& _config;
126128
HWND _enableRouting;

0 commit comments

Comments
 (0)