private void EMainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { string message = Properties.Resources.Tx_MainFormClosing; string caption = Text; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Displays the MessageBox. result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); if (result != DialogResult.Yes) { e.Cancel = true; RefreshFormTimer.Start(); // in case of the tmier is stopped(eg. lost of communication) - it is better to start it } }
private void TimerTick(object sender, System.EventArgs e) { try { RefreshMainForm(); if (tabControlInterface.SelectedTab.Name == tabStation.Name) { RefreshStationPage(); } if (tabControlInterface.SelectedTab.Name == tabPageSegments.Name) { RefreshSegmentPage(); } if (tabControlInterface.SelectedTab.Name == tabPageInterface.Name) { RefreshInterfacePage(); } if (tabControlInterface.SelectedTab.Name == tabPageProtocol.Name) { RefreshProtocolPage(); } if (Manager.NumOfErrors > 0) { new EventLogMonitor("Communication server console finished with Assert error", EventLogEntryType.Error, 0, 0).WriteEntry(); Close(); } } catch (Exception exc) { RefreshFormTimer.Stop(); MessageBox.Show("CommServer - has ben stopped, it is highly recommended to close the console. " #if DEBUG + " reason:" + exc.ToString() #endif ); new EventLogMonitor("CommServer - has been stopped, it is highly recommended to close the console.", EventLogEntryType.Error, 0, 0).WriteEntry(); Close(); } }