From 93b81961fec400fc3ddb8683c3c60890396051ac Mon Sep 17 00:00:00 2001 From: lltcggie Date: Sun, 20 Mar 2016 14:27:28 +0900 Subject: [PATCH] =?UTF-8?q?GUI=E3=81=AEexe=E3=81=AB=E7=94=BB=E5=83=8F?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=80=81=E3=83=95=E3=82=A9?= =?UTF-8?q?=E3=83=AB=E3=83=80=E3=82=92=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=B3=E5=BC=95=E6=95=B0=E3=82=92=E6=B8=A1?= =?UTF-8?q?=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=80=81=E5=89=8D=E5=9B=9E?= =?UTF-8?q?=E8=B5=B7=E5=8B=95=E6=99=82=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=81=A7?= =?UTF-8?q?=E5=A4=89=E6=8F=9B=E3=82=92=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waifu2x-caffe-gui/Source.cpp | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/waifu2x-caffe-gui/Source.cpp b/waifu2x-caffe-gui/Source.cpp index 8f487d9..7bcd30b 100644 --- a/waifu2x-caffe-gui/Source.cpp +++ b/waifu2x-caffe-gui/Source.cpp @@ -182,6 +182,8 @@ private: std::atomic TimeLeftThread; std::atomic TimeLeftGetTimeThread; + bool isCommandLineStart; + private: template static tstring to_tstring(T val) @@ -1098,7 +1100,7 @@ public: DialogEvent() : dh(nullptr), mode("noise_scale"), noise_level(1), scale_ratio(2.0), scale_width(0), scale_height(0), model_dir(TEXT("models/anime_style_art_rgb")), process("gpu"), outputExt(TEXT(".png")), inputFileExt(TEXT("png:jpg:jpeg:tif:tiff:bmp:tga")), use_tta(false), output_quality(100), output_depth(8), crop_size(128), batch_size(1), isLastError(false), scaleType(eScaleTypeEnd), - TimeLeftThread(-1), TimeLeftGetTimeThread(0) + TimeLeftThread(-1), TimeLeftGetTimeThread(0), isCommandLineStart(false) { } @@ -1172,16 +1174,27 @@ public: EnableWindow(GetDlgItem(dh, IDC_BUTTON_EXEC), TRUE); EnableWindow(GetDlgItem(dh, IDC_BUTTON_CHECK_CUDNN), TRUE); + bool endFlag = false; if (!isLastError) { if (!cancelFlag) + { AddLogMessage(langStringList.GetString(L"MessageTransSuccess").c_str()); + if (isCommandLineStart) // コマンドライン引数を渡されて起動して、変換に成功したら終了する + endFlag = true; + } + Waifu2xTime(); MessageBeep(MB_ICONASTERISK); } else MessageBox(dh, langStringList.GetString(L"MessageErrorHappen").c_str(), langStringList.GetString(L"MessageTitleError").c_str(), MB_OK | MB_ICONERROR); + + isCommandLineStart = false; + + if (endFlag) + SendMessage(dh, WM_CLOSE, 0, 0); } void Timer(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) @@ -1785,6 +1798,36 @@ public: } SetDepthAndQuality(); + + + int nArgs = 0; + LPTSTR *lplpszArgs; + lplpszArgs = CommandLineToArgvW(GetCommandLine(), &nArgs); + if (lplpszArgs) + { + input_str_multi.clear(); + + if (nArgs > 1) + { + if (nArgs == 2) + { + OnSetInputFilePath(lplpszArgs[1]); + } + else if (nArgs > 2) + { + for (int i = 1; i < nArgs; i++) + input_str_multi.push_back(lplpszArgs[i]); + + OnSetInputFilePath(); + } + + isCommandLineStart = true; + + ::PostMessage(GetDlgItem(dh, IDC_BUTTON_EXEC), BM_CLICK, 0, 0); + } + + LocalFree(lplpszArgs); + } } void Cancel(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)