コード例 #1
0
        /// <summary>
        /// Checks whether the current project needs to be saved or not.
        /// If it hasn't been saved, the user will be asked. If the user
        /// decided not to save, any edits performed since the last save
        /// will be discarded. This should be called when the Editor
        /// application is being closed.
        /// </summary>
        internal void CheckSave()
        {
            // Always save project settings
            if (m_Project != null)
            {
                m_Project.SaveSettings();
            }

            if (IsSaved)
            {
                return;
            }

            Session s = CadastralMapModel.Current.WorkingSession;

            Debug.Assert(s != null);

            if (MessageBox.Show("Do you want to save changes?", "Changes not saved", MessageBoxButtons.YesNo)
                == DialogResult.Yes)
            {
                s.SaveChanges();
            }
            else
            {
                s.DiscardChanges();
            }
        }
コード例 #2
0
        /// <summary>
        /// Records the fact that this project has been "saved". This doesn't actually
        /// save anything, since that happens each time you perform an edit.
        /// </summary>
        internal void SaveChanges()
        {
            // Update the number of the last saved item (as far as the user's session
            // is concerned). Note that m_Data.NumItem corresponds to what's already
            // been saved in the database (well, it should).
            Project p = EditingController.Current.Project;

            m_LastSavedItem = p.LastItemId;

            // Save the project settings for good measure.
            p.SaveSettings();
        }
コード例 #3
0
        /// <summary>
        /// Closes a open project. If no edits have been performed, this will delete the file that
        /// records the session. Otherwise the timestamp stored in the session file will be updated.
        /// Local project settings will also be saved for luck.
        /// </summary>
        /// <param name="p">The project to close</param>
        internal void CloseProject(Project p)
        {
            Session s = p.Model.WorkingSession;

            if (s != null)
            {
                if (s.ChangeCount == 0)
                {
                    string sessionFile = s.FileName;
                    File.Delete(sessionFile);
                }
                else
                {
                    // Rollup the edits in the session
                    s.EndSession();

                    // Get rid of any undo folder
                    p.DeleteUndoFolder();
                }
            }

            p.SaveSettings();
        }