private void NewFromTemplate(string templateFilePath)
        {
            if (Document.DocumentManager.ActiveDocument != null)
            {
                if (Document.DocumentManager.ActiveDocument.IsModified)
                {
                    DialogResult dr = MessageBox.Show("Do you want to save the changes to the curent document?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        bool savingSucceeded = Save();
                        if (!savingSucceeded)
                        {
                            return;                   // If the doc is still dirty, it means that Save failed. We must not replace the current document with another one.
                        }
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            Document.Project p = Document.Project.NewFromTemplate(templateFilePath);
            projectExplorerControl1.Project         = p;
            Document.DocumentManager.ActiveDocument = p;
            p.Modified += new EventHandler <Document.DocumentPartModifiedEventArgs>(OnDocumentModified);

            Text = Document.DocumentManager.ActiveDocument.Title + " - OWASP Tiger";

            splitContainer1.Panel1.SuspendLayout();
            splitContainer1.Panel1.BackColor = SystemColors.AppWorkspace;
            splitContainer1.Panel1.Controls.Clear();
            splitContainer1.Panel1.ResumeLayout();
        }
        private void Open()
        {
            if (Document.DocumentManager.ActiveDocument != null)
            {
                if (Document.DocumentManager.ActiveDocument.IsModified)
                {
                    DialogResult dr = MessageBox.Show("Do you want to save the changes to the curent document?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        bool saveSucceeded = Save();
                        if (!saveSucceeded)
                        {
                            return;                 // If the doc is still dirty, it means that Save failed. We must not replace the current document with another one.
                        }
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Document.Project p = Document.Project.LoadFromFile(openDialog.FileName);
                    projectExplorerControl1.Project         = p;
                    Document.DocumentManager.ActiveDocument = p;
                    p.Modified += new EventHandler <Document.DocumentPartModifiedEventArgs>(OnDocumentModified);

                    Text = Document.DocumentManager.ActiveDocument.Title + " - OWASP Tiger";

                    splitContainer1.Panel1.SuspendLayout();
                    splitContainer1.Panel1.BackColor = SystemColors.AppWorkspace;
                    splitContainer1.Panel1.Controls.Clear();
                    splitContainer1.Panel1.ResumeLayout();

                    //Text = System.IO.Path.GetFileName(openDialog.FileName) + " - OWASP Tiger";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Failed to open project", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            System.Windows.Forms.Cursor.Current = Cursors.Default;
        }
Example #3
0
 public static Project New()
 {
     Project p = new Project();
     p.name = "<Untitled Project>";
     p.isModified = false;
     return p;
 }