Exemple #1
0
        void addKey()
        {
            try
            {
                ExtendedTreeNode selected = (ExtendedTreeNode)iniSectionTreeView.SelectedNode;

                switch (selected.GetIntegerType())
                {
                case (0):
                    ExtendedTreeNode addKey = new ExtendedTreeNode(String.Format("NewKey{0}", keyNumber), 1);
                    selected.Nodes.Add(addKey);
                    IniFile.IniSection selectedSection = ini.GetSection(selected.Text);
                    selectedSection.AddKey(String.Format("NewKey{0}", keyNumber));
                    keyNumber++;
                    break;

                case (1):
                    MessageBox.Show("Please select a section node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case (2):
                    MessageBox.Show("Please select a section node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            catch
            {
                MessageBox.Show("Please select a section node!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (SELECTEDNODE.GetIntegerType())
            {
            case (0):
                ini.RenameSection(SELECTEDNODE.Text, secValueTextBox.Text);
                SELECTEDNODE.Text = secValueTextBox.Text;
                break;

            case (1):
                MessageBox.Show("Section not selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case (2):
                MessageBox.Show("Section not selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
            changed = true;
        }
Exemple #3
0
        void remove()
        {
            if (iniSectionTreeView.Nodes.Count > 0)
            {
                if (iniSectionTreeView.SelectedNode != null)
                {
                    DialogResult dr = MessageBox.Show(String.Format("Are you sure you'd like to delete the item '{0}'?", iniSectionTreeView.SelectedNode.Text),
                                                      "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    switch (dr)
                    {
                    case (DialogResult.Yes):
                        ExtendedTreeNode selected = (ExtendedTreeNode)iniSectionTreeView.SelectedNode;

                        switch (selected.GetIntegerType())
                        {
                        case (0):
                            DialogResult drt = MessageBox.Show("This will delete all keys within this section. This cannot be undone. Proceed?",
                                                               "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            switch (drt)
                            {
                            case (DialogResult.Yes):
                                IniFile.IniSection section = ini.GetSection(selected.Text);
                                ini.RemoveSection(section);
                                selected.Remove();
                                changed = true;
                                break;

                            case (DialogResult.No):
                                break;
                            }
                            break;

                        case (1):
                            IniFile.IniSection sectionn = ini.GetSection(selected.Parent.Text);
                            sectionn.RemoveKey(selected.Text);
                            selected.Remove();
                            changed = true;
                            break;

                        case (2):
                            break;
                        }
                        break;

                    case (DialogResult.No):
                        break;
                    }
                }
            }
        }
Exemple #4
0
        private void iniSectionTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            ExtendedTreeNode selected = (ExtendedTreeNode)iniSectionTreeView.SelectedNode;

            switch (selected.GetIntegerType())
            {
            //0 is a section, 1 is a key, 2 is a value but 2 is just there as a just in case
            case (0):
                currentSection        = ini.GetSection(selected.Text);
                SELECTEDNODE          = selected;
                editSectionLabel.Text = String.Format("Edit Section {0}", currentSection.Name.ToString());
                secValueTextBox.Text  = currentSection.Name.ToString();
                break;

            case (1):
                currentSection  = ini.GetSection(selected.Parent.Text);
                currentKey      = selected.Text;
                currentKeyValue = ini.GetKeyValue(currentSection.Name.ToString(), selected.Text);
                //
                editSectionLabel.Text = String.Format("Edit Section {0}", currentSection.Name.ToString());
                secValueTextBox.Text  = currentSection.Name.ToString();
                //
                editKeyLabel.Text    = String.Format("Edit Section {0}", currentKey);
                keyValueTextBox.Text = currentKey;
                //
                if (currentKeyValue != null)
                {
                    string value = currentKeyValue;
                    currentKeyValue     = value.Replace("\"", "");
                    valueTextBox.Text   = currentKeyValue;
                    editValueLabel.Text = String.Format("Edit Value {0}", currentKey);
                }
                SELECTEDNODE = selected;
                break;

            case (2):
                //invalid????
                break;
            }
        }