From 5d03ff7368eaf1556a0f7071e6079348e443ff63 Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 8 Apr 2010 17:44:22 +0000 Subject: [PATCH] Updated code to save Ascii text to DocAscii field. Added code to look for and replace Symbol Characters. --- PROMS/Volian.Controls.Library/DSOTabPanel.cs | 38 ++++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index ee6cd732..0e20fd8d 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -140,6 +140,7 @@ namespace Volian.Controls.Library //this.GotFocus += new EventHandler(DSOTabPanel_GotFocus); //this.LostFocus += new EventHandler(DSOTabPanel_LostFocus); Application.DoEvents(); + CheckForSymbolCharacters(); FindSearchString(); } catch (Exception ex) @@ -150,6 +151,17 @@ namespace Volian.Controls.Library // TODO: Should try to do a direct open using Word. } } + + private void CheckForSymbolCharacters() + { + LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); + if (doc.HasSymbolCharacters) + { + if (MessageBox.Show("This document contains Symbol Characters.\r\n\r\nDo you want to correct this?", + "Replace Symbol Characters", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + doc.FixSymbolCharacters(); + } + } public void FindSearchString() { if (SearchString == null) return; @@ -159,7 +171,8 @@ namespace Volian.Controls.Library LBFind find = wordDoc.Application.Selection.Find; find.ClearFormatting(); bool wildCards = SearchString.Contains("?") || SearchString.Contains("*"); - Console.WriteLine("find = {0}", find.Execute(SearchString, false, false, wildCards, false, false, true, LBWdFindWrap.wdFindContinue,null,null,null,false,false,false,false)); + bool found = find.Execute(SearchString, false, false, wildCards, false, false, true, LBWdFindWrap.wdFindContinue, null, null, null, false, false, false, false); + //Console.WriteLine("find = {0}", found); } /// /// Text will either replace current selection or be inserted at the current cursor position if no selection @@ -256,7 +269,7 @@ namespace Volian.Controls.Library } LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); - MyDSOFile.SaveFile(doc.Length); + MyDSOFile.SaveFile(doc.Length,doc.Ascii); } /// /// Before a document closes check to see if it's contents should be saved. @@ -333,7 +346,7 @@ namespace Volian.Controls.Library _MyDSOFramer.Save(); LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); - MyDSOFile.SaveFile(doc.Length); + MyDSOFile.SaveFile(doc.Length, doc.Ascii); } catch (Exception ex) { @@ -349,7 +362,7 @@ namespace Volian.Controls.Library /// public bool SaveDirty() { - if (_MyDSOFramer.IsDirty) + if (_MyDSOFramer != null && _MyDSOFramer.IsDirty) { // Unfortunately, the only way to handle view mode for DSO Framer is to not save. if (PanelViewEditMode == E_ViewMode.View) @@ -383,13 +396,16 @@ namespace Volian.Controls.Library bool result = true; try { - SaveDirty(); - _MyDSOFramer.Close(); - Controls.Remove(_MyDSOFramer); - components.Remove(_MyDSOFramer); - _MyDSOFramer.Dispose(); - _MyDSOFramer = null; - _Count--; + if (_MyDSOFramer != null) + { + SaveDirty(); + _MyDSOFramer.Close(); + Controls.Remove(_MyDSOFramer); + components.Remove(_MyDSOFramer); + _MyDSOFramer.Dispose(); + _MyDSOFramer = null; + _Count--; + } } catch (Exception ex) {