示例#1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            // Check if we already have a Workplace open
            if (workbench.Workplace != null)
            {
                // Try to close and check if successful
                if (workbench.CloseAllDocuments(true) == false)
                {
                    this.Close(); // the operation was cancelled by the user.
                    return;
                }
            }


            // Verify if name is good
            if (tbName.Text.Length > 0)
            {
                string location = cbLocation.Text;

                // Check if directory exists
                if (!Directory.Exists(location))
                {
                    // Directory does not exist
                    DialogResult r = MessageBox.Show("Directory creation", "The directory does not exist. Do you want Sinapse to automatically create it for you?", MessageBoxButtons.YesNo);
                    if (r == DialogResult.Yes)
                    {
                        Directory.CreateDirectory(location);
                    }
                    else
                    {
                        return;
                    }
                }

                Sinapse.Data.HistoryListener.Write("Creating Workplace Directory");

                if (cbCreateFolder.Checked)
                {
                    location = Path.Combine(location, tbName.Text);
                    Directory.CreateDirectory(location);
                }


                Sinapse.Data.HistoryListener.Write("Creating Workplace");

                Workplace workplace = new Workplace(tbName.Text,
                                                    new FileInfo(Path.Combine(location, tbName.Text + ".workplace")));

                workplace.Save();                   // creates the directory structure
                workbench.OpenWorkplace(workplace); // opens the workplace in the current workbench.

                this.Close();
            }
        }
示例#2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            HistoryListener.Write("Exiting...");

            base.OnClosing(e);

            // Close Workbench


            // Close Workplace, always asking for confirmation
            if (!workbench.CloseAllDocuments(true))
            {
                e.Cancel = true;
                return;
            }


            // Save ToolStripPanels
            ToolStripManager.SaveSettings(this);

            // Save Workbench Layout
            workbench.SaveLayout();

            // Save settings before closing
            Properties.Settings.Default.main_FirstLoad   = false;
            Properties.Settings.Default.main_WindowState = this.WindowState;
            if (this.WindowState == FormWindowState.Normal)
            {
                Properties.Settings.Default.main_Size     = this.Size;
                Properties.Settings.Default.main_Location = this.Location;
            }
            else
            {
                Properties.Settings.Default.main_Size     = this.RestoreBounds.Size;
                Properties.Settings.Default.main_Location = this.RestoreBounds.Location;
            }
        }