Example #1
0
 private void OnPointCloudChanged(object sender, naru.ui.PathEventArgs e)
 {
     if (string.IsNullOrEmpty(txtName.Text))
     {
         txtName.Text = Path.GetFileNameWithoutExtension(e.Path.FullName);
     }
 }
Example #2
0
 public static void OnSelectVector(System.Windows.Forms.TextBox txt, naru.ui.PathEventArgs e, GCDConsoleLib.GDalGeometryType.SimpleTypes geometryType)
 {
     if (GISSelectingVectorEventHandler != null)
     {
         ProjectManager.GISSelectingVectorEventHandler(txt, e, geometryType);
     }
 }
Example #3
0
            public void OnGISBrowseVector(System.Windows.Forms.TextBox txt, naru.ui.PathEventArgs e, GCDConsoleLib.GDalGeometryType.SimpleTypes geometryType)
            {
                System.IO.DirectoryInfo dir = null;
                string FCName = string.Empty;

                if (e.Path is System.IO.FileInfo)
                {
                    dir    = e.Path.Directory;
                    FCName = System.IO.Path.GetFileNameWithoutExtension(e.Path.FullName);
                }

                ArcMapBrowse.BrowseGISTypes eType = ArcMapBrowse.BrowseGISTypes.Any;
                switch (geometryType)
                {
                case GCDConsoleLib.GDalGeometryType.SimpleTypes.Point: eType = ArcMapBrowse.BrowseGISTypes.Point; break;

                case GCDConsoleLib.GDalGeometryType.SimpleTypes.LineString: eType = ArcMapBrowse.BrowseGISTypes.Line; break;

                case GCDConsoleLib.GDalGeometryType.SimpleTypes.Polygon: eType = ArcMapBrowse.BrowseGISTypes.Polygon; break;
                }

                GCDConsoleLib.Vector result = ArcMapBrowse.BrowseOpenVector(e.FormTitle, dir, FCName, eType, e.hWndParent);
                if (result is GCDConsoleLib.Vector)
                {
                    txt.Text = result.GISFileInfo.FullName;
                }
            }
Example #4
0
            public void OnGISSelectingVector(System.Windows.Forms.TextBox txt, naru.ui.PathEventArgs e, GCDConsoleLib.GDalGeometryType.SimpleTypes geometryType)
            {
                try
                {
                    ArcMapBrowse.BrowseGISTypes eType = ArcMapBrowse.BrowseGISTypes.Polygon;
                    switch (geometryType)
                    {
                    case GCDConsoleLib.GDalGeometryType.SimpleTypes.Point:
                        eType = ArcMapBrowse.BrowseGISTypes.Point;
                        break;

                    case GCDConsoleLib.GDalGeometryType.SimpleTypes.LineString:
                        eType = ArcMapBrowse.BrowseGISTypes.Line;
                        break;

                    case GCDConsoleLib.GDalGeometryType.SimpleTypes.Polygon:
                        eType = ArcMapBrowse.BrowseGISTypes.Polygon;
                        break;
                    }

                    frmLayerSelector frm = new frmLayerSelector(eType);
                    if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        txt.Text = frm.SelectedLayer.FullPath.FullName;
                    }
                }
                catch (Exception ex)
                {
                    GCDCore.GCDException.HandleException(ex);
                }
            }
Example #5
0
        public static GCDConsoleLib.Raster BrowseRaster(string formTitle, IntPtr parentWindow)
        {
            FileInfo path = null;

            if (IsArcMap)
            {
                if (GISLayerBrowsingEventHandler != null)
                {
                    naru.ui.PathEventArgs e = new naru.ui.PathEventArgs(path, formTitle, parentWindow);
                    ProjectManager.GISLayerBrowsingEventHandler(null, e);
                    if (e.Path is FileInfo)
                    {
                        path = e.Path;
                    }
                }
            }
            else
            {
                path = naru.os.File.BrowseOpenFile(formTitle, "Raster Files (*.tif, *.tiff, *.img)|*.tif;*.tiff;*.img");
            }

            GCDConsoleLib.Raster raster = null;
            if (path is FileInfo)
            {
                raster = new GCDConsoleLib.Raster(path);
            }

            return(raster);
        }
Example #6
0
 public static void OnBrowseRaster(System.Windows.Forms.TextBox txt, naru.ui.PathEventArgs e)
 {
     if (GISLayerBrowsingEventHandler != null)
     {
         ProjectManager.GISLayerBrowsingEventHandler(txt, e);
     }
 }
