示例#1
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (m_exportList.SelectedItems.Count == 0)
                return;

            //if (ItemDisabled((string)m_exportList.SelectedItems[0].Tag))
            //    return;
            m_exportItems.Clear();
            foreach (ListViewItem sel in m_exportList.SelectedItems)
                m_exportItems.Add(sel);
            var mainControl = EnsureViewInfo();
            try
            {

                if (!PrepareForExport())
                    return;

                bool fLiftExport = m_exportItems[0].SubItems[2].Text == "lift";
                string sFileName;
                string sDirectory;
                if (fLiftExport)
                {
                    using (var dlg = new FolderBrowserDialogAdapter())
                    {
                        dlg.Tag = xWorksStrings.ksChooseLIFTFolderTitle; // can't set title !!??
                        dlg.Description = String.Format(xWorksStrings.ksChooseLIFTExportFolder,
                            m_exportItems[0].SubItems[1].Text);
                        dlg.ShowNewFolderButton = true;
                        dlg.RootFolder = Environment.SpecialFolder.Desktop;
                        dlg.SelectedPath = m_mediator.PropertyTable.GetStringProperty("ExportDir",
                            Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                        if (dlg.ShowDialog(this) != DialogResult.OK)
                            return;
                        sDirectory = dlg.SelectedPath;
                    }
                    string sFile = Path.GetFileName(sDirectory);
                    sFileName = Path.Combine(sDirectory, sFile + FwFileExtensions.ksLexiconInterchangeFormat);
                    string sMsg = null;
                    MessageBoxButtons btns = MessageBoxButtons.OKCancel;
                    if (File.Exists(sFileName))
                    {
                        sMsg = xWorksStrings.ksLIFTAlreadyExists;
                        btns = MessageBoxButtons.OKCancel;
                    }
                    else
                    {
                        string[] rgfiles = Directory.GetFiles(sDirectory);
                        if (rgfiles.Length > 0)
                        {
                            sMsg = xWorksStrings.ksLIFTFolderNotEmpty;
                            btns = MessageBoxButtons.YesNo;
                        }
                    }
                    if (!String.IsNullOrEmpty(sMsg))
                    {
                        using (LiftExportMessageDlg dlg = new LiftExportMessageDlg(sMsg, btns))
                        {
                            if (dlg.ShowDialog(this) != DialogResult.OK)
                                return;
                        }
                    }
                }
                else
                {
                    FxtType ft;
                    // Note that DiscourseExportDialog doesn't add anything to m_rgFxtTypes.
                    // See FWR-2506.
                    if (m_rgFxtTypes.Count > 0)
                    {
                        string fxtPath = (string) m_exportItems[0].Tag;
                        ft = m_rgFxtTypes[FxtIndex(fxtPath)];
                    }
                    else
                    {
                        // Choose a dummy value that will take the default branch of merely choosing
                        // an output file.
                        ft.m_ft = FxtTypes.kftConfigured;
                    }
                    switch (ft.m_ft)
                    {
                        case FxtTypes.kftTranslatedLists:
                            using (var dlg = new ExportTranslatedListsDlg())
                            {
                                dlg.Initialize(m_mediator, m_cache,
                                    m_exportItems[0].SubItems[1].Text,
                                    m_exportItems[0].SubItems[2].Text,
                                    m_exportItems[0].SubItems[3].Text);
                                if (dlg.ShowDialog(this) != DialogResult.OK)
                                    return;
                                sFileName = dlg.FileName;
                                sDirectory = Path.GetDirectoryName(sFileName);
                                m_translationWritingSystems = dlg.SelectedWritingSystems;
                                m_translatedLists = dlg.SelectedLists;
                            }
                            break;
                        case FxtTypes.kftSemanticDomains:
                            using (var dlg = new ExportSemanticDomainsDlg())
                            {
                                dlg.Initialize(m_cache);
                                if (dlg.ShowDialog(this) != DialogResult.OK)
                                    return;
                                m_translationWritingSystems = new List<int>();
                                m_translationWritingSystems.Add(dlg.SelectedWs);
                                m_allQuestions = dlg.AllQuestions;
                            }
                            goto default;
                        case FxtTypes.kftPathway:
                            ProcessPathwayExport();
                            return;
                        default:
                            using (var dlg = new SaveFileDialogAdapter())
                            {
                                dlg.AddExtension = true;
                                dlg.DefaultExt = m_exportItems[0].SubItems[2].Text;
                                dlg.Filter = m_exportItems[0].SubItems[3].Text;
                                dlg.Title = String.Format(xWorksStrings.ExportTo0, m_exportItems[0].SubItems[1].Text);
                                dlg.InitialDirectory = m_mediator.PropertyTable.GetStringProperty("ExportDir",
                                    Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                                if (dlg.ShowDialog(this) != DialogResult.OK)
                                    return;
                                sFileName = dlg.FileName;
                                sDirectory = Path.GetDirectoryName(sFileName);
                            }
                            break;
                    }
                }
                if (sDirectory != null)
                {
                    m_mediator.PropertyTable.SetProperty("ExportDir", sDirectory);
                    m_mediator.PropertyTable.SetPropertyPersistence("ExportDir", true);
                }
                if (fLiftExport) // Fixes LT-9437 Crash exporting a discourse chart (or interlinear too!)
                {
                    DoExport(sFileName, true);
                }
                else
                {
                    DoExport(sFileName); // Musn't use the 2 parameter version here or overrides get messed up.
                }
                if (m_chkShowInFolder.Checked)
                {
                    OpenExportFolder(sDirectory, sFileName);
                    m_mediator.PropertyTable.SetProperty("ExportDlgShowInFolder", "true");
                    m_mediator.PropertyTable.SetPropertyPersistence("ExportDlgShowInFolder", true);
                }
                else
                {
                    m_mediator.PropertyTable.SetProperty("ExportDlgShowInFolder", "false");
                    m_mediator.PropertyTable.SetPropertyPersistence("ExportDlgShowInFolder", true);
                }
            }
            finally
            {
                if (mainControl != null)
                    mainControl.Dispose();
            }
        }
示例#2
0
		private void btnExport_Click(object sender, System.EventArgs e)
		{
			if (m_exportList.SelectedItems.Count == 0)
				return;

			if (ItemDisabled((string)m_exportList.SelectedItems[0].Tag))
				return;

			if (!PrepareForExport())
				return;

			bool fLiftExport = m_exportList.SelectedItems[0].SubItems[2].Text == "lift";
			string sFileName = null;
			string sDirectory = null;
			if (fLiftExport)
			{
				using (FolderBrowserDialog dlg = new FolderBrowserDialog())
				{
					dlg.Tag = xWorksStrings.ksChooseLIFTFolderTitle;	// can't set title !!??
					dlg.Description = String.Format(xWorksStrings.ksChooseLIFTExportFolder,
						m_exportList.SelectedItems[0].SubItems[1].Text);
					dlg.ShowNewFolderButton = true;
					dlg.RootFolder = Environment.SpecialFolder.Desktop;
					dlg.SelectedPath = m_mediator.PropertyTable.GetStringProperty("ExportDir",
						System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
					if (dlg.ShowDialog(this) != DialogResult.OK)
						return;
					sDirectory = dlg.SelectedPath;
				}
				string sFile = Path.GetFileName(sDirectory);
				sFileName = Path.Combine(sDirectory, sFile + ".lift");
				string sMsg = null;
				MessageBoxButtons btns = MessageBoxButtons.OKCancel;
				if (File.Exists(sFileName))
				{
					sMsg = xWorksStrings.ksLIFTAlreadyExists;
					btns = MessageBoxButtons.OKCancel;
				}
				else
				{
					string[] rgfiles = Directory.GetFiles(sDirectory);
					if (rgfiles.Length > 0)
					{
						sMsg = xWorksStrings.ksLIFTFolderNotEmpty;
						btns = MessageBoxButtons.YesNo;
					}
				}
				if (!String.IsNullOrEmpty(sMsg))
				{
					using (LiftExportMessageDlg dlg = new LiftExportMessageDlg(sMsg, btns))
					{
						if (dlg.ShowDialog(this) != DialogResult.OK)
							return;
					}
				}
			}
			else
			{
				using (SaveFileDialog dlg = new SaveFileDialog())
				{
					dlg.AddExtension = true;
					dlg.DefaultExt = m_exportList.SelectedItems[0].SubItems[2].Text;
					dlg.Filter = m_exportList.SelectedItems[0].SubItems[3].Text;
					dlg.Title = String.Format(xWorksStrings.ExportTo0, m_exportList.SelectedItems[0].SubItems[1].Text);
					dlg.InitialDirectory = m_mediator.PropertyTable.GetStringProperty("ExportDir",
						System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
					if (dlg.ShowDialog(this) != DialogResult.OK)
						return;
					sFileName = dlg.FileName;
					sDirectory = Path.GetDirectoryName(sFileName);
				}
			}
			m_mediator.PropertyTable.SetProperty("ExportDir", sDirectory);
			m_mediator.PropertyTable.SetPropertyPersistence("ExportDir", true);
			if (fLiftExport) // Fixes LT-9437 Crash exporting a discourse chart (or interlinear too!)
			{
				DoExport(sFileName, true);
				ExportWsAsLDML(sDirectory);
			}
			else
			{
				DoExport(sFileName); // Musn't use the 2 parameter version here or overrides get messed up.
			}
		}
示例#3
0
        private void btnExport_Click(object sender, System.EventArgs e)
        {
            if (m_exportList.SelectedItems.Count == 0)
            {
                return;
            }

            if (ItemDisabled((string)m_exportList.SelectedItems[0].Tag))
            {
                return;
            }

            if (!PrepareForExport())
            {
                return;
            }

            bool   fLiftExport = m_exportList.SelectedItems[0].SubItems[2].Text == "lift";
            string sFileName   = null;
            string sDirectory  = null;

            if (fLiftExport)
            {
                using (FolderBrowserDialog dlg = new FolderBrowserDialog())
                {
                    dlg.Tag         = xWorksStrings.ksChooseLIFTFolderTitle;                    // can't set title !!??
                    dlg.Description = String.Format(xWorksStrings.ksChooseLIFTExportFolder,
                                                    m_exportList.SelectedItems[0].SubItems[1].Text);
                    dlg.ShowNewFolderButton = true;
                    dlg.RootFolder          = Environment.SpecialFolder.Desktop;
                    dlg.SelectedPath        = m_mediator.PropertyTable.GetStringProperty("ExportDir",
                                                                                         System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                    if (dlg.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                    sDirectory = dlg.SelectedPath;
                }
                string sFile = Path.GetFileName(sDirectory);
                sFileName = Path.Combine(sDirectory, sFile + ".lift");
                string            sMsg = null;
                MessageBoxButtons btns = MessageBoxButtons.OKCancel;
                if (File.Exists(sFileName))
                {
                    sMsg = xWorksStrings.ksLIFTAlreadyExists;
                    btns = MessageBoxButtons.OKCancel;
                }
                else
                {
                    string[] rgfiles = Directory.GetFiles(sDirectory);
                    if (rgfiles.Length > 0)
                    {
                        sMsg = xWorksStrings.ksLIFTFolderNotEmpty;
                        btns = MessageBoxButtons.YesNo;
                    }
                }
                if (!String.IsNullOrEmpty(sMsg))
                {
                    using (LiftExportMessageDlg dlg = new LiftExportMessageDlg(sMsg, btns))
                    {
                        if (dlg.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }
                    }
                }
            }
            else
            {
                using (SaveFileDialog dlg = new SaveFileDialog())
                {
                    dlg.AddExtension     = true;
                    dlg.DefaultExt       = m_exportList.SelectedItems[0].SubItems[2].Text;
                    dlg.Filter           = m_exportList.SelectedItems[0].SubItems[3].Text;
                    dlg.Title            = String.Format(xWorksStrings.ExportTo0, m_exportList.SelectedItems[0].SubItems[1].Text);
                    dlg.InitialDirectory = m_mediator.PropertyTable.GetStringProperty("ExportDir",
                                                                                      System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                    if (dlg.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                    sFileName  = dlg.FileName;
                    sDirectory = Path.GetDirectoryName(sFileName);
                }
            }
            m_mediator.PropertyTable.SetProperty("ExportDir", sDirectory);
            m_mediator.PropertyTable.SetPropertyPersistence("ExportDir", true);
            if (fLiftExport)             // Fixes LT-9437 Crash exporting a discourse chart (or interlinear too!)
            {
                DoExport(sFileName, true);
                ExportWsAsLDML(sDirectory);
            }
            else
            {
                DoExport(sFileName);                 // Musn't use the 2 parameter version here or overrides get messed up.
            }
        }