Updated code to save Ascii text to DocAscii field.

Added code to look for and replace Symbol Characters.
This commit is contained in:
Rich 2010-04-08 17:44:22 +00:00
parent 24c892b008
commit 5d03ff7368

View File

@ -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);
}
/// <summary>
/// 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);
}
/// <summary>
/// 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
/// <returns></returns>
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)
{