コード例 #1
0
 private void selectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         DEMSurveys.ToList <DEMItem>().ForEach(x => x.Include = ((System.Windows.Forms.ToolStripMenuItem)sender).Name.ToLower().Contains("all"));
     }
     catch (Exception ex)
     {
         GCDException.HandleException(ex);
     }
 }
コード例 #2
0
        protected DialogResult EditTreeItem(Form frm, bool treeReload = true)
        {
            if (frm == null)
            {
                return(DialogResult.Abort);
            }

            DialogResult eResult = DialogResult.OK;

            try
            {
                eResult = frm.ShowDialog();
                if (eResult == DialogResult.OK && treeReload)
                {
                    IProjectItemForm iForm = frm as IProjectItemForm;
                    if (iForm != null)
                    {
                        // Get the GCD project item that was just added or edited
                        GCDProjectItem changedItem = iForm.GCDProjectItem;

                        // Selected this node if it is an item node and was just edited
                        if (this is TreeNodeItem && ((TreeNodeItem)this).Item.Equals(changedItem))
                        {
                            Text = changedItem.Name;
                        }
                        else
                        {
                            // Polymorphic loading of relevant child nodes
                            LoadChildNodes();

                            // Loop through the child nodes and select the item that was just added
                            foreach (TreeNode childNode in Nodes)
                            {
                                if (childNode is TreeNodeItem)
                                {
                                    if (((TreeNodeItem)childNode).Item.Equals(changedItem))
                                    {
                                        TreeView.SelectedNode = childNode;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error Editing GCD Project Item");
            }

            return(eResult);
        }
コード例 #3
0
ファイル: GCDProjectGroup.cs プロジェクト: tarinishukla/gcd
 public void OnRefresh(object sender, EventArgs e)
 {
     try
     {
         ProjectManager.OpenProject(ProjectManager.Project.ProjectFile);
         LoadChildNodes();
     }
     catch (Exception ex)
     {
         GCDException.HandleException(ex, "Error refreshing GCD project explorer tree.");
     }
 }
コード例 #4
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (Assoc == null)
                {
                    FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiOutput.Directory.Create();

                    switch (SelectedAssociatedSurfaceType)
                    {
                    case AssocSurface.AssociatedSurfaceTypes.SlopeDegree:
                        GCDConsoleLib.RasterOperators.SlopeDegrees(DEM.Raster, fiOutput, ProjectManager.OnProgressChange);
                        break;

                    case AssocSurface.AssociatedSurfaceTypes.SlopePercent:
                        GCDConsoleLib.RasterOperators.SlopePercent(DEM.Raster, fiOutput, ProjectManager.OnProgressChange);

                        break;

                    default:
                        // This form is not capable of creating other associated surface types
                        throw new NotImplementedException(string.Format("The associated surface form is not capable of creating {0} rasters", SelectedAssociatedSurfaceType));
                    }

                    Assoc = new AssocSurface(txtName.Text, fiOutput, DEM, SelectedAssociatedSurfaceType);
                    DEM.AssocSurfaces.Add(Assoc);
                    ProjectManager.AddNewProjectItemToMap(Assoc);
                }
                else
                {
                    Assoc.Name             = txtName.Text;
                    Assoc.AssocSurfaceType = SelectedAssociatedSurfaceType;
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error generating associated surface raster.");
                DialogResult = DialogResult.None;
            }
        }
コード例 #5
0
 private void selectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         bool bIncude = ((System.Windows.Forms.ToolStripMenuItem)sender).Name.ToLower().Contains("all");
         MaskItems.ToList <GCDCore.Project.Masks.MaskItem>().ForEach(x => x.Include = bIncude);
         MaskItems.ResetBindings();
     }
     catch (Exception ex)
     {
         GCDException.HandleException(ex);
     }
 }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>PGB - 5 May 2011
        /// Change this so that the XML file is created when the file is created. This is needed because
        /// the XML file stores the name of the project, which is required now for the toolbar.</remarks>
        private void btnOK_Click(System.Object sender, System.EventArgs e)
        {
            if (!ValidateForm())
            {
                this.DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Properties.Settings.Default.LastUsedProjectFolder = Path.GetDirectoryName(txtGCDPath.Text);
                Properties.Settings.Default.Save();

                if (CreateMode)
                {
                    // Creating a new project
                    Directory.CreateDirectory(Path.GetDirectoryName(txtGCDPath.Text));
                    System.IO.FileInfo          projectFile = new System.IO.FileInfo(txtGCDPath.Text);
                    GCDConsoleLib.GCD.UnitGroup units       = GetSelectedUnits();

                    GCDProject project = new GCDProject(txtName.Text, txtDescription.Text, projectFile, DateTime.Now, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), UnitsNet.Area.From(0, units.ArUnit), units);

                    UpdateProjectMetdata(project);

                    ProjectManager.CreateProject(project);
                }
                else
                {
                    // Editing properties of existing project
                    ProjectManager.Project.Name        = txtName.Text;
                    ProjectManager.Project.Description = txtDescription.Text;

                    // only allowed to change the units if there are no DEMs
                    if (ProjectManager.Project.DEMSurveys.Count < 1)
                    {
                        ProjectManager.Project.Units = GetSelectedUnits();
                    }

                    UpdateProjectMetdata(ProjectManager.Project);
                    ProjectManager.Project.Save();
                }
            }
            catch (Exception ex)
            {
                DialogResult            = DialogResult.None;
                ex.Data["Project Name"] = txtName.Text;
                ex.Data["XML File"]     = txtGCDPath.Text;
                ex.Data["Directory"]    = txtDirectory.Text;
                GCDException.HandleException(ex, "An error occured while trying to save the information");
            }
        }
コード例 #7
0
 private void selectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         for (int i = 0; i < lstDoDs.Items.Count; i++)
         {
             lstDoDs.SetItemChecked(i, ((System.Windows.Forms.ToolStripMenuItem)sender).Name.ToLower().Contains("all"));
         }
     }
     catch (Exception ex)
     {
         GCDException.HandleException(ex);
     }
 }
