public EditStringEvent(IOneString str, IEditableFile containerFile = null, bool scrollToEnd = true, string prev = "") { StringToEdit = str; ContainerFile = containerFile; Typed = prev; ScrollToEnd = scrollToEnd; }
private static IDictionaryFile CreateDictionary(IXmlFile first, IXmlFile second, string resultFilename) { var result = new DictionaryFile(resultFilename); var strings = second.SpecDetails.ToList(); if (Path.GetFileName(first.FileName) == "strings.xml") { foreach (var str in first.Details) { IOneString item = second.Details.FirstOrDefault(it => it.Name == str.Name); if (item != null && item.OldText != str.OldText) { result.Add(str.OldText, item.OldText); } } } else { foreach (var sourceString in first.SpecDetails) { IOneString item = strings.FirstOrDefault(targetString => sourceString.EqualsNavigations(targetString)); if (item != null && sourceString.OldText != item.OldText) { result.Add(sourceString.OldText, item.OldText); } } } return(result); }
public OneFoundItem(string fileName, string text, IOneString str) { FileName = fileName; FormattedName = _globalVariables.CurrentProjectFolder.Value == null ? fileName : "..." + fileName.Remove(0, _globalVariables.CurrentProjectFolder.Value.Length); Text = text; EditString = str; }
private void FindFilesCommand_Execute() { if (_globalVariables.CurrentProjectFolder.Value.IsNullOrEmpty()) { MessBox.ShowDial(StringResources.SearchWindow_FolderIsNotSelected); return; } string GetFormattedName(string fileName) { return(StartFormattedString + fileName.Substring(_globalVariables.CurrentProjectFolder.Value.Length + 1)); } AddToSearchAdds(TextToSearch.Value); var filesToAdd = new List <FoundItem>(); LoadingProcessWindow.ShowWindow( beforeStarting: () => IsBusy = true, threadActions: (cts, invoker) => { var projectFolder = _globalVariables.CurrentProjectFolder.Value; var buildFolder = Path.DirectorySeparatorChar + "build"; var buildFolderM = Path.DirectorySeparatorChar + "build" + Path.DirectorySeparatorChar; List <string> xmlFiles = Directory.EnumerateFiles(projectFolder, "*.xml", SearchOption.AllDirectories) .Where(file => { // ReSharper disable once PossibleNullReferenceException var dir = Path.GetDirectoryName(file).Substring(projectFolder.Length); return(dir != buildFolder && !dir.StartsWith(buildFolderM, StringComparison.Ordinal)); } ) .ToList(); List <string> smaliFiles = Directory.EnumerateFiles(projectFolder, "*.smali", SearchOption.AllDirectories).ToList(); invoker.ProcessValue = 0; invoker.ProcessMax = xmlFiles.Count + smaliFiles.Count; bool onlyFullWords = OnlyFullWords.Value; bool matchCase = MatchCase.Value; Func <string, string, bool> checkRules; if (!matchCase && !onlyFullWords) { checkRules = (f, s) => f.IndexOf(s, StringComparison.OrdinalIgnoreCase) != -1; } else if (!matchCase /*&& onlyFullWords*/) { checkRules = (f, s) => f.Equals(s, StringComparison.OrdinalIgnoreCase); } else if (/*matchCase &&*/ !onlyFullWords) { checkRules = (f, s) => f.IndexOf(s, StringComparison.Ordinal) != -1; } else /*if (matchCase && onlyFullWords)*/ { checkRules = (f, s) => f.Equals(s, StringComparison.Ordinal); } IEnumerable <IEditableFile> union = xmlFiles.SelectSafe <string, IEditableFile>(XmlFile.Create) .Concat(smaliFiles.SelectSafe(it => new SmaliFile(it))); foreach (IEditableFile file in union) { cts.ThrowIfCancellationRequested(); IOneString found = file.Details?.FirstOrDefault(str => checkRules(str.OldText, TextToSearch.Value)); if (found != null) { filesToAdd.Add(new FoundItem(GetFormattedName(file.FileName), found.OldText)); } invoker.ProcessValue++; } }, finishActions: () => { IsBusy = false; if (filesToAdd.Count == 0) { Files.Clear(); MessBox.ShowDial(StringResources.TextNotFound); } else { Files.ReplaceRange(filesToAdd); } }, ownerWindow: _window ); }