Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportXmlDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ExportXmlDialog(FdoCache cache, FilteredScrBooks filter, ScrReference refBook,
                               IVwStylesheet stylesheet, FileType exportType)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            m_scr         = cache.LangProject.TranslatedScriptureOA;
            m_eExportType = exportType;
            string key;

            switch (m_eExportType)
            {
            case FileType.OXES:
                key = "ExportFolderForXML";
                break;

            case FileType.XHTML:
                Text = TeResourceHelper.GetResourceString("kstidExportXHTML");                         // "Export XHTML"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.ODT:
                Text = TeResourceHelper.GetResourceString("kstidExportODT");                         // "Export Open Office file"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.PDF:
                Text = TeResourceHelper.GetResourceString("kstidExportPDF");                         // "Export Adobe Portable Document"
                key  = "ExportFolderForXhtml";
                break;

            default:
                key = "ExportFolderForXML";
                break;
            }
            m_xmlFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName,
                                                    cache.DatabaseName, key, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            string fileName = m_xmlFolder.Value;

            m_fileDialog = new TeImportExportFileDialog(cache, m_eExportType);

            // Append a filename if it was set to just a directory
            if (Directory.Exists(fileName))
            {
                fileName = Path.Combine(fileName, m_fileDialog.DefaultFileName);
            }
            m_txtOutputFile.Text = fileName;
            // Ensure that the end of the filename is visible.
            m_txtOutputFile.Select(fileName.Length, 0);

            FillFilterListLabel(filter);

            // Set the single book from the current one in use if possible, otherwise set
            // it from the first available book, if any are available.
            if (refBook == null)
            {
                refBook          = new ScrReference();
                refBook.BBCCCVVV = 1001001;
                if (m_scr.ScriptureBooksOS.Count > 0)
                {
                    refBook.Book = m_scr.ScriptureBooksOS[0].CanonicalNum;
                }
            }

            m_scrBook.Initialize(refBook, m_scr as Scripture, true);
            m_scrBook.PassageChanged += m_scrBook_PassageChanged;

            // Initialize the combo boxes, and then adjust their heights (and the locations
            // of following controls) as needed.
            m_oldComboHeight = cboFrom.Height;
            m_gap            = cboTo.Top - cboFrom.Bottom;
            FwStyleSheet ss = stylesheet as FwStyleSheet;

            m_fntVern    = new Font(ss.GetNormalFontFaceName(cache, cache.DefaultVernWs), 10);
            cboFrom.Font = cboTo.Font = m_fntVern;

            // Now that the sizes are fixed, load the combo box lists.
            LoadSectionsForBook(refBook.Book);

            m_nBookForSections = refBook.Book;
            m_sRangeBookFmt    = m_grpSectionRange.Text;
            UpdateBookSectionGroupLabel();

            //m_scrBook.Enabled = false;
            //m_grpSectionRange.Enabled = false;
            m_grpSectionRange.Visible = true;

            // Initialize the description.
            DateTime now = DateTime.Now;

            // "{0} exported by {1} on {2} {3}, {4} at {5}"
            m_txtDescription.Text = String.Format(DlgResources.ResourceString("kstidOxesExportDescription"),
                                                  cache.LangProject.Name.BestAnalysisVernacularAlternative.Text,
                                                  System.Security.Principal.WindowsIdentity.GetCurrent().Name.Normalize(),
                                                  now.ToString("MMMM"), now.Day, now.Year, now.ToShortTimeString());

            // TODO: Set export type from the stored registry setting.
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ExportXmlDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ExportXmlDialog(FdoCache cache, FilteredScrBooks filter, int defaultBookNum,
                               IVwStylesheet stylesheet, FileType exportType, IHelpTopicProvider helpTopicProvider)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            m_helpTopicProvider = helpTopicProvider;
            m_scr         = cache.LangProject.TranslatedScriptureOA;
            m_eExportType = exportType;

            string key;
            string descriptionFmt = "kstidOxesExportDescription";

            switch (m_eExportType)
            {
            case FileType.XHTML:
                Text = TeResourceHelper.GetResourceString("kstidExportXHTML");                         // "Export XHTML"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.ODT:
                Text = TeResourceHelper.GetResourceString("kstidExportODT");                         // "Export Open Office file"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.PDF:
                Text = TeResourceHelper.GetResourceString("kstidExportPDF");                         // "Export Adobe Portable Document"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.OXEKT:
                Text = TeResourceHelper.GetResourceString("kstidExportOXEKT");                         // "Export Open XML for Exchanging Key Terms"
                m_lblExportWhat.Text = TeResourceHelper.GetResourceString("kstidExportWhatOXEKT");
                key            = "ExportFolderForXml";
                descriptionFmt = "kstidOxektExportDescription";
                break;

            case FileType.OXES:
            default:
                key = "ExportFolderForXml";
                break;
            }

            m_xmlFolder = new RegistryStringSetting(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                                    key, FwSubKey.TE);
            string fileName = m_xmlFolder.Value;

            m_fileDialog = new TeImportExportFileDialog(cache.ProjectId.Name, m_eExportType);

            // Append a filename if it was set to just a directory
            if (Directory.Exists(fileName))
            {
                fileName = Path.Combine(fileName, m_fileDialog.DefaultFileName);
            }
            m_txtOutputFile.Text = fileName;
            // Ensure that the end of the filename is visible.
            m_txtOutputFile.Select(fileName.Length, 0);

            FillFilterListLabel(filter);

            // Set the single book from the current one in use if possible, otherwise set
            // it from the first available book, if any are available.
            if (defaultBookNum < 1 || defaultBookNum > BCVRef.LastBook)
            {
                defaultBookNum = 1;
                if (m_scr.ScriptureBooksOS.Count > 0)
                {
                    defaultBookNum = m_scr.ScriptureBooksOS[0].CanonicalNum;
                }
            }

            m_scrBook.Initialize(defaultBookNum, m_scr.ScriptureBooksOS.Select(b => b.CanonicalNum).ToArray());
            m_scrBook.PassageChanged += m_scrBook_PassageChanged;

            // Initialize the combo boxes, and then adjust their heights (and the locations
            // of following controls) as needed.
            m_oldComboHeight = cboFrom.Height;
            m_gap            = cboTo.Top - cboFrom.Bottom;
            m_fntVern        = ((FwStyleSheet)stylesheet).GetUiFontForWritingSystem(
                cache.DefaultVernWs, FontInfo.kDefaultFontSize);
            cboFrom.Font = cboTo.Font = m_fntVern;

            // Now that the sizes are fixed, load the combo box lists.
            LoadSectionsForBook(defaultBookNum);

            m_nBookForSections = defaultBookNum;
            m_sRangeBookFmt    = m_grpSectionRange.Text;
            UpdateBookSectionGroupLabel();

            //m_scrBook.Enabled = false;
            //m_grpSectionRange.Enabled = false;
            m_grpSectionRange.Visible = true;

            // Initialize the description.
            DateTime now = DateTime.Now;

            // "{0} exported by {1} on {2} {3}, {4} at {5}"
            m_txtDescription.Text = String.Format(DlgResources.ResourceString(descriptionFmt),
                                                  cache.ProjectId.Name,
                                                  System.Security.Principal.WindowsIdentity.GetCurrent().Name.Normalize(),
                                                  now.ToString("MMMM"), now.Day, now.Year, now.ToShortTimeString());

            // TODO: Set export type from the stored registry setting.
        }
Ejemplo n.º 3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes the start and end ref controls.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void InitializeStartAndEndRefControls()
 {
     scrPsgFrom.Initialize(StartRef.Book, m_importSettings.BooksForProject.ToArray());
     scrPsgTo.Initialize(EndRef.Book, m_importSettings.BooksForProject.ToArray());
 }