コード例 #8
0
ファイル: ucVectorInput.cs プロジェクト: tarinishukla/gcd
        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));
                }
            }
        }
コード例 #9
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ucName.ValidateForm() || !ucErrProps.ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (chkDefault.Checked && DEM.ErrorSurfaces.Count > 0)
                {
                    // Need to set all other error surfaces to not be the default
                    DEM.ErrorSurfaces.ToList().ForEach(x => x.IsDefault = false);
                }

                if (ErrorSurface == null)
                {
                    // If this is a FIS error surface then copy the FIS file to the project and point the error surface property to
                    // this local file before saving the project. This will ensure that path to the FIS file is local to the project.
                    // MUST BE DONE BEFORE SAVING ERROR PROPERTIES TO THE PROJECT
                    ucErrProps.ErrSurfProperty.CloneToProject(ucName.ItemName, ucName.AbsolutePath.Directory);

                    // Create the raster then add it to the DEM survey
                    ucName.AbsolutePath.Directory.Create();
                    RasterOperators.CreateErrorRaster(DEM.Raster, ucErrProps.ErrSurfProperty.GCDErrSurfPropery, ucName.AbsolutePath, ProjectManager.OnProgressChange);
                    ErrorSurface = new ErrorSurface(ucName.ItemName, ucName.AbsolutePath, DEM, chkDefault.Checked, ucErrProps.ErrSurfProperty);
                    DEM.ErrorSurfaces.Add(ErrorSurface);
                    ProjectManager.AddNewProjectItemToMap(ErrorSurface);
                }
                else
                {
                    ErrorSurface.Name = ucName.ItemName;
                }

                // Handles unsetting default on other error surface and setting it for this one
                DEM.DefaultErrorSurface = ErrorSurface;

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Error Surface Created Successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error editing single region error surface");
            }
        }
コード例 #10
0
        private void cmdOK_Click(System.Object sender, System.EventArgs e)
        {
            if (!ValidateForm())
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }

            try
            {
                Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                System.IO.DirectoryInfo dFolder = ProjectManager.Project.GetAbsoluteDir(txtOutputFolder.Text);
                GCDCore.Engines.ChangeDetectionEngineBase cdEngine = null;

                if (ucThresholding.ThresholdProperties.Method == Engines.DoD.ThresholdProps.ThresholdMethods.MinLoD)
                {
                    cdEngine = new Engines.ChangeDetectionEngineMinLoD(ucDEMs.NewSurface, ucDEMs.OldSurface, ucDEMs.AOIMask, ucThresholding.ThresholdProperties.Threshold);
                }
                else
                {
                    if (ucThresholding.ThresholdProperties.Method == Engines.DoD.ThresholdProps.ThresholdMethods.Propagated)
                    {
                        cdEngine = new Engines.ChangeDetectionEnginePropProb(ucDEMs.NewSurface, ucDEMs.OldSurface, ucDEMs.NewError, ucDEMs.OldError, ucDEMs.AOIMask);
                    }
                    else
                    {
                        cdEngine = new Engines.ChangeDetectionEngineProbabilistic(ucDEMs.NewSurface, ucDEMs.OldSurface, ucDEMs.AOIMask, ucDEMs.NewError, ucDEMs.OldError, ucThresholding.ThresholdProperties.Threshold, ucThresholding.ThresholdProperties.SpatialCoherenceProps);
                    }
                }

                DoD = cdEngine.Calculate(txtName.Text, dFolder, true, ProjectManager.Project.Units);

                ProjectManager.OnAddRasterToMap(DoD.ThrDoD);

                ProjectManager.Project.DoDs.Add(DoD);
                ProjectManager.Project.Save();
                ProjectManager.AddNewProjectItemToMap(DoD);
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex);
                DoD = null;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
