Ejemplo n.º 1
0
        private void LoadProject(string fileName, bool verifyVersion, bool secure)
        {
            using (SavingLoadingForm frm = new SavingLoadingForm(fileName, false, verifyVersion, secure))
            {
                InitializeTree();

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    SetTitle(CANAPEProject.CurrentProject.FileName);
                    OnProjectChanged();
                    UpdateRecentFiles(fileName);
                }
                else
                {
                    if ((frm.Error is InvalidVersionException) && verifyVersion)
                    {
                        if (MessageBox.Show(this, String.Format(Properties.Resources.LoadProject_OpenAnyway, frm.Error.Message),
                                            Properties.Resources.LoadProject_OpenAnywayCaption,
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            LoadProject(fileName, false, secure);
                        }
                    }
                    else if ((frm.Error is SecurityException) && secure)
                    {
                        if (MessageBox.Show(this, String.Format(Properties.Resources.LoadProject_SecurityWarning, frm.Error.Message),
                                            Properties.Resources.LoadProject_SecurityWarningCaption,
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            LoadProject(fileName, verifyVersion, false);
                        }
                    }
                    else
                    {
                        if (frm.Error != null)
                        {
                            MessageBox.Show(this, frm.Error.Message,
                                            Properties.Resources.MessageBox_ErrorString,
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(this, Properties.Resources.MainForm_UnknownError,
                                            Properties.Resources.MessageBox_ErrorString,
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void SaveDocument(bool bSaveAs)
        {
            string fileName = null;

            if (bSaveAs || (CANAPEProject.CurrentProject.FileName == null))
            {
                using (SaveFileDialog dlg = new SaveFileDialog())
                {
                    dlg.Filter          = Properties.Resources.OpenFileDialog_ProjectFilter;
                    dlg.OverwritePrompt = true;

                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        fileName = dlg.FileName;
                    }
                }
            }
            else
            {
                fileName = CANAPEProject.CurrentProject.FileName;
            }

            if (fileName != null)
            {
                using (SavingLoadingForm frm = new SavingLoadingForm(fileName, true, true, true))
                {
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        SetTitle(CANAPEProject.CurrentProject.FileName);
                        UpdateRecentFiles(fileName);
                    }
                    else
                    {
                        MessageBox.Show(this, frm.Error.Message,
                                        Properties.Resources.MessageBox_ErrorString,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void SaveDocument(bool bSaveAs)
        {
            string fileName = null;

            if (bSaveAs || (CANAPEProject.CurrentProject.FileName == null))
            {
                using (SaveFileDialog dlg = new SaveFileDialog())
                {
                    dlg.Filter = Properties.Resources.OpenFileDialog_ProjectFilter;
                    dlg.OverwritePrompt = true;

                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        fileName = dlg.FileName;
                    }
                }
            }
            else
            {
                fileName = CANAPEProject.CurrentProject.FileName;
            }

            if(fileName != null)
            {
                using (SavingLoadingForm frm = new SavingLoadingForm(fileName, true, true))
                {
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        SetTitle(CANAPEProject.CurrentProject.FileName);
                        UpdateRecentFiles(fileName);
                    }
                    else
                    {
                        MessageBox.Show(this, frm.Error.Message,
                            Properties.Resources.MessageBox_ErrorString,
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void LoadProject(string fileName, bool verifyVersion)
        {
            using (SavingLoadingForm frm = new SavingLoadingForm(fileName, false, verifyVersion))
            {
                InitializeTree();

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    SetTitle(CANAPEProject.CurrentProject.FileName);
                    OnProjectChanged();
                    UpdateRecentFiles(fileName);
                }
                else
                {
                    if ((frm.Error is InvalidVersionException) && (verifyVersion))
                    {
                        if (MessageBox.Show(this, String.Format(Properties.Resources.LoadProject_OpenAnyway, frm.Error.Message),
                            Properties.Resources.LoadProject_OpenAnywayCaption,
                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            LoadProject(fileName, false);
                        }
                    }
                    else
                    {
                        if (frm.Error != null)
                        {
                            MessageBox.Show(this, frm.Error.Message,
                                Properties.Resources.MessageBox_ErrorString,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(this, Properties.Resources.MainForm_UnknownError,
                                Properties.Resources.MessageBox_ErrorString,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }