Example #1
0
        /*
         * Loads the sections from the XML OneNote hierarchy and writes them to the string array
         * currentlist
         */
        private void loadSections(object sender, EventArgs e)
        {
            GetAllSections(sectionNameBox.Text);
            dgvNotebook.Rows.Clear();
            dgvNotebook.Refresh();
            foreach (NotebookObject notebook in notebooks)
            {
                dgvNotebook.Rows.Add(notebook.name);
            }
            bool loaded = false;

            for (int i = 0; i < notebooks.Length; i++)
            {
                if (notebooks[i].name.Equals(SettingsManager.notebook))
                {
                    loadNotebookToDGV(notebooks[i]);
                    dgvNotebook.CurrentCell = dgvNotebook.Rows[i].Cells[0];
                    currentNotebook         = notebooks[i];
                    //dgvNotebook.MultiSelect = false;
                    loaded = true;
                }
            }
            if (!loaded)
            {
                loadNotebookToDGV(notebooks[0]);
            }
        }
Example #2
0
 /*
  * Loads the notebook that is represented by the clicked cell to the section data grid view
  */
 private void dgvNotebook_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         loadNotebookToDGV(notebooks[e.RowIndex]);
         currentNotebook = notebooks[e.RowIndex];
     }
 }
Example #3
0
        /*
         * Loads a given notebook objects sections to the data grid view for sections.
         */
        private void loadNotebookToDGV(NotebookObject notebook)
        {
            SettingsManager.notebook = notebook.name;
            dgvSection.Rows.Clear();
            dgvSection.Refresh();
            List <String> added     = new List <string>();
            string        error     = "";
            bool          showError = false;

            foreach (SectionObject section in notebook.sections)
            {
                string errorAdder = "";
                if (added.Contains(section.fileName))
                {
                    showError = true;
                    if (error == "")
                    {
                        error += section.section;
                    }
                    else
                    {
                        error += "," + section.section;
                    }
                    errorAdder = "    DUPLICATE EXPORT FILENAME";
                }
                //@ Adding to dgv based on position !
                //#C100
                dgvSection.Rows.Add(section.export,
                                    section.sectionGroup,
                                    section.section,
                                    section.fileName,
                                    section.exportTime
                                    );
            }

            if (showError)
            {
                MessageBox.Show("The sections : \n" + error + " have export file names that were found more than once.\n" +
                                "There may be problems with exporting due to multiple sections with same name in the same notebook.");
            }
        }
Example #4
0
        /*
         * Returns an array of all sections found,where every string is a single section. Structure of string:
         * notebook name,SPLITTER,section name,SPLITTER,ID,SPLITTER, exported file creation time,SPLITTER,FileName,
         */
        SectionObject[] GetAllSections(string section)
        {
            updateNotebookData();
            var ns = XDocument.Parse(strXML).Root.Name.Namespace;

            List <SectionObject> returnlist = new List <SectionObject>();

            //List<NotebookObject> notebooks = new List<NotebookObject>();

            notebooks = new NotebookObject[XDocument.Parse(strXML).Descendants(ns + "Notebook").Count()];

            int index = 0;

            XDocument sd = XDocument.Parse(strXML);

            foreach (var nodeBook in XDocument.Parse(strXML).Descendants(ns + "Notebook"))
            {
                NotebookObject currentNotebook = new NotebookObject(nodeBook.Attribute("name").Value);


                foreach (XElement element in nodeBook.Elements())
                {
                    string type             = element.Name.ToString().Split('}')[1];
                    String sectionGroupName = "";
                    Console.WriteLine(element.Attribute("name").Value);
                    SectionObject toAdd = new SectionObject();
                    if (type == "SectionGroup")
                    {
                        if (!element.Attribute("name").Value.ToString().Equals("OneNote_RecycleBin"))
                        {
                            sectionGroupName = element.Attribute("name").Value;
                            foreach (var nodeSection in element.Descendants(ns + "Section"))
                            {
                                if (nodeSection.Attribute("name").ToString().Contains(section) || section.Equals("") || section.Equals(String.Empty))
                                {
                                    toAdd = new SectionObject(nodeBook.Attribute("name").Value, sectionGroupName, nodeSection.Attribute("name").Value, nodeSection.Attribute("ID").Value);
                                    if (!nodeSection.Parent.Attribute("name").Value.ToString().Equals(toAdd.sectionGroup))
                                    {
                                        toAdd = new SectionObject(nodeBook.Attribute("name").Value, sectionGroupName, nodeSection.Parent.Attribute("name").Value.ToString() + "-" + toAdd.section, nodeSection.Attribute("ID").Value);
                                    }
                                    if (!returnlist.Contains(toAdd))
                                    {
                                        currentNotebook.addSectionTry(toAdd);
                                        returnlist.Add(toAdd);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (element.Attribute("name").ToString().Contains(section) || section.Equals("") || section.Equals(String.Empty))
                        {
                            toAdd = new SectionObject(nodeBook.Attribute("name").Value, sectionGroupName, element.Attribute("name").Value, element.Attribute("ID").Value);
                            if (!returnlist.Contains(toAdd))
                            {
                                currentNotebook.addSectionTry(toAdd);
                                returnlist.Add(toAdd);
                            }
                        }
                    }
                }
                notebooks[index] = currentNotebook;
                index++;
            }
            currentNotebook = notebooks[0];
            allSections     = returnlist.ToArray();
            SettingsManager.checkForUnusedSetting();
            return(returnlist.ToArray());
        }