コード例 #1
0
        private bool CheckSaveTemplate(bool mustHaveContents, bool newFileName)
        {
            if (mustHaveContents && !m_Template.HasContents())
            {
                return(true);
            }

            if (!newFileName && m_Template.Save())
            {
                m_EditedSinceLastSave = false;

                UpdateCaption();
                return(true);
            }

            // Prompt for a file path
            var dlg = new SaveFileDialog
            {
                //InitialDirectory = LastBrowsedFolder,
                Title = m_Trans.Translate("Save Report Template"),

                AutoUpgradeEnabled = true,
                CheckPathExists    = true,

                Filter           = FileFilter,
                FilterIndex      = 0,
                RestoreDirectory = true,
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (m_Template.Save(dlg.FileName))
                {
                    m_TemplateFilePath    = dlg.FileName;
                    m_EditedSinceLastSave = false;

                    AddFileToTopOfHistory(m_TemplateFilePath);
                    UpdateCaption();

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            if (!e.Cancel)
            {
                m_Template.Save(m_TemplateFilePath);
            }
        }