コード例 #11
0
        public override void OnAdd(object sender, EventArgs e)
        {
            // Determine if this is the first DEM in the project or use the first existing DEM as a reference surface
            DEMSurvey referenceDEM = null;

            SurveyLibrary.frmImportRaster.Purposes ePurpose = SurveyLibrary.frmImportRaster.Purposes.FirstDEM;
            if (ProjectManager.Project.DEMSurveys.Count > 0)
            {
                referenceDEM = ProjectManager.Project.DEMSurveys.First();
                ePurpose     = SurveyLibrary.frmImportRaster.Purposes.SubsequentDEM;
            }

            try
            {
                SurveyLibrary.frmImportRaster frm = SurveyLibrary.frmImportRaster.PrepareToImportRaster(referenceDEM, ePurpose, "DEM Survey", new IntPtr(0));

                if (EditTreeItem(frm, false) == DialogResult.OK)
                {
                    GCDConsoleLib.Raster rDEM = frm.ProcessRaster();
                    DEMSurvey            dem  = new DEMSurvey(frm.txtName.Text, null, rDEM.GISFileInfo, Surface.HillShadeRasterPath(rDEM.GISFileInfo));
                    ProjectManager.Project.DEMSurveys.Add(dem);

                    // If this was the first raster then we need to store the cell resolution on the project
                    if (ePurpose == SurveyLibrary.frmImportRaster.Purposes.FirstDEM)
                    {
                        ProjectManager.Project.CellArea = dem.Raster.Extent.CellArea(ProjectManager.Project.Units);
                    }

                    ProjectManager.Project.Save();
                    ProjectManager.AddNewProjectItemToMap(dem);
                    LoadChildNodes();

                    // Loop through the child nodes and select the item that was just added
                    foreach (TreeNodeItem childNode in Nodes)
                    {
                        if (childNode.Item.Equals(dem))
                        {
                            TreeView.SelectedNode = childNode;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error Importing DEM Survey");
            }
        }
コード例 #12
0
ファイル: DoDGroup.cs プロジェクト: tarinishukla/gcd
 public override void OnAdd(object sender, EventArgs e)
 {
     BudgetSegregation.frmBudgetSegProperties frm = new BudgetSegregation.frmBudgetSegProperties(DoD);
     if (EditTreeItem(frm) == DialogResult.OK)
     {
         try
         {
             BudgetSegregation.frmBudgetSegResults frmResults = new BudgetSegregation.frmBudgetSegResults(frm.BudgetSeg);
             frmResults.ShowDialog();
         }
         catch (Exception ex)
         {
             GCDException.HandleException(ex);
         }
     }
 }
コード例 #13
0
ファイル: DoDGroup.cs プロジェクト: tarinishukla/gcd
 public void OnViewResults(object sender, EventArgs e)
 {
     ChangeDetection.frmDoDResults frm = new ChangeDetection.frmDoDResults(DoD);
     try
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             // User might have edited the name
             Text = DoD.Name;
         }
     }
     catch (Exception ex)
     {
         GCDException.HandleException(ex, "Error viewing change detection results");
     }
 }
コード例 #14
0
ファイル: OnlineHelp.cs プロジェクト: tarinishukla/gcd
        public static void Show(string helpKey)
        {
            string helpURL = GCDCore.Properties.Resources.GCDWebSiteURL;

            try
            {
                helpURL = string.Format("{0}?APPKEY={1}", helpURL, helpKey);
                System.Diagnostics.Process.Start(helpURL);
            }
            catch (Exception ex)
            {
                ex.Data["Help Key"] = helpKey;
                ex.Data["Help URL"] = helpURL;
                GCDException.HandleException(ex, "Error launching online help.");
            }
        }
コード例 #15
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                this.DialogResult = DialogResult.None;
                return;
            }

            RasterOperators.MultiMathOpType eMethod = (RasterOperators.MultiMathOpType)((naru.db.NamedObject)cboMethod.SelectedItem).ID;

            List <Tuple <DEMSurvey, ErrorSurface> > rInputs = new List <Tuple <DEMSurvey, ErrorSurface> >();

            for (int i = 0; i < grdData.Rows.Count; i++)
            {
                DEMItem dem = grdData.Rows[i].DataBoundItem as DEMItem;
                if (!dem.Include)
                {
                    continue;
                }

                DataGridViewComboBoxCell comboCell = grdData.Rows[i].Cells["colError"] as DataGridViewComboBoxCell;
                BindingSource            bs        = comboCell.DataSource as BindingSource;
                ErrorSurface             err       = bs.Current as ErrorSurface;

                rInputs.Add(new Tuple <DEMSurvey, ErrorSurface>(dem._DEM, err));
            }

            Engines.ReferenceSurfaceEngine eng = new Engines.ReferenceSurfaceEngine(txtName.Text, rInputs, eMethod);

            System.IO.FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
            System.IO.FileInfo fiError  = Surface.ErrorSurfaceRasterPath(fiOutput.Directory, txtName.Text);

            try
            {
                Cursor = Cursors.WaitCursor;

                Surface surf = eng.Run(fiOutput, fiError);
                ProjectManager.AddNewProjectItemToMap(surf);
                Cursor = Cursors.Default;
                MessageBox.Show("Reference surface generated successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error generating reference surface from DEM surveys.");
                this.DialogResult = DialogResult.None;
            }
        }
