public void importShapefilesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Import(ATT.Configuration.PostGisShapefileDirectory,

                   new CompleteImporterFormDelegate(f =>
                       {
                           f.AddNumericUpdown("Source SRID:", 0, 0, 0, decimal.MaxValue, 1, "source_srid");
                           f.AddNumericUpdown("Target SRID:", 0, 0, 0, decimal.MaxValue, 1, "target_srid");
                           f.AddDropDown("Shapefile type:", Enum.GetValues(typeof(Shapefile.ShapefileType)).Cast<Shapefile.ShapefileType>().ToArray(), Shapefile.ShapefileType.Area, "type", true, new Action<object, EventArgs>((o, args) =>
                               {
                                   ComboBox cb = o as ComboBox;
                                   NumericUpDown boxSizeUpDown = f.GetControl<NumericUpDown>("containment_box_size");
                                   if (boxSizeUpDown != null)
                                       boxSizeUpDown.Parent.Visible = (Shapefile.ShapefileType)cb.SelectedItem == Shapefile.ShapefileType.Area;
                               }));
                           f.AddNumericUpdown("Area containment box size (meters):", 1000, 0, 1, decimal.MaxValue, 1, "containment_box_size");
                           return f;
                       }),

                   new CreateImporterDelegate((name, path, sourceURI, importerForm) =>
                       {
                           int sourceSRID = Convert.ToInt32(importerForm.GetValue<decimal>("source_srid"));
                           int targetSRID = Convert.ToInt32(importerForm.GetValue<decimal>("target_srid"));
                           Shapefile.ShapefileType shapefileType = importerForm.GetValue<Shapefile.ShapefileType>("type");

                           ShapefileInfoRetriever shapefileInfoRetriever = new ShapefileInfoRetriever(name, sourceSRID, targetSRID);
                           string relativePath = RelativizePath(path, ATT.Configuration.PostGisShapefileDirectory, PathRelativizationId.ShapefileDirectory);

                           if (shapefileType == Shapefile.ShapefileType.Area)
                           {
                               int containmentBoxSize = Convert.ToInt32(importerForm.GetValue<decimal>("containment_box_size"));
                               return new AreaShapefileImporter(name, path, relativePath, sourceURI, sourceSRID, targetSRID, shapefileInfoRetriever, containmentBoxSize);
                           }
                           else if (shapefileType == Shapefile.ShapefileType.Feature)
                               return new FeatureShapefileImporter(name, path, relativePath, sourceURI, sourceSRID, targetSRID, shapefileInfoRetriever);
                           else
                               throw new NotImplementedException("Unrecognized shapefile type:  " + shapefileType);
                       }),

                   ATT.Configuration.PostGisShapefileDirectory,
                   "Shapefiles (*.shp;*.zip)|*.shp;*.zip", new string[] { "*.shp" },
                   new ImportCompletionDelegate(() => { RefreshPredictionAreas(); }));
        }
        public void importIncidentsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Import(ATT.Configuration.IncidentsImportDirectory,

                   new CompleteImporterFormDelegate(f =>
                       {
                           Area[] areas = Area.GetAll().ToArray();
                           if (areas.Length == 0)
                           {
                               MessageBox.Show("No areas available. Import one first.");
                               return null;
                           }

                           f.AddDropDown("Import into area:", areas, null, "area", true);
                           f.AddNumericUpdown("Incident hour offset:", 0, 0, decimal.MinValue, decimal.MaxValue, 1, "offset");

                           return f;
                       }),

                   new CreateImporterDelegate((name, path, sourceURI, importerForm) =>
                       {
                           Area importArea = importerForm.GetValue<Area>("area");
                           int hourOffset = Convert.ToInt32(importerForm.GetValue<decimal>("offset"));

                           string extension = Path.GetExtension(path).ToLower();
                           if (extension == ".xml")
                           {
                               DynamicForm f = new DynamicForm("Location SRID", DynamicForm.CloseButtons.OK);
                               f.AddNumericUpdown("Location SRID:", 0, 0, 0, decimal.MaxValue, 1, "source_srid");
                               f.ShowDialog();
                               int sourceSRID = Convert.ToInt32(f.GetValue<decimal>("source_srid"));

                               Type[] rowInserterTypes = Assembly.GetAssembly(typeof(XmlImporter.XmlRowInserter)).GetTypes().Where(type => !type.IsAbstract && (type == typeof(XmlImporter.IncidentXmlRowInserter) || type.IsSubclassOf(typeof(XmlImporter.IncidentXmlRowInserter)))).ToArray();
                               string[] databaseColumns = new string[] { Incident.Columns.NativeId, Incident.Columns.Time, Incident.Columns.Type, Incident.Columns.X(importArea), Incident.Columns.Y(importArea) };

                               return CreateXmlImporter(name, path, ATT.Configuration.IncidentsImportDirectory, PathRelativizationId.IncidentDirectory, sourceURI, rowInserterTypes, databaseColumns, databaseColumnInputColumn =>
                                                        {
                                                            return new XmlImporter.IncidentXmlRowInserter(databaseColumnInputColumn, importArea, hourOffset, sourceSRID);
                                                        });
                           }
                           else if (extension == ".shp")
                           {
                               int targetSRID = importArea.Shapefile.SRID;
                               ShapefileInfoRetriever shapefileInfoRetriever = new ShapefileInfoRetriever(name, 0, targetSRID);
                               return new IncidentShapefileImporter(name, path, RelativizePath(path, ATT.Configuration.IncidentsImportDirectory, PathRelativizationId.IncidentDirectory), sourceURI, 0, targetSRID, shapefileInfoRetriever, importArea, new IncidentTableShapefileTableMappingRetriever(), hourOffset);
                           }
                           else
                               throw new NotImplementedException("Unrecognized incident import file extension:  " + extension);
                       }),

                   ATT.Configuration.IncidentsImportDirectory,
                   "Incident files (*.shp;*.xml;*.zip)|*.shp;*.xml;*.zip",
                   new string[] { "*.xml", "*.shp" },
                   null);
        }