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);
            }
        }
Example #2
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);
            }
        }
Example #3
0
        void addSection()
        {
            ExtendedTreeNode addSection = new ExtendedTreeNode(String.Format("NewSection{0}", secNumber), 0);

            iniSectionTreeView.Nodes.Add(addSection);
            ini.AddSection(addSection.Text);
            secNumber++;
        }
Example #4
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;
                    }
                }
            }
        }
Example #5
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;
            }
        }
Example #6
0
        void openIniFile()
        {
            clear();
            try
            {
                iniSectionTreeView.BeginUpdate();
                ini.Load(curFileName);
                foreach (IniFile.IniSection s in ini.Sections)
                {
                    sectionsList.Add(s.Name);
                    foreach (IniFile.IniSection.IniKey k in s.Keys)
                    {
                        keysList.Add(k.Name);
                    }
                }

                foreach (IniFile.IniSection s in ini.Sections)
                {
                    ExtendedTreeNode ex = new ExtendedTreeNode(s.Name, 0);
                    foreach (IniFile.IniSection.IniKey k in s.Keys)
                    {
                        ExtendedTreeNode keyy = new ExtendedTreeNode(k.Name, 1);
                        ex.Nodes.Add(keyy);
                    }
                    iniSectionTreeView.Nodes.Add(ex);
                }
                iniSectionTreeView.TreeViewNodeSorter = new NumericComparer();
                iniSectionTreeView.EndUpdate();
                this.Text = String.Format("C# INI Editor - {0}", Path.GetFileName(curFileName));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Text   = "C# INI Editor";
                curFileName = null;
            }
            this.Cursor = Cursors.Arrow;
        }
 void addSection()
 {
     ExtendedTreeNode addSection = new ExtendedTreeNode(String.Format("NewSection{0}", secNumber), 0);
     iniSectionTreeView.Nodes.Add(addSection);
     ini.AddSection(addSection.Text);
     secNumber++;
 }
        void openIniFile()
        {
            clear();
            try
            {
                iniSectionTreeView.BeginUpdate();
                ini.Load(curFileName);
                foreach (IniFile.IniSection s in ini.Sections)
                {
                    sectionsList.Add(s.Name);
                    foreach (IniFile.IniSection.IniKey k in s.Keys)
                    {
                        keysList.Add(k.Name);
                    }
                }

                foreach (IniFile.IniSection s in ini.Sections)
                {
                    ExtendedTreeNode ex = new ExtendedTreeNode(s.Name, 0);
                    foreach (IniFile.IniSection.IniKey k in s.Keys)
                    {
                        ExtendedTreeNode keyy = new ExtendedTreeNode(k.Name, 1);
                        ex.Nodes.Add(keyy);
                    }
                    iniSectionTreeView.Nodes.Add(ex);
                }
                iniSectionTreeView.TreeViewNodeSorter = new NumericComparer();
                iniSectionTreeView.EndUpdate();
                this.Text = String.Format("C# INI Editor - {0}", Path.GetFileName(curFileName));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Text = "C# INI Editor";
                curFileName = null;
            }
            this.Cursor = Cursors.Arrow;
        }
        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;
            }
        }