Ejemplo n.º 1
0
        internal static void AppendFileContent(Form1 form)
        {
            XtraTabControl       pagesTabControl      = form.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar;
            CustomRichTextBox    pageTextBox          = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
            OpenFileDialog       openFileDialog       = form.openFileDialog;

            try
            {
                openFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form);
                SetFileDialogFilter(openFileDialog);

                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    toolStripProgressBar.Visible = false;
                    return;
                }
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;
                toolStripProgressBar.PerformStep();

                ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(openFileDialog.FileName));
                toolStripProgressBar.PerformStep();

                String fileContents = FileUtil.ReadToEndWithEncoding(openFileDialog.FileName);
                toolStripProgressBar.PerformStep();

                pageTextBox.AppendText(fileContents);
                TextManager.RefreshUndoRedoExternal(form);

                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(openFileDialog.FileName), LanguageUtil.GetCurrentLanguageString("Appended", className));
                toolStripProgressBar.PerformStep();
                toolStripProgressBar.Visible = false;
            }
            catch (Exception exception)
            {
                toolStripProgressBar.Visible = false;
                WindowManager.ShowErrorBox(form, exception.Message, exception);
            }
        }