コード例 #16
0
ファイル: DoDGroup.cs プロジェクト: tarinishukla/gcd
        public void OnDelete(object sender, EventArgs e)
        {
            if (DoD.IsItemInUse)
            {
                MessageBox.Show(string.Format("The {0} {1} is currently in use and cannot be deleted. Before you can delete this {1}," +
                                              " you must delete all GCD project items that refer to this {1} before it can be deleted.", DoD.Name, DoD.Noun),
                                string.Format("{0} In Use", DoD.Noun), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show(string.Format("Are you sure that you want to delete the {0} {1}? The {0} {1} and all its underlying data will be deleted permanently.", DoD.Name, DoD.Noun),
                                Properties.Resources.ApplicationNameLong, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
            {
                return;
            }

            try
            {
                // Grab the PArent so we can reload the children after the delete
                ChangeDetectionGroup cdPArent = (ChangeDetectionGroup)Parent.Parent;
                DoD.Delete();
                Remove();
                cdPArent.LoadChildNodes();
            }
            catch (IOException ex)
            {
                string processes = string.Empty;

                if (ex.Data.Contains("Locks"))
                {
                    MessageBox.Show(string.Format("The following files are being used by other process." +
                                                  " Close all applications that are using these files and try to delete this {0} again.\n\n{1}", NounSingle.ToLower(), ex.Data["Locks"]), "File Locked", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (ex.Data.Contains("Processes"))
                {
                    processes = string.Format(" ({0})", ex.Data["Processes"]);

                    MessageBox.Show(string.Format("One or more files belonging to this {0} are being used by another process{1}." +
                                                  " Close all applications that are using these files and try to delete this {0} again.", NounSingle.ToLower(), processes), "File Locked", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex);
            }
        }
コード例 #17
0
        public override void OnAdd(object sender, EventArgs e)
        {
            DEMSurvey referenceDEM = null;

            if (ProjectManager.Project.DEMSurveys.Count > 0)
            {
                referenceDEM = ProjectManager.Project.DEMSurveys.First();
            }
            else
            {
                MessageBox.Show("You must have at least one DEM survey in your GCD project before you can generate a constant reference surface.", "DEM Surveys Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            try
            {
                SurveyLibrary.frmImportRaster frm = SurveyLibrary.frmImportRaster.PrepareToImportRaster(referenceDEM, SurveyLibrary.frmImportRaster.Purposes.ReferenceSurface, "Reference Surface", new IntPtr(0));

                if (EditTreeItem(frm, false) == DialogResult.OK)
                {
                    GCDConsoleLib.Raster    rDEM = frm.ProcessRaster();
                    GCDCore.Project.Surface surf = new Surface(frm.txtName.Text, rDEM.GISFileInfo, Surface.HillShadeRasterPath(rDEM.GISFileInfo));
                    ProjectManager.Project.ReferenceSurfaces.Add(surf);

                    ProjectManager.Project.Save();
                    LoadChildNodes();

                    ProjectManager.AddNewProjectItemToMap(surf);

                    // Loop through the child nodes and select the item that was just added
                    foreach (TreeNodeItem childNode in Nodes)
                    {
                        if (childNode.Item.Equals(surf))
                        {
                            TreeView.SelectedNode = childNode;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error Importing DEM Survey");
            }
        }
コード例 #18
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (Mask == null)
                {
                    FileInfo fiMask = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiMask.Directory.Create();

                    ucPolygon.SelectedItem.Copy(fiMask);

                    string lablField = chkLabel.Checked ? cboLabel.Text : string.Empty;
                    string distField = chkDistance.Checked ? cboDistance.Text : string.Empty;

                    Mask = new DirectionalMask(txtName.Text, fiMask, cboField.Text, lablField, cboDirection.Text, rdoAscending.Checked, distField);
                    ProjectManager.Project.Masks.Add(Mask);
                    ProjectManager.AddNewProjectItemToMap(Mask);
                }
                else
                {
                    Mask.Name          = txtName.Text;
                    Mask.LabelField    = chkLabel.Checked ? cboLabel.Text : string.Empty;
                    Mask.DistanceField = chkDistance.Checked ? cboDistance.Text : string.Empty;
                    Mask.Ascending     = rdoAscending.Checked;
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error creating regular mask.");
            }
        }
コード例 #19
0
ファイル: frmAOIProperties.cs プロジェクト: tarinishukla/gcd
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (AOIMask == null)
                {
                    FileInfo fiDestination = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiDestination.Directory.Create();

                    ucPolygon.SelectedItem.Copy(fiDestination);

                    AOIMask = new GCDCore.Project.Masks.AOIMask(txtName.Text, fiDestination);
                    ProjectManager.Project.Masks.Add(AOIMask);
                    ProjectManager.AddNewProjectItemToMap(AOIMask);
                }
                else
                {
                    AOIMask.Name = txtName.Text;
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Area of interest mask saved successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error saving area of interest mask.");
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
コード例 #20
0
 private void txtName_TextChanged(object sender, System.EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtName.Text))
         {
             txtOutputFolder.Text = string.Empty;
         }
         else
         {
             txtOutputFolder.Text = ProjectManager.Project.GetRelativePath(ProjectManager.Project.GetDoDFolder().FullName);
         }
     }
     catch (Exception ex)
     {
         ex.Data["DoD Name"]     = txtName.Text;
         ex.Data["Project Path"] = ProjectManager.Project.ProjectFile.Directory.FullName;
         GCDException.HandleException(ex, "Error attempting to generate change detection directory");
     }
 }
コード例 #21
0
ファイル: frmFISLibrary.cs プロジェクト: tarinishukla/gcd
        private void FISLibraryForm_Load(System.Object sender, System.EventArgs e)
        {
            tTip.SetToolTip(btnAddFIS, "Add a FIS file to the GCD FIS Library.");
            tTip.SetToolTip(btnEditFIS, "Edit the selected FIS file.");
            tTip.SetToolTip(btnDeleteFIS, "Delete the selected FIS file.");
            tTip.SetToolTip(btnFISRepo, "Open a web browser and view the contents of the online FIS repository.");

            grdFIS.AutoGenerateColumns = false;

            try
            {
                FISList           = ProjectManager.FISLibrary.FISItems;
                grdFIS.DataSource = FISList;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex);
            }

            UpdateControls(sender, e);
        }
コード例 #22
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            try
            {
                //validate form
                if (!ValidateForm())
                {
                    this.DialogResult = DialogResult.None;
                    return;
                }

                Cursor = Cursors.WaitCursor;

                List <Tuple <string, GCDConsoleLib.GCD.DoDStats> > dodStats = new List <Tuple <string, GCDConsoleLib.GCD.DoDStats> >();
                List <DoDBase> dods = new List <DoDBase>();
                foreach (DoDBase dod in lstDoDs.CheckedItems)
                {
                    dodStats.Add(new Tuple <string, GCDConsoleLib.GCD.DoDStats>(dod.Name, dod.Statistics));
                    dods.Add(dod);
                }

                System.IO.FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                if (!fiOutput.Directory.Exists)
                {
                    fiOutput.Directory.Create();
                }

                Engines.InterComparison.Generate(dodStats, fiOutput);

                InterComparison = new InterComparison(txtName.Text, fiOutput, dods);
                ProjectManager.Project.InterComparisons.Add(InterComparison);
                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Change detection inter-comparison generated successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error performing change detection inter-comparison.");
            }
        }
コード例 #23
0
ファイル: frmPointDensity.cs プロジェクト: tarinishukla/gcd
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (!ValidateForm())
                {
                    DialogResult = DialogResult.None;
                    return;
                }

                Cursor = Cursors.WaitCursor;

                FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                fiOutput.Directory.Create();

                RasterOperators.PointDensity(DEM.Raster, ucPointCloud.SelectedItem, fiOutput, KernelShape, valSampleDistance.Value,
                                             ProjectManager.OnProgressChange);

                Assoc = new AssocSurface(txtName.Text, fiOutput, DEM, AssocSurface.AssociatedSurfaceTypes.PointDensity);
                DEM.AssocSurfaces.Add(Assoc);
                ProjectManager.Project.Save();
                ProjectManager.AddNewProjectItemToMap(Assoc);
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor       = Cursors.Default;
                DialogResult = DialogResult.None;

                if (ex.Message.ToLower().Contains("multipart") || ex.Message.ToLower().Contains("multi-part"))
                {
                    MessageBox.Show("The ShapeFile contains multi-part features and is incompatible with the GCD. Please select a single part point ShapeFile.", "Multi-Part Features Detected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    GCDException.HandleException(ex, "Error generating point density associated surface raster.");
                }
            }
        }
コード例 #24
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (ProfileRoute == null)
                {
                    FileInfo fiMask = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiMask.Directory.Create();

                    ucPolyline.SelectedItem.Copy(fiMask);

                    string lablField = chkLabel.Checked ? cboLabel.Text : string.Empty;

                    ProfileRoute = new GCDCore.Project.ProfileRoutes.ProfileRoute(txtName.Text, fiMask, cboDistance.Text, lablField, ProfileRouteType);
                    ProjectManager.Project.ProfileRoutes.Add(ProfileRoute);
                    ProjectManager.AddNewProjectItemToMap(ProfileRoute);
                }
                else
                {
                    ProfileRoute.Name = txtName.Text;
                }

                ProjectManager.Project.Save();

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error creating regular mask.");
            }
        }
コード例 #25
0
        /// <summary>
        /// Handles clicking the OK button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdOK_Click(object sender, EventArgs e)
        {
            //validate form
            if (!ValidateForm())
            {
                this.DialogResult = DialogResult.None;
                return;
            }

            try
            {
                //Change state of UI
                this.UseWaitCursor = true;

                cmdOK.Enabled          = false;
                cmdCancel.DialogResult = DialogResult.None;
                DisableForm();

                //set chronological order
                for (int i = 0; i < DEMs.Count; i++)
                {
                    DEMSurveyItem currentSurveyItem = DEMs[i];
                    DEMSurvey     currentDEMSurvey  = currentSurveyItem.DEM;
                    currentDEMSurvey.ChronologicalOrder = i;
                }
                ProjectManager.Project.Save();

                //setup and run batch engine
                ThresholdProps threshold    = ucThresholding1.ThresholdProperties;
                List <Epoch>   ActiveEpochs = Epochs.Where(epoch => epoch.IsActive == true).ToList();
                BatchEngine = new ChangeDetectionMultiEpoch(ActiveEpochs, ucAOI1.AOIMask, threshold);
                bgWorker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex);
            }
        }
コード例 #26
0
 private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         // Generate an inline event handler function to call our async progresschanged function below
         EventHandler <GCDConsoleLib.OpStatus> receivedEventsHandler = delegate(object innerSender, GCDConsoleLib.OpStatus innerEvent) {
             if (bgWorker.IsBusy)
             {
                 bgWorker.ReportProgress(innerEvent.Progress, innerEvent);
             }
         };
         ProjectManager.OnProgressChangeAsync += receivedEventsHandler;
         BatchEngine.Run(bgWorker);
     }
     catch (Exception ex)
     {
         GCDException.HandleException(ex);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
コード例 #27
0
ファイル: frmMorpProperties.cs プロジェクト: tarinishukla/gcd
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                // Create the morphological analysis
                Analysis = new MorphologicalAnalysis(txtName.Text, ProjectManager.Project.GetAbsoluteDir(txtPath.Text), cboBS.SelectedItem as GCDCore.Project.BudgetSegregation);

                try
                {
                    // Save the morphological spreadsheet to file
                    Analysis.OutputFolder.Create();
                    Analysis.SaveExcelSpreadsheet();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    // We can live without the spreadsheet
                    Console.Write("Morphological analysis spreadsheet error saving to " + Analysis.Spreadsheet.FullName);
                }

                GCDCore.Project.BudgetSegregation bs = cboBS.SelectedItem as GCDCore.Project.BudgetSegregation;
                bs.MorphologicalAnalyses.Add(Analysis);
                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error generating morphological analysis.");
            }
        }
