Ejemplo n.º 1
0
        // This closes a script and returns true when closed
        private bool CloseScript(ScriptDocumentTab t, bool saveonly)
        {
            if (t.IsChanged)
            {
                // Ask to save
                DialogResult result = MessageBox.Show(this.ParentForm, "Do you want to save changes to " + t.Text + "?", "Close File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    // Save file
                    if (!SaveScript(t))
                    {
                        return(false);
                    }
                }
                else if (result == DialogResult.Cancel)
                {
                    // Cancel
                    return(false);
                }
            }

            if (!saveonly)
            {
                // Close file
                tabs.TabPages.Remove(t);
                t.Dispose();
            }
            return(true);
        }
Ejemplo n.º 2
0
        // This closes a script and returns true when closed
        private bool CloseScript(ScriptDocumentTab t, bool saveonly)
        {
            if (t.IsChanged)
            {
                // Ask to save
                DialogResult result = MessageBox.Show(this.ParentForm, "Do you want to save changes to " + t.Title + "?", "Close File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                switch (result)
                {
                case DialogResult.Yes:
                    if (!SaveScript(t))
                    {
                        return(false);
                    }
                    break;

                case DialogResult.Cancel:
                    return(false);
                }
            }

            if (!saveonly)
            {
                //mxd. Select tab to the left of the one we are going to close
                if (t == tabs.SelectedTab && tabs.SelectedIndex > 0)
                {
                    tabs.SelectedIndex--;
                }

                // Close file
                tabs.TabPages.Remove(t);
                t.Dispose();
            }
            return(true);
        }