diff options
Diffstat (limited to 'Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h')
| -rw-r--r-- | Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h new file mode 100644 index 000000000..4953b7b15 --- /dev/null +++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h @@ -0,0 +1,88 @@ +#include "DFUMode.h" +#include <stdio.h> +#include "stdafx.h" +#include <stdlib.h> +#include <conio.h> +#include <windows.h> +#include "lmdfu.h" +#include "lmdfuwrap.h" +#include "DFUDevice.h" +#include "ProgressMode.h" + +#pragma once + +using namespace System::Windows::Forms; + +namespace Tango +{ + namespace FirmwareUpdateLib + { + ref class ProgressForm : + public Form + { + private: + ProgressMode _mode; + int _currentTotal; + bool _verified; + bool _verifiable; + ProgressCallbackDelegate^ _callback; + + void RaiseCallback(ProgressMode mode, int current, int total) + { + if (_callback != nullptr) + { + _callback(mode, current, total); + } + } + public: + ProgressForm(ProgressCallbackDelegate^ callback, bool verifiable) + { + _verifiable = verifiable; + _callback = callback; + }; + protected: virtual void WndProc(System::Windows::Forms::Message% m) override + { + switch (m.Msg) + { + case WM_DFU_DOWNLOAD: + _verified = !_verifiable; + _mode = ProgressMode::Uploading; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_UPLOAD: + _verified = true; + _mode = ProgressMode::Downloading; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_VERIFY: + _verified = true; + _mode = ProgressMode::Verifying; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_COMPLETE: + if (_verified) + { + _mode = ProgressMode::Completed; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + } + break; + case WM_DFU_ERROR: + _mode = ProgressMode::Error; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_PROGRESS: + RaiseCallback(_mode, (int)m.WParam, _currentTotal); + break; + } + + Form::WndProc(m); + } + }; + } +} + |
