public static bool Load(string path) { try { using (FileStream zipToOpen = new FileStream(path, FileMode.Open)) { var pd = new UserControls.ProgressDialog(); using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Read, false, Encoding.UTF8)) { pd.Show(MainWindow.Instance); pd.Message = "データの読み込み中"; LoadAll(archive, pd); pd.Message = "グラフの読み込み中"; LoadGraph(archive, pd); } pd.Close(); } FilePath = path; } catch (Exception ex) { Log.Output(ex.Message); return(false); } return(true); }
static void LoadGraph(ZipArchive archive, UserControls.ProgressDialog pd = null) { var node = UserControls.GraphViewer.TopNode.Load(archive, MainWindow.GraphTreeView, pd); MainWindow.GraphTreeView.Nodes.Clear(); MainWindow.GraphTreeView.Nodes.Add(node); node.Expand(); }
static void LoadAll(ZipArchive archive, UserControls.ProgressDialog pd = null) { List <string> FolderTree = new List <string>(); foreach (var entry in archive.Entries) { if (entry.FullName.Contains("node.xml")) { FolderTree.Add(Path.GetDirectoryName(entry.FullName)); } } FolderTree.Sort(); FolderTree.Reverse(); if (pd != null) { pd.Maximum = FolderTree.Count; pd.Value = 0; } ProjectNode = LoadAll(null, archive, "", FolderTree, pd) as ProjectTree.Node_Project; ProjectNode.OnStateChanged += DataStateChangedImpl; DataStateChangedImpl(ProjectNode.State); }
static ProjectTree.ProjectTreeNode LoadAll(ProjectTree.ProjectTreeNode parent, ZipArchive archive, string path, List <string> folderTree, UserControls.ProgressDialog pd = null) { var lastPath = folderTree.Last(); while (lastPath != null && lastPath.Contains(path)) { var node = ProjectTree.ProjectTreeNode.Load(archive, lastPath + "\\", parent); if (pd != null) { ++pd.Value; } folderTree.RemoveAt(folderTree.Count - 1); if (folderTree.Count == 0) { return(node); } LoadAll(node, archive, lastPath, folderTree, pd); if (folderTree.Count == 0) { return(node); } lastPath = folderTree.Last(); } return(null); }