Exemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ExportRtfDialog"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public ExportRtfDialog(FdoCache cache, IHelpTopicProvider helpTopicProvider)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			// If the current settings are for arabic digits then don't show the option
			// to export them as arabic.
			m_scr = cache.LangProject.TranslatedScriptureOA;
			m_helpTopicProvider = helpTopicProvider;

			// Set default export folder.
			m_rtfFolder = new RegistryStringSetting(
				Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
				"ExportFolderForRTF", FwSubKey.TE);
			string fileName = m_rtfFolder.Value;

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

			// 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;
		}
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged
        /// resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        /// ------------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (m_fntVern != null)
                {
                    m_fntVern.Dispose();
                    m_fntVern = null;
                }
                if (m_fileDialog != null)
                {
                    m_fileDialog.Dispose();
                    m_fileDialog = null;
                }
            }

            base.Dispose(disposing);
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportRtfDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ExportRtfDialog(FdoCache cache)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // If the current settings are for arabic digits then don't show the option
            // to export them as arabic.
            m_scr = cache.LangProject.TranslatedScriptureOA;

            // Set default export folder.
            m_rtfFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName,
                                                    cache.DatabaseName, "ExportFolderForRTF",
                                                    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            string fileName = m_rtfFolder.Value;

            m_fileDialog = new TeImportExportFileDialog(cache, FileType.RTF);

            // 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;
        }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged
        /// resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        /// ------------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (m_fntVern != null)
                {
                    m_fntVern.Dispose();
                    m_fntVern = null;
                }
                if (m_fileDialog != null)
                {
                    m_fileDialog.Dispose();
                    m_fileDialog = null;
                }
            }

            base.Dispose(disposing);
        }
Exemplo n.º 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportUsfmDialog"/> class.
        /// </summary>
        /// <param name="cache">database cache</param>
        /// <param name="filter">book filter to display which books we will export</param>
        /// <param name="appKey">location of registry</param>
        /// ------------------------------------------------------------------------------------
        public ExportTbxDialog(FdoCache cache, FilteredScrBooks filter, RegistryKey appKey)
            : base(cache, filter, appKey, MarkupType.Toolbox)
        {
            InitializeComponent();
            // Save default label for BT control
            m_defaultBtLabel = chkBackTranslation.Text;

            m_fileDialog = new TeImportExportFileDialog(m_cache, FileType.ToolBox);
        }
Exemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ExportUsfmDialog"/> class.
		/// </summary>
		/// <param name="cache">database cache</param>
		/// <param name="filter">book filter to display which books we will export</param>
		/// <param name="appKey">location of registry</param>
		/// ------------------------------------------------------------------------------------
		public ExportTbxDialog(FdoCache cache, FilteredScrBooks filter, RegistryKey appKey)
			: base(cache, filter, appKey, MarkupType.Toolbox)
		{
			InitializeComponent();
			// Save default label for BT control
			m_defaultBtLabel = chkBackTranslation.Text;

			m_fileDialog = new TeImportExportFileDialog(m_cache, FileType.ToolBox);
		}
Exemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise,
		/// false.</param>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
				if (m_fileDialog != null)
				{
					m_fileDialog.Dispose();
					m_fileDialog = null;
				}
			}
			base.Dispose(disposing);
		}
Exemplo n.º 8
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise,
 /// false.</param>
 /// ------------------------------------------------------------------------------------
 protected override void Dispose(bool disposing)
 {
     if (disposing && (components != null))
     {
         components.Dispose();
         if (m_fileDialog != null)
         {
             m_fileDialog.Dispose();
             m_fileDialog = null;
         }
     }
     base.Dispose(disposing);
 }
Exemplo n.º 9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the m_btnBrowse control.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void m_btnBrowse_Click(object sender, EventArgs e)
        {
            string fileName = string.Empty;

            if (!String.IsNullOrEmpty(m_tbFilename.Text) &&
                !String.IsNullOrEmpty(m_tbFilename.Text.Trim()))
            {
                fileName = m_tbFilename.Text;
            }

            if (m_openFileDialog == null)
            {
                m_openFileDialog = new TeImportExportFileDialog(m_cache.ProjectId.Name, FileType.OXES);
            }
            DialogResult res = m_openFileDialog.ShowOpenDialog(fileName, Owner);

            if (res == DialogResult.OK)
            {
                m_tbFilename.Text = m_openFileDialog.FileName;
            }
        }
