From 97b3281553b54c16292cd4d45bd11a8cfe79e54b Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 22 Feb 2018 18:44:13 +0000 Subject: [PATCH] B2018-038 MathType replaces EQNEDT32.EXE --- .../Volian.Controls.Library/StepTabRibbon.cs | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index 49579e06..491596fb 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -1171,17 +1171,43 @@ namespace Volian.Controls.Library folderPath = @"C:\Program Files\Common Files\Microsoft Shared\EQUATION\EQNEDT32.EXE"; fi = new System.IO.FileInfo(folderPath); if (fi.Exists) return fi.FullName; - // B2018-038 MathType replaces EqnEdt32.EXE - //folderPath = @"C:\Program Files\MathType\MathType.EXE"; - //fi = new System.IO.FileInfo(folderPath); - //if (fi.Exists) return fi.FullName; return null; } if (retval == null) _MyLog.WarnFormat("Equation Editor executable could not be found."); return retval; } - + // B2018-038 MathType Replacement for EQNEDT32.EXE + private static string GetMathType() + { + string retval = null; + try + { + RegistryKey key = Registry.ClassesRoot; + string rootName = key.Name; + string clsid = GetDefaultKeyValue(key.Name + "\\DSEquations\\CLSID"); + retval = GetDefaultKeyValue(key.Name + "\\CLSID\\" + clsid + "\\LocalServer32"); + } + catch (Exception ex) + { + _MyLog.WarnFormat("MathType Equation Editor is not correctly configured in the registry."); + string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); + folderPath += @"\MathType\MathType.EXE"; + System.IO.FileInfo fi = new System.IO.FileInfo(folderPath); + if (fi.Exists) return fi.FullName; + folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).Replace(" (x86)", ""); + folderPath += @"\MathType\MathType.EXE"; + fi = new System.IO.FileInfo(folderPath); + if (fi.Exists) return fi.FullName; + folderPath = @"C:\Program Files\\MathType\MathType.EXE"; + fi = new System.IO.FileInfo(folderPath); + if (fi.Exists) return fi.FullName; + return null; + } + if (retval == null) + _MyLog.WarnFormat("Equation Editor executable could not be found."); + return retval; + } private static string GetVisio() // Added support for Visio { string retval = _SpecifiedVisioPath; // use the Visio path specified by the user @@ -1230,6 +1256,7 @@ namespace Volian.Controls.Library { _OleObjectEditors = 0;// no OLE Object Editors _EqnEdtPath = GetEqnEdt(); + if (_EqnEdtPath == null) _EqnEdtPath = GetMathType();// B2018-038 MathType Replacement for EQNEDT32.EXE // B2017-067 check for empty string as well as a null for paths to the Equation Editor and Visio if (_EqnEdtPath != null && _EqnEdtPath != "") _OleObjectEditors += 1; _VisioPath = GetVisio();