private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)///15Jan2013
{
try
{
MainWindow mwindow = LifetimeService.Instance.Container.Resolve <MainWindow>();//28Jan2013
mwindow.Activate();
if (mwindow.OwnedWindows.Count > 1)
{
System.Windows.Forms.DialogResult dresult = ExitAppMessageBox(); //19feb2013
if (dresult == System.Windows.Forms.DialogResult.Yes) //save & exit
{
#region CLose Output Windows and then Close Syntax Eiditor
//// Close output window and synedtr window /// 05Feb2013
OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve <IOutputWindowContainer>()) as OutputWindowContainer;
SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>();
// First collect window names
string[] outwinnames = new string[owc.Count];
int i = 0;
foreach (KeyValuePair <String, IOutputWindow> item in owc.AllOutputWindows)
{
outwinnames[i] = item.Key;
i++;
}
//close each output window one by one.
foreach (string winname in outwinnames)
{
(owc.GetOuputWindow(winname) as Window).Close();//invoke close {Closing then Closed }
}
//now close Syntax Editor window
sewindow.SynEdtForceClose = true;
sewindow.Close();
if (owc.Count > 0 || sewindow != null && !sewindow.SynEdtForceClose) // if any of the output window is open
{
e.Cancel = true; // abort closing.
}
#endregion
}
else if (dresult == System.Windows.Forms.DialogResult.No) //Exit without save
{
}
else //cancel exit. Keep the app open.
{
e.Cancel = true;
return;
}
}
}
catch (Exception ex)
{
logService.WriteToLogLevel("Error while closing:" + ex.Message, LogLevelEnum.Error);
}
}