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:
		@@ -1,7 +1,7 @@
 | 
				
			|||||||
//------------------------------------------------------------------------------
 | 
					//------------------------------------------------------------------------------
 | 
				
			||||||
// <auto-generated>
 | 
					// <auto-generated>
 | 
				
			||||||
//     This code was generated by a tool.
 | 
					//     This code was generated by a tool.
 | 
				
			||||||
//     Runtime Version:4.0.30319.18444
 | 
					//     Runtime Version:4.0.30319.42000
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//     Changes to this file may cause incorrect behavior and will be lost if
 | 
					//     Changes to this file may cause incorrect behavior and will be lost if
 | 
				
			||||||
//     the code is regenerated.
 | 
					//     the code is regenerated.
 | 
				
			||||||
@@ -375,19 +375,28 @@ namespace VEPROMS.Properties {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
				[global::System.Configuration.UserScopedSettingAttribute()]
 | 
					        [global::System.Configuration.UserScopedSettingAttribute()]
 | 
				
			||||||
				[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
 | 
					        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
 | 
				
			||||||
				[global::System.Configuration.DefaultSettingValueAttribute("False")]
 | 
					        [global::System.Configuration.DefaultSettingValueAttribute("False")]
 | 
				
			||||||
				public bool SeparateWindows
 | 
					        public bool SeparateWindows {
 | 
				
			||||||
				{
 | 
					            get {
 | 
				
			||||||
					get
 | 
					                return ((bool)(this["SeparateWindows"]));
 | 
				
			||||||
					{
 | 
					            }
 | 
				
			||||||
						return ((bool)(this["SeparateWindows"]));
 | 
					            set {
 | 
				
			||||||
					}
 | 
					                this["SeparateWindows"] = value;
 | 
				
			||||||
					set
 | 
					            }
 | 
				
			||||||
					{
 | 
					        }
 | 
				
			||||||
						this["SeparateWindows"] = value;
 | 
					        
 | 
				
			||||||
					}
 | 
					        [global::System.Configuration.UserScopedSettingAttribute()]
 | 
				
			||||||
				}
 | 
					        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
 | 
				
			||||||
		}
 | 
					        [global::System.Configuration.DefaultSettingValueAttribute("")]
 | 
				
			||||||
 | 
					        public string VisioPath {
 | 
				
			||||||
 | 
					            get {
 | 
				
			||||||
 | 
					                return ((string)(this["VisioPath"]));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            set {
 | 
				
			||||||
 | 
					                this["VisioPath"] = value;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,5 +95,8 @@
 | 
				
			|||||||
    <Setting Name="SeparateWindows" Type="System.Boolean" Scope="User">
 | 
					    <Setting Name="SeparateWindows" Type="System.Boolean" Scope="User">
 | 
				
			||||||
      <Value Profile="(Default)">False</Value>
 | 
					      <Value Profile="(Default)">False</Value>
 | 
				
			||||||
    </Setting>
 | 
					    </Setting>
 | 
				
			||||||
 | 
					    <Setting Name="VisioPath" Type="System.String" Scope="User">
 | 
				
			||||||
 | 
					      <Value Profile="(Default)" />
 | 
				
			||||||
 | 
					    </Setting>
 | 
				
			||||||
  </Settings>
 | 
					  </Settings>
 | 
				
			||||||
</SettingsFile>
 | 
					</SettingsFile>
 | 
				
			||||||
@@ -18,6 +18,12 @@ namespace Volian.Controls.Library
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	public partial class StepTabRibbon : UserControl
 | 
						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;
 | 
							private static bool _PastePlainTextSetting = false;
 | 
				
			||||||
		public static bool PastePlainTextSetting
 | 
							public static bool PastePlainTextSetting
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -1035,7 +1041,6 @@ namespace Volian.Controls.Library
 | 
				
			|||||||
				switch (OleObjectEditors)
 | 
									switch (OleObjectEditors)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					case 0: // None
 | 
										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);
 | 
											MessageBox.Show("The Equation Editor needs to be started.", "Reminder", MessageBoxButtons.OK);
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
					case 1: // Equation Editor
 | 
										case 1: // Equation Editor
 | 
				
			||||||
@@ -1073,6 +1078,7 @@ namespace Volian.Controls.Library
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			catch (Exception ex)
 | 
								catch (Exception ex)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
 | 
									_MyLog.WarnFormat("Equation Editor is not correctly configured in the registry.");
 | 
				
			||||||
				string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
 | 
									string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
 | 
				
			||||||
				folderPath += @"\Common Files\Microsoft Shared\EQUATION\EQNEDT32.EXE";
 | 
									folderPath += @"\Common Files\Microsoft Shared\EQUATION\EQNEDT32.EXE";
 | 
				
			||||||
				System.IO.FileInfo fi = new System.IO.FileInfo(folderPath);
 | 
									System.IO.FileInfo fi = new System.IO.FileInfo(folderPath);
 | 
				
			||||||
@@ -1086,26 +1092,39 @@ namespace Volian.Controls.Library
 | 
				
			|||||||
				if (fi.Exists) return fi.FullName;
 | 
									if (fi.Exists) return fi.FullName;
 | 
				
			||||||
				return null;
 | 
									return null;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if (retval == null)
 | 
				
			||||||
 | 
									_MyLog.WarnFormat("Equation Editor executable could not be found.");
 | 
				
			||||||
			return retval;
 | 
								return retval;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private static string GetVisio() // Added support for Visio
 | 
							private static string GetVisio() // Added support for Visio
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			string retval = null;
 | 
								string retval = _SpecifiedVisioPath; // use the Visio path specified by the user
 | 
				
			||||||
			try
 | 
								if (retval != null && retval != "")
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				RegistryKey key = Registry.ClassesRoot;
 | 
									if (!retval.ToUpper().EndsWith(".EXE"))
 | 
				
			||||||
				string rootName = key.Name;
 | 
										retval += (retval.EndsWith("\\")) ? "visio.exe" : "\\visio.exe";
 | 
				
			||||||
				string curVer = GetDefaultKeyValue(key.Name + "\\Visio.Drawing\\CurVer");
 | 
									if (!File.Exists(retval)) // visio path was invalid, so try the registry next
 | 
				
			||||||
				string clsid = GetDefaultKeyValue(key.Name + "\\" + curVer + "\\CLSID");
 | 
									{
 | 
				
			||||||
				retval = GetDefaultKeyValue(key.Name + "\\CLSID\\" + clsid + "\\LocalServer32");
 | 
										_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));
 | 
									try
 | 
				
			||||||
				string path = FindFile(di, "visio.exe");
 | 
									{
 | 
				
			||||||
				if (path != null) return path;
 | 
										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;
 | 
							private static string _EqnEdtPath = null;
 | 
				
			||||||
		public static string EqnEdtPath
 | 
							public static string EqnEdtPath
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user