Exemplo n.º 1
0
        /// <summary>
        /// Füllt das TreeControl rekursiv
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private TreeNode createRootNode(ConfigFile file)
        {
            string filename = file.Path.Substring(file.Path.LastIndexOf('\\') + 1); //TODO filename prop
            TreeNode node = new TreeNode(filename);
            node.Tag = file.Path;

            ValidationLevel state = file.getValidationLevel();
            switch (state)
            {
                case ValidationLevel.Unknown:
                    node.BackColor = Color.LightGray;
                    break;
                case ValidationLevel.Ok:
                    break;
                case ValidationLevel.Error:
                    node.BackColor = Color.Red;
                    break;
                case ValidationLevel.Warning:
                    node.BackColor = Color.Orange;
                    break;
                default:
                    break;
            }
            
            foreach (WeakReference cfgFileRef in file.SubConfigRef)
                node.Nodes.Add(createRootNode((ConfigFile)cfgFileRef.Target));

            return node;
        }
Exemplo n.º 2
0
 private void fillTreeView(ConfigFile file)
 {
     treeView.Nodes.Add(createRootNode(file));
     treeView.ExpandAll();
 }
Exemplo n.º 3
0
 private IEnumerable<ConfigFile> CfgsWhichReferTo(ConfigFile cfgFile)
 {
     return this.cfgFiles.Where(file => file.SubConfigRef.Any(cfgref => (cfgref.Target as ConfigFile).Id == cfgFile.Id));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Fügt dem Manager anhand eines Path eine ConfigFile hinzu.
        /// </summary>
        /// <param name="path">Gültiger Pfad zur Config Datei</param>
        /// <returns>ConfigFile-Id</returns>
        /// <param name="save">Soll der Path als standardPath hinzugefügt werden?</param>
        public int addConfig(string path, bool save)
        {
            if (save)
                cfgPaths.Add(path);

            ConfigFile newCfgFile = new ConfigFile(path, this.getCfgFileType(path));
            this.cfgFiles.Add(newCfgFile);
            return newCfgFile.Id;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Prüft den Weg Rückwärts auf Zyklen
        /// </summary>
        /// <param name="targetPath"></param>
        /// <param name="cfgFile"></param>
        /// <returns></returns>
        public bool checkForCircle(string targetPath, ConfigFile cfgFile)
        {
            if (cfgFile.Path == targetPath)
                return true;

            IEnumerable<ConfigFile> prevFiles = CfgsWhichReferTo(cfgFile);
            return prevFiles.Any(cfg => checkForCircle(targetPath, cfg));
        }