Esempio n. 1
0
        private void cSVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //saveCSV("geographic_draft_info.csv");

            for (int i = 0; i < sheetIDs.Count; i++)
            {
                var si = sheet.getSheetInfo(sheetIDs[i]);
                currentSheetInfo = si;

                foreach (var page in si.pages)
                {
                    // garbage, ignore these sheets
                    if (page.Contains("Sheet") || page.Contains("Empty") || page.Contains("template") || page.Contains("Template"))
                    {
                        continue;
                    }
                    if (page.Contains("Correspondence") || page.Contains("correspondence") || si.title.Contains("Correspondence") || si.title.Contains("correspondence"))
                    {
                        continue;
                    }

                    if (page.Contains("Draft"))
                    {
                        Dictionary <string, string>[] info = sheet.readColumns(currentSheetInfo.id, "");
                        saveGeoCSV("geographic_draft_info.csv", info);
                        break; // only need the first "draft" page, can ignore the rest
                    }
                }
            }

            MessageBox.Show("Finished writing CSV to geographic_draft_info.csv");
        }
Esempio n. 2
0
 public static void setSelectedPage(ref SheetInfo si, string pageName)
 {
     for (int i = 0; i < si.pages.Count; i++)
     {
         if (si.pages[i].Contains(pageName))
         {
             si.selectedPage = i;
             break;
         }
     }
 } // end set selected page
Esempio n. 3
0
        private void createGeneralCSVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Dictionary <string, string>[]> allInfo = new List <Dictionary <string, string>[]>();
            List <string> stories = new List <string>();

            for (int i = 0; i < sheetIDs.Count; i++)
            {
                var si = sheet.getSheetInfo(sheetIDs[i]);
                currentSheetInfo = si;

                foreach (var page in si.pages)
                {
                    // garbage, ignore these sheets
                    if (page.Contains("Sheet") || page.Contains("Empty") || page.Contains("template") || page.Contains("Template"))
                    {
                        continue;
                    }
                    if (page.Contains("Correspondence") || page.Contains("correspondence") || si.title.Contains("Correspondence") || si.title.Contains("correspondence"))
                    {
                        continue;
                    }

                    if (page.Contains("Draft"))
                    {
                        Dictionary <string, string>[] info = sheet.readColumns(currentSheetInfo.id, "");
                        allInfo.Add(info);
                        stories.Add(si.title);
                        break; // only need the first "draft" page, can ignore the rest
                    }
                }
            }

            List <string> keys = new List <string>();

            // get list of all column headers
            for (int i = 0; i < stories.Count; i++)
            {
                foreach (var doc in allInfo[i])
                {
                    foreach (var entry in doc)
                    {
                        if (!keys.Contains(entry.Key))
                        {
                            if (entry.Key.Contains("Character #") || entry.Key.Contains("Setting #") || entry.Key.Contains("Ref #") || entry.Key.Contains("ref #") || entry.Key.Contains("Ref#") || entry.Key.Contains("Ref. #") ||
                                entry.Key.Contains("Character(s) #") || entry.Key.Contains("Scanned image") || entry.Key.Contains("Protagonist") || entry.Key.Contains("Cultural References"))
                            {
                                continue;
                            }
                            keys.Add(entry.Key);
                        }
                    }
                }
            }

            using (System.IO.StreamWriter file = new System.IO.StreamWriter("draft_info.csv", false, System.Text.Encoding.UTF8))
            {
                // header
                file.Write("Story,");
                foreach (var key in keys)
                {
                    file.Write(process(key) + ",");
                }
                file.WriteLine("Num Deletions,Num Revisions,Num Outside Rev");

                // body
                for (int i = 0; i < stories.Count; i++)
                {
                    foreach (var doc in allInfo[i])
                    {
                        int numDeletions = 0, numRevisions = 0, outside = 0;

                        file.Write(process(stories[i]) + ",");
                        foreach (var key in keys)
                        {
                            if (doc.ContainsKey(key))
                            {
                                file.Write(process(doc[key]) + ',');
                                if (key.Contains("Typed Deletions (# per page, including 0 for none, separated by commas)"))
                                {
                                    numDeletions = SplitAndSum(doc[key]);
                                }
                                if (key.Contains("Author's Editorial Revisions (# per page, including 0 for none, separated by commas)"))
                                {
                                    numRevisions = SplitAndSum(doc[key]);
                                }
                                if (key.Contains("Outside Editorial Revisions (# per page, including 0 for none, separated by commas)"))
                                {
                                    outside = SplitAndSum(doc[key]);
                                }
                            }
                            else
                            {
                                file.Write(',');
                            }
                        } // end for each key
                        file.WriteLine(numDeletions.ToString() + "," + numRevisions.ToString() + "," + outside);
                    }     // end for each doc
                }         // end for
                file.Close();
            }             // end using


            MessageBox.Show("Finished writing CSV to draft_info.csv");
        } // end create general csv tool strim menu item clicked
