Added ability for user to enter the path to Visio

Use the user specified path to Visio, else look in the registry
This commit is contained in:
2017-03-20 20:32:39 +00:00
parent ca9e0b2c1c
commit dd65177acd
3 changed files with 61 additions and 30 deletions

View File

@@ -18,6 +18,12 @@ namespace Volian.Controls.Library
{
public partial class StepTabRibbon : UserControl
{
private static string _SpecifiedVisioPath = null;
public static string SpecifiedVisioPath
{
get { return StepTabRibbon._SpecifiedVisioPath; }
set { StepTabRibbon._SpecifiedVisioPath = value; }
}
private static bool _PastePlainTextSetting = false;
public static bool PastePlainTextSetting
{
@@ -1035,7 +1041,6 @@ namespace Volian.Controls.Library
switch (OleObjectEditors)
{
case 0: // None
_MyLog.WarnFormat("Equation Editor is not correctly configured in the registry.");
MessageBox.Show("The Equation Editor needs to be started.", "Reminder", MessageBoxButtons.OK);
break;
case 1: // Equation Editor
@@ -1073,6 +1078,7 @@ namespace Volian.Controls.Library
}
catch (Exception ex)
{
_MyLog.WarnFormat("Equation Editor is not correctly configured in the registry.");
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
folderPath += @"\Common Files\Microsoft Shared\EQUATION\EQNEDT32.EXE";
System.IO.FileInfo fi = new System.IO.FileInfo(folderPath);
@@ -1086,26 +1092,39 @@ namespace Volian.Controls.Library
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 = null;
try
string retval = _SpecifiedVisioPath; // use the Visio path specified by the user
if (retval != null && retval != "")
{
RegistryKey key = Registry.ClassesRoot;
string rootName = key.Name;
string curVer = GetDefaultKeyValue(key.Name + "\\Visio.Drawing\\CurVer");
string clsid = GetDefaultKeyValue(key.Name + "\\" + curVer + "\\CLSID");
retval = GetDefaultKeyValue(key.Name + "\\CLSID\\" + clsid + "\\LocalServer32");
if (!retval.ToUpper().EndsWith(".EXE"))
retval += (retval.EndsWith("\\")) ? "visio.exe" : "\\visio.exe";
if (!File.Exists(retval)) // visio path was invalid, so try the registry next
{
_MyLog.WarnFormat("Specified Visio Path is Invalid: {0}",retval);
retval = null; // look in the registry
}
}
catch (Exception)
if (retval == null || retval == "")
{
DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
string path = FindFile(di, "visio.exe");
if (path != null) return path;
try
{
RegistryKey regVersionString = Registry.ClassesRoot.OpenSubKey("Visio.Drawing\\CurVer");
RegistryKey regClassId = Registry.ClassesRoot.OpenSubKey(regVersionString.GetValue("") + "\\CLSID");
RegistryKey regInstallPath = Registry.ClassesRoot.OpenSubKey("CLSID\\" + regClassId.GetValue("") + "\\LocalServer32");
retval = Path.GetFullPath(regInstallPath.GetValue("").ToString()); // this will convert a short file/folder names to long file/folder names
}
catch
{
_MyLog.WarnFormat("Visio was not found in the registry.");
}
}
return retval;
return retval;
}
private static string _EqnEdtPath = null;
public static string EqnEdtPath