Esempio n. 1
0
 public Test(Controller _core, IGEPlugin _ge, TextFileEditor txt)
 {
     core = _core;
     t_pool = core.getTrips();
     record = core.getRecord();
     ge = _ge;
     txtedit = txt;
 }
Esempio n. 2
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");
                }
            }
        }