/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Constructor /// </summary> /// <history> /// 01 Nov 18 Cynic - Originally Written /// </history> public frmMain() { bool retBOOL = false; HResult hr = 0; if (DesignMode == false) { // set the current directory equal to the exe directory. We do this because // people can start from a link and if the start-in directory is not right // it can put the log file in strange places Directory.SetCurrentDirectory(Application.StartupPath); // set up the Singleton g_Logger instance. Simply using it in a test // creates it. if (g_Logger == null) { // did not work, nothing will start say so now in a generic way MessageBox.Show("Logger Class Failed to Initialize. Nothing will work well."); return; } // record this in the logger for everybodys use g_Logger.ApplicationMainForm = this; g_Logger.DefaultDialogBoxTitle = APPLICATION_NAME; try { // set the icon for this form and for all subsequent forms g_Logger.AppIcon = new Icon(GetType(), "App.ico"); this.Icon = new Icon(GetType(), "App.ico"); } catch (Exception) { } // Register the global error handler as soon as we can in Main // to make sure that we catch as many exceptions as possible // this is a last resort. All execeptions should really be trapped // and handled by the code. OISGlobalExceptions ex1 = new OISGlobalExceptions(); Application.ThreadException += new ThreadExceptionEventHandler(ex1.OnThreadException); // set the culture so our numbers convert consistently System.Threading.Thread.CurrentThread.CurrentCulture = g_Logger.GetDefaultCulture(); } InitializeComponent(); if (DesignMode == false) { // set up our logging retBOOL = g_Logger.InitLogging(DEFAULTLOGDIR, APPLICATION_NAME, false); if (retBOOL == false) { // did not work, nothing will start say so now in a generic way MessageBox.Show("The log file failed to create. No log file will be recorded."); } // pump out the header g_Logger.EmitStandardLogfileheader(APPLICATION_NAME); LogMessage(""); LogMessage("Version: " + APPLICATION_VERSION); LogMessage(""); // we always have to initialize MF. The 0x00020070 here is the WMF version // number used by the MF.Net samples. Not entirely sure if it is appropriate hr = MFExtern.MFStartup(0x00020070, MFStartup.Full); if (hr != 0) { LogMessage("Constructor: call to MFExtern.MFStartup returned " + hr.ToString()); } // some initial configuration this.textBoxVideoFileNameAndPath.Text = INITIALFILE; ctlTantaEVRFilePlayer1.VideoFileAndPathToPlay = INITIALFILE; // set our heartbeat going LaunchHeartBeat(); } }
private const double SECONDS_PER_CYCLE = 660e-9; // yep, 660 x 10^-9 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Constructor /// </summary> /// <history> /// 19 Nov 18 Cynic - Started /// </history> public frmMain() { bool retBOOL = false; if (DesignMode == false) { // set the current directory equal to the exe directory. We do this because // people can start from a link and if the start-in directory is not right // it can put the log file in strange places Directory.SetCurrentDirectory(Application.StartupPath); // set up the Singleton g_Logger instance. Simply using it in a test // creates it. if (g_Logger == null) { // did not work, nothing will start say so now in a generic way MessageBox.Show("Logger Class Failed to Initialize. Nothing will work well."); return; } // record this in the logger for everybodys use g_Logger.ApplicationMainForm = this; g_Logger.DefaultDialogBoxTitle = APPLICATION_NAME; try { // set the icon for this form and for all subsequent forms g_Logger.AppIcon = new Icon(GetType(), "App.ico"); this.Icon = new Icon(GetType(), "App.ico"); } catch (Exception) { } // Register the global error handler as soon as we can in Main // to make sure that we catch as many exceptions as possible // this is a last resort. All execeptions should really be trapped // and handled by the code. OISGlobalExceptions ex1 = new OISGlobalExceptions(); Application.ThreadException += new ThreadExceptionEventHandler(ex1.OnThreadException); // set the culture so our numbers convert consistently System.Threading.Thread.CurrentThread.CurrentCulture = g_Logger.GetDefaultCulture(); } InitializeComponent(); if (DesignMode == false) { // set up our logging retBOOL = g_Logger.InitLogging(DEFAULTLOGDIR, APPLICATION_NAME, false); if (retBOOL == false) { // did not work, nothing will start say so now in a generic way MessageBox.Show("The log file failed to create. No log file will be recorded."); } // pump out the header g_Logger.EmitStandardLogfileheader(APPLICATION_NAME); LogMessage(""); LogMessage("Version: " + APPLICATION_VERSION); LogMessage(""); } }