From 601632f01928acc991c7acde10657ef2158d8fd8 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 27 Apr 2011 13:13:09 +0000 Subject: [PATCH] Use Timer to close MSWord App about 1 second after it is used. Check to see if the Bars exist before removing them Add 1 point to the width of boxed text to get proper Line-Wrapping --- .../Extension/DocumentExt.cs | 44 ++++++++++++++++--- .../DisplayTabControl.cs | 1 + PROMS/Volian.Print.Library/vlnParagraph.cs | 2 +- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 3095cd38..1e097689 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -662,16 +662,48 @@ namespace VEPROMS.CSLA.Library myDoc.PageSetup.BottomMargin = (11 * 72) - newLength; } } - + //public static void CloseApp() + //{ + // WaitMS(900);// This was added because MSWord will sometimes get the error below + // // Microsoft Office Word has stopped working + // // It appears that this is caused by quiting the MS Word application + // // to soon after closing the document or doing an export. + // MyApp.Quit(false); + // _MyApp = null; + //} + /// + /// This closes the MS Word Application, but, delays for about 1 second. + /// It appears that closing MSWord to quickly causes a: + /// "Microsoft Office Word has stopped working" error. + /// public static void CloseApp() { - WaitMS(300);// This was added because MSWord will sometimes get the error below - // Microsoft Office Word has stopped working - // It appears that this is caused by quiting the MS Word application - // to soon after closing the document or doing an export. - MyApp.Quit(false); + System.Windows.Forms.Application.DoEvents(); + new CloseWordApp(_MyApp, 1000); _MyApp = null; } + private class CloseWordApp:System.Windows.Forms.Timer + { + LBApplicationClass _MyApp; + public LBApplicationClass MyApp + { + get { return _MyApp; } + set { _MyApp = value; } + } + public CloseWordApp(LBApplicationClass myApp, int interval) + { + MyApp = myApp; + Interval = interval; + Tick += new EventHandler(CloseWordApp_Tick); + Enabled = true; + } + void CloseWordApp_Tick(object sender, EventArgs e) + { + Enabled = false; + MyApp.Quit(false); + Dispose(); + } + } private static void WaitMS(int n) { DateTime dtw = DateTime.Now.AddMilliseconds(n); diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index 17de83ea..d338150f 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -293,6 +293,7 @@ namespace Volian.Controls.Library myTabItem.MyDSOTabPanel.CloseDSO(); } } + if (((Bar)sender).Items == null) return; if (((Bar)sender).Items.Count == 1)// Remove bar if last item is closed... { Bar bar = sender as Bar; diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 6705c98e..6100f23b 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -1294,7 +1294,7 @@ namespace Volian.Print.Library if (bxIndx != null) { Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - Width = _WidthAdjustBox + (float)bx.TxtWidth - tabWidth; + Width = _WidthAdjustBox + (float)bx.TxtWidth - tabWidth; // add 1 to get it to wrap like 16Bit } else if (itemInfo.IsHigh) {