diff --git a/.github/Plugin_Readme.txt b/.github/Plugin_Readme.txt
index 9af4803..a02ba45 100644
--- a/.github/Plugin_Readme.txt
+++ b/.github/Plugin_Readme.txt
@@ -46,6 +46,12 @@
1920x1080 程度の軽い素材はプロキシにしても速くならないためです。
条件は「設定」メニューの「プロキシ編集」で変えられます。
--------------------------------------------------------------------------------
+ ■ 保存先の管理
+
+ 設定画面の「保存先を管理」で開きます。
+ 保存先にあるプロキシを、素材名・状態・容量・進捗・最終使用日時で一覧します。
+ 元素材が消えたプロキシはまとめて削除できます。元素材は削除しません。
+
■ 設定
--------------------------------------------------------------------------------
「設定」メニューの「プロキシ編集」から変更できます。
diff --git a/ProxyEdit.vcxproj b/ProxyEdit.vcxproj
index 1e5a7bc..7f2fb95 100644
--- a/ProxyEdit.vcxproj
+++ b/ProxyEdit.vcxproj
@@ -110,6 +110,7 @@
+
@@ -130,6 +131,7 @@
+
diff --git a/ProxyEdit.vcxproj.filters b/ProxyEdit.vcxproj.filters
index a5862c8..32c6230 100644
--- a/ProxyEdit.vcxproj.filters
+++ b/ProxyEdit.vcxproj.filters
@@ -73,6 +73,9 @@
ソース ファイル
+
+ ソース ファイル
+
@@ -126,6 +129,9 @@
ヘッダー ファイル
+
+ ヘッダー ファイル
+
SDK
diff --git a/README.md b/README.md
index c69dbc9..e0d6394 100644
--- a/README.md
+++ b/README.md
@@ -84,9 +84,19 @@
「表示」メニューの「プロキシ編集」で開きます。素材ごとに、作成済みの区間を帯で示し、進捗・速度・容量を表示します。行を右クリックすると、その素材を全部作る、または破棄することができます。作成中はタスクバーのアイコンにも進捗が出ます。
+本体は読めてもプロキシを作れない素材があります(対応する形式が異なるためです)。その場合は素材名と理由を並べて示します。生成に失敗した素材は自動で元素材へ戻すので、読めない画が残ることはありません。
+
### 4. 出力時の保護
-ファイル出力の間は、入力プラグインが `get_edit_state()` を見て必ず元素材を読みます。プロキシへ差し替えたまま出力しても、プロキシの画質で書き出されることはありません。設定で切ることはできません。
+ファイル出力を始める前に、タイムラインを元素材へ戻します。出力は本体が元素材を直接読むので、画質も色も普段の出力と変わりません。出力が終わるとプロキシへ戻します。設定で切ることはできません。
+
+この経路で捕まえられない出力に備えて、入力プラグイン側でも `get_edit_state()` を見て元素材を返す保険を残してあります。
+
+### 5. 保存先の管理
+
+設定画面の「保存先を管理」で開きます。保存先にあるプロキシを、素材名・状態・容量・進捗・最終使用日時で一覧します。列見出しを押すと並べ替えられます。
+
+元素材が消えたプロキシは誰も使わないまま容量を食い続けるので、「元素材が無いものを削除」でまとめて片付けられます。選んで消すこともできます。削除する前にタイムラインを元素材へ戻すため、使用中のものを消しても壊れません。元素材は削除しません。
---
@@ -105,7 +115,7 @@
| 先読みに使う量 | 48 MB | 読み出し時に先読みへ充てる量 |
| 生成の並列数 | 0 | 0 で自動。論理コア数の半分、最大4 |
| 保存の上限 | 20 GB | 超えると古い順に破棄する |
-| プロキシの保存先 | ProgramData 配下 | 別のドライブへ移せる |
+| プロキシの保存先 | ProgramData 配下 | 別のドライブへ移せる。「参照...」で選べる |
設定は `C:\ProgramData\aviutl2\ProxyEdit.ini` に保存されます。
diff --git a/src/ProxyFormat.cpp b/src/ProxyFormat.cpp
index 90d9546..47821ab 100644
--- a/src/ProxyFormat.cpp
+++ b/src/ProxyFormat.cpp
@@ -182,6 +182,23 @@ bool ProxyReader::HasFrame(int frame) {
return entry.size > 0;
}
+int ProxyReader::ReadyFrames() {
+ std::lock_guard lock(mutex_);
+ if (file_ == INVALID_HANDLE_VALUE) return 0;
+ const int count = header_.frame_count;
+ if (count <= 0) return 0;
+ std::vector index((size_t)count);
+ if (!ReadAt(file_, ProxyIndexOffset(0), index.data(),
+ (DWORD)(index.size() * sizeof(ProxyIndexEntry)))) {
+ return 0;
+ }
+ int ready = 0;
+ for (const ProxyIndexEntry& entry : index) {
+ if (entry.size > 0) ready++;
+ }
+ return ready;
+}
+
bool ProxyReader::ReadFrame(int frame, std::vector& out) {
std::lock_guard lock(mutex_);
if (file_ == INVALID_HANDLE_VALUE) return false;
diff --git a/src/ProxyFormat.h b/src/ProxyFormat.h
index f2f3e48..9aa0f63 100644
--- a/src/ProxyFormat.h
+++ b/src/ProxyFormat.h
@@ -70,6 +70,7 @@ public:
const ProxyHeader& Header() const { return header_; }
bool HasFrame(int frame);
bool ReadFrame(int frame, std::vector& out);
+ int ReadyFrames();
private:
HANDLE file_ = INVALID_HANDLE_VALUE;
diff --git a/src/ProxyStore.cpp b/src/ProxyStore.cpp
index 5d9c1a6..17136f8 100644
--- a/src/ProxyStore.cpp
+++ b/src/ProxyStore.cpp
@@ -5,6 +5,7 @@
#include
#include "Log.h"
+#include "ProxyFormat.h"
#include "Settings.h"
namespace pe {
@@ -96,6 +97,34 @@ std::wstring ProxyPathFor(const SourceKey& key) {
return EffectiveStorePath() + L"\\" + BaseName(key.path) + suffix;
}
+std::vector StoreContents() {
+ std::vector items;
+ for (const StoreEntry& entry : CollectEntries()) {
+ StoreItem item;
+ item.proxy = entry.path;
+ item.size = entry.size;
+ item.used = entry.used;
+ ProxyReader reader;
+ if (reader.Open(entry.path)) {
+ const ProxyHeader& header = reader.Header();
+ item.readable = true;
+ item.source = header.source_path;
+ item.proxy_width = header.proxy_width;
+ item.proxy_height = header.proxy_height;
+ item.frame_count = header.frame_count;
+ item.ready_frames = reader.ReadyFrames();
+ SourceKey key;
+ if (QuerySource(item.source, key)) {
+ item.source_exists = true;
+ item.source_changed = !SameSource(key, header.source_size, header.source_time);
+ }
+ reader.Close();
+ }
+ items.push_back(std::move(item));
+ }
+ return items;
+}
+
long long StoreUsage() {
long long total = 0;
for (const StoreEntry& entry : CollectEntries()) total += entry.size;
diff --git a/src/ProxyStore.h b/src/ProxyStore.h
index 8e6eb54..4fe4334 100644
--- a/src/ProxyStore.h
+++ b/src/ProxyStore.h
@@ -20,6 +20,22 @@ bool SameSource(const SourceKey& key, long long size, long long time);
bool EnsureStoreDirectory();
std::wstring ProxyPathFor(const SourceKey& key);
+struct StoreItem {
+ std::wstring proxy;
+ std::wstring source;
+ long long size = 0;
+ long long used = 0;
+ int proxy_width = 0;
+ int proxy_height = 0;
+ int frame_count = 0;
+ int ready_frames = 0;
+ bool readable = false;
+ bool source_exists = false;
+ bool source_changed = false;
+};
+
+std::vector StoreContents();
+
long long StoreUsage();
void ReleaseCapacity(long long incoming, const std::wstring& keep);
void RemoveProxy(const std::wstring& proxy_path);
diff --git a/src/ScanController.cpp b/src/ScanController.cpp
index 1263ec7..bb6b41e 100644
--- a/src/ScanController.cpp
+++ b/src/ScanController.cpp
@@ -388,6 +388,12 @@ void RequestRestoreProxy(const std::wstring& proxy) {
Post(kRequestRestoreFailed);
}
+int RestoreProxiesNow(const std::vector& proxies) {
+ ScanResult result = RestoreFailed(proxies);
+ if (result.restored > 0) PublishStateChange();
+ return result.restored;
+}
+
std::vector UnsupportedSources() {
std::lock_guard lock(g_report_lock);
return g_unsupported;
diff --git a/src/ScanController.h b/src/ScanController.h
index fee8793..72d4549 100644
--- a/src/ScanController.h
+++ b/src/ScanController.h
@@ -29,6 +29,7 @@ void RequestRestore();
int RestoreForExport();
void RequestRestoreProxy(const std::wstring& proxy);
+int RestoreProxiesNow(const std::vector& proxies);
std::vector UnsupportedSources();
void ApplyAfterExport();
void SuspendAutomaticScan(bool suspend);
diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp
index 9efb478..4e7c6e7 100644
--- a/src/SettingsDialog.cpp
+++ b/src/SettingsDialog.cpp
@@ -10,6 +10,7 @@
#include "Log.h"
#include "ProxyStore.h"
#include "Settings.h"
+#include "StoreDialog.h"
namespace pe {
@@ -222,8 +223,8 @@ void Build(HWND window) {
const int button_width = Scaled(window, 96);
const int button_height = Scaled(window, 24);
const int total = margin + label_width + edit_width + suffix_width;
- MakeControl(window, L"BUTTON", L"保存先を開く", BS_PUSHBUTTON, margin, y, button_width, button_height,
- kIdOpenStore);
+ MakeControl(window, L"BUTTON", L"保存先を管理", BS_PUSHBUTTON, margin, y, button_width,
+ button_height, kIdOpenStore);
MakeControl(window, L"BUTTON", L"取消", BS_PUSHBUTTON, total - button_width, y, button_width,
button_height, kIdCancel);
MakeControl(window, L"BUTTON", L"適用", BS_DEFPUSHBUTTON,
@@ -280,7 +281,7 @@ LRESULT CALLBACK SettingsProc(HWND window, UINT message, WPARAM first, LPARAM se
UpdateStoreInfo(window);
} else if (id == kIdOpenStore) {
EnsureStoreDirectory();
- ShellExecuteW(window, L"open", EffectiveStorePath().c_str(), nullptr, nullptr, SW_SHOW);
+ OpenStoreDialog(window);
}
return 0;
}
diff --git a/src/StoreDialog.cpp b/src/StoreDialog.cpp
new file mode 100644
index 0000000..ccd8a6f
--- /dev/null
+++ b/src/StoreDialog.cpp
@@ -0,0 +1,405 @@
+#include "StoreDialog.h"
+
+#include
+#include
+
+#include
+#include
+#include
+
+#include "HostContext.h"
+#include "Log.h"
+#include "Notify.h"
+#include "ProxyBuilder.h"
+#include "ProxyStore.h"
+#include "ScanController.h"
+#include "Settings.h"
+
+namespace pe {
+
+namespace {
+
+const wchar_t* kClassName = L"ProxyEditStoreWindow";
+const UINT kStateMessage = WM_APP + 2;
+
+enum ControlId {
+ kIdList = 1200,
+ kIdRefresh,
+ kIdDeleteSelected,
+ kIdDeleteOrphans,
+ kIdOpenStore,
+ kIdClose,
+ kIdSummary,
+};
+
+struct Row {
+ StoreItem item;
+ bool in_use = false;
+ std::wstring name;
+ std::wstring state;
+};
+
+HWND g_window = nullptr;
+HWND g_list = nullptr;
+HFONT g_font = nullptr;
+std::vector g_rows;
+int g_sort_column = 2;
+bool g_sort_descending = true;
+
+int Scaled(HWND window, int value) {
+ UINT dpi = GetDpiForWindow(window);
+ if (dpi == 0) dpi = 96;
+ return MulDiv(value, (int)dpi, 96);
+}
+
+std::wstring SizeText(long long bytes) {
+ wchar_t buffer[64];
+ if (bytes >= 1024LL * 1024 * 1024) {
+ _snwprintf_s(buffer, _TRUNCATE, L"%.1f GB", (double)bytes / 1024.0 / 1024.0 / 1024.0);
+ } else {
+ _snwprintf_s(buffer, _TRUNCATE, L"%.0f MB", (double)bytes / 1024.0 / 1024.0);
+ }
+ return buffer;
+}
+
+std::wstring TimeText(long long stamp) {
+ if (stamp <= 0) return L"-";
+ FILETIME raw;
+ raw.dwLowDateTime = (DWORD)(stamp & 0xFFFFFFFF);
+ raw.dwHighDateTime = (DWORD)(stamp >> 32);
+ FILETIME local{};
+ SYSTEMTIME when{};
+ if (!FileTimeToLocalFileTime(&raw, &local) || !FileTimeToSystemTime(&local, &when)) return L"-";
+ wchar_t buffer[64];
+ _snwprintf_s(buffer, _TRUNCATE, L"%04d/%02d/%02d %02d:%02d", when.wYear, when.wMonth, when.wDay,
+ when.wHour, when.wMinute);
+ return buffer;
+}
+
+std::wstring ShortName(const std::wstring& path) {
+ size_t separator = path.find_last_of(L"\\/");
+ return separator == std::wstring::npos ? path : path.substr(separator + 1);
+}
+
+std::wstring ProgressText(const StoreItem& item) {
+ if (!item.readable || item.frame_count <= 0) return L"-";
+ const int percent = (int)((long long)item.ready_frames * 100 / item.frame_count);
+ wchar_t buffer[32];
+ _snwprintf_s(buffer, _TRUNCATE, L"%d%%", percent);
+ return buffer;
+}
+
+std::wstring StateText(const Row& row) {
+ if (!row.item.readable) return L"壊れています";
+ if (!row.item.source_exists) return L"元素材がありません";
+ if (row.item.source_changed) return L"元素材が更新されています";
+ if (row.in_use) return L"使用中";
+ return L"未使用";
+}
+
+bool Orphan(const Row& row) {
+ return !row.item.readable || !row.item.source_exists;
+}
+
+void Sort() {
+ std::stable_sort(g_rows.begin(), g_rows.end(), [](const Row& left, const Row& right) {
+ bool less = false;
+ switch (g_sort_column) {
+ case 0: less = _wcsicmp(left.name.c_str(), right.name.c_str()) < 0; break;
+ case 1: less = left.state < right.state; break;
+ case 2: less = left.item.size < right.item.size; break;
+ case 3: less = (long long)left.item.ready_frames * 1000 /
+ std::max(left.item.frame_count, 1) <
+ (long long)right.item.ready_frames * 1000 /
+ std::max(right.item.frame_count, 1);
+ break;
+ default: less = left.item.used < right.item.used; break;
+ }
+ return g_sort_descending ? !less : less;
+ });
+}
+
+void Fill() {
+ ListView_DeleteAllItems(g_list);
+ for (size_t index = 0; index < g_rows.size(); index++) {
+ Row& row = g_rows[index];
+ LVITEMW entry{};
+ entry.mask = LVIF_TEXT | LVIF_PARAM;
+ entry.iItem = (int)index;
+ entry.pszText = (LPWSTR)row.name.c_str();
+ entry.lParam = (LPARAM)index;
+ ListView_InsertItem(g_list, &entry);
+ ListView_SetItemText(g_list, (int)index, 1, (LPWSTR)row.state.c_str());
+ std::wstring size = SizeText(row.item.size);
+ ListView_SetItemText(g_list, (int)index, 2, (LPWSTR)size.c_str());
+ std::wstring progress = ProgressText(row.item);
+ ListView_SetItemText(g_list, (int)index, 3, (LPWSTR)progress.c_str());
+ std::wstring used = TimeText(row.item.used);
+ ListView_SetItemText(g_list, (int)index, 4, (LPWSTR)used.c_str());
+ }
+}
+
+void Refresh() {
+ std::vector jobs = BuilderSnapshot();
+ g_rows.clear();
+ for (StoreItem& item : StoreContents()) {
+ Row row;
+ row.item = item;
+ row.name = item.readable ? ShortName(item.source) : ShortName(item.proxy);
+ for (const JobProgress& job : jobs) {
+ if (_wcsicmp(job.proxy.c_str(), item.proxy.c_str()) == 0) {
+ row.in_use = true;
+ break;
+ }
+ }
+ row.state = StateText(row);
+ g_rows.push_back(std::move(row));
+ }
+ Sort();
+ Fill();
+
+ long long total = 0;
+ int orphans = 0;
+ for (const Row& row : g_rows) {
+ total += row.item.size;
+ if (Orphan(row)) orphans++;
+ }
+ wchar_t line[256];
+ _snwprintf_s(line, _TRUNCATE, L"%d 件 %s / 上限 %s 元素材が無いもの %d 件", (int)g_rows.size(),
+ SizeText(total).c_str(), SizeText(CurrentSettings().capacity_bytes).c_str(), orphans);
+ SetDlgItemTextW(g_window, kIdSummary, line);
+}
+
+void Erase(const std::vector& targets) {
+ if (targets.empty()) return;
+ std::vector proxies;
+ proxies.reserve(targets.size());
+ for (const Row* row : targets) proxies.push_back(row->item.proxy);
+ RestoreProxiesNow(proxies);
+
+ int erased = 0;
+ for (const Row* row : targets) {
+ if (row->in_use && !row->item.source.empty()) {
+ DiscardSource(row->item.source);
+ } else {
+ RemoveProxy(row->item.proxy);
+ }
+ erased++;
+ }
+ Say(L"プロキシを削除しました: %d 件", erased);
+ PublishStateChange();
+ Refresh();
+}
+
+std::vector Selected() {
+ std::vector targets;
+ int index = -1;
+ while ((index = ListView_GetNextItem(g_list, index, LVNI_SELECTED)) >= 0) {
+ if (index >= 0 && index < (int)g_rows.size()) targets.push_back(&g_rows[(size_t)index]);
+ }
+ return targets;
+}
+
+bool Confirm(HWND window, int count, const wchar_t* what) {
+ wchar_t message[256];
+ _snwprintf_s(message, _TRUNCATE, L"%s %d 件を削除します。元素材は消えません。よろしいですか。", what,
+ count);
+ return MessageBoxW(window, message, L"プロキシの削除", MB_OKCANCEL | MB_ICONWARNING) == IDOK;
+}
+
+HWND MakeControl(HWND parent, const wchar_t* type, const wchar_t* text, DWORD style, int x, int y,
+ int width, int height, int id) {
+ HWND control = CreateWindowExW(0, type, text, WS_CHILD | WS_VISIBLE | style, x, y, width, height,
+ parent, (HMENU)(INT_PTR)id, ModuleInstance(), nullptr);
+ if (g_font) SendMessageW(control, WM_SETFONT, (WPARAM)g_font, TRUE);
+ return control;
+}
+
+void Layout(HWND window) {
+ RECT client;
+ GetClientRect(window, &client);
+ const int margin = Scaled(window, 10);
+ const int button_height = Scaled(window, 26);
+ const int line = Scaled(window, 20);
+ const int bottom = client.bottom - margin - button_height;
+ const int summary_top = bottom - Scaled(window, 6) - line;
+ SetWindowPos(g_list, nullptr, margin, margin, client.right - margin * 2, summary_top - margin * 2,
+ SWP_NOZORDER);
+ SetWindowPos(GetDlgItem(window, kIdSummary), nullptr, margin, summary_top,
+ client.right - margin * 2, line, SWP_NOZORDER);
+
+ const int button_width = Scaled(window, 150);
+ const int gap = Scaled(window, 6);
+ int x = margin;
+ const int order[4] = {kIdRefresh, kIdDeleteSelected, kIdDeleteOrphans, kIdOpenStore};
+ for (int id : order) {
+ SetWindowPos(GetDlgItem(window, id), nullptr, x, bottom, button_width, button_height,
+ SWP_NOZORDER);
+ x += button_width + gap;
+ }
+ SetWindowPos(GetDlgItem(window, kIdClose), nullptr, client.right - margin - Scaled(window, 96),
+ bottom, Scaled(window, 96), button_height, SWP_NOZORDER);
+}
+
+void Build(HWND window) {
+ NONCLIENTMETRICSW metrics{};
+ metrics.cbSize = sizeof(metrics);
+ if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0)) {
+ LOGFONTW description = metrics.lfMessageFont;
+ UINT dpi = GetDpiForWindow(window);
+ if (dpi == 0) dpi = 96;
+ description.lfHeight = MulDiv(description.lfHeight, (int)dpi, 96);
+ g_font = CreateFontIndirectW(&description);
+ }
+
+ g_list = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, L"",
+ WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS, 0, 0, 10, 10,
+ window, (HMENU)(INT_PTR)kIdList, ModuleInstance(), nullptr);
+ if (g_font) SendMessageW(g_list, WM_SETFONT, (WPARAM)g_font, TRUE);
+ ListView_SetExtendedListViewStyle(g_list, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER |
+ LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);
+
+ struct Column {
+ const wchar_t* title;
+ int width;
+ };
+ const Column columns[5] = {
+ {L"素材", 330}, {L"状態", 170}, {L"容量", 90}, {L"進捗", 70}, {L"最終使用", 130},
+ };
+ int columns_width = 0;
+ for (int index = 0; index < 5; index++) {
+ LVCOLUMNW column{};
+ column.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
+ column.pszText = (LPWSTR)columns[index].title;
+ column.cx = Scaled(window, columns[index].width);
+ column.iSubItem = index;
+ ListView_InsertColumn(g_list, index, &column);
+ columns_width += column.cx;
+ }
+
+ const int margin = Scaled(window, 10);
+ RECT wanted{0, 0, margin * 2 + columns_width + GetSystemMetrics(SM_CXVSCROLL) + Scaled(window, 8),
+ Scaled(window, 460)};
+ AdjustWindowRectEx(&wanted, (DWORD)GetWindowLongPtrW(window, GWL_STYLE), FALSE, 0);
+ SetWindowPos(window, nullptr, 0, 0, wanted.right - wanted.left, wanted.bottom - wanted.top,
+ SWP_NOMOVE | SWP_NOZORDER);
+
+ MakeControl(window, L"STATIC", L"", SS_LEFT | SS_ENDELLIPSIS, 0, 0, 10, 10, kIdSummary);
+ MakeControl(window, L"BUTTON", L"更新", BS_PUSHBUTTON, 0, 0, 10, 10, kIdRefresh);
+ MakeControl(window, L"BUTTON", L"選んだものを削除", BS_PUSHBUTTON, 0, 0, 10, 10, kIdDeleteSelected);
+ MakeControl(window, L"BUTTON", L"元素材が無いものを削除", BS_PUSHBUTTON, 0, 0, 10, 10,
+ kIdDeleteOrphans);
+ MakeControl(window, L"BUTTON", L"保存先を開く", BS_PUSHBUTTON, 0, 0, 10, 10, kIdOpenStore);
+ MakeControl(window, L"BUTTON", L"閉じる", BS_PUSHBUTTON, 0, 0, 10, 10, kIdClose);
+
+ Layout(window);
+ Refresh();
+}
+
+LRESULT CALLBACK StoreProc(HWND window, UINT message, WPARAM first, LPARAM second) {
+ switch (message) {
+ case WM_CREATE:
+ AddStateListener(window, kStateMessage);
+ return 0;
+ case kStateMessage:
+ AcknowledgeStateChange(window);
+ if (IsWindowVisible(window)) Refresh();
+ return 0;
+ case WM_SIZE:
+ if (g_list) Layout(window);
+ return 0;
+ case WM_NOTIFY: {
+ LPNMHDR header = (LPNMHDR)second;
+ if (header && header->idFrom == kIdList && header->code == LVN_COLUMNCLICK) {
+ LPNMLISTVIEW view = (LPNMLISTVIEW)second;
+ if (view->iSubItem == g_sort_column) {
+ g_sort_descending = !g_sort_descending;
+ } else {
+ g_sort_column = view->iSubItem;
+ g_sort_descending = true;
+ }
+ Sort();
+ Fill();
+ }
+ return 0;
+ }
+ case WM_COMMAND: {
+ const int id = LOWORD(first);
+ if (id == kIdRefresh) {
+ Refresh();
+ } else if (id == kIdDeleteSelected) {
+ std::vector targets = Selected();
+ if (targets.empty()) {
+ MessageBoxW(window, L"削除するものが選ばれていません。", L"プロキシの削除",
+ MB_OK | MB_ICONINFORMATION);
+ } else if (Confirm(window, (int)targets.size(), L"選んだプロキシ")) {
+ Erase(targets);
+ }
+ } else if (id == kIdDeleteOrphans) {
+ std::vector targets;
+ for (Row& row : g_rows) {
+ if (Orphan(row)) targets.push_back(&row);
+ }
+ if (targets.empty()) {
+ MessageBoxW(window, L"元素材が無いプロキシはありません。", L"プロキシの削除",
+ MB_OK | MB_ICONINFORMATION);
+ } else if (Confirm(window, (int)targets.size(), L"元素材が無いプロキシ")) {
+ Erase(targets);
+ }
+ } else if (id == kIdOpenStore) {
+ EnsureStoreDirectory();
+ ShellExecuteW(window, L"open", EffectiveStorePath().c_str(), nullptr, nullptr, SW_SHOW);
+ } else if (id == kIdClose) {
+ DestroyWindow(window);
+ }
+ return 0;
+ }
+ case WM_CLOSE:
+ DestroyWindow(window);
+ return 0;
+ case WM_DESTROY:
+ RemoveStateListener(window);
+ g_rows.clear();
+ g_window = nullptr;
+ g_list = nullptr;
+ if (g_font) {
+ DeleteObject(g_font);
+ g_font = nullptr;
+ }
+ return 0;
+ default:
+ break;
+ }
+ return DefWindowProcW(window, message, first, second);
+}
+
+}
+
+void OpenStoreDialog(HWND owner) {
+ if (g_window) {
+ SetForegroundWindow(g_window);
+ return;
+ }
+ INITCOMMONCONTROLSEX controls{};
+ controls.dwSize = sizeof(controls);
+ controls.dwICC = ICC_LISTVIEW_CLASSES;
+ InitCommonControlsEx(&controls);
+
+ WNDCLASSEXW description{};
+ description.cbSize = sizeof(description);
+ description.lpfnWndProc = StoreProc;
+ description.hInstance = ModuleInstance();
+ description.lpszClassName = kClassName;
+ description.hCursor = LoadCursorW(nullptr, IDC_ARROW);
+ description.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
+ RegisterClassExW(&description);
+
+ g_window = CreateWindowExW(0, kClassName, L"プロキシの保存先", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
+ CW_USEDEFAULT, 960, 560, owner, nullptr, ModuleInstance(), nullptr);
+ if (!g_window) return;
+ Build(g_window);
+ ShowWindow(g_window, SW_SHOW);
+ SetForegroundWindow(g_window);
+}
+
+}
diff --git a/src/StoreDialog.h b/src/StoreDialog.h
new file mode 100644
index 0000000..7b29d25
--- /dev/null
+++ b/src/StoreDialog.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include
+
+namespace pe {
+
+void OpenStoreDialog(HWND owner);
+
+}