Esempio n. 4
0
        public Form1()
        {
            InitializeComponent();

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);


            sheet = new GoogleSheets();


            sheetIDs.Add(@"1J5_1PDObU7ZHEfEABypaPDKC8ppmjSGv3CeLMr_kz9Y"); // Accident
            sheetIDs.Add(@"1UOKQUcinr1YDik_J7dpO7UjGTFbrnXMoE1KNTr3F930"); // Bardon Bus
            sheetIDs.Add(@"1MZGv0wj9NtfXPtL-s-1R2YgZSguhIHKc94LpjDWco1U"); // Chaddeleys and Flemings
            sheetIDs.Add(@"1YoJ4ix2_hN-qEEOcWkZFlx_1hRongDzOsC3l0s98sh4"); // Dulse
            sheetIDs.Add(@"1IrqPm6pciMknPf6DliHubwh_CZxDUo5rT--Dd-_14tM"); // Hard luck stories
            sheetIDs.Add(@"1HdgxEhcqER9VTKH_61qX3He7CT9dNmpd_zDqZdoUNVM"); // Labor Day Dinner
            sheetIDs.Add(@"1vDCXa-e_2GhFcUcXLoBtXo1bnqQDp6YMUy-_NOK3ngM"); // Moons of Jupiter
            sheetIDs.Add(@"1Ykn93bo8HH0PpfEaZ2AqJsWdRx_aUYF6MbiVuuyEoWg"); // Mrs Cross and Mrs Kidd
            sheetIDs.Add(@"1O8c8PWhWTBUZQjEOjUUNpPzv1B93EEWfuFIgVCbLiyI"); // Privilege
            sheetIDs.Add(@"12hKFpeEAjwSfIQOo6L6fPaP4PrIin5zT9CKi-SWZyUg"); // Providence
            sheetIDs.Add(@"1aXK51JWFjVhFkHwFJ9RbPb2pEJkhJ8NTKX7ol3Hewlk"); // Prue
            sheetIDs.Add(@"1bFfCrsXGA_SM_V1qW-lDNOu_5Lmj0AlY2eUTjhKF_sg"); // Royal Beatings

            //sheetIDs.Add(@"1cTP06iwtGePdXfNj8HbO7dsrhtWlHhecLtVc0_RpsE8"); // Simon's Luck *****

            sheetIDs.Add(@"19EO1joffnYoTOypijmYD942U7YUITjSwlPA6Va3SGsw"); // Spelling
            sheetIDs.Add(@"1IMFgjiiwR60lavptcNM1XCue_k3AVEHCyow-crP2yp4"); // The Beggar Maid
            sheetIDs.Add(@"1v74L4dcgbopflanlcWdcznE0hgAAqv5KsEyn58DDvww"); // The Turkey Season
            sheetIDs.Add(@"1Mxg0KLXWB5yOyzJidcusV7HZM8XiShv4b70vkTU0_aI"); // Visitors
            sheetIDs.Add(@"1d8Frpt6nN9vzYBk4eUHkk1a8yMqSpYlVwatv1r80eQA"); // Who Do You Think You Are

            sheetIDs.Add(@"1X5sPMFzUH7B1zpLBTo3FdNrspGyXS5E1cGQzzcKdHbg"); // Wild swans

            // create the data menu
            for (int i = 0; i < sheetIDs.Count; i++)
            {
                var si = sheet.getSheetInfo(sheetIDs[i]);
                currentSheetInfo = si;

                foreach (var page in si.pages)
                {
                    // garbage, ignore these sheets
                    if (page.Contains("Sheet") || page.Contains("Empty") || page.Contains("template") || page.Contains("Template"))
                    {
                        continue;
                    }

                    bool corr = false;
                    if (page.Contains("Correspondence") || page.Contains("correspondence") || si.title.Contains("Correspondence") || si.title.Contains("correspondence"))
                    {
                        corr = true;
                    }

                    // create menu item
                    ToolStripItem it = new ToolStripMenuItem(si.title + ": " + page, null, new EventHandler((sender, e) =>
                    {
                        currentSheetInfo = si;
                        GoogleSheets.setSelectedPage(ref currentSheetInfo, page);
                        this.Text = "Material Explorer        " + currentSheetInfo.title + ": " + currentSheetInfo.pages[currentSheetInfo.selectedPage];

                        loadItems(!corr);
                    }));

                    if (corr)
                    {
                        correspondenceToolStripMenuItem.DropDownItems.Add(it);
                    }
                    else
                    {
                        dataToolStripMenuItem.DropDownItems.Add(it);
                    }
                }

                /*
                 * if (i == 0) currentSheetInfo = si;
                 * ToolStripMenuItem item = new ToolStripMenuItem(si.title);
                 * foreach (var page in si.pages)
                 *  item.DropDownItems.Add(page, null, new EventHandler((sender, e) =>
                 *  {
                 *      currentSheetInfo = si;
                 *      GoogleSheets.setSelectedPage(ref currentSheetInfo, page);
                 *      this.Text = "Material Explorer        " + currentSheetInfo.title + ": " + currentSheetInfo.pages[currentSheetInfo.selectedPage];
                 *      loadItems();
                 *      //Console.WriteLine("Sheet " + currentSheetInfo.title + ", page " + currentSheetInfo.pages[currentSheetInfo.selectedPage] + " was selected.");
                 *  }));
                 * dataToolStripMenuItem.DropDownItems.Add(item);
                 */
            }
            this.Text = "Material Explorer        " + currentSheetInfo.title + ": " + currentSheetInfo.pages[0];

            /*
             *
             * this.Paint += new PaintEventHandler((sender, e) =>
             * {
             *  if (e.ClipRectangle.Width < .9 * this.Width)
             *      this.Invalidate(this.ClientRectangle);
             *  else
             *  {
             *      for (int i = 2; i < Controls.Count; i++)
             *      {
             *          var c = Controls[i];
             *          if (c.GetType().Name == "ListView" && c.Visible)
             *          {
             *              var cp = Controls[i - 1];
             *              Pen pen = new Pen(Color.Gray);
             *              pen.Width = 2;
             *
             *              if (Math.Abs(cp.Bottom - c.Top) + Math.Abs(cp.Left - c.Left) > 5)
             *                  e.Graphics.DrawLine(pen, cp.Left, cp.Bottom, c.Left, c.Top);
             *          }
             *      }
             *  }
             *
             * });
             */
        }