public override void Launch(LaunchConfig config) { switch (_cmdName.Trim()) { case "RegisterExplorerContextMenu": { if (ShellIntegration.RegisterContextMenu()) { ErrorLog.Inst.ShowInfo("Explorer Context Menu Registration Completed."); } } break; case "WriteConfigRegistryValues": { var launchTool = Editors.EditorFactory.Inst.GetEditor(RuntimeInfo.Generic); launchTool.UpdateRegistry(Configs_Root.Inst.Configs); ErrorLog.Inst.ShowInfo("Environment Registry Integration completed"); } break; case "UpdatePythonScriptFolder": { var pythonEnv = new PythonEnvironment(); pythonEnv.UpdateScripts(Configs_Root.Inst); ErrorLog.Inst.ShowInfo("Updating Python Environment Scripts folder is completed"); } break; } }
private void ShowFileProperties() { // get the unique set of files from the selections List <string> files = new List <string>(); foreach (var item in inputData.SelectedItems) { var fileNode = item as FormattedGrepResult; if (fileNode != null) { string name = fileNode.GrepResult.FileNameReal; if (!files.Contains(name) && File.Exists(name)) { files.Add(name); } } var lineNode = item as FormattedGrepLine; if (lineNode != null) { string name = lineNode.Parent.GrepResult.FileNameReal; if (!files.Contains(name) && File.Exists(name)) { files.Add(name); } } } foreach (var fileName in files) { ShellIntegration.ShowFileProperties(fileName); } }
public void ShellExtInstall(bool val, string path) { try { if (path == "") { path = System.Reflection.Assembly.GetEntryAssembly().Location; } string[] ext = new string[1] { "*" }; string icon = path.Replace(".exe", APPDATA_ICON_APP); if (!val) { if (ShellIntegration.IsExtension(ext, SHELL_EXTENSION_NAME, path)) { if (Admin.ElevateAndIfNotRestart()) { BslSettings.Instance.GeneralShellExtInstallForce = true; Application.Current.Shutdown(); } ShellIntegration.ExtensionsRemove(ext, SHELL_EXTENSION_NAME); } } else { if (!ShellIntegration.IsExtension(ext, SHELL_EXTENSION_NAME, path)) { if (Admin.ElevateAndIfNotRestart()) { BslSettings.Instance.GeneralShellExtInstallForce = true; Application.Current.Shutdown(); } ShellIntegration.ExtensionsRemove(ext, SHELL_EXTENSION_NAME); ShellIntegration.ExtensionsAdd(ext, SHELL_EXTENSION_NAME, path, icon); } } } catch (Exception) { } }
private void btnShowFileProperties_Click(object sender, RoutedEventArgs e) { string fileName = ""; if (tvSearchResult.SelectedItem is FormattedGrepLine) { FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem; fileName = selectedNode.Parent.GrepResult.FileNameReal; } else if (tvSearchResult.SelectedItem is FormattedGrepResult) { FormattedGrepResult selectedNode = (FormattedGrepResult)tvSearchResult.SelectedItem; fileName = selectedNode.GrepResult.FileNameReal; } if (fileName != "" && File.Exists(fileName)) { ShellIntegration.ShowFileProperties(fileName); } }
private static void Main(params string[] folders) { if (folders?.Length == 1) { var command = folders[0].Trim('/', '-'); if (string.Equals(command, "uninstall", StringComparison.OrdinalIgnoreCase) || string.Equals(command, "remove", StringComparison.OrdinalIgnoreCase)) { ShellIntegration.Remove(); Environment.Exit(0); return; } } if (Settings.Default.EnableShellIntegration) { Task.Run(ShellIntegration.Create); } Application.ApplicationExit += (sender, args) => History.Default.Save(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += (sender, args) => LogUnhandledException(args.Exception, "Uncaught thread exception"); AppDomain.CurrentDomain.UnhandledException += (sender, args) => LogUnhandledException( args.ExceptionObject as Exception, $"Uncaught exception: {sender}, terminating: {args.IsTerminating}"); TaskScheduler.UnobservedTaskException += (sender, args) => { LogUnhandledException(args.Exception, $"Uncaught task exception: {sender}"); args.SetObserved(); }; Mediator.Run(folders); }
private void EnableShellCheck_CheckedChanged(object sender, EventArgs e) { ProgressWindowCheck.Enabled = OpenUiCheck.Enabled = EnableShellCheck.Checked; if (EnableShellCheck.Checked) { if (!_isStartup) { ShellIntegration.Create(); } } else { if (!_isStartup) { ShellIntegration.Remove(); } OpenUiCheck.Checked = Settings.Default.ShowUiFromShell = false; ProgressWindowCheck.Checked = Settings.Default.ShowProgressWindow = false; } }
protected override bool LaunchCustom(LaunchConfig config) { switch (Tool.Path.Trim()) { case "RegisterExplorerContextMenu": { if (ShellIntegration.RegisterContextMenu()) { ErrorLog.Inst.ShowInfo("Explorer Context Menu Registration Completed."); } } break; case "WriteConfigRegistryValues": { UpdateConfigRegistry(Configs_Root.Inst.Configs); ErrorLog.Inst.ShowInfo("Environment Registry Integration completed"); } break; case "UpdatePythonScriptFolder": { UpdatePythonScripts(Configs_Root.Inst); ErrorLog.Inst.ShowInfo("Updating Python Environment Scripts folder is completed"); } break; default: { ErrorLog.Inst.ShowError("Unable to find known command: {0}", Tool.Path); } break; } return(false); }
public void ShellAssocInstall(bool val, string path) { try { if (path == "") { path = System.Reflection.Assembly.GetEntryAssembly().Location; } string[] extension = new string[7] { ".hex", ".out", ".elf", ".s", ".srec", ".s19", ".eep" }; string[] progID = new string[7] { "BSL430.NET.Firmware.IntelHEX", "BSL430.NET.Firmware.ELF", "BSL430.NET.Firmware.ELF", "BSL430.NET.Firmware.SREC", "BSL430.NET.Firmware.SREC", "BSL430.NET.Firmware.SREC", "BSL430.NET.Firmware.EEPROM" }; string[] desc = new string[7] { "Intel-HEX Firmware", "ELF Firmware", "ELF Firmware", "SREC Firmware", "SREC Firmware", "SREC Firmware", "EEPROM File" }; string icon = path.Replace(".exe", APPDATA_ICON_FILE); if (!val) { if (ShellIntegration.IsAssociated(extension, progID, path)) { if (Admin.ElevateAndIfNotRestart()) { BslSettings.Instance.GeneralShellAssocInstallForce = true; Application.Current.Shutdown(); } ShellIntegration.Deassociate(extension, progID); } } else { if (!ShellIntegration.IsAssociated(extension, progID, path)) { if (Admin.ElevateAndIfNotRestart()) { BslSettings.Instance.GeneralShellAssocInstallForce = true; Application.Current.Shutdown(); } ShellIntegration.Deassociate(extension, progID); ShellIntegration.Associate(extension, progID, desc, icon, path); } } bool isWin10 = (ShellIntegration.CurrentOS().Contains("Windows 10")); // rebuild icon cache try { using (Process process = new Process()) { ProcessStartInfo info = new ProcessStartInfo { WindowStyle = ProcessWindowStyle.Hidden, FileName = @"c:\windows\sysnative\ie4uinit.exe", Arguments = (isWin10 ? "-show" : "-ClearIconCache") }; process.StartInfo = info; process.Start(); } } catch (Exception) { } } catch (Exception ex) { System.Windows.Application.Current.Dispatcher.Invoke((System.Action)(() => { var result = MessageBox.Show($"Shell Association Failed!\n{ex.Message}", "BSL430.NET", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); })); } }