Beispiel #1
0
 /// <summary>
 /// Call this when saving the form data to update the project with the contents of binding list from the data grid
 /// </summary>
 /// <param name="project"></param>
 private void UpdateProjectMetdata(GCDProject project)
 {
     project.MetaData.Clear();
     foreach (ProjectMetaData item in MetaData)
     {
         project.MetaData[item.Key] = item.Value;
     }
 }
Beispiel #2
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");
            }
        }