Example #1
0
 //This will parse the data to a Data Set
 public void parseFileToDataSet(String filePath, data textDatabase)
 {
     //This function is a test function to parse items into a dataset.
     String[] FileLines = System.IO.File.ReadAllLines(filePath); // This will store all the lines of the file into a string array
     foreach (String line in FileLines)
     {
         int tabCount = 0; // reset the tabCount
         String[] temp = new String[tabCount];
         foreach (char c in line)
         {
             if (c.Equals('\t'))
             {
                 tabCount++;
             }
         }
         if (tabCount > 0)  // if the line contains tab characters, it means that it is a data line. So it should be parsed and added to our data structure.
         {
             // here we will resize the array depending on the tabCount
             temp = (String[])resizeArray(temp, tabCount + 1);
             temp = line.Split('\t');
             if (temp[0].Equals("Day") || temp[0].StartsWith("The") || temp[0].Equals(""))  // this won't add the first row which contains the headings.
                 /*do nothing*/
                 ;
             else
                 textDatabase.addRow(temp, textDatabase);  // This will add the parsed data as a row in the database.
         }
     }
 }
Example #2
0
 //This will parse the data to a Data Set
 public void parseFileToDataSet(String filePath, data textDatabase, data textDatabaseView, String day)
 {
     //This function is a test function to parse items into a dataset.
     String[] FileLines = System.IO.File.ReadAllLines(filePath); // This will store all the lines of the file into a string array
     foreach (String line in FileLines)
     {
         int tabCount = 0; // reset the tabCount
         String[] temp = new String[tabCount];
         // here we will resize the array depending on the tabCount
         temp = line.Split('\t');
         if (temp.Count() < 16 && temp.Count() != 1)
         {
             temp = (String[])resizeArray(temp); // in some lines in the text file, the last field is sometimes incomplete and without a tab character.
         }
         if (temp[0].Equals("Day") || temp[0].Equals("") || temp[0].StartsWith("The") || temp[0].StartsWith("***") )  // this won't add the first row which contains the headings.
             Console.WriteLine();  // just a stupid step
         else
         {
             textDatabase.addRow(temp, textDatabase);
             if(temp[0].Equals(day))  // and if it belongs to the day from the KML file, we'll use that.
             {
                 //Check if this is the day before the day we want
                 textDatabaseView.addRow(temp, textDatabaseView);  // This will add the parsed data as a row in the database. //But this will add only the days for this KML file
             }
         }
     }
 }
Example #3
0
 public String buildStringForWriting(data table)
 {
     int rowCount = table.getDataTable().Rows.Count;
     String outputText = "";
     String finalOutputText = "";
     DataRow[] rows = table.getDataTable().Select();
     for (int i = 0; i < rows.Length; i++)
     {
         int j = 0;
         for (j = 0; j < 16; j++)
         {
             outputText = rows[i][j].ToString();
             finalOutputText = finalOutputText + outputText + '\t';
         }
         finalOutputText = finalOutputText + "\r\n";
     }
     return finalOutputText;
 }
Example #4
0
        /*
        String ns = "<Style id=\"normalStart\"><IconStyle><Icon><href>http://maps.google.com/mapfiles/kml/paddle/grn-stars.png</href></Icon><scale>0.7</scale></IconStyle><LabelStyle><color>00000000</color></LabelStyle></Style>" +
                    "<Style id=\"highlightStart\"><IconStyle><Icon><href>http://maps.google.com/mapfiles/kml/paddle/grn-stars.png</href></Icon><scale>1.2</scale></IconStyle><LabelStyle><color>ffffffff</color></LabelStyle></Style>" +
                    "<StyleMap id=\"Start\"><Pair><key>normal</key><styleUrl>#normalStart</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#highlightStart</styleUrl></Pair></StyleMap>";
        */
        private void button1_Click(object sender, EventArgs e)
        {
            if (ge != null)
            {
                if (kmlex == ".kml" && txtex == ".txt")
                {
                    try
                    {
                        ge.getFeatures().appendChild(ge.parseKml(correction(System.IO.File.ReadAllText(kmlfpath))));

                        data textDatabase = new data();
                        Parser textParser = new Parser();
                        textParser.parseFileToDataSet(txtfpath, textDatabase);

                        D_parser();
                        foreach (String trip in t_pool.getNames())
                        {
                            checkedListBox1.Items.Add(trip);
                        }

                        ge.getView().setAbstractView(allocate());
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Unable to load '" + kmln + "'.", "ERROR");
                    }
                }
                else if (kmlfpath == null && txtfpath == null)
                {
                    MessageBox.Show("Please choose the input KML and output TXT files.", "Caution");
                }
                else
                {
                    MessageBox.Show("Wrong file format.", "Caution");
                }
            }
        }
Example #5
0
 public Table(data database)
 {
     assignDatabaseToViewer(database.getDataTable());
     undoTable = createUndoTable();
     undoTypeTable = createUndoTypeTable();
 }
Example #6
0
 public void setViewer(data ParsedDataViewer)
 {
     databaseViewer = ParsedDataViewer.getDataTable();
     GlobalDay      = databaseViewer.Rows[0]["Day"].ToString();
 }
Example #7
0
 public void setViewerTotal(data ParsedData)
 {
     databaseViewerTotal = ParsedData.getDataTable();
 }
Example #8
0
 public Table(data database)
 {
     assignDatabaseToViewer(database.getDataTable());
     undoTable     = createUndoTable();
     undoTypeTable = createUndoTypeTable();
 }
Example #9
0
 public void setViewerTotal(data ParsedData)
 {
     databaseViewerTotal = ParsedData.getDataTable();
 }
