Beispiel #1
0
        private void MakeViewCopy(ProfileTree tr, TreeNode node)
        {
            foreach (TreeNode item in node.Nodes)
            {
                string Path = item.FullPath;
                Path = PathRemoveRoot(Path);
                Path = ParentPath(Path);
                tr.AdddNode(Path, new profileNode((profileNode)item.Tag));

                if (item.Nodes.Count > 0)
                {
                    MakeViewCopy(tr, item);
                }
            }
        }
Beispiel #2
0
        private void GetNodes(TreeNode node, ProfileTree tree)
        {
            profileNode nodeP;
            string      parentPath = node.FullPath;
            Regex       reg        = new Regex("^Profiles");

            parentPath = reg.Replace(parentPath, "");
            foreach (TreeNode item in node.Nodes)
            {
                string Path = item.FullPath;
                Path  = reg.Replace(Path, "");
                nodeP = treeProfiles.FindNode(Path);
                tree.AdddNode(parentPath, new profileNode(nodeP));
                if (item.Nodes != null)
                {
                    GetNodes(item, tree);
                }
            }
        }
Beispiel #3
0
        private void EditProfile(string Path, bool edit, profileType type)
        {
            ProfileDefinitionForm profDef     = null;
            InternalProfileForm   internalDef = null;
            profileNode           node        = null;
            profileNode           newNode     = null;
            DialogResult          res         = DialogResult.Cancel;

            if (edit)
            {
                node = treeProfiles.FindNode(Path);
                if (node.internalName != null)
                {
                    internalDef = new InternalProfileForm(node, filter);
                    res         = internalDef.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        newNode                  = internalDef.localNode;
                        toolSave.Enabled         = true;
                        toolStripButton6.Enabled = true;
                    }
                }
                else
                {
                    profDef = new ProfileDefinitionForm(node);
                    res     = profDef.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        newNode                  = profDef.profile;
                        toolSave.Enabled         = true;
                        toolStripButton6.Enabled = true;
                    }
                }
            }
            else
            {
                if (Path == null)
                {
                    Path = "Profiles";
                }
                if (type == profileType.EXTERNAL)
                {
                    profDef = new ProfileDefinitionForm();
                    res     = profDef.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        node = profDef.profile;
                        node.internalName        = null;
                        toolSave.Enabled         = true;
                        toolStripButton6.Enabled = true;
                    }
                }
                else
                {
                    Settings set = new Settings();
                    set.Load();
                    InternalProfilesManager manager       = new InternalProfilesManager();
                    List <profileNode>      validProfiles = new List <profileNode>();
                    foreach (var item in InternalProfilesManager.internalList.Keys)
                    {
                        if (manager.CheckAccessibility(item, set.mode))
                        {
                            validProfiles.Add(item);
                        }
                    }

                    ListInternal intr = new ListInternal(validProfiles);

                    res = intr.ShowDialog();

                    if (res == DialogResult.OK)
                    {
                        InternalProfileForm intForm;
                        profileNode         localNode = InternalProfilesManager.GetNode(intr.selectedProfile);
                        if (localNode.profName.Contains("Load"))
                        {
                            intForm = new InternalProfileForm(localNode, filter, false);
                        }
                        else
                        {
                            intForm = new InternalProfileForm(localNode, filter);
                        }

                        res = intForm.ShowDialog();
                        if (res == DialogResult.OK)
                        {
                            node                     = intForm.localNode;
                            node.profProgram         = intr.selectedProfile;
                            newNode                  = node;
                            toolSave.Enabled         = true;
                            toolStripButton6.Enabled = true;
                        }
                    }
                }
            }

            if (res == DialogResult.OK)
            {
                if (node != null && File.Exists(node.OutFileName))
                {
                    File.Delete(node.OutFileName);
                }
                //profChanged = true;

                if (!edit)
                {
                    //profChanged = true;
                    Regex exp = new Regex("^/");

                    TreeNode nodeT;//= new TreeNode(profDef.profile.profName);

                    string nPath = "";
                    if (Path != null)
                    {
                        nPath = exp.Replace(Path, "");
                    }
                    if (profilesView.SelectedNode == null)
                    {
                        nodeT = profilesView.Nodes[0].Nodes.Add(node.profName);
                        profilesView.Nodes[0].Expand();
                    }
                    else
                    {
                        nodeT = profilesView.SelectedNode.Nodes.Add(node.profName);
                        profilesView.SelectedNode.Expand();
                    }
                    nodeT.Tag = newNode;
                    Regex exp2 = new Regex("^Profiles");
                    Path = exp2.Replace(Path, "");
                    treeProfiles.AdddNode(Path, node);
                }
                else
                {
                    profilesView.SelectedNode.Text = node.profName;
                    treeProfiles.RemoveNode(Path);
                    Regex exp2 = new Regex("^Profiles");
                    Path = exp2.Replace(Path, "");
                    treeProfiles.AdddNode(ParentPath(Path), newNode);
                    node.CopyNode(newNode);
                    ShowTree();
                }
            }
        }
        public static ProfileTree AnalyseProfileFile(string fileName, SIMDIST similarityFlag)
        {
            ProfileTree t = new ProfileTree();

            StreamReader wr;
            if (fileName == null || !File.Exists(fileName))
                throw new Exception("File:" + fileName + " not exists");

            wr = new StreamReader(fileName);
            string line = wr.ReadLine();
            
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();
            while (line != null)
            {
                if (line.Contains(">"))
                {
                    line = wr.ReadLine();
                    while (line != null && line[0] != '>')
                    {
                        if (line.Contains("profile") && !line.Contains("SEQ"))
                        {
                            string[] tmp = line.Split(new string[] { " profile " }, StringSplitOptions.None);
                            if (!dic.ContainsKey(tmp[0]))
                                dic.Add(tmp[0], new Dictionary<string, int>());
                            string[] aux;
                            if (tmp[1].Contains(" "))
                                aux = tmp[1].Split(' ');
                            else
                            {
                                aux = new string[tmp[1].Length];
                                for (int i = 0; i < tmp[1].Length; i++)
                                    aux[i] = tmp[1][i].ToString();
                            }
                            foreach (var item in aux)
                                if (item != "-" && item!="")
                                    if (!dic[tmp[0]].ContainsKey(item))
                                           dic[tmp[0]].Add(item, 0);

                        }
                        line = wr.ReadLine();
                    }
                }
                else
                    line = wr.ReadLine();
            }
            wr.Close();

            if (dic.Keys.Count == 0)
                throw new Exception("File " + fileName + " is not valid Profile file!");

            foreach (var item in dic)
            {
                profileNode node = new profileNode();
                node.active = true;
                node.internalName = "User defined profile";
                node.profName = item.Key;
                foreach (var itemK in item.Value)
                    node.AddStateItem(itemK.Key, itemK.Key);

                node.profWeights = GenerateWeights(new List<string>(item.Value.Keys), similarityFlag);
                t.AdddNode("/", node);
            }

          //  t.pr


            return t;
        }
        public static ProfileTree AnalyseProfileFile(string fileName, SIMDIST similarityFlag, string internalName = null)
        {
            ProfileTree t = new ProfileTree();

            StreamReader wr;

            if (fileName == null || !File.Exists(fileName))
            {
                throw new Exception("File:" + fileName + " not exists");
            }

            wr = new StreamReader(fileName);
            string line = wr.ReadLine();

            Dictionary <string, Dictionary <string, int> > dic = new Dictionary <string, Dictionary <string, int> >();

            while (line != null)
            {
                if (line.Contains(">"))
                {
                    line = wr.ReadLine();
                    while (line != null && line[0] != '>')
                    {
                        if (line.Contains("profile") && !line.Contains("SEQ"))
                        {
                            string[] tmp = line.Split(new string[] { " profile " }, StringSplitOptions.None);
                            if (!dic.ContainsKey(tmp[0]))
                            {
                                dic.Add(tmp[0], new Dictionary <string, int>());
                            }
                            string[] aux;
                            if (tmp[1].Contains(" "))
                            {
                                aux = tmp[1].Split(' ');
                            }
                            else
                            {
                                aux = new string[tmp[1].Length];
                                for (int i = 0; i < tmp[1].Length; i++)
                                {
                                    aux[i] = tmp[1][i].ToString();
                                }
                            }
                            foreach (var item in aux)
                            {
                                if (item != "-" && item != "")
                                {
                                    if (!dic[tmp[0]].ContainsKey(item))
                                    {
                                        dic[tmp[0]].Add(item, 0);
                                    }
                                }
                            }
                        }
                        line = wr.ReadLine();
                    }
                }
                else
                {
                    line = wr.ReadLine();
                }
            }
            wr.Close();

            if (dic.Keys.Count == 0)
            {
                throw new Exception("File " + fileName + " is not valid Profile file!");
            }

            foreach (var item in dic)
            {
                profileNode node = new profileNode();
                node.active = true;
                if (internalName != null)
                {
                    node.internalName = internalName;
                }
                else
                {
                    node.internalName = "User defined profile";
                }
                node.profName = item.Key;
                foreach (var itemK in item.Value)
                {
                    node.AddStateItem(itemK.Key, itemK.Key);
                }

                node.profWeights = GenerateWeights(new List <string>(item.Value.Keys), similarityFlag);
                t.AdddNode("/", node);
            }

            //  t.pr


            return(t);
        }
Beispiel #6
0
        private void MakeViewCopy(ProfileTree tr,TreeNode node)
        {
            foreach (TreeNode item in node.Nodes)
            {
                string Path = item.FullPath;
                Path = PathRemoveRoot(Path);
                Path = ParentPath(Path);
                tr.AdddNode(Path, new profileNode((profileNode)item.Tag));

                if (item.Nodes.Count > 0)
                    MakeViewCopy(tr,item);


            }
        }
Beispiel #7
0
        private void GetNodes(TreeNode node, ProfileTree tree)
        {
            profileNode nodeP;
            string parentPath = node.FullPath;
            Regex reg = new Regex("^Profiles");
            parentPath = reg.Replace(parentPath, "");
            foreach (TreeNode item in node.Nodes)
            {                
                string Path=item.FullPath;
                Path=reg.Replace(Path,"");
                nodeP=treeProfiles.FindNode(Path);
                tree.AdddNode(parentPath, new profileNode(nodeP));
                if (item.Nodes != null)
                    GetNodes(item, tree);

            }
        }