Exemplo n.º 1
0
        public void Save(bool showSaveUnsavedChangesQuestion)
        {
            if (!AreProjectOrSessionsChanged())
            {
                // Sanity check.
                // The UI should not call this method when nothing has changed.
                Debug.Assert(false);
            }
            else
            {
                _HasUserCancelledLastOperation = false;
                bool mustSaveChanges = false;

                if (showSaveUnsavedChangesQuestion)
                {
                    DialogResult theDialogResult = ShowSaveUnsavedChangesQuestion();

                    if (theDialogResult == DialogResult.Yes)
                    {
                        mustSaveChanges = true;
                    }
                    else if (theDialogResult == DialogResult.No)
                    {
                        mustSaveChanges = false;
                    }
                    else
                    {
                        _HasUserCancelledLastOperation = true;
                    }
                }

                if ((!showSaveUnsavedChangesQuestion) ||
                    (showSaveUnsavedChangesQuestion && mustSaveChanges)
                    )
                {
                    SaveForm theSaveForm = new SaveForm();

                    // Fill the save form with all files that have been changed.
                    if (_HasProjectChanged)
                    {
                        theSaveForm.AddChangedItem(ProjectFileName);
                    }

                    for (int i = 0; i < GetNrSessions(); i++)
                    {
                        if (GetSessionChanged(GetSession(i)))
                        {
                            theSaveForm.AddChangedItem(GetSession(i).SessionFileName);
                        }
                    }

                    // Show the save form to the user.
                    DialogResult theDialogResult = theSaveForm.ShowDialog();

                    if (theDialogResult == DialogResult.Cancel)
                    // User pressed cancel.
                    {
                        _HasUserCancelledLastOperation = true;
                        return;
                    }
                    else
                    // User did not press cancel.
                    {
                        foreach (string theFileName in theSaveForm.ItemsToSave)
                        {
                            if (theFileName == ProjectFileName)
                            {
                                SaveProject();
                            }
                            else
                            {
                                SaveSession(theFileName);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Save(bool showSaveUnsavedChangesQuestion)
        {
            if (!AreProjectOrSessionsChanged())
            {
                // Sanity check.
                // The UI should not call this method when nothing has changed.
                Debug.Assert (false);
            }
            else
            {
                _HasUserCancelledLastOperation = false;
                bool mustSaveChanges = false;

                if (showSaveUnsavedChangesQuestion)
                {
                    DialogResult theDialogResult = ShowSaveUnsavedChangesQuestion();

                    if (theDialogResult == DialogResult.Yes)
                    {
                        mustSaveChanges = true;
                    }
                    else if (theDialogResult == DialogResult.No)
                    {
                        mustSaveChanges = false;
                    }
                    else
                    {
                        _HasUserCancelledLastOperation = true;
                    }
                }

                if ( (!showSaveUnsavedChangesQuestion) ||
                    (showSaveUnsavedChangesQuestion && mustSaveChanges)
                    )
                {
                    SaveForm theSaveForm = new SaveForm ();

                    // Fill the save form with all files that have been changed.
                    if (_HasProjectChanged)
                    {
                        theSaveForm.AddChangedItem(ProjectFileName);
                    }

                    for (int i = 0 ; i < GetNrSessions(); i++)
                    {
                        if (GetSessionChanged(GetSession (i)))
                        {
                            theSaveForm.AddChangedItem (GetSession(i).SessionFileName);
                        }
                    }

                    // Show the save form to the user.
                    DialogResult theDialogResult = theSaveForm.ShowDialog();

                    if (theDialogResult == DialogResult.Cancel)
                        // User pressed cancel.
                    {
                        _HasUserCancelledLastOperation = true;
                        return;
                    }
                    else
                        // User did not press cancel.
                    {
                        foreach (string theFileName in theSaveForm.ItemsToSave)
                        {
                            if (theFileName == ProjectFileName)
                            {
                                SaveProject();
                            }
                            else
                            {
                                SaveSession(theFileName);
                            }
                        }
                    }
                }
            }
        }