Example #10
0
 public void setViewer(data ParsedDataViewer)
 {
     databaseViewer = ParsedDataViewer.getDataTable();
     GlobalDay = databaseViewer.Rows[0]["Day"].ToString();
 }
Example #11
0
 public void addRow(String[] line, data textDatabase)
 {
     textDatabase.TextDataTable.Rows.Add("", line[0], line[1], line[2], line[3], line[4], line[5], line[6], line[7], line[8], line[9], line[10], line[11], line[12], line[13], line[14], line[15]);
 }
Example #12
0
        /********************************************** Form Button Operations *********************************************/
        /******************
         * Load Data
         * *****************/
        private void btLoad_Click(object sender, EventArgs e)
        {
            data ParsedData = new data();
            data ParsedDataForDay = new data();
            if (ge != null)
            {
                if (kmlex == ".kml" && txtex == ".txt" /*&& ( poiex == ".xlsx" || poiex == ".xls" )*/ )
                {
                    try
                    {
                        statusText = "Reading KML Data";
                        ge.getFeatures().appendChild(ge.parseKml((System.IO.File.ReadAllText(kmlfpath))));
                        statusText = "Parsing KML Data";
                        D_parser();
                        statusText = "Creating Trip Selector";
                        foreach (String trip in t_pool.getNames())
                        {
                            cblTrips.Items.Add(trip);
                        }
                        core = new Controller(ge, t_pool, record);
                        panel2.Visible = true;
                        panel4.Visible = true;
                        panel5.Visible = true;
                        panel1.Visible = true;

                        //Now we'll show the textDataGrid to the user
                        btUnhidePanelFunction();
                        statusText = "Parsing Text File Data";
                        Module.writeToTestingFile("Parsing Text File Data at " + DateTime.Now.ToString());
                        //If the file input is correct we will parse the text file into memory wehere it can be easily edited by the user
                        textParser.parseFileToDataSet(txtfpath, ParsedData, ParsedDataForDay, d_name);
                        txtEditor.setViewerTotal(ParsedData);
                        txtEditor.setViewer(ParsedDataForDay);
                        statusText = "Setting up Interface";
                        Module.writeToTestingFile("Setting up interface at " + DateTime.Now.ToString());
                        //Now we'll add the data to the viewer in the Form
                        textDataGrid.DataSource = txtEditor.getViewer();
                        KMLTripView.DataSource = t_pool.getTripDetails();
                        textDataGrid.Columns["Day"].Visible = false;
                        textDataGrid.Columns["HouseHold"].Visible = false;
                        textDataGrid.Columns["Person"].Visible = false;
                        textDataGrid.Columns["Date"].Visible = false;
                        textDataGrid.Columns["Weekday"].Visible = false;
                        KMLTripView.Columns["HouseHoldID"].Visible = false;
                        KMLTripView.Columns["Trip"].Visible = false;
                        KMLTripView.Columns["Person"].Visible = false;
                        KMLTripView.Columns["Day"].Visible = false;
                        KMLTripView.Columns["Date"].Visible = false;
                        KMLTripView.Columns["Weekday"].Visible = false;
                        KMLTripView.Columns["Remain"].Visible = false;
                        houseHoldText.Text = txtEditor.getViewer().Rows[0]["HouseHold"].ToString();
                        personText.Text = txtEditor.getViewer().Rows[0]["Person"].ToString();
                        dateText.Text = txtEditor.getViewer().Rows[0]["Date"].ToString();
                        dayText.Text = txtEditor.getViewer().Rows[0]["Weekday"].ToString();
                        if (t_pool.getSize() > txtEditor.getViewer().Rows.Count)
                        {
                            tripConflictText.ForeColor = System.Drawing.Color.Red;
                            tripConflictText.Text = "KML and Text File trips don't match.";
                        }
                        if (poifpath != null)
                        {
                            statusText = "Parsing POI Data";
                            Module.writeToTestingFile("Parsing POI File Data at " + DateTime.Now.ToString());
                            POIData.getDataFromExcelFile(poifpath, txtEditor.getViewer());
                        }
                        statusText = "Creating POI on map";
                        setPOIsOnMap(POIData.getHomes(), POIData.getSchools(), POIData.getWorks(), POIData.getShoppings());
                        ge.getView().setAbstractView(core.allocate());
                        statusText = "Matching KML and Text Data";
                        Module.writeToTestingFile("Match KML and Text Data at " + DateTime.Now.ToString());
                        matchKMLTripstoTextDataTrips();
                        DataGridViewComboBoxColumn temp = generateDropDownListForTrips();
                        KMLTripView.Columns.Add(temp); ;
                        match_check();
                        //Enable the Rest Tilt button
                        btResetTilt.Visible = true;
                        //btResetTilt.SetBounds((int)ge.getNavigationControl().getScreenXY().getX(), (int)ge.getNavigationControl().getScreenXY().getY() + 20, btResetTilt.Size.Width, btResetTilt.Size.Height);

                        // Disable load button until one of the file browse button is click onto
                        btLoad.Enabled = false;
                        Module.writeToTestingFile("Finish at " + DateTime.Now.ToString());
                        Module.writeTestingFile();

                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Unable to load '" + kmln + "'.", "ERROR");
                    }
                }
                else if (kmlfpath == null && txtfpath == null)
                {
                    MessageBox.Show("Please choose the input KML and output TXT files.", "Caution");
                }
                else
                {
                    MessageBox.Show("Wrong file format.", "Caution");
                }
            }
        }
Example #13
0
 public void addRow(String[] line, data textDatabase)
 {
     DataTable table;
     table = textDatabase.getDataTable();
     table.Rows.Add(line[0], line[1], line[2], line[3], line[4], line[5], line[6], line[7], line[8], line[9], line[10], line[11], line[12], line[13], line[14], line[15]);
 }