Пример #1
0
        public void ImportGroups(string filePath)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var json   = File.ReadAllText(filePath);
            var import = JsonConvert.DeserializeObject <ExportData>(json);

            if (SolutionName != import.SolutionName)
            {
                var window = new ImportGroupsConfirmOverwriteWindow();
                if (window.ShowDialog() == true)
                {
                    var originalSolutionName = import.SolutionName;
                    var newSolutionName      = SolutionName;
                    var originalSolutionPath = Path.GetDirectoryName(originalSolutionName);
                    var newSolutionPath      = Path.GetDirectoryName(newSolutionName);
                    foreach (var group in import.Tabs)
                    {
                        var newFiles = new DocumentFilesHashSet();
                        foreach (var file in group.Files)
                        {
                            if (file.StartsWith(originalSolutionPath, StringComparison.OrdinalIgnoreCase))
                            {
                                var fileRelativePath = file.Substring(originalSolutionPath.Length + 1);
                                newFiles.Add(Path.Combine(newSolutionPath, fileRelativePath));
                            }
                            else
                            {
                                newFiles.Add(file);
                            }
                        }
                        group.Files       = newFiles;
                        group.Description = String.Join(", ", group.Files.Select(Path.GetFileName));
                        group.Positions   = null;
                    }
                    import.SolutionName = newSolutionName;
                }
            }
            SaveGroupsForSolution(import.SolutionName, import.Tabs);
            if (SolutionName == import.SolutionName)
            {
                LoadGroups();
            }
        }
Пример #2
0
        public void ImportGroups(string filePath)
        {
            var json   = File.ReadAllText(filePath);
            var import = JsonConvert.DeserializeObject <ExportData>(json);

            if (SolutionName != import.SolutionName)
            {
                var window = new ImportGroupsConfirmOverwriteWindow();
                if (window.ShowDialog() == true)
                {
                    TranslateSolutionPaths(import, SolutionName);
                }
            }
            SaveGroupsForSolution(import.SolutionName, import.Groups);
            if (SolutionName == import.SolutionName)
            {
                LoadGroups();
            }
        }