Exemplo n.º 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Export an Open XML for Exchanging Scripture Annotations (OXESA) file.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool OnFileExportOXESA(object args)
		{
			CheckDisposed();
			XmlScrAnnotationsList list = new XmlScrAnnotationsList(Cache);
			// need to use the dataAccess from the rootbox to get the filtered list - TE-9277
			var dataAccess = m_dataEntryView.RootBox.DataAccess;
			foreach (IScrBookAnnotations annotations in m_scr.BookAnnotationsOS)
			{
				List<IScrScriptureNote> notesToExport = new List<IScrScriptureNote>();
				// TE-9371: Changed way to get hvo's of filtered notes to improve performance
				int arraySize = dataAccess.get_VecSize(annotations.Hvo, ScrBookAnnotationsTags.kflidNotes);
				int[] itemHvos;
				using (var arrayPtr = MarshalEx.ArrayToNative<int>(arraySize))
				{
					int chvo;
					dataAccess.VecProp(annotations.Hvo, ScrBookAnnotationsTags.kflidNotes, arraySize, out chvo, arrayPtr);
					itemHvos = MarshalEx.NativeToArray<int>(arrayPtr, chvo);
				}
				foreach (int hvo in itemHvos)
				{
					IScrScriptureNote note =
						Cache.ServiceLocator.GetInstance<IScrScriptureNoteRepository>().GetObject(hvo);

					if (note.AnnotationTypeRA.Guid == CmAnnotationDefnTags.kguidAnnTranslatorNote ||
						note.AnnotationTypeRA.Guid == CmAnnotationDefnTags.kguidAnnConsultantNote)
					{
						// When we are exporting only notes, we only want to export notes that
						// are translator notes or consultant notes (i.e. no checking error notes).
						notesToExport.Add(note);
					}
				}
				list.Add(notesToExport);
			}

			using (TeImportExportFileDialog dlg = new TeImportExportFileDialog(Cache.ProjectId.Name, FileType.OXESA))
			{
				// TODO: Need to supply a decent default filename. Should it include
				// a date/time to avoid accidental overwriting?
				if (dlg.ShowSaveDialog(null, this) == DialogResult.OK)
					list.SerializeToFile(dlg.FileName);
			}

			return true;
		}
Exemplo n.º 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Import an Open XML for Exchanging Scripture Annotations (OXESA) file.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool OnFileImportOXESA(object args)
		{
			CheckDisposed();
			using (TeImportExportFileDialog dlg = new TeImportExportFileDialog(m_cache.ProjectId.Name, FileType.OXESA))
			{
				if (dlg.ShowOpenDialog(null, this) == DialogResult.OK)
				{
					string sUndo, sRedo;
					TeResourceHelper.MakeUndoRedoLabels("kstidImportAnnotations", out sUndo, out sRedo);

					using (UndoTaskHelper undoHelper = new UndoTaskHelper(Cache.ActionHandlerAccessor,
					   null, sUndo, sRedo))
					{
						using (WaitCursor waitCursor = new WaitCursor(this))
						{

							Exception e;
							XmlScrAnnotationsList.LoadFromFile(dlg.FileName, m_cache, m_StyleSheet, out e);
							if (e != null)
							{
								// Something went wrong while importing so let the user know.
								MessageBox.Show(string.Format(Properties.Resources.kstidOxesaImportFailedMsg, e.Message),
												Properties.Resources.kstidOxesaImportFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
							}
							undoHelper.RollBack = false;
						}
					}
				}
			}
			return true;
		}
Exemplo n.º 12
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.
		}
Exemplo n.º 13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing"><c>true</c> to release both managed and unmanaged
		/// resources; <c>false</c> to release only unmanaged resources.
		/// </param>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose( bool disposing )
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if( disposing )
			{
				if(components != null)
					components.Dispose();

				if (m_fntVern != null)
				{
					m_fntVern.Dispose();
					m_fntVern = null;
				}
				if (m_fileDialog != null)
				{
					m_fileDialog.Dispose();
					m_fileDialog = null;
				}
			}

			base.Dispose( disposing );
		}
Exemplo n.º 14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing"><c>true</c> to release both managed and unmanaged
		/// resources; <c>false</c> to release only unmanaged resources.
		/// </param>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose( bool disposing )
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if( disposing )
			{
				if(components != null)
					components.Dispose();

				if (m_fntVern != null)
				{
					m_fntVern.Dispose();
					m_fntVern = null;
				}
				if (m_fileDialog != null)
				{
					m_fileDialog.Dispose();
					m_fileDialog = null;
				}
			}

			base.Dispose( disposing );
		}