コード例 #28
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (Mask == null)
                {
                    FileInfo fiMask = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiMask.Directory.Create();

                    ucPolygon.SelectedItem.Copy(fiMask);

                    Mask = new GCDCore.Project.Masks.RegularMask(txtName.Text, fiMask, cboField.Text, MaskItems.ToList <GCDCore.Project.Masks.MaskItem>());
                    ProjectManager.Project.Masks.Add(Mask);
                    ProjectManager.AddNewProjectItemToMap(Mask);
                }
                else
                {
                    Mask.Name = txtName.Text;
                }

                ProjectManager.Project.Save();

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error creating regular mask.");
            }
        }
コード例 #29
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            DialogResult = ValidateForm();
            if (DialogResult != DialogResult.OK)
            {
                return;
            }


            GCDConsoleLib.Raster template = ((DEMSurvey)cboDEMSurvey.SelectedItem).Raster;

            List <float> Values     = new List <float>();
            string       successMsg = string.Empty;

            if (rdoSingle.Checked)
            {
                Values.Add((float)valSingle.Value);
                successMsg = "Reference surface generated successfully.";
            }
            else
            {
                for (decimal aVal = valLower.Value; aVal <= valUpper.Value; aVal += valIncrement.Value)
                {
                    Values.Add((float)aVal);
                }
                successMsg = string.Format("{0} reference surfaces generated successfully.", Values.Count);
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                foreach (float value in Values)
                {
                    string name = GetUniqueName(value);

                    // Get a unique name and ensure directory exists
                    FileInfo fiOutput = ProjectManager.Project.ReferenceSurfacePath(name);
                    fiOutput.Directory.Create();

                    // Generate reference surface
                    GCDConsoleLib.Raster rOut = GCDConsoleLib.RasterOperators.Uniform <float>(template, fiOutput, value, ProjectManager.OnProgressChange);
                    ReferenceSurface = new Surface(name, rOut, null);
                    ProjectManager.Project.ReferenceSurfaces.Add(ReferenceSurface);

                    // Error surface
                    string   errName = string.Format("Uniform Error at {0:0.000}", valError.Value);
                    FileInfo fiError = Surface.ErrorSurfaceRasterPath(fiOutput.Directory, errName);
                    fiError.Directory.Create();

                    GCDConsoleLib.RasterOperators.Uniform <float>(template, fiError, (float)valError.Value, ProjectManager.OnProgressChange);
                    ErrorSurface errSurf = new ErrorSurface(errName, fiError, ReferenceSurface);
                    ReferenceSurface.ErrorSurfaces.Add(errSurf);
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show(successMsg, Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error generating reference surface.");
                this.DialogResult = DialogResult.None;
            }
        }
コード例 #30
0
ファイル: frmMorphResults.cs プロジェクト: tarinishukla/gcd
        private void exportTablularDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog frm = new SaveFileDialog();

            frm.Title  = "Save Tabular Data To File";
            frm.Filter = "Comma Separated Value (CSV) Files (*.csv)|*.csv";

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            try
            {
                // Header row
                List <string> values = new List <string>();
                foreach (DataGridViewColumn col in grdData.Columns)
                {
                    values.Add(col.HeaderText.ToString().Replace(",", ""));
                }
                sb.AppendLine(string.Join(",", values));

                // Data rows
                foreach (DataGridViewRow dgvr in grdData.Rows)
                {
                    values = new List <string>();
                    for (int i = 0; i < grdData.Columns.Count; i++)
                    {
                        values.Add(dgvr.Cells[i].FormattedValue.ToString().Replace(",", ""));
                    }

                    sb.AppendLine(string.Join(",", values));
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error serializing data table");
            }

            try
            {
                using (StreamWriter file = new System.IO.StreamWriter(frm.FileName))
                {
                    file.WriteLine(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error Writing Tabular Data To CSV File");
            }

            if (File.Exists(frm.FileName))
            {
                try
                {
                    System.Diagnostics.Process.Start(frm.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("The tabular data file was created at {0} but an error occured attempting to open the file.\n\n{1}", frm.FileName, ex.Message), Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }