Пример #1
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();
                }
            }
        }
Пример #2
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();
                }

            }
        }