private void ProxyCreateRandom()
        {
            // Default sample size
            int pSample = 25;

            var mSelectedLayer = ExtFunctions.GetSelectedLayer(theMap);

            IFeatureLayer mLayer = null;

            if (mSelectedLayer == null || !(mSelectedLayer is IFeatureLayer))
            {
                this.Log("No feature layer selected, please select a layer and try again.");
                return;
            }
            mLayer = (IFeatureLayer)mSelectedLayer;

            var mFrmInputBox = new frmInputBox("Specify size of sample", "Please specify number of items to be included in the output file", pSample);

            if (DialogResult.OK == mFrmInputBox.ShowDialog())
            {
                if (mFrmInputBox.GetAsInteger() != null)
                {
                    pSample = (int)mFrmInputBox.GetAsInteger();
                    Utilities.LogDebug("Using specified sample size: " + pSample);
                }
                else if (mFrmInputBox.GetAsPercent() != null)
                {
                    int         mPercentage = (int)mFrmInputBox.GetAsPercent();
                    IFeatureSet mFeatureSet = mLayer.DataSet;
                    pSample = (int)Math.Floor(((double)mPercentage * (double)mFeatureSet.NumRows()) / 100);
                    Utilities.LogDebug("Using " + mPercentage + "% : " + pSample);
                }
                else
                {
                    Utilities.LogDebug("Using default sample size: " + pSample);
                }

                this.Log(pSample.ToString());
                if (pSample > 0)
                {
                    var mRndFeatureSet = ExtFunctions.CreateRandomSelection(mLayer, pSample);

                    if (mRndFeatureSet == null)
                    {
                        Utilities.LogDebug("Creation of random selection layer failed");
                        return;
                    }

                    var mLayer2 = (IFeatureLayer)ExtFunctions.GetFeatureLayer(theMap.Layers, mRndFeatureSet, mLayer.LegendText + " : random", ExtFunctions.CopyLayerSymbolizer(mLayer), mLayer.Projection);
                    ExtFunctions.AddLabelsForFeatureLayer(mLayer2, "Address unit numbers", "#[ADDRESSUNITNR], [ROADNAME_EN]", GoogleMapsColors.BoundaryMajor);
                }
            }
        }
 private void importRoadsAndRoadCenterLinesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Add select dialog here...
     dlgOpenMdbFile.Filter   = "Addressing Database|*.mdb";
     dlgOpenMdbFile.FileName = "*.mdb";
     if (dlgOpenMdbFile.ShowDialog() == DialogResult.OK)
     {
         var mRoadsFeatureSet = ExtFunctions.GetRoadFeatureSetFromAdmAdrMdb(ref this.pgBar, Log, dlgOpenMdbFile.FileName, 1);
         var mRoadsLayer      = ExtFunctions.GetFeatureLayer(theMap.Layers, mRoadsFeatureSet, "SimplifiedRoads", MapSymbols.LineSymbol(SignColors.AddressUnitSign, 2), KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone40N);
         dlgSaveFile.Filter = "FileGeodatabases|*.gdb";
         dlgSaveFile.Title  = "Save imported roads to ESRI FileGDB";
         if (dlgSaveFile.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 ExtFunctions.ExportFeatureLayerToOGR("FileGDB", mRoadsLayer, dlgSaveFile.FileName, KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone40N, KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone40N);
             }
             catch (Exception ex)
             {
                 Log("Operation cancelled");
                 Log(ex.Message);
             }
         }
         else
         {
             Log("Export to FileGDB cancelled");
         }
         if (MessageBox.Show("Would you like to add the imported roads to the map?", "Import roads", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
         {
             mRoadsLayer.Reproject(theMap.Projection);
             theMap.Refresh();
         }
     }
     else
     {
         Log("Operation cancelled, please select an addressing database file");
     }
 }
        private void importAddressingDistrictsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            dlgOpenMdbFile.Title    = "Please select an addressing database";
            dlgOpenMdbFile.FileName = "*.mdb";
            dlgOpenMdbFile.Filter   = "Addressing Database|*.mdb";

            if (dlgOpenMdbFile.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var mDistrictsFeatureSet = ExtFunctions.GetDistrictsFeatureSetFromAdmAdrMdb(ref this.pgBar, dlgOpenMdbFile.FileName, 0);
                    if (mDistrictsFeatureSet == null)
                    {
                        return;
                    }
                    var mDistrictsLayer = ExtFunctions.GetFeatureLayer(theMap.Layers, mDistrictsFeatureSet, "Districts", MapSymbols.PolygonSymbol(Color.Transparent, Color.Red), KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone40N);

                    mDistrictsLayer.DataSet.ExportToShapeUsingOgr(DistrictImport.GetShapefileName());

                    mDistrictsLayer.Reproject(theMap.Projection);
                    theMap.Refresh();


                    // Set properties
                    Properties.Settings.Default.DistrictFilePresent    = true;
                    Properties.Settings.Default.DistrictImportFileDate = DateTime.Now;

                    Log("Operation completed, saved imported districts to: " + DistrictImport.GetShapefileName());
                }
                catch (Exception ex)
                {
                    Log("Operation aborted: " + ex.Message);
                    Log("Look for issues with duplicate district abbreviations and make sure that you have selected an 'adm-adr' ESRI Personal Geodatabase file that contains districts...");
                }
            }
        }