示例#1
0
        private void EditProjectProperties(string project)
        {
            // edit current project properties
            DataTable projectprops = new DataTable("T5PROJECT");
            projectprops.Columns.Add("CARMAKE");
            projectprops.Columns.Add("CARMODEL");
            projectprops.Columns.Add("CARMY");
            projectprops.Columns.Add("CARVIN");
            projectprops.Columns.Add("NAME");
            projectprops.Columns.Add("BINFILE");
            projectprops.Columns.Add("VERSION");
            projectprops.ReadXml(m_appSettings.ProjectFolder + "\\" + project + "\\projectproperties.xml");

            frmProjectProperties projectproperties = new frmProjectProperties();
            projectproperties.Version = projectprops.Rows[0]["VERSION"].ToString();
            projectproperties.ProjectName = projectprops.Rows[0]["NAME"].ToString();
            projectproperties.CarMake = projectprops.Rows[0]["CARMAKE"].ToString();
            projectproperties.CarModel = projectprops.Rows[0]["CARMODEL"].ToString();
            projectproperties.CarVIN = projectprops.Rows[0]["CARVIN"].ToString();
            projectproperties.CarMY = projectprops.Rows[0]["CARMY"].ToString();
            projectproperties.BinaryFile = projectprops.Rows[0]["BINFILE"].ToString();
            bool _reopenProject = false;

            if (projectproperties.ShowDialog() == DialogResult.OK)
            {
                if (project != projectproperties.ProjectName)
                {
                    Directory.Move(m_appSettings.ProjectFolder + "\\" + project, m_appSettings.ProjectFolder + "\\" + projectproperties.ProjectName);
                    project = projectproperties.ProjectName;
                    m_CurrentWorkingProject = project;
                    // set the working file to the correct folder
                    projectproperties.BinaryFile = Path.Combine(m_appSettings.ProjectFolder + "\\" + project, Path.GetFileName(projectprops.Rows[0]["BINFILE"].ToString()));
                    _reopenProject = true;
                    // open this project

                }
                // delete the original XML file
                File.Delete(m_appSettings.ProjectFolder + "\\" + project + "\\projectproperties.xml");
                DataTable dtProps = new DataTable("T5PROJECT");
                dtProps.Columns.Add("CARMAKE");
                dtProps.Columns.Add("CARMODEL");
                dtProps.Columns.Add("CARMY");
                dtProps.Columns.Add("CARVIN");
                dtProps.Columns.Add("NAME");
                dtProps.Columns.Add("BINFILE");
                dtProps.Columns.Add("VERSION");
                dtProps.Rows.Add(projectproperties.CarMake, projectproperties.CarModel, projectproperties.CarMY, projectproperties.CarVIN, MakeDirName(projectproperties.ProjectName), projectproperties.BinaryFile, projectproperties.Version);
                dtProps.WriteXml(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectproperties.ProjectName) + "\\projectproperties.xml");
                if (_reopenProject)
                {
                    OpenProject(m_CurrentWorkingProject);
                }
                m_ProjectLog.WriteLogbookEntry(LogbookEntryType.PropertiesEdited, projectproperties.Version);
            }
        }
示例#2
0
 private void btnCreateProject_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // show the project properties screen for the user to fill in
     // if a bin file is loaded, ask the user whether this should be the new projects binary file
     // the project XML should contain a reference to this binfile as well as a lot of other stuff
     frmProjectProperties projectprops = new frmProjectProperties();
     if (m_trionicFile != null)
     {
         projectprops.BinaryFile = m_trionicFileInformation.Filename;
         projectprops.CarModel = m_trionicFile.GetTrionicProperties().Carmodel.Trim();
         projectprops.ProjectName = m_trionicFile.GetTrionicProperties().Enginetype.Trim() + " " + m_trionicFile.GetTrionicProperties().Partnumber.Trim() + " " + m_trionicFile.GetTrionicProperties().SoftwareID.Trim();
     }
     if (projectprops.ShowDialog() == DialogResult.OK)
     {
         if (!Directory.Exists(m_appSettings.ProjectFolder)) Directory.CreateDirectory(m_appSettings.ProjectFolder);
         // create a new folder with these project properties.
         // also copy the binary file into the subfolder for this project
         if (Directory.Exists(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName)))
         {
             frmInfoBox info = new frmInfoBox("The chosen projectname already exists, please choose another one");
             //TODO: reshow the dialog if the project name already exists
         }
         else
         {
             // create the project
             Directory.CreateDirectory(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName));
             // copy the selected binary file to this folder
             string binfilename = m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName) + "\\" + Path.GetFileName(projectprops.BinaryFile);
             File.Copy(projectprops.BinaryFile, binfilename);
             // now create the projectproperties.xml in this new folder
             DataTable dtProps = new DataTable("T5PROJECT");
             dtProps.Columns.Add("CARMAKE");
             dtProps.Columns.Add("CARMODEL");
             dtProps.Columns.Add("CARMY");
             dtProps.Columns.Add("CARVIN");
             dtProps.Columns.Add("NAME");
             dtProps.Columns.Add("BINFILE");
             dtProps.Columns.Add("VERSION");
             dtProps.Rows.Add(projectprops.CarMake, projectprops.CarModel, projectprops.CarMY, projectprops.CarVIN, MakeDirName(projectprops.ProjectName), binfilename, projectprops.Version);
             dtProps.WriteXml(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName) + "\\projectproperties.xml");
             OpenProject(projectprops.ProjectName); //?
         }
     }
 }