/// <summary> /// Alert for FileNotOpen. Wrapper function of AQ_Exception class. /// </summary> private void alertFileNotOpen() { AQ_Exceptions.AQ_Exception(AQ_EXCEPTION_CODE.FILE_NOT_OPEN , "File not opened. Please open a set file" , true , this); return; }
public override void AwakeFromNib() { /////// /// Glorified Event "Handler" /////// /// All outside calls from outside this class that update the GUI /// need to be wrapped around the: /// NSApplication.CheckForIllegalCrossThreadCalls = false/true; /// for the updates to properly work. // *************************** // // TODO // // Make each button function properly // - Pause (Doesnt reset tickTimer) // - Next / Prev (Reset timers properly) base.AwakeFromNib(); SetRunner sr = SetRunner.Instance; NSApplication.CheckForIllegalCrossThreadCalls = false; updateGUI(); NSApplication.CheckForIllegalCrossThreadCalls = true; // Component settings tbvSetList.AllowsColumnSelection = false; ///// /// TBV clicked ///// tbvSetList.Activated += (object sender, EventArgs e) => { updateTBV(); }; // for countdown timer Timer tickTimer = new Timer(1000); // credit for disabling cross thread calls in NSApplication: // http://stackoverflow.com/questions/19795522/monomac-create-context-in-bacground-thread // Disable UIKit thread checks for a couple of methods ///// /// Pause Button ///// btnPause.Activated += (object sender, EventArgs e) => { // Check if a file has been opened if (!m_at.FileOpen()) { alertFileNotOpen(); return; } // call for pause sr.Pause(); // stop ticktimer tickTimer.Stop(); // update gui NSApplication.CheckForIllegalCrossThreadCalls = false; updateGUI(); NSApplication.CheckForIllegalCrossThreadCalls = true; }; ///// /// Stop Button ///// btnStop.Activated += (object sender, EventArgs e) => { // Check if a file has been opened if (!m_at.FileOpen()) { alertFileNotOpen(); return; } // call for stop (resets set pointer) sr.Stop(); // stop and reset ticktimer tickTimer.Stop(); m_iSec = 0; tickTimer = new Timer(1000); // update gui NSApplication.CheckForIllegalCrossThreadCalls = false; updateGUI(); NSApplication.CheckForIllegalCrossThreadCalls = true; }; ///// /// Start Button ///// btnStart.Activated += (object sender, EventArgs e) => { // Check if a file has been opened if (!m_at.FileOpen()) { alertFileNotOpen(); return; } // start timers sr.Start(); tickTimer.Start(); // update gui NSApplication.CheckForIllegalCrossThreadCalls = false; updateGUI(); NSApplication.CheckForIllegalCrossThreadCalls = true; }; ///// /// Next Button ///// btnNext.Activated += (object sender, EventArgs e) => { // Check if a file has been opened if (!m_at.FileOpen()) { alertFileNotOpen(); return; } // stop tickTimer tickTimer.Stop(); tickTimer.Dispose(); m_iSec = 0; // call next set sr.Next(); // reset tickTimer tickTimer = new Timer(1000); tickTimer.Start(); // update gui NSApplication.CheckForIllegalCrossThreadCalls = false; updateGUI(); NSApplication.CheckForIllegalCrossThreadCalls = true; }; ///// /// Previous Button ///// btnPrev.Activated += (object sender, EventArgs e) => { // Check if a file has been opened if (!m_at.FileOpen()) { alertFileNotOpen(); return; } // stop tickTimer tickTimer.Stop(); tickTimer.Dispose(); m_iSec = 0; // call previous set sr.Previous(); // reset tickTimer tickTimer = new Timer(1000); tickTimer.Start(); // update gui NSApplication.CheckForIllegalCrossThreadCalls = false; updateGUI(); NSApplication.CheckForIllegalCrossThreadCalls = true; }; ///// /// tick /// countdown clock tick ///// tickTimer.Elapsed += (object sender, ElapsedEventArgs e) => { NSApplication.CheckForIllegalCrossThreadCalls = false; updateCountDown(); NSApplication.CheckForIllegalCrossThreadCalls = true; }; ///// /// Set Completed /// Reset countdown clock ///// sr.SetEnded += (object source, SetEndArgs e) => { Console.WriteLine(string.Format("{0}-- Ended", e.CurrentSet.ToString())); m_iSec = 0; }; ///// /// ResetCount /// reset countdown clock ///// sr.ResetCount += (object source, EventArgs e) => { NSApplication.CheckForIllegalCrossThreadCalls = false; updateGUI(); NSApplication.CheckForIllegalCrossThreadCalls = true; m_iSec = 0; tickTimer = new Timer(1000); tickTimer.Start(); }; ///// /// Tab Selected ///// tabvMain.DidSelect += (object sender, NSTabViewItemEventArgs e) => { // load error log into console tbConsole.Value = AQ_Exceptions.AQ_Exception_Log(); }; }