Exemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor for FwUpdateReportDlg
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public FwUpdateReportDlg()
		{
			InitializeComponent();
			saveFileDialog = new SaveFileDialogAdapter();
			saveFileDialog.DefaultExt = "txt";
			saveFileDialog.SupportMultiDottedExtensions = true;
			saveFileDialog.Filter = FileUtils.FileDialogFilterCaseInsensitiveCombinations(FwCoreDlgs.TextFileFilter);
		}
Exemplo n.º 2
0
		/// <summary>
		/// Class to choose input, output files for Db4o to XML conversion
		/// </summary>
		public FileInOutChooser()
		{
			InitializeComponent();

			Db4oFile = new OpenFileDialogAdapter();
			Db4oFile.Filter = "Db4o Files|*.fwdb|All Files|*.*";

			XmlFile = new SaveFileDialogAdapter();
			XmlFile.DefaultExt = "fwxml";
		}
Exemplo n.º 3
0
 private void OnSaveAsHtmlButtonClick(object sender, EventArgs e)
 {
     if (File.Exists(m_sHtmlFileName))
     {
         using (var dlg = new SaveFileDialogAdapter())
         {
             InitSaveAsWebpageDialog(dlg);
             if (dlg.ShowDialog() == DialogResult.OK)
             {
                 string dlgFileName = dlg.FileName;
                 // For those poor souls who have run into LT-6264,
                 // we need to be nice and remove the read-only attr.
                 // Besides, the reporter may not believe the bug is dead,
                 // as it still won't be in a copy state. :-)
                 RemoveWriteProtection(dlgFileName);
                 File.Copy(m_sHtmlFileName, dlg.FileName, true);
                 // If m_sHtmlFileName is the initial doc, then it will be read-only.
                 // Setting the attr to normal fixes LT-6264.
                 // I (RandyR) don't know why the save button is enabled,
                 // when the sketch has not been generated, but this ought to be the 'fix/hack'.
                 RemoveWriteProtection(dlgFileName);
                 if (File.Exists(m_sAlsoSaveFileName))
                 {
                     InitAlsoSaveDialog(dlg);
                     if (dlg.ShowDialog() == DialogResult.OK)
                     {
                         DoAlsoSaveAs(dlg);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
		/// <summary></summary>
		public ConverterTest()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();
			ofDlg = new OpenFileDialogAdapter();
			ofDlg.DefaultExt = "txt";
			ofDlg.Filter = FileUtils.FileDialogFilterCaseInsensitiveCombinations(FwCoreDlgs.ofDlg_Filter);

			saveFileDialog = new SaveFileDialogAdapter();
			saveFileDialog.DefaultExt = "txt";
			saveFileDialog.RestoreDirectory = true;
			saveFileDialog.Filter = ofDlg.Filter;

			if (DesignMode)
				return;

			InputArgsChanged();	// set the initial state of the Convert button

			// Set view properties.
			m_fHasOutput = false;
			m_svOutput = new SampleView();
			m_svOutput.WritingSystemFactory = FwUtils.CreateWritingSystemManager();
			m_svOutput.Dock = DockStyle.Fill;
			m_svOutput.Visible = true;
			m_svOutput.Enabled = false;
			m_svOutput.BackColor = OutputPanel.BackColor;
			m_svOutput.TabIndex = 1;
			m_svOutput.TabStop = true;
			OutputPanel.Controls.Add(m_svOutput);
		}
Exemplo n.º 5
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();
            }
        }
 private void m_btnBrowse_Click(object sender, EventArgs e)
 {
     using (var dlg = new SaveFileDialogAdapter())
     {
         dlg.AddExtension = true;
         dlg.DefaultExt = String.IsNullOrEmpty(m_defaultExt) ? ".xml" : m_defaultExt;
         dlg.Filter = String.IsNullOrEmpty(m_filter) ? "*.xml" : m_filter;
         dlg.Title = String.Format(xWorksStrings.ExportTo0,
             String.IsNullOrEmpty(m_titleFrag) ? "Translated List" : m_titleFrag);
         dlg.InitialDirectory = m_mediator.PropertyTable.GetStringProperty("ExportDir",
             Environment.GetFolderPath(Environment.SpecialFolder.Personal));
         if (dlg.ShowDialog(this) != DialogResult.OK)
             return;
         m_tbFilepath.Text = dlg.FileName;
         EnableExportButton();
     }
 }