Exemplo n.º 15
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.
		}
Exemplo n.º 16
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.
        }
Exemplo n.º 17
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.
        }
Exemplo n.º 18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handles the Click event of the m_btnBrowse control.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void m_btnBrowse_Click(object sender, EventArgs e)
		{
			string fileName = string.Empty;
			if (!String.IsNullOrEmpty(m_tbFilename.Text) &&
				!String.IsNullOrEmpty(m_tbFilename.Text.Trim()))
			{
				fileName = m_tbFilename.Text;
			}

			if (m_openFileDialog == null)
				m_openFileDialog = new TeImportExportFileDialog(m_cache.ProjectId.Name, FileType.OXES);
			DialogResult res = m_openFileDialog.ShowOpenDialog(fileName, Owner);
			if (res == DialogResult.OK)
				m_tbFilename.Text = m_openFileDialog.FileName;
		}
Exemplo n.º 19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Import Key Terms menu handler
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected bool OnFileImportKeyTerms(object args)
		{
			CheckDisposed();
			using (TeImportExportFileDialog dlg = new TeImportExportFileDialog(m_cache.ProjectId.Name, FileType.OXEKT))
			{
				if (dlg.ShowOpenDialog(null, this) == DialogResult.OK)
				{
					string sUndo, sRedo;
					TeResourceHelper.MakeUndoRedoLabels("kstidImportKeyTerms", out sUndo, out sRedo);

					using (UndoTaskHelper undoHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor,
					   null, sUndo, sRedo))
					{
						using (WaitCursor waitCursor = new WaitCursor(this))
						{

							Exception e;
							XmlTermRenderingsList.LoadFromFile(dlg.FileName, m_cache,
								(occurrence, existingRendering, importedRendering) =>
								{
									using (ResolveKeyTermRenderingImportConflictDlg resolver =
										new ResolveKeyTermRenderingImportConflictDlg(this, occurrence, existingRendering, importedRendering, m_stylesheet))
									{
										return resolver.UseImportedRendering;
									}
								},
								out e);
							if (e != null)
							{
								// Something went wrong while importing so let the user know.
								MessageBox.Show(string.Format(Properties.Resources.kstidOxektImportFailedMsg, e.Message),
												Properties.Resources.kstidOxektImportTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
								return true;
							}
							undoHelper.RollBack = false;
							MessageBox.Show(Properties.Resources.kstidOxektImportCompleteMsg,
								Properties.Resources.kstidOxektImportTitle, MessageBoxButtons.OK);
						}
					}
				}
			}
			return true;
		}
Exemplo n.º 20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Export an Open XML for Exchanging Scripture Annotations (OXESA) file.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool OnFileExportOXESA(object args)
		{
			CheckDisposed();

			XmlScrAnnotationsList list = new XmlScrAnnotationsList(Cache);
			TeNotesVc vc = m_dataEntryView.NotesEditingHelper.CurrentNotesVc;
			int filterFlid = vc.NotesSequenceHandler.Tag;
			foreach (int hvoAnnotations in m_scr.BookAnnotationsOS.HvoArray)
			{
				int[] allHvos = Cache.GetVectorProperty(hvoAnnotations, filterFlid, true);
				List<int> notesToExport = new List<int>();
				foreach (int noteHvo in allHvos)
				{
					ScrScriptureNote note = new ScrScriptureNote(m_cache, noteHvo);
					if (note.AnnotationTypeRA.Guid == LangProject.kguidAnnTranslatorNote ||
						note.AnnotationTypeRA.Guid == LangProject.kguidAnnConsultantNote)
					{
						// When we are exporting only notes, we only want to export notes that
						// are translator notes or consultant notes (i.e. no checking error notes).
						notesToExport.Add(noteHvo);
					}
				}
				list.Add(new FdoObjectSet<IScrScriptureNote>(Cache, notesToExport.ToArray(), false));
			}

			using (TeImportExportFileDialog dlg = new TeImportExportFileDialog(Cache, FileType.OXESA))
			{
				// TODO: Need to supply a decent default filename. Should it include
				// a date/time to avoid accidental overwriting?
				if (dlg.ShowSaveDialog(null, this) == DialogResult.OK)
					list.SerializeToFile(dlg.FileName);
			}
			return true;
		}