Example #7
0
        public void cmdBrowseRaster_Click(object sender, naru.ui.PathEventArgs e)
        {
            try
            {
                if (ProjectManager.IsArcMap)
                {
                    if (BrowseRaster != null)
                    {
                        BrowseRaster((TextBox)sender, e);
                    }
                }
                else
                {
                    naru.ui.Textbox.BrowseOpenRaster(txtPath, naru.ui.UIHelpers.WrapMessageWithNoun("Browse and Select a", Noun, "Raster"));
                }

                if (!string.IsNullOrEmpty(txtPath.Text) && System.IO.File.Exists(txtPath.Text))
                {
                    FullPath = new System.IO.FileInfo(txtPath.Text);
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error browsing to raster");
            }
        }
Example #8
0
        public void cmdBrowse_Click(object sender, naru.ui.PathEventArgs e)
        {
            try
            {
                if (ProjectManager.IsArcMap)
                {
                    if (BrowseVector != null)
                    {
                        BrowseVector((TextBox)sender, e, m_GeometryType);
                    }
                }
                else
                {
                    naru.ui.Textbox.BrowseOpenVector(txtPath, naru.ui.UIHelpers.WrapMessageWithNoun("Browse and Select a", Noun, "ShapeFile"));
                }

                if (!string.IsNullOrEmpty(txtPath.Text) && System.IO.File.Exists(txtPath.Text))
                {
                    FullPath = new System.IO.FileInfo(txtPath.Text);
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower().Contains("missing spatial reference"))
                {
                    string msg = string.Format("The selected feature class appears to be missing a spatial reference. All GCD feature classes must possess a spatial reference and it must be the same spatial reference for all GIS datasets in a GCD project.");

                    GCDConsoleLib.Projection refProj = ProjectManager.Project.ReferenceProjection;
                    if (refProj != null)
                    {
                        msg += string.Format("{1}{1}If the selected feature class does in fact exist in the GCD project coordinate system, but the feature class coordinate system has not yet been defined, then" +
                                             " use a GIS 'Define Projection' geoprocessing tool to correct the problem with the selected feature class by defining the spatial reference as follows. " +
                                             "Then try importing it into the GCD again:{1}{1}{1}{0}", refProj.PrettyWkt, Environment.NewLine);
                    }

                    txtPath.Text = string.Empty;
                    MessageBox.Show(msg, "Missing Spatial Reference", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (ex.Data.Contains("MultiPart"))
                {
                    MessageBox.Show("The Shapefile contains one or more multi-part features. Multi-part features are incompatible with the GCD." +
                                    " Remove or split all multi-part features and then try again.", "Multi-Part Features", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtPath.Text = string.Empty;
                }
                else
                {
                    GCDException.HandleException(ex, string.Format("Error browsing to vector {0}", Noun));
                }
            }
        }
Example #9
0
        private void InputShapeFileChanged(object sender, naru.ui.PathEventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            GCDConsoleLib.Vector shapeFile = ucPolygon.SelectedItem;

            // Use the ShapeFile file name if the user hasn't specified one yet
            if (string.IsNullOrEmpty(txtName.Text))
            {
                txtName.Text = Path.GetFileNameWithoutExtension(shapeFile.GISFileInfo.FullName);
            }

            Cursor = Cursors.Default;
            cmdOK.Select();
        }
Example #10
0
            public void OnGISBrowseRaster(System.Windows.Forms.TextBox txt, naru.ui.PathEventArgs e)
            {
                System.IO.DirectoryInfo dir = null;
                string RasterName           = string.Empty;

                if (e.Path is System.IO.FileInfo)
                {
                    dir        = e.Path.Directory;
                    RasterName = System.IO.Path.GetFileName(e.Path.FullName);
                }

                GCDConsoleLib.Raster result = ArcMapBrowse.BrowseOpenRaster(e.FormTitle, dir, RasterName, e.hWndParent);
                if (result is GCDConsoleLib.Raster)
                {
                    e.Path = result.GISFileInfo;
                }
            }
Example #11
0
        private void InputShapeFileChanged(object sender, naru.ui.PathEventArgs e)
        {
            if (ucPolyline.SelectedItem == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            GCDConsoleLib.Vector shapeFile = ucPolyline.SelectedItem;

            // Use the ShapeFile file name if the user hasn't specified one yet
            if (string.IsNullOrEmpty(txtName.Text))
            {
                txtName.Text = naru.os.File.RemoveDangerousCharacters(System.IO.Path.GetFileNameWithoutExtension(shapeFile.GISFileInfo.FullName));
            }

            cboLabel.DataSource = shapeFile.Fields.Values.Where(x => x.Type.Equals(GCDConsoleLib.GDalFieldType.StringField)).ToList <GCDConsoleLib.VectorField>();
            List <GCDConsoleLib.VectorField> distanceFields = shapeFile.Fields.Values.Where(x => x.Type.Equals(GCDConsoleLib.GDalFieldType.RealField)).ToList <GCDConsoleLib.VectorField>();

            cboDistance.DataSource = distanceFields;

            // Help the user by finding default distance field
            try
            {
                string[] defaults = { "Distance", "Station" };
                foreach (string strField in defaults)
                {
                    if (distanceFields.Any(x => string.Compare(x.Name, strField, true) == 0))
                    {
                        cboDistance.SelectedIndex = distanceFields.IndexOf(distanceFields.First(x => string.Compare(x.Name, strField, true) == 0));
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error attempting to auto-select the profile route distance field: " + ex.Message);
            }

            Cursor = Cursors.Default;
        }
Example #12
0
        private void InputShapeFileChanged(object sender, naru.ui.PathEventArgs e)
        {
            cboField.DataSource = null;

            if (ucPolygon.SelectedItem == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            GCDConsoleLib.Vector shapeFile = ucPolygon.SelectedItem;

            // Use the ShapeFile file name if the user hasn't specified one yet
            if (string.IsNullOrEmpty(txtName.Text))
            {
                txtName.Text = Path.GetFileNameWithoutExtension(shapeFile.GISFileInfo.FullName);
            }

            cboField.DataSource = shapeFile.Fields.Values.Where(x => x.Type.Equals(GCDConsoleLib.GDalFieldType.StringField)).ToList <GCDConsoleLib.VectorField>();
            Cursor = Cursors.Default;
        }