void Start() { string shortcut = (PickShortcut != null ? PickShortcut : "Control+MiddleClick"); LOGGER.debug("Using pick shortcut: {0}", shortcut); partPickerShortcut = ShortcutHelper.CompileShortcut(shortcut); }
private Shortcut DiscoverShortcut(string path, ShortcutPattern pattern) { Shortcut shortcut = null; if (!string.IsNullOrEmpty(pattern.PathPattern)) { var match = Regex.Match(path, pattern.PathPattern.Replace("\\", "\\\\")); if (match.Success && pattern.InnerPathPatterns.Any() && _fileSystem.DirectoryExists(path)) { foreach (var innerPath in _fileSystem.DirectoryList(path)) { if (!pattern.InnerPathPatterns.All(p => Regex.IsMatch(innerPath, p))) { match = null; } } } if (match?.Success == true) { var name = Path.GetFileName(path); var location = pattern.Location; if (string.IsNullOrWhiteSpace(location)) { location = match.Groups["location"].Value; } if (string.IsNullOrWhiteSpace(location)) { location = Path.GetFileName(pattern.RootDirectory); } shortcut = new Shortcut(name, location, path); } } return(shortcut); }