Exemplo n.º 1
0
        /// <summary>
        /// Creating experiment tree from experiment directory :)
        /// </summary>
        /// <param name="rootPath">Absolute path to the root experiment folder</param>
        /// <param name="selectedPath">Relative (including root) path to the selected experiment</param>
        /// <param name="loadedPath">Relative (including root) path to the loaded experiment</param>
        public static Experiment Load(string rootPath, string selectedPath, string loadedPath)
        {
            var exp = new Experiment();

            exp.Path = rootPath;

            var expDataFileName = Directory.GetFiles(rootPath, "*" + ExperimentData.EXPERIMENT_DATA_POSTFIX).FirstOrDefault();

            if (!string.IsNullOrWhiteSpace(expDataFileName))
            {
                exp.Data = ExperimentData.Load(expDataFileName);
            }

            exp.Number = SysAdmin.ExtractExperimentNumberFromPath(rootPath);

            string selectedRoot = SysAdmin.GetRootDirectory(selectedPath);

            exp.IsOpen = selectedRoot.EndsWith(string.Format(@"#{0}\", exp.Number));

            string loadedRoot = SysAdmin.GetRootDirectory(loadedPath);

            exp.IsLoaded = loadedRoot.EndsWith(string.Format(@"#{0}\", exp.Number));

            string s1 = (selectedPath.Contains(selectedRoot) && !string.IsNullOrWhiteSpace(selectedRoot)) ? selectedPath.Replace(selectedRoot, "") : string.Empty;
            string s2 = (loadedPath.Contains(loadedRoot) && !string.IsNullOrWhiteSpace(loadedRoot)) ? loadedPath.Replace(loadedRoot, "") : string.Empty;

            exp.BuildTree(rootPath, s1, s2);

            return(exp);
        }
Exemplo n.º 2
0
        private void BuildTree(string rootPath, string selectedPath, string loadedPath)
        {
            var subDirs = Directory.GetDirectories(rootPath, "#*");

            foreach (string subDir in subDirs)
            {
                int n   = SysAdmin.ExtractExperimentNumberFromPath(subDir);
                var exp = Experiment.Load(subDir, selectedPath + '\\', loadedPath + '\\');
                this.ChildNodes.Add(exp);

                //exp.BuildTree(subDir);
            }
        }