diff --git a/PROMS/LBWordLibrary/LBObjectExtension.cs b/PROMS/LBWordLibrary/LBObjectExtension.cs
index 139a52df..8af4c527 100644
--- a/PROMS/LBWordLibrary/LBObjectExtension.cs
+++ b/PROMS/LBWordLibrary/LBObjectExtension.cs
@@ -422,150 +422,6 @@ namespace LBWordLibrary
return true;
return false;
}
- ///
- /// If document contains symbol characters, returns problem font.
- ///
- public string FontHasSymbolCharacters
- {
- get
- {
- LBRange myRange = Range();
- myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
- myRange.Start = 0;
- int end = myRange.End;
- string myText = GetRangeText(myRange);
- //return _RegFindSymbol.IsMatch(myText);
- MatchCollection problems = _RegFindSymbol.Matches(myText);
- int offset = 0;
- List alreadyProcessed = new List();
- List fontHasSymbols = new List();
- foreach (Match problem in problems)
- {
- if (!alreadyProcessed.Contains(problem.Value))
- {
- myRange.Start = problem.Index + offset;
- myRange.End = problem.Index + problem.Length + offset;
- int newOffset = FindRangeOffset(myRange, problem, offset, end);
- string fontName = myRange.Font.Name;
- if (IsSymbolFont(fontName))
- {
- if( !fontHasSymbols.Contains(fontName))
- {
- fontHasSymbols.Add(fontName);
- // Found symbol font
- _MyLog.InfoFormat("Font '{0}' has Symbols", fontName);
- }
- //Console.WriteLine("Font '{0}' has Symbols", myRange.Font.Name);
- //return true;
- }
- else
- return myRange.Font.Name;
- offset = newOffset;
- alreadyProcessed.Add(problem.Value);
- }
- }
- return null;
- }
- }
- ///
- /// Debug Tool - Return a string containing a list of the fonts that have symbol characters.
- ///
- public string FontsHaveSymbolCharacters
- {
- get
- {
- string sep = "";
- StringBuilder sb = new StringBuilder();
- List fonts=new List();
- LBRange myRange = Range();
- myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
- myRange.Start = 0;
- int end = myRange.End;
- string myText = GetRangeText(myRange);
- //return _RegFindSymbol.IsMatch(myText);
- MatchCollection problems = _RegFindSymbol.Matches(myText);
- int offset = 0;
- foreach (Match problem in problems)
- {
- myRange.Start = problem.Index + offset;
- myRange.End = problem.Index + problem.Length + offset;
- int newOffset = FindRangeOffset(myRange, problem, offset, end);
- if (!fonts.Contains(myRange.Font.Name))
- {
- fonts.Add(myRange.Font.Name);
- sb.Append(sep + "'" + myRange.Font.Name + "'");
- sep = ",";
- }
- offset = newOffset;
- }
- if (sb.Length > 0) return sb.ToString();
- return null;
- }
- }
- ///
- /// Debug Tool - Return a list of symbol characters using VESYMB font.
- ///
- public string FontsHaveSymbolCharacters2
- {
- get
- {
- try
- {
- Dictionary> fonts = new Dictionary>();
- LBRange myRange = Range();
- myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
- myRange.Start = 0;
- int end = myRange.End;
- string myText = GetRangeText(myRange);
- //return _RegFindSymbol.IsMatch(myText);
- MatchCollection problems = _RegFindSymbol.Matches(myText);
- int offset = 0;
- foreach (Match problem in problems)
- {
- myRange.Start = problem.Index + offset;
- myRange.End = problem.Index + problem.Length + offset;
- int newOffset = FindRangeOffset(myRange, problem, offset, end);
- string sFont = myRange.Font.Name;
- if (sFont.ToUpper().StartsWith("VESYM"))
- {
- if (!fonts.ContainsKey(sFont))
- {
- fonts.Add(sFont, new List());
- }
- List symbols = fonts[sFont];
- string myTextSymb = GetRangeText(myRange);
- foreach (char c in myTextSymb)
- {
- if (!symbols.Contains((int)c))
- symbols.Add((int)c);
- }
- }
- offset = newOffset;
- }
- if (fonts.Count > 0)
- {
- string sep = "";
- StringBuilder sb = new StringBuilder();
- foreach (string font in fonts.Keys)
- {
- sb.Append(sep + "'" + font + "'");
- sep = ",";
- foreach (int i in fonts[font])
- {
- sb.Append(sep);
- sb.Append(i);
- }
- }
- return sb.ToString();
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("{0},{1},{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
- }
- return null;
- }
- }
///
/// Checks to see if the document contains symbol characters
@@ -601,86 +457,7 @@ namespace LBWordLibrary
}
}
Regex _RegFindSymbol = new Regex("[\\uF020-\\uF07F]+");
- ///
- /// FixSymbolCharacters - Fix any symbol characters in the document
- ///
- public void FixSymbolCharacters()
- {
- // Set up range object to be used to process text
- LBRange myRange = Range();
- myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
- int end = myRange.End;
- myRange.Start = 0;
- string myText = GetRangeText(myRange);
- MatchCollection problems = _RegFindSymbol.Matches(myText);
- int offset = 0;
- foreach (Match problem in problems)
- {
- myRange.Start = problem.Index + offset;
- myRange.End = problem.Index + problem.Length + offset;
- int newOffset = FindRangeOffset(myRange, problem, offset, end);
- if (myRange.Font.Name == "")
- {
- int wrdStart = myRange.Start;
- int wrdEnd = myRange.End;
- int wrdMiddle = wrdStart;
- while (myRange.Font.Name == "")
- {
- do
- {
- myRange.End = ++wrdMiddle;
- } while(myRange.Font.Name != "");
- myRange.End = wrdMiddle - 1;
- ReplaceSymbolCharacters(myRange);
- myRange.Start = wrdMiddle -1;
- myRange.End = wrdEnd;
- }
- ReplaceSymbolCharacters(myRange);
- }
- else
- {
- ReplaceSymbolCharacters(myRange);
- }
- offset = newOffset;
- }
- }
- ///
- /// Try to fix the first character in the symbol range F000 to F0FF. If it cannot be
- /// fixed, it is an indicator that the font is not installed properly. Regardless of
- /// whether there is success, the change is undone so that the document will not be
- /// considered dirty, i.e. will not prompt user for save.
- ///
- ///
- public bool AttemptToFixASymbolCharacter()
- {
- // Set up range object to be used to process text
- LBRange myRange = Range();
- myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
-
- int end = myRange.End;
- myRange.Start = 0;
- string myText = GetRangeText(myRange);
- MatchCollection problems = _RegFindSymbol.Matches(myText);
- if (problems.Count>0)
- {
- Match problem = problems[0];
- myRange.Start = problem.Index;
- myRange.End = myRange.Start + 1;
- if (IsSymbolFont(myRange.Font.Name)) return true; // if it's a symbol font already, no issue.
- string before = GetRangeText(myRange);
- string updated = ReplaceSymbolCharacters(before);
- myRange.Text = updated;
- string after = GetRangeText(myRange);
- Undo(1);
- //Console.WriteLine("Undo1 results = {0}", tst);
- //tst = Undo(1);
- //Console.WriteLine("Undo2 results = {0}", tst);
- //tst = Undo(1);
- //Console.WriteLine("Undo3 results = {0}", tst);
- return (updated == after);
- }
- return true;
- }
+
///
/// Get the Range Text with error handling. myRange.Text sometimes will get a null reference exception.
///
@@ -737,35 +514,6 @@ namespace LBWordLibrary
return myRange.Start - problem.Index;
}
///
- /// ReplaceSymbolCharacters Replaces any symbol characters in the specified range
- ///
- ///
- private static void ReplaceSymbolCharacters(LBRange myRange)
- {
- try
- {
- if (IsSymbolFont(myRange.Font.Name))
- return;
- string before = GetRangeText(myRange);
- string updated = ReplaceSymbolCharacters(before);
- myRange.Text = updated;
- string after = GetRangeText(myRange);
- if (after != updated) // If the Word text doesn't match try including a character before and after and do it again.
- {
- Console.WriteLine("'TryEntireRange Failed',{0},{1},'{2}','{3}','{4}'", myRange.Start, myRange.End, before, updated, after);
- int end = myRange.End;
- myRange.Start = myRange.Start - 1;
- myRange.End = end + 1;
- myRange.Text = ReplaceSymbolCharacters(GetRangeText(myRange));
- Console.WriteLine("'TryEntireRange Failed',{0},{1},'{2}'", myRange.Start, myRange.End, GetRangeText(myRange));
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("'TryEntireRange Exception',{0},{1},'{2}'", myRange.Start, myRange.End, ex.Message);
- }
- }
- ///
/// ReplaceSymbolCharacters processes the string returned and changes any symbols (0xF0??) to normal characters
///
///
diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs
index d2f33d9d..2da63893 100644
--- a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs
+++ b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs
@@ -83,7 +83,6 @@ namespace VEPROMS
this.lblUser = new DevComponents.DotNetBar.LabelItem();
this.lblLastChange = new DevComponents.DotNetBar.LabelItem();
this.btnStepRTF = new DevComponents.DotNetBar.ButtonItem();
- this.btnFixMSWord = new DevComponents.DotNetBar.ButtonItem();
this.epAnnotations = new DevComponents.DotNetBar.ExpandablePanel();
this.ctrlAnnotationDetails = new Volian.Controls.Library.AnnotationDetails();
this.btnAnnoDetailsPushPin = new DevComponents.DotNetBar.ButtonX();
@@ -541,8 +540,7 @@ namespace VEPROMS
this.btnEditItem,
this.lblUser,
this.lblLastChange,
- this.btnStepRTF,
- this.btnFixMSWord});
+ this.btnStepRTF});
this.bottomBar.Location = new System.Drawing.Point(5, 573);
this.bottomBar.Name = "bottomBar";
this.bottomBar.Size = new System.Drawing.Size(1185, 25);
@@ -728,14 +726,6 @@ namespace VEPROMS
this.btnStepRTF.Text = "Step RTF";
this.btnStepRTF.Click += new System.EventHandler(this.btnStepRTF_Click);
//
- // btnFixMSWord
- //
- this.btnFixMSWord.ForeColor = System.Drawing.Color.Black;
- this.btnFixMSWord.Name = "btnFixMSWord";
- this.btnFixMSWord.Text = "Fix Symbol Fonts";
- this.btnFixMSWord.Visible = false;
- this.btnFixMSWord.Click += new System.EventHandler(this.btnFixMSWord_Click);
- //
// epAnnotations
//
this.epAnnotations.CanvasColor = System.Drawing.SystemColors.Control;
@@ -1775,7 +1765,6 @@ namespace VEPROMS
private DevComponents.DotNetBar.ButtonItem btnItemInfo;
private DevComponents.DotNetBar.ButtonItem btnFilter;
private DevComponents.DotNetBar.TextBoxItem txtFilter;
- private DevComponents.DotNetBar.ButtonItem btnFixMSWord;
private Volian.Controls.Library.DisplayBookMarks displayBookMarks;
//private DevComponents.DotNetBar.LabelItem lblLocked;
private DevComponents.DotNetBar.ButtonItem btnShortCuts;
diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs
index c73eb983..10210c96 100644
--- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs
+++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs
@@ -234,7 +234,7 @@ namespace VEPROMS
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
displayRO.TabControl = tc; // B2019-043 this was being passed in as a parameter for DisplayRO which caused issues with the Visual Studio designer
- SetupFolder(MyDocVersion.FolderID);
+ SetupFolder(MyDocVersion.FolderID);
tc.MySessionInfo = MyParent.MySessionInfo;
displaySearch1.TopFolderID = myDocVersion.FolderID;
SelectedDVI = myDocVersion;
@@ -1578,13 +1578,13 @@ namespace VEPROMS
}
else
{
- SelectedROFst = myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
+ SelectedROFst = myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
}
}
}
else if (tc.MyEditItem != null && displayRO.MyROFST != null && tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].ROFstID != displayRO.MyROFST.ROFstID)
{
- SelectedROFst = tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
+ SelectedROFst = tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
}
// need this to update RO Tree after UpdateRofst (B2015-226)
@@ -1592,9 +1592,9 @@ namespace VEPROMS
if (displayRO.MyROFST != SelectedROFst)
{
displayRO.MyROFST = SelectedROFst;
- // B2023-021: force Load of Step Prop/RO panel RO tree by passing in
- // true to LoadTree
- displayRO.LoadTree(true);
+ // B2023-021: force Load of Step Prop/RO panel RO tree by passing in
+ // true to LoadTree
+ displayRO.LoadTree(true);
}
}
@@ -2396,8 +2396,8 @@ namespace VEPROMS
tv.MyUserInfo = MyUserInfo;
StepTabRibbon.MySessionInfo = MySessionInfo;
- // Initialize Caption with Server name and Database name.
- SetCaption(tv.TopNode as VETreeNode);
+ // Initialize Caption with Server name and Database name.
+ SetCaption(tv.TopNode as VETreeNode);
System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false);
//System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(MySessionInfo.PingSession);
@@ -4552,8 +4552,8 @@ namespace VEPROMS
SetCaption(tv.SelectedNode as VETreeNode);
displayApplicability.MyDisplayTabItem = tc.SelectedDisplayTabItem;
-
- if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0)
+
+ if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0)
{
displayRO.MyROFST = tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
}
@@ -4628,8 +4628,6 @@ namespace VEPROMS
if (args != null && args.MyEditItem != null && !args.MyEditItem.MyStepPanel.ContainsFocus)
return;
- btnFixMSWord.Visible = (args != null && (args.MyItemInfo != null && args.MyEditItem == null));
-
if (_LastStepRTB != null && !_LastStepRTB.Disposing && !_LastStepRTB.Closed)
_LastStepRTB.EditModeChanged -= new StepRTBEvent(_LastStepRTB_EditModeChanged);
@@ -4767,9 +4765,9 @@ namespace VEPROMS
// B2022-026 RO Memory reduction coding (Jakes Merge)
displayRO.ProgressBar = bottomProgBar;
displayRO.MyRTB = args.MyEditItem.MyStepRTB;
- displayRO.LoadTree();
+ displayRO.LoadTree();
- displayBookMarks.MyEditItem = args.MyEditItem;
+ displayBookMarks.MyEditItem = args.MyEditItem;
displayHistory.MyEditItem = args.MyEditItem;
lblEditView.Text = args.MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? "Edit" : "View";
@@ -4932,7 +4930,7 @@ namespace VEPROMS
// B2022-026 RO Memory reduction coding (Jakes Merge)
displayRO.LoadTree();
- }
+ }
#endregion
@@ -5241,19 +5239,6 @@ namespace VEPROMS
Clipboard.SetDataObject(mydo);
}
}
- private void btnFixMSWord_Click(object sender, EventArgs e)
- {
- if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyDSOTabPanel != null)
- {
- string btnText = btnFixMSWord.Text;
- btnFixMSWord.FixedSize = btnFixMSWord.Size;
- btnFixMSWord.Text = "Processing ...";
- this.Cursor = Cursors.WaitCursor;
- tc.SelectedDisplayTabItem.MyDSOTabPanel.FixSymbolCharacters();
- btnFixMSWord.Text = btnText;
- this.Cursor = Cursors.Default;
- }
- }
private void epAnnotations_Resize(object sender, EventArgs e)
{
diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs
index 45b5b70c..a97e038a 100644
--- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs
+++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs
@@ -14,736 +14,701 @@ using Volian.Base.Library;
namespace Volian.Controls.Library
{
- public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer
- {
- #region Private Fields
- private DisplayTabControl _MyDisplayTabControl;
- private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
- private AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement
- public AxEDWordLib.AxEDWord MyEdWord
- {
- get { return _MyEdWord; }
- set { _MyEdWord = value; }
- }
- private TransparentPanel _MyTransparentPanel;
- private static int _Count = 0;
- private DocumentInfo _MyDocumentInfo;
- private int _MyCount;
- private DisplayTabItem _MyDisplayTabItem;
- private DSOFile _DSOFile;
- public static int MSWordLimit = 10;
- #endregion
- #region Public Properties
- private String _SearchString;
- public String SearchString
- {
- get { return _SearchString; }
- set { _SearchString = value; FindSearchString(); }
- }
- ///
- /// Count of DSO Pages open. Limited to 18 in DisplayTabControl
- ///
- public static int Count
- {
- get { return _Count; }
- set { _Count = value; }
- }
- ///
- /// Pointer to the related DisplayTabItem
- ///
- public DisplayTabItem MyDisplayTabItem
- {
- get { return _MyDisplayTabItem; }
- set
- {
- _MyDisplayTabItem = value;
- _MyDisplayTabItem.Visible = false;
- _MyDisplayTabItem.Visible = true;
- }
- }
- ///
- /// DocumentInfo record for the Word document
- ///
- public DocumentInfo MyDocumentInfo
- {
- get { return _MyDocumentInfo; }
- }
- ///
- /// Temporary Word file used for editing.
- ///
- internal DSOFile MyDSOFile
- {
- get
- {
- if (_DSOFile == null)
- _DSOFile = new DSOFile(_MyDocumentInfo);
- return _DSOFile;
- }
- }
- ///
- /// Dirty status. Only saved if dirty.
- ///
- public bool IsDirty
- {
- get
- {
- if (_MyEdWord == null) return false; // B2017-133 Edraw Is Dirty Property
- // B2017-249 Recover Temporary File And AutoSave support for MSWord
- return _MyEdWord.IsDirty() || MyDSOFile.ContentIsDirty;
- //LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- //return !doc.Saved;
- }
- }
- private bool _OverrideClose = false;
- public bool OverrideClose
- {
- get { return _OverrideClose; }
- set { _OverrideClose = value; }
- }
- public E_ViewMode PanelViewEditMode = E_ViewMode.Edit;
- #endregion
- //private frmPG _frm = null;
- #region Constructors
- private Timer _RefreshTimer;
- private ItemInfo _ItemInfo;
- private bool _AllowedToEdit;
- public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl, ItemInfo itemInfo, bool allowedToEdit)
- {
- _MyDisplayTabControl = myDisplayTabControl;
- _ItemInfo = itemInfo;
- _AllowedToEdit = allowedToEdit;
- InitializeComponent();
- SetupDSOTabPanel();
- _MyDocumentInfo = documentInfo;
- SetupDSO();
- if (_MyEdWord == null) return; //B2017-219 could not open the word attachment so just return
+ public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer
+ {
+ #region Private Fields
+ private DisplayTabControl _MyDisplayTabControl;
+ private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ private AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement
+ public AxEDWordLib.AxEDWord MyEdWord
+ {
+ get { return _MyEdWord; }
+ set { _MyEdWord = value; }
+ }
+ private TransparentPanel _MyTransparentPanel;
+ private static int _Count = 0;
+ private DocumentInfo _MyDocumentInfo;
+ private int _MyCount;
+ private DisplayTabItem _MyDisplayTabItem;
+ private DSOFile _DSOFile;
+ public static int MSWordLimit = 10;
+ #endregion
+ #region Public Properties
+ private String _SearchString;
+ public String SearchString
+ {
+ get { return _SearchString; }
+ set { _SearchString = value; FindSearchString(); }
+ }
+ ///
+ /// Count of DSO Pages open. Limited to 18 in DisplayTabControl
+ ///
+ public static int Count
+ {
+ get { return _Count; }
+ set { _Count = value; }
+ }
+ ///
+ /// Pointer to the related DisplayTabItem
+ ///
+ public DisplayTabItem MyDisplayTabItem
+ {
+ get { return _MyDisplayTabItem; }
+ set
+ {
+ _MyDisplayTabItem = value;
+ _MyDisplayTabItem.Visible = false;
+ _MyDisplayTabItem.Visible = true;
+ }
+ }
+ ///
+ /// DocumentInfo record for the Word document
+ ///
+ public DocumentInfo MyDocumentInfo
+ {
+ get { return _MyDocumentInfo; }
+ }
+ ///
+ /// Temporary Word file used for editing.
+ ///
+ internal DSOFile MyDSOFile
+ {
+ get
+ {
+ if (_DSOFile == null)
+ _DSOFile = new DSOFile(_MyDocumentInfo);
+ return _DSOFile;
+ }
+ }
+ ///
+ /// Dirty status. Only saved if dirty.
+ ///
+ public bool IsDirty
+ {
+ get
+ {
+ if (_MyEdWord == null) return false; // B2017-133 Edraw Is Dirty Property
+ // B2017-249 Recover Temporary File And AutoSave support for MSWord
+ return _MyEdWord.IsDirty() || MyDSOFile.ContentIsDirty;
+ //LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
+ //return !doc.Saved;
+ }
+ }
+ private bool _OverrideClose = false;
+ public bool OverrideClose
+ {
+ get { return _OverrideClose; }
+ set { _OverrideClose = value; }
+ }
+ public E_ViewMode PanelViewEditMode = E_ViewMode.Edit;
+ #endregion
+ //private frmPG _frm = null;
+ #region Constructors
+ private Timer _RefreshTimer;
+ private ItemInfo _ItemInfo;
+ private bool _AllowedToEdit;
+ public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl, ItemInfo itemInfo, bool allowedToEdit)
+ {
+ _MyDisplayTabControl = myDisplayTabControl;
+ _ItemInfo = itemInfo;
+ _AllowedToEdit = allowedToEdit;
+ InitializeComponent();
+ SetupDSOTabPanel();
+ _MyDocumentInfo = documentInfo;
+ SetupDSO();
+ if (_MyEdWord == null) return; //B2017-219 could not open the word attachment so just return
_RefreshTimer = new Timer(); // Enabled is false and interval is 1/10th of second.
- _RefreshTimer.Interval = 500;// B2017-133 Edraw
- ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged);
- _RefreshTimer.Tick += new EventHandler(_RefreshTimer_Tick);
- // B2018-070 Activate MS Word Panel
- _RefreshTimer.Enabled = true;
- _MyEdWord.BeforeDocumentSaved += _MyEdWord_BeforeDocumentSaved;// B2017-133 Edraw
- }
- void _MyEdWord_BeforeDocumentSaved(object sender, EventArgs e)// B2017-133 Edraw
- {
- _MyEdWord.Save(); // B2017-135 Only open the Message Box once
- }
- void DisableWordCommands()// B2017-133 Edraw
- {
- _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableClose, true);
- _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableNew, true);
- _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrint, true);
- _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintPreview, true);
- _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintQuick, true);
- _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSave, true);
- _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSaveAs, true);
- _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeSave, true);
- _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeClose, true);
- _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypePrint, true);
- _MyEdWord.DisableSaveHotKey(true);
- _MyEdWord.DisablePrintHotKey(true);
- }
- // B2019-161 When tracking timing time this action
- private static VolianTimer _TimeActivity = new VolianTimer("DSOTabPanel.cs _RefreshTimer_Tick", 148);
+ _RefreshTimer.Interval = 500;// B2017-133 Edraw
+ ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged);
+ _RefreshTimer.Tick += new EventHandler(_RefreshTimer_Tick);
+ // B2018-070 Activate MS Word Panel
+ _RefreshTimer.Enabled = true;
+ _MyEdWord.BeforeDocumentSaved += _MyEdWord_BeforeDocumentSaved;// B2017-133 Edraw
+ }
+ void _MyEdWord_BeforeDocumentSaved(object sender, EventArgs e)// B2017-133 Edraw
+ {
+ _MyEdWord.Save(); // B2017-135 Only open the Message Box once
+ }
+ void DisableWordCommands()// B2017-133 Edraw
+ {
+ _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableClose, true);
+ _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableNew, true);
+ _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrint, true);
+ _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintPreview, true);
+ _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintQuick, true);
+ _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSave, true);
+ _MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSaveAs, true);
+ _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeSave, true);
+ _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeClose, true);
+ _MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypePrint, true);
+ _MyEdWord.DisableSaveHotKey(true);
+ _MyEdWord.DisablePrintHotKey(true);
+ }
+ // B2019-161 When tracking timing time this action
+ private static VolianTimer _TimeActivity = new VolianTimer("DSOTabPanel.cs _RefreshTimer_Tick", 148);
- void _RefreshTimer_Tick(object sender, EventArgs e)
- {
- _TimeActivity.Open();
- _RefreshTimer.Enabled = false;
- if (_MyEdWord != null)// B2017-133 Edraw
- {
- // B2018-070 Activate MS Word Panel
- _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null);
- }
- //else
- //{
- // _MyDisplayTabControl.CloseTabItem(_MyDisplayTabItem);
- //}
- _TimeActivity.Close();
- }
+ void _RefreshTimer_Tick(object sender, EventArgs e)
+ {
+ _TimeActivity.Open();
+ _RefreshTimer.Enabled = false;
+ if (_MyEdWord != null)// B2017-133 Edraw
+ {
+ // B2018-070 Activate MS Word Panel
+ _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null);
+ }
+ //else
+ //{
+ // _MyDisplayTabControl.CloseTabItem(_MyDisplayTabItem);
+ //}
+ _TimeActivity.Close();
+ }
- void DSOTabPanel_ClientSizeChanged(object sender, EventArgs e)
- {
- // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
- if (_InDSOTabPanel)
- {
+ void DSOTabPanel_ClientSizeChanged(object sender, EventArgs e)
+ {
+ // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
+ if (_InDSOTabPanel)
+ {
_RefreshTimer.Enabled = false; // This assures that interval is used from last event.
- _RefreshTimer.Enabled = true;
- }
- }
- #endregion
- #region Private Methods
- private void SetupDSOTabPanel()
- {
- Dock = System.Windows.Forms.DockStyle.Fill; // Automatically Fill the panel
- }
- private void SetupDSO()
- {
- _Count++; // Increment the count of open Word documents (Limit = MSWordLimit)
- _MyCount = _Count;
- this._MyTransparentPanel = new TransparentPanel();
- this._MyEdWord = new AxEDWordLib.AxEDWord();// B2017-133 Edraw
- _MyEdWord.BeginInit();
- this.Controls.Add(this._MyEdWord);
- this.Controls.Add(this._MyTransparentPanel); // A transparent panel is added over top of the DSO Framer window so that
- // the related tab can be activated when the user clicks on a Word Document. Since the Word document is actually running
- // in a different thread, it does not behave properly with focus events.
- this.components.Add(this._MyEdWord);// B2017-133 Edraw
- this.components.Add(this._MyTransparentPanel);
- this._MyTransparentPanel.Dock = System.Windows.Forms.DockStyle.Fill;
- this._MyTransparentPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this._MyTransparentPanel.ForeColor = System.Drawing.Color.Brown; // This is the color used to show InActive on the right side on the Word
- // document menu line.
- //this._MyTransPanel.Location = new System.Drawing.Point(0, 0);
- //this._MyTransPanel.Name = "transPanel1";
- //this._MyTransPanel.Size = new System.Drawing.Size(370, 423);
- //this._MyTransPanel.TabIndex = 1;
- this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click);
- this._MyEdWord.Dock = System.Windows.Forms.DockStyle.Fill;
- //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab));
- //this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState")));
- _MyEdWord.EndInit();
- LBDocumentClass doc;
- try
- {
- try
- {
- this._MyEdWord.LicenseName = "Volian7573291802";// B2017-133 Edraw
- this._MyEdWord.LicenseCode = "EDW8-5527-1201-AB8A";// B2017-133 Edraw
- DisableWordCommands();
- this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
- doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- }
- catch (Exception ex)
- {
- // B2017-137 Restore Previous valid version if the current version cannot be opened,
- using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID))
- {
- if (dail.Count > 0)
- {
- //DocumentAuditInfo dai = dail[0];
- //foreach (DocumentAuditInfo tmpa in dail)
- //{
- // if (tmpa.DTS > dai.DTS) dai = tmpa;
- //}
- if (MessageBox.Show("Do you want to revert to a previous version?", "Error in MS Word section",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- using (Document myDoc = Document.Get(MyDocumentInfo.DocID))
- {
- myDoc.RestoreWordDoc(_ItemInfo);
- }
- using (Document myDoc = Document.Get(MyDocumentInfo.DocID))
- {
- System.IO.FileStream fs = MyDSOFile.MyFile.Create();
- fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length);
- fs.Close();
- MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the restored document to database
- this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
- return;
- //_MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID);
- //DocumentInfo.Refresh(myDoc);
- ////_DSOFile = null;
- //this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
- //doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- //doc.Range(1, 1);
- }
- }
+ _RefreshTimer.Enabled = true;
+ }
+ }
+ #endregion
+ #region Private Methods
+ private void SetupDSOTabPanel()
+ {
+ Dock = System.Windows.Forms.DockStyle.Fill; // Automatically Fill the panel
+ }
+ private void SetupDSO()
+ {
+ _Count++; // Increment the count of open Word documents (Limit = MSWordLimit)
+ _MyCount = _Count;
+ this._MyTransparentPanel = new TransparentPanel();
+ this._MyEdWord = new AxEDWordLib.AxEDWord();// B2017-133 Edraw
+ _MyEdWord.BeginInit();
+ this.Controls.Add(this._MyEdWord);
+ this.Controls.Add(this._MyTransparentPanel); // A transparent panel is added over top of the DSO Framer window so that
+ // the related tab can be activated when the user clicks on a Word Document. Since the Word document is actually running
+ // in a different thread, it does not behave properly with focus events.
+ this.components.Add(this._MyEdWord);// B2017-133 Edraw
+ this.components.Add(this._MyTransparentPanel);
+ this._MyTransparentPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._MyTransparentPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this._MyTransparentPanel.ForeColor = System.Drawing.Color.Brown; // This is the color used to show InActive on the right side on the Word
+ // document menu line.
+ //this._MyTransPanel.Location = new System.Drawing.Point(0, 0);
+ //this._MyTransPanel.Name = "transPanel1";
+ //this._MyTransPanel.Size = new System.Drawing.Size(370, 423);
+ //this._MyTransPanel.TabIndex = 1;
+ this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click);
+ this._MyEdWord.Dock = System.Windows.Forms.DockStyle.Fill;
+ //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab));
+ //this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState")));
+ _MyEdWord.EndInit();
+ LBDocumentClass doc;
+ try
+ {
+ try
+ {
+ this._MyEdWord.LicenseName = "Volian7573291802";// B2017-133 Edraw
+ this._MyEdWord.LicenseCode = "EDW8-5527-1201-AB8A";// B2017-133 Edraw
+ DisableWordCommands();
+ this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
+ doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
+ }
+ catch (Exception ex)
+ {
+ // B2017-137 Restore Previous valid version if the current version cannot be opened,
+ using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID))
+ {
+ if (dail.Count > 0)
+ {
+ //DocumentAuditInfo dai = dail[0];
+ //foreach (DocumentAuditInfo tmpa in dail)
+ //{
+ // if (tmpa.DTS > dai.DTS) dai = tmpa;
+ //}
+ if (MessageBox.Show("Do you want to revert to a previous version?", "Error in MS Word section",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ using (Document myDoc = Document.Get(MyDocumentInfo.DocID))
+ {
+ myDoc.RestoreWordDoc(_ItemInfo);
+ }
+ using (Document myDoc = Document.Get(MyDocumentInfo.DocID))
+ {
+ System.IO.FileStream fs = MyDSOFile.MyFile.Create();
+ fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length);
+ fs.Close();
+ MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the restored document to database
+ this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
+ return;
+ //_MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID);
+ //DocumentInfo.Refresh(myDoc);
+ ////_DSOFile = null;
+ //this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
+ //doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
+ //doc.Range(1, 1);
+ }
+ }
- }
- else
- {
- System.IO.FileStream fs = MyDSOFile.MyFile.Create();
- fs.Close();
- MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the blank document to database
- MessageBox.Show("Reverting to Blank Document", "Error in MS Word section",
- MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
- return;
- }
- }
- this._MyEdWord.Open(MyDSOFile.MyFile.FullName);// B2017-133 Edraw
- }
- doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- //Console.WriteLine("Version {0}", doc.Application.Version);
- float ver;
- if (!float.TryParse(doc.Application.Version, out ver))
- ver = 12.0F;
- this.Enter += new EventHandler(DSOTabPanel_Enter);
- // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
- this.Leave += DSOTabPanel_Leave;
- Application.DoEvents();
- // The following line corrects Symbol characters in MSWord Sections
- // CheckForSymbolCharacters(doc);
- InitializeWordDocument(doc);
- FindSearchString();
- }
- catch (Exception ex)
- {
- //string message = ShowException(ex);
- //Console.WriteLine("\r\n-------------\r\n{0}{1}{2}\r\n-------------\r\n", MyDSOFile.MyFile.FullName, ex.GetType().Name, message);
- // TODO: Should output a message
- // TODO: Should try to do a direct open using Word.
- }
- }
+ }
+ else
+ {
+ System.IO.FileStream fs = MyDSOFile.MyFile.Create();
+ fs.Close();
+ MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the blank document to database
+ MessageBox.Show("Reverting to Blank Document", "Error in MS Word section",
+ MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
+ return;
+ }
+ }
+ this._MyEdWord.Open(MyDSOFile.MyFile.FullName);// B2017-133 Edraw
+ }
+ doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
+ //Console.WriteLine("Version {0}", doc.Application.Version);
+ float ver;
+ if (!float.TryParse(doc.Application.Version, out ver))
+ ver = 12.0F;
+ this.Enter += new EventHandler(DSOTabPanel_Enter);
+ // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
+ this.Leave += DSOTabPanel_Leave;
+ Application.DoEvents();
+ // The following line corrects Symbol characters in MSWord Sections
+ // CheckForSymbolCharacters(doc);
+ InitializeWordDocument(doc);
+ FindSearchString();
+ }
+ catch (Exception ex)
+ {
+ //string message = ShowException(ex);
+ //Console.WriteLine("\r\n-------------\r\n{0}{1}{2}\r\n-------------\r\n", MyDSOFile.MyFile.FullName, ex.GetType().Name, message);
+ // TODO: Should output a message
+ // TODO: Should try to do a direct open using Word.
+ }
+ }
- void DSOTabPanel_Leave(object sender, EventArgs e)
- {
- // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
- _InDSOTabPanel = false;
- }
- public void FixSymbolCharacters()
- {
- CheckForSymbolCharacters(new LBDocumentClass(_MyEdWord.ActiveDocument()));// B2017-133 Edraw
- }
- private void CheckForSymbolCharacters(LBDocumentClass doc)
- {
- string fontHasSymbolCharacters = doc.FontHasSymbolCharacters;
- if (fontHasSymbolCharacters != null)
- {
- // do a string for the log message, depending if this is a libdoc.
- string msg = null;
- if (MyDocumentInfo.LibTitle == null || MyDocumentInfo.LibTitle == "")
- {
- if (MyDocumentInfo.DocumentEntryCount>0)
- msg = string.Format("Procedure = {0}, Section {1}", MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyProcedure, MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].DisplayText);
- else
- msg = string.Format("Procedure and Section can't be determined");
- }
- else
- msg = string.Format("Library Document: {0}", MyDocumentInfo.LibTitle);
- if (doc.AttemptToFixASymbolCharacter()) // font is installed correctly, 'fix' this file.
- {
- //MessageBox.Show(string.Format("This document uses the font {0}, which previously had an error.\r\nThe program will attempt to fix the problem for this Word section.", fontHasSymbolCharacters),
- // "Font Being Corrected", MessageBoxButtons.OK);
- doc.FixSymbolCharacters();
- _MyLog.Info(string.Format("Font problem being fixed in Font: {0}, {1}.",fontHasSymbolCharacters, msg));
- }
- else
- {
- MessageBox.Show(string.Format("This document uses the font {0}, which has an error.\r\n\r\nReinstall this font.", fontHasSymbolCharacters),
- "Reinstall Font", MessageBoxButtons.OK);
- _MyLog.Info(string.Format("Font problem found in Font: {0}, {1}.",fontHasSymbolCharacters, msg));
- }
- }
- }
+ void DSOTabPanel_Leave(object sender, EventArgs e)
+ {
+ // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
+ _InDSOTabPanel = false;
+ }
- private void InitializeWordDocument(LBDocumentClass doc)
- {
- if (MyDocumentInfo.Config == null || MyDocumentInfo.Config == "" && MyDocumentInfo.DocumentEntryCount > 0)
- {
- DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle;
- // this will cause an error and goto the Catch if the family or size is null,
- // Westinghouse needs it to to this - at least for now
- //if (ds.Font.Family != null) doc.Application.Selection.Font.Name = ds.Font.Family;
- //if (ds.Font.Size != null) doc.Application.Selection.Font.Size = (float)ds.Font.Size;
- doc.Application.Selection.Font.Name = ds.Font.Family;
- doc.Application.Selection.Font.Size = (float)ds.Font.Size;
- doc.Application.Selection.ParagraphFormat.SpaceBefore = 0;
- doc.Application.Selection.ParagraphFormat.SpaceAfter = 0;
- doc.Application.Selection.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly;
- doc.Application.Selection.ParagraphFormat.LineSpacing = 72 / 6; // for 6 LPI
- MSWordToPDF.AdjustMargins(ds, doc, false);
- }
- if (doc.ActiveWindow.ActivePane.View.Zoom.Percentage < 40)
- doc.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
- }
- public void FindSearchString()
- {
- if (SearchString == null) return;
- // Get the Document
+ private void InitializeWordDocument(LBDocumentClass doc)
+ {
+ if (MyDocumentInfo.Config == null || MyDocumentInfo.Config == "" && MyDocumentInfo.DocumentEntryCount > 0)
+ {
+ DocStyle ds = MyDocumentInfo.DocumentEntries[0].MyContent.ContentItems[0].MyDocStyle;
+ // this will cause an error and goto the Catch if the family or size is null,
+ // Westinghouse needs it to to this - at least for now
+ //if (ds.Font.Family != null) doc.Application.Selection.Font.Name = ds.Font.Family;
+ //if (ds.Font.Size != null) doc.Application.Selection.Font.Size = (float)ds.Font.Size;
+ doc.Application.Selection.Font.Name = ds.Font.Family;
+ doc.Application.Selection.Font.Size = (float)ds.Font.Size;
+ doc.Application.Selection.ParagraphFormat.SpaceBefore = 0;
+ doc.Application.Selection.ParagraphFormat.SpaceAfter = 0;
+ doc.Application.Selection.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly;
+ doc.Application.Selection.ParagraphFormat.LineSpacing = 72 / 6; // for 6 LPI
+ MSWordToPDF.AdjustMargins(ds, doc, false);
+ }
+ if (doc.ActiveWindow.ActivePane.View.Zoom.Percentage < 40)
+ doc.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
+ }
+ public void FindSearchString()
+ {
+ if (SearchString == null) return;
+ // Get the Document
LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- //LBSelection sel = wordDoc.Application.Selection;
- LBFind find = wordDoc.Application.Selection.Find;
- find.ClearFormatting();
- bool wildCards = SearchString.Contains("?") || SearchString.Contains("*");
- 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
- ///
- ///
- public void InsertText(string txt)
- {
- if (txt == null || txt.Length == 0) return; //nothing to insert
- // Get the Document
- LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- //This will get the selected range or just the current cursor position
- LBSelection sel = wordDoc.Application.Selection;
- // This will replace the selection or insert at current position
- sel.Text = txt;
- }
+ //LBSelection sel = wordDoc.Application.Selection;
+ LBFind find = wordDoc.Application.Selection.Find;
+ find.ClearFormatting();
+ bool wildCards = SearchString.Contains("?") || SearchString.Contains("*");
+ 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
+ ///
+ ///
+ public void InsertText(string txt)
+ {
+ if (txt == null || txt.Length == 0) return; //nothing to insert
+ // Get the Document
+ LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
+ //This will get the selected range or just the current cursor position
+ LBSelection sel = wordDoc.Application.Selection;
+ // This will replace the selection or insert at current position
+ sel.Text = txt;
+ }
- public string GetSelectedString()
- {
- LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- //This will get the selected range or just the current cursor position
- LBSelection sel = wordDoc.Application.Selection;
- // if the start & end are the same, nothing is selected:
- if (sel.Start == sel.End) return null;
- return sel.Text;
- }
+ public string GetSelectedString()
+ {
+ LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
+ //This will get the selected range or just the current cursor position
+ LBSelection sel = wordDoc.Application.Selection;
+ // if the start & end are the same, nothing is selected:
+ if (sel.Start == sel.End) return null;
+ return sel.Text;
+ }
- private string ShowException(Exception ex)
- {
- string sep = "\r\n ";
- StringBuilder sb = new StringBuilder();
- do
- {
- sb.Append(sep + ex.Message);
- sep += " ";
- ex = ex.InnerException;
- } while (ex != null);
- return sb.ToString();
- }
+ private string ShowException(Exception ex)
+ {
+ string sep = "\r\n ";
+ StringBuilder sb = new StringBuilder();
+ do
+ {
+ sb.Append(sep + ex.Message);
+ sep += " ";
+ ex = ex.InnerException;
+ } while (ex != null);
+ return sb.ToString();
+ }
- //void _MyDSOFramer_Leave(object sender, EventArgs e)
- //{
- // vlnStackTrace.ShowStack("DSO Leave {0}", this.MyDocumentInfo.DocID);
- //}
+ //void _MyDSOFramer_Leave(object sender, EventArgs e)
+ //{
+ // vlnStackTrace.ShowStack("DSO Leave {0}", this.MyDocumentInfo.DocID);
+ //}
- //void _MyDSOFramer_Enter(object sender, EventArgs e)
- //{
- // vlnStackTrace.ShowStack("DSO Enter {0}", this.MyDocumentInfo.DocID);
- //}
+ //void _MyDSOFramer_Enter(object sender, EventArgs e)
+ //{
+ // vlnStackTrace.ShowStack("DSO Enter {0}", this.MyDocumentInfo.DocID);
+ //}
- //void _MyDSOFramer_GotFocus(object sender, EventArgs e)
- //{
- // vlnStackTrace.ShowStack("DSO Got Focus {0}",this.MyDocumentInfo.DocID);
- //}
+ //void _MyDSOFramer_GotFocus(object sender, EventArgs e)
+ //{
+ // vlnStackTrace.ShowStack("DSO Got Focus {0}",this.MyDocumentInfo.DocID);
+ //}
- //void _MyDSOFramer_LostFocus(object sender, EventArgs e)
- //{
- // vlnStackTrace.ShowStack("DSO Lost Focus {0}", this.MyDocumentInfo.DocID);
- //}
- public void EnterPanel()
- {
- DSOTabPanel_Enter(this, new EventArgs());
- }
- //void DSOTabPanel_LostFocus(object sender, EventArgs e)
- //{
- // vlnStackTrace.ShowStack("DSOTabPanel_LostFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
- //}
- //void DSOTabPanel_GotFocus(object sender, EventArgs e)
- //{
- // vlnStackTrace.ShowStack("DSOTabPanel_GotFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
- //}
- #endregion
- #region Event Handlers
- ///
- /// Display MyTransparentPanel over the DSOPanel so that the Word "Inactive" appears in the upper right hand corner.
- ///
- public void InActive()
- {
- _MyTransparentPanel.BringToFront();
- }
- ///
- /// Force this item to be selected when the transparent window is clicked.
- /// This will in-turn send the Transparent Panel to back and make the DSO Panel
- /// editable.
- ///
- ///
- ///
- void _MyTransparentPanel_Click(object sender, EventArgs e)
- {
- this.Select();
- }
- /////
- ///// If the user presses the save button, tell the file to save it's contents to the database
- /////
- /////
- /////
- //void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
- //{
- // _MyLog.WarnFormat("_MyDSOFramer_OnSaveCompleted");
- // Volian.Base.Library.vlnStackTrace.ShowStack("_MyDSOFramer_OnSaveCompleted");
- // SaveDSO_Phase2();
- //}
+ //void _MyDSOFramer_LostFocus(object sender, EventArgs e)
+ //{
+ // vlnStackTrace.ShowStack("DSO Lost Focus {0}", this.MyDocumentInfo.DocID);
+ //}
+ public void EnterPanel()
+ {
+ DSOTabPanel_Enter(this, new EventArgs());
+ }
+ //void DSOTabPanel_LostFocus(object sender, EventArgs e)
+ //{
+ // vlnStackTrace.ShowStack("DSOTabPanel_LostFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
+ //}
+ //void DSOTabPanel_GotFocus(object sender, EventArgs e)
+ //{
+ // vlnStackTrace.ShowStack("DSOTabPanel_GotFocus {0} DocID {1} Index {2} {3}", _In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
+ //}
+ #endregion
+ #region Event Handlers
+ ///
+ /// Display MyTransparentPanel over the DSOPanel so that the Word "Inactive" appears in the upper right hand corner.
+ ///
+ public void InActive()
+ {
+ _MyTransparentPanel.BringToFront();
+ }
+ ///
+ /// Force this item to be selected when the transparent window is clicked.
+ /// This will in-turn send the Transparent Panel to back and make the DSO Panel
+ /// editable.
+ ///
+ ///
+ ///
+ void _MyTransparentPanel_Click(object sender, EventArgs e)
+ {
+ this.Select();
+ }
+ /////
+ ///// If the user presses the save button, tell the file to save it's contents to the database
+ /////
+ /////
+ /////
+ //void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
+ //{
+ // _MyLog.WarnFormat("_MyDSOFramer_OnSaveCompleted");
+ // Volian.Base.Library.vlnStackTrace.ShowStack("_MyDSOFramer_OnSaveCompleted");
+ // SaveDSO_Phase2();
+ //}
- private void SaveDSO_Phase2()
- {
- // Unfortunately, the only way to handle view mode for DSO Framer is to not save.
- if (PanelViewEditMode == E_ViewMode.View)
- {
- MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip);
- return;
- }
- LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
- //while (doc.Saved = false)
- // Application.DoEvents();
- string tmp = GetReflectiveProperty(_MyEdWord.ActiveDocument(), "FullName");
- if (System.IO.File.Exists(tmp))
- MyDSOFile.FullName = tmp;
- else
- _MyLog.FatalFormat("File does not exist {0}\r\nFile was {1}", tmp, MyDSOFile.FullName);
- // if this was a library document, ask user if it should be saved for all usages.
- bool cvtLibDoc = false;
- if (MyDisplayTabItem.MyItemInfo != null) // B2016-131 if myiteminfo is null then the lib doc is not referenced, so just save the changes - don't generate a pdf
- {
- EntryInfo myei = MyDisplayTabItem.MyItemInfo.MyContent.MyEntry;
- if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "")
- {
- // C2019-033 - make save options more clear with respect to library documents
- string msgstr = "Save to Library Document?" +
- "\n\n YES - Save for all usages of this Library Document." +
- "\n\n NO - Unlink this Section from the Library Document and Save in this Word Section.\n\n" +
- _MyDocumentInfo.LibraryDocumentUsageAll;
- DialogResult ans = FlexibleMessageBox.Show(msgstr, "Document Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (ans == DialogResult.No) cvtLibDoc = true;
- }
- }
- MyDSOFile.SaveFile(doc.Length, doc.Ascii, MyDisplayTabItem.MyItemInfo, cvtLibDoc, StatusChanged);
- if (cvtLibDoc)
- {
- MyDisplayTabItem.Text = MyDisplayTabItem.MyItemInfo.TabTitle;
- MyDisplayTabItem.Tooltip = MyDisplayTabItem.MyItemInfo.TabToolTip;
- MyDisplayTabItem.SetPrivateTooltip(MyDisplayTabItem.MyItemInfo.TabToolTip);
- }
- }
- public void StatusChanged(VolianStatusType type, int count, string text)
- {
- if (Parent != null && Parent.Parent != null && Parent.Parent.Parent is DisplayTabControl)
- {
- DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl;
- tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text));
- }
- }
- /////
- ///// Before a document closes check to see if it's contents should be saved.
- /////
- /////
- /////
- //void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
- //{
- // SaveDSOPhase1();
- //}
+ private void SaveDSO_Phase2()
+ {
+ // Unfortunately, the only way to handle view mode for DSO Framer is to not save.
+ if (PanelViewEditMode == E_ViewMode.View)
+ {
+ MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip);
+ return;
+ }
+ LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
+ //while (doc.Saved = false)
+ // Application.DoEvents();
+ string tmp = GetReflectiveProperty(_MyEdWord.ActiveDocument(), "FullName");
+ if (System.IO.File.Exists(tmp))
+ MyDSOFile.FullName = tmp;
+ else
+ _MyLog.FatalFormat("File does not exist {0}\r\nFile was {1}", tmp, MyDSOFile.FullName);
+ // if this was a library document, ask user if it should be saved for all usages.
+ bool cvtLibDoc = false;
+ if (MyDisplayTabItem.MyItemInfo != null) // B2016-131 if myiteminfo is null then the lib doc is not referenced, so just save the changes - don't generate a pdf
+ {
+ EntryInfo myei = MyDisplayTabItem.MyItemInfo.MyContent.MyEntry;
+ if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "")
+ {
+ // C2019-033 - make save options more clear with respect to library documents
+ string msgstr = "Save to Library Document?" +
+ "\n\n YES - Save for all usages of this Library Document." +
+ "\n\n NO - Unlink this Section from the Library Document and Save in this Word Section.\n\n" +
+ _MyDocumentInfo.LibraryDocumentUsageAll;
+ DialogResult ans = FlexibleMessageBox.Show(msgstr, "Document Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ if (ans == DialogResult.No) cvtLibDoc = true;
+ }
+ }
+ MyDSOFile.SaveFile(doc.Length, doc.Ascii, MyDisplayTabItem.MyItemInfo, cvtLibDoc, StatusChanged);
+ if (cvtLibDoc)
+ {
+ MyDisplayTabItem.Text = MyDisplayTabItem.MyItemInfo.TabTitle;
+ MyDisplayTabItem.Tooltip = MyDisplayTabItem.MyItemInfo.TabToolTip;
+ MyDisplayTabItem.SetPrivateTooltip(MyDisplayTabItem.MyItemInfo.TabToolTip);
+ }
+ }
+ public void StatusChanged(VolianStatusType type, int count, string text)
+ {
+ if (Parent != null && Parent.Parent != null && Parent.Parent.Parent is DisplayTabControl)
+ {
+ DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl;
+ tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text));
+ }
+ }
+ /////
+ ///// Before a document closes check to see if it's contents should be saved.
+ /////
+ /////
+ /////
+ //void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
+ //{
+ // SaveDSOPhase1();
+ //}
- private void SaveDSO_Phase1()
- {
- try
- {
- if (!IsBeingDeleted)
- SaveDirty();
- this.Enter -= new EventHandler(DSOTabPanel_Enter);
- // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
- this.Leave -= DSOTabPanel_Leave;
- // SaveDirty(); // SaveDirty happens in CloseDSO(bool)
- }
- catch (Exception ex)
- {
- _MyLog.Warn("Before Closing Document ", ex);
- }
- }
- ///
- /// Save the contents of the Word Document to a file
- /// and save the file to the database
- ///
- ///
- public bool SaveDSO()
- {
- bool result = true;
- try
- {
- bool stat = _MyEdWord.Save();// B2017-133 Edraw
- //Console.WriteLine("Save = {0}", stat);
- SaveDSO_Phase2();
- //_MyDSOFramer_OnSaveCompleted(this, null);
- // These are handled in the method above
- //LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
- //MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName");
- //MyDSOFile.SaveFile(doc.Length, doc.Ascii);
- }
- catch (Exception ex)
- {
- if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO", ex);
- MessageBox.Show(ex.Message, "Error Saving Document", MessageBoxButtons.OK, MessageBoxIcon.Error);
- result = false;
- }
- return result;
- }
- ///
- /// Check to see if a Word document should be saved. If it is dirty ask the user if the
- /// changes should be changed. Save the changes if the user says "yes".
- ///
- ///
- public bool SaveDirty()
- {
- if (OverrideClose)
- return false;
- // B2017-249 Recover Temporary File And AutoSave support for MSWord
- if (IsDirty || MyDSOFile.MyDocument.ContentIsDirty)
- {
- // Unfortunately, the only way to handle view mode for DSO Framer is to not save.
- if (PanelViewEditMode == E_ViewMode.View || !_AllowedToEdit)
- {
- MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip);
- return false;
- }
- //if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- // B2017-249 Recover Temporary File And AutoSave support for MSWord
- // C2019-033 - make save options more clear with respect to library documents second dialog will appear if Yes is selected and it's a library document
- string msgstr = "Save changes to " + (MyDSOFile.MyDocument.ContentIsDirty ? "Recovered Version of " : "") + _MyDisplayTabItem.Text;
+ private void SaveDSO_Phase1()
+ {
+ try
+ {
+ if (!IsBeingDeleted)
+ SaveDirty();
+ this.Enter -= new EventHandler(DSOTabPanel_Enter);
+ // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
+ this.Leave -= DSOTabPanel_Leave;
+ // SaveDirty(); // SaveDirty happens in CloseDSO(bool)
+ }
+ catch (Exception ex)
+ {
+ _MyLog.Warn("Before Closing Document ", ex);
+ }
+ }
+ ///
+ /// Save the contents of the Word Document to a file
+ /// and save the file to the database
+ ///
+ ///
+ public bool SaveDSO()
+ {
+ bool result = true;
+ try
+ {
+ bool stat = _MyEdWord.Save();// B2017-133 Edraw
+ //Console.WriteLine("Save = {0}", stat);
+ SaveDSO_Phase2();
+ //_MyDSOFramer_OnSaveCompleted(this, null);
+ // These are handled in the method above
+ //LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
+ //MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName");
+ //MyDSOFile.SaveFile(doc.Length, doc.Ascii);
+ }
+ catch (Exception ex)
+ {
+ if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO", ex);
+ MessageBox.Show(ex.Message, "Error Saving Document", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ result = false;
+ }
+ return result;
+ }
+ ///
+ /// Check to see if a Word document should be saved. If it is dirty ask the user if the
+ /// changes should be changed. Save the changes if the user says "yes".
+ ///
+ ///
+ public bool SaveDirty()
+ {
+ if (OverrideClose)
+ return false;
+ // B2017-249 Recover Temporary File And AutoSave support for MSWord
+ if (IsDirty || MyDSOFile.MyDocument.ContentIsDirty)
+ {
+ // Unfortunately, the only way to handle view mode for DSO Framer is to not save.
+ if (PanelViewEditMode == E_ViewMode.View || !_AllowedToEdit)
+ {
+ MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip);
+ return false;
+ }
+ //if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ // B2017-249 Recover Temporary File And AutoSave support for MSWord
+ // C2019-033 - make save options more clear with respect to library documents second dialog will appear if Yes is selected and it's a library document
+ string msgstr = "Save changes to " + (MyDSOFile.MyDocument.ContentIsDirty ? "Recovered Version of " : "") + _MyDisplayTabItem.Text;
if (FlexibleMessageBox.Show(msgstr, (IsDirty ? "Document has Changed" : "Previous Changes were not Saved"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- return SaveDSO();
- //Console.WriteLine("Delete {0}", MyDSOFile.MyFile.Name);
- DeleteOnClose = true;
- return false;
- }
- return true;
- }
- // B2017-249 Recover Temporary File And AutoSave support for MSWord
- private bool _DeleteOnClose = false;
+ return SaveDSO();
+ //Console.WriteLine("Delete {0}", MyDSOFile.MyFile.Name);
+ DeleteOnClose = true;
+ return false;
+ }
+ return true;
+ }
+ // B2017-249 Recover Temporary File And AutoSave support for MSWord
+ private bool _DeleteOnClose = false;
- public bool DeleteOnClose
- {
- get { return _DeleteOnClose; }
- set { _DeleteOnClose = value; }
- }
- public static bool IgnoreEnter = false;
+ public bool DeleteOnClose
+ {
+ get { return _DeleteOnClose; }
+ set { _DeleteOnClose = value; }
+ }
+ public static bool IgnoreEnter = false;
private bool _In_DSOTabPanel_Enter=false;
- // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
- private bool _InDSOTabPanel = false;
- ///
- /// When a Word document is selected make sure it's tab is activated and
- /// the SelectedItem for the DisplayTabControl is updated.
- ///
- ///
- ///
- private void DSOTabPanel_Enter(object sender, EventArgs e)
- {
- // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
- _InDSOTabPanel = true;
- if (IgnoreEnter) return;
- _MyTransparentPanel.SendToBack();
+ // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
+ private bool _InDSOTabPanel = false;
+ ///
+ /// When a Word document is selected make sure it's tab is activated and
+ /// the SelectedItem for the DisplayTabControl is updated.
+ ///
+ ///
+ ///
+ private void DSOTabPanel_Enter(object sender, EventArgs e)
+ {
+ // B2018-070 Use InDSOTabPanel to determine if the word panel should be activated - Activate MS Word Panel
+ _InDSOTabPanel = true;
+ if (IgnoreEnter) return;
+ _MyTransparentPanel.SendToBack();
- // Set whether this worddoc is in view/edit mode by checking whether the
- // procedure is in view/edit mode (based on the steppanel. This occurs on
- // the enter event so that the mode is determined any time this panel becomes
- // active.
- // find steptabpanel and its view/edit. If it doesn't have a steptabpanel
- // use default - edit. Later when we have ownership, need to use that.
+ // Set whether this worddoc is in view/edit mode by checking whether the
+ // procedure is in view/edit mode (based on the steppanel. This occurs on
+ // the enter event so that the mode is determined any time this panel becomes
+ // active.
+ // find steptabpanel and its view/edit. If it doesn't have a steptabpanel
+ // use default - edit. Later when we have ownership, need to use that.
PanelViewEditMode = E_ViewMode.Edit; // default to edit
- if (MyDisplayTabItem.MyItemInfo != null) // lib doc with no associated active procedure defaults to edit
- {
- StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo);
- PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode;
- }
- try
- {
- //_MyDSOFramer.EventsEnabled = true;
- //_MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
- }
- catch (Exception ex)
- {
- if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
- }
- if (_In_DSOTabPanel_Enter) return;
- //vlnStackTrace.ShowStack("DSOTabPanel_Enter {0} DocID {1} Index {2} {3}",_In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
- _In_DSOTabPanel_Enter = true;
+ if (MyDisplayTabItem.MyItemInfo != null) // lib doc with no associated active procedure defaults to edit
+ {
+ StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo);
+ PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode;
+ }
+ try
+ {
+ //_MyDSOFramer.EventsEnabled = true;
+ //_MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
+ }
+ catch (Exception ex)
+ {
+ if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
+ }
+ if (_In_DSOTabPanel_Enter) return;
+ //vlnStackTrace.ShowStack("DSOTabPanel_Enter {0} DocID {1} Index {2} {3}",_In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
+ _In_DSOTabPanel_Enter = true;
if (MyDisplayTabItem.MyItemInfo != null)
_MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyDisplayTabItem.MyItemInfo));
- _MyEdWord.Focus();
- _In_DSOTabPanel_Enter = false;
- _MyDisplayTabControl.SelectedDisplayTabItem = MyDisplayTabItem;
- // B2018-070 Position the text cursor - Activate MS Word Panel
- _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null);
- }
- #endregion
- #region Public Methods
- private bool _IsBeingDeleted = false;
- public bool IsBeingDeleted
- {
- get { return _IsBeingDeleted; }
- set { _IsBeingDeleted = value; }
- }
- ///
- /// Cleans-up the DSO Framer window
- ///
- ///
- public bool CloseDSO()
- {
- return CloseDSO(false);
- }
- ///
- /// Cleans-up the DSO Framer window
- ///
- ///
- ///
- public bool CloseDSO(bool force)
- {
- _MyLog.Debug("CloseDSO");
- bool result = true;
- try
- {
- if (_MyEdWord != null)
- {
- SaveDSO_Phase1();
- _MyEdWord.CloseDoc();
- Controls.Remove(_MyEdWord);
- components.Remove(_MyEdWord);
- _MyEdWord.Dispose();
- _MyEdWord = null;
- // B2017-249 Recover Temporary File And AutoSave support for MSWord
- if (DeleteOnClose) MyDSOFile.MyFile.Delete();
- _Count--;
- }
- }
- catch (Exception ex)
- {
- if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO - " + this.Name, ex);
- result = false;
- }
- return result;
- }
- ///
- /// Activates the current DSO Framer window (Word)
- ///
- public void Activate()
- {
- try
- {
- //this._MyEdWord.Activate();
- //if (_MyCount <= MSWordLimit)
- // this._MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
- }
- catch (Exception ex)
- {
- if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex);
- }
- }
- #endregion
- #region DocumentProperties
+ _MyEdWord.Focus();
+ _In_DSOTabPanel_Enter = false;
+ _MyDisplayTabControl.SelectedDisplayTabItem = MyDisplayTabItem;
+ // B2018-070 Position the text cursor - Activate MS Word Panel
+ _MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToObject, EDWordLib.WdGoToDirection.wdGoToNext, 0, null);
+ }
+ #endregion
+ #region Public Methods
+ private bool _IsBeingDeleted = false;
+ public bool IsBeingDeleted
+ {
+ get { return _IsBeingDeleted; }
+ set { _IsBeingDeleted = value; }
+ }
+ ///
+ /// Cleans-up the DSO Framer window
+ ///
+ ///
+ public bool CloseDSO()
+ {
+ return CloseDSO(false);
+ }
+ ///
+ /// Cleans-up the DSO Framer window
+ ///
+ ///
+ ///
+ public bool CloseDSO(bool force)
+ {
+ _MyLog.Debug("CloseDSO");
+ bool result = true;
+ try
+ {
+ if (_MyEdWord != null)
+ {
+ SaveDSO_Phase1();
+ _MyEdWord.CloseDoc();
+ Controls.Remove(_MyEdWord);
+ components.Remove(_MyEdWord);
+ _MyEdWord.Dispose();
+ _MyEdWord = null;
+ // B2017-249 Recover Temporary File And AutoSave support for MSWord
+ if (DeleteOnClose) MyDSOFile.MyFile.Delete();
+ _Count--;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO - " + this.Name, ex);
+ result = false;
+ }
+ return result;
+ }
+ ///
+ /// Activates the current DSO Framer window (Word)
+ ///
+ public void Activate()
+ {
+ try
+ {
+ //this._MyEdWord.Activate();
+ //if (_MyCount <= MSWordLimit)
+ // this._MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
+ }
+ catch (Exception ex)
+ {
+ if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex);
+ }
+ }
+ #endregion
+ #region DocumentProperties
- private string GetReflectiveProperty(object objectToInspect, string propertyName)
- {
- string returnString = "";
- //To use reflection on an object, you
- // first need to get an instance
- // of that object's type.
- Type objectType = objectToInspect.GetType();
- //After you have the object's type, you can get
- // information on that type. In this case, we're
- // asking the type to tell us all the
- // properties that it contains.
- PropertyInfo[] properties = objectType.GetProperties();
- //You can then use the PropertyInfo array
- // to loop through each property of the type.
- foreach (PropertyInfo property in properties)
- {
- //The interest part of this code
- // is the GetValue method. This method
- // returns the value of the property.
+ private string GetReflectiveProperty(object objectToInspect, string propertyName)
+ {
+ string returnString = "";
+ //To use reflection on an object, you
+ // first need to get an instance
+ // of that object's type.
+ Type objectType = objectToInspect.GetType();
+ //After you have the object's type, you can get
+ // information on that type. In this case, we're
+ // asking the type to tell us all the
+ // properties that it contains.
+ PropertyInfo[] properties = objectType.GetProperties();
+ //You can then use the PropertyInfo array
+ // to loop through each property of the type.
+ foreach (PropertyInfo property in properties)
+ {
+ //The interest part of this code
+ // is the GetValue method. This method
+ // returns the value of the property.
if(property.Name == propertyName)
- return property.GetValue(objectToInspect, null).ToString();
- }
- return null;
- }
- #endregion
- public override string ToString()
- {
- return string.Format("DSOTabPanel Document {0}", MyDocumentInfo.DocID);
- }
- }
+ return property.GetValue(objectToInspect, null).ToString();
+ }
+ return null;
+ }
+ #endregion
+ public override string ToString()
+ {
+ return string.Format("DSOTabPanel Document {0}", MyDocumentInfo.DocID);
+ }
+ }
}