Permalink
Browse files

Changed the MainFormController to use the generic FormController.

  • Loading branch information...
mdfeist committed Jun 6, 2013
1 parent 8df0c77 commit d476acc957798b02238f8a1d8c5e52c8b00d352e
@@ -14,10 +14,9 @@ int main(array<System::String ^> ^args)
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
-
- // Create the Main Form and attach it to MainFormController
- MainForm ^mainForm = gcnew MainForm();
- MainFormController::getInstance()->attachMainForm(mainForm);
+
+ // Create the MainForm using MainFormController
+ MainForm^ mainForm = MainFormController::getInstance()->createForm();
// Create the ClientHandler and attach it to the global App Data
ClientHandler* client = new ClientHandler();
@@ -36,7 +35,7 @@ int main(array<System::String ^> ^args)
MessageBox::Show(gcnew String(AppData::getInstance()->getLastError()));
Marshal::FreeHGlobal((IntPtr)fileName);
- }
+ }
// Create the main window and run it
Application::Run(mainForm);
@@ -11,7 +11,7 @@
using namespace System;
-public ref class EyeCalibrationWizardFormController :
+public ref class EyeCalibrationWizardFormController sealed :
public FormController<EyeCalibrationWizardFormController^ volatile, BlinkAnalysis::EyeCalibrationWizardForm^>
{
public:
@@ -22,6 +22,15 @@ public ref class FormController abstract
return m_pInstance;
}
+ // Creates a form if not already created
+ FormType createForm() {
+ if (!form || form->IsDisposed) {
+ form = gcnew FormType();
+ }
+
+ return form;
+ }
+
// Create a instance of the Form if
// it doesn't already exist and show it
void Show() {
@@ -3,47 +3,39 @@
#include "AppData.h"
-MainFormController::MainFormController(void)
-{
-}
-
-MainFormController::~MainFormController(void)
-{
-}
-
void MainFormController::dikablisOutputLog(std::string msg) {
- this->mainForm->dikablisOutputLog(gcnew String(msg.c_str()));
+ this->form->dikablisOutputLog(gcnew String(msg.c_str()));
}
void MainFormController::dikablisMessage(Dikablis::journal_struct journal) {
// Image
- this->mainForm->dikablisSetIndex(journal.index);
- this->mainForm->dikablisSetTimeStamp(journal.timestamp);
+ this->form->dikablisSetIndex(journal.index);
+ this->form->dikablisSetTimeStamp(journal.timestamp);
// Calibration
- this->mainForm->dikablisSetEyeRoiHoriz(journal.eyeroihoriz);
- this->mainForm->dikablisSetEyeRoiVert(journal.eyeroivert);
- this->mainForm->dikablisSetEyeRoiZoomX(journal.eyeroizoomx);
- this->mainForm->dikablisSetEyeRoiZoomY(journal.eyeroizoomy);
+ this->form->dikablisSetEyeRoiHoriz(journal.eyeroihoriz);
+ this->form->dikablisSetEyeRoiVert(journal.eyeroivert);
+ this->form->dikablisSetEyeRoiZoomX(journal.eyeroizoomx);
+ this->form->dikablisSetEyeRoiZoomY(journal.eyeroizoomy);
// Eye Data
- this->mainForm->dikablisSetEyeX(journal.eye_x);
- this->mainForm->dikablisSetEyeY(journal.eye_y);
- this->mainForm->dikablisSetFieldX(journal.field_x);
- this->mainForm->dikablisSetFieldY(journal.field_y);
+ this->form->dikablisSetEyeX(journal.eye_x);
+ this->form->dikablisSetEyeY(journal.eye_y);
+ this->form->dikablisSetFieldX(journal.field_x);
+ this->form->dikablisSetFieldY(journal.field_y);
if (journal.eye_valid)
- this->mainForm->dikablisSetEyeValid("Pupil was detected");
+ this->form->dikablisSetEyeValid("Pupil was detected");
else
- this->mainForm->dikablisSetEyeValid("Pupil was not detected");
+ this->form->dikablisSetEyeValid("Pupil was not detected");
if (journal.olinecalib)
- this->mainForm->dikablisSetOnlineCalibration("Calibration was performed online");
+ this->form->dikablisSetOnlineCalibration("Calibration was performed online");
else
- this->mainForm->dikablisSetOnlineCalibration("No online calibration");
+ this->form->dikablisSetOnlineCalibration("No online calibration");
}
void MainFormController::optiTrackOutputLog(std::string msg) {
- this->mainForm->optiTrackOutputLog(gcnew String(msg.c_str()));
+ this->form->optiTrackOutputLog(gcnew String(msg.c_str()));
}
@@ -11,21 +11,18 @@
#include "Dikablis.h"
#include "MainForm.h"
+#include "FormController.h"
using namespace System;
-public ref class MainFormController sealed
+public ref class MainFormController sealed :
+ public FormController<MainFormController^ volatile, BlinkAnalysis::MainForm^>
{
public:
- static MainFormController^ getInstance() {
- if(!m_pInstance) m_pInstance = gcnew MainFormController();
- return m_pInstance;
- }
-
// Saving
- void updateFormTitle() { this->mainForm->updateTitle(); }
- void setInfo() { this->mainForm->setInformation(); }
- void getInfo() { this->mainForm->getInformation(); }
+ void updateFormTitle() { this->form->updateTitle(); }
+ void setInfo() { this->form->setInformation(); }
+ void getInfo() { this->form->getInformation(); }
// Prints to the Output window in the Dikablis Tab of the MainForm
void dikablisOutputLog(std::string msg);
@@ -35,18 +32,8 @@ public ref class MainFormController sealed
// Prints to the Output window in the OptiTrack Tab of the MainForm
void optiTrackOutputLog(std::string msg);
// Indicate that there was a change to the OptiTrack data
- void optiTrackUpdateData() { this->mainForm->optiTrackUpdateData(); }
+ void optiTrackUpdateData() { this->form->optiTrackUpdateData(); }
// Initiate the OptiTrack view
- void optiTrackInitDataView() { this->mainForm->optiTrackInitDataView(); }
-
- // Attach a instance of the MainForm to the controller
- void attachMainForm(BlinkAnalysis::MainForm ^form) { this->mainForm = form; }
-protected:
- MainFormController();
- ~MainFormController();
-private:
- static MainFormController^ volatile m_pInstance;
-
- BlinkAnalysis::MainForm ^mainForm;
+ void optiTrackInitDataView() { this->form->optiTrackInitDataView(); }
};

0 comments on commit d476acc

Please sign in to comment.