示例#1
0
        /// <summary>
        /// Saves user settings for this project.
        /// </summary>
        internal void SaveSettings()
        {
            string dataFolder       = m_Container.CreateDataFolder(m_Id);
            string settingsFileName = Path.Combine(dataFolder, "settings.txt");

            m_Settings.WriteXML(settingsFileName);
        }
示例#2
0
        /// <summary>
        /// Creates a brand new project. If this completes without any exception, you can
        /// call <see cref="OpenProject"/> to activate the project.
        /// </summary>
        /// <param name="projectName">The user-perceived name for the project.</param>
        /// <param name="layer">The map layer the project is for (not null)</param>
        internal void CreateProject(string projectName, ILayer layer)
        {
            if (String.IsNullOrWhiteSpace(projectName) || layer == null)
            {
                throw new ArgumentNullException();
            }

            // Confirm that the project name is unique
            if (FindProjectId(projectName) != null)
            {
                throw new ArgumentException("Specified project already exists");
            }

            // Define the event data
            NewProjectEvent e = new NewProjectEvent()
            {
                ProjectId     = Guid.NewGuid(),
                ProjectName   = projectName,
                LayerId       = layer.Id,
                DefaultSystem = String.Empty,
                UserName      = System.Environment.UserName,
                MachineName   = System.Environment.MachineName
            };

            // Create the index entry
            CreateIndexEntry(projectName, e.ProjectId);

            // Create the data folder
            string dataFolder = CreateDataFolder(e.ProjectId);

            // Serialize the event data to the data folder. Specify <Change> so that
            // the class name will be included in the output file.
            string s        = EditSerializer.GetSerializedString <Change>(DataField.Edit, e);
            string fileName = Path.Combine(dataFolder, GetDataFileName(e.EditSequence));

            File.WriteAllText(fileName, s);

            // Write initial project settings to the data folder
            ProjectSettings ps = new ProjectSettings();
            IDataServer     ds = EditingController.Current.DataServer;

            if (ds != null)
            {
                ps.ConnectionString = ds.ConnectionString;
            }

            // Turn off auto-number if there's no database connection string
            if (String.IsNullOrEmpty(ps.ConnectionString))
            {
                ps.IsAutoNumber = false;
            }

            // Remember default entity types for points, lines, text, polygons
            ps.SetEntityTypeDefaults(layer);

            // Save the settings
            string settingsFileName = Path.Combine(dataFolder, "settings.txt");

            ps.WriteXML(settingsFileName);
        }