Esempio n. 1
0
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            if (openFileDialog1.FileName != "")
            {
                file_path = openFileDialog1.FileName;
                Readactor readactor = new Readactor();
                readactor.Form_Create(openFileDialog1.FileName, this);
                switch (openFileDialog1.FilterIndex)
                {
                case (1):
                    if (File.Exists(openFileDialog1.FileName))
                    {
                        StreamReader reader =
                            new StreamReader(openFileDialog1.FileName);
                        Program.RedactTB.Text = reader.ReadToEnd();
                        reader.Close();
                    }
                    break;

                case (2):
                    word.Application application = new word.Application();
                    word.Document    documents
                        = application.Documents.Open(openFileDialog1.FileName);
                    try
                    {
                        for (int i = 0; i < documents.Paragraphs.Count; ++i)
                        {
                            Program.RedactTB.Font
                                = new Font(documents.Paragraphs[i + 1].Range.Font.Name,
                                           documents.Paragraphs[i + 1].Range.Font.Size);
                            Program.RedactTB.
                            AppendText(documents.Paragraphs[i + 1].Range.Text.ToString());
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        documents.Close();
                        application.Quit();
                    }
                    break;

                case (3):
                    word.Application application1 = new word.Application();
                    word.Document    documents1   = application1.Documents.Open(openFileDialog1.FileName);
                    try
                    {
                        for (int i = 0; i < documents1.Paragraphs.Count; ++i)
                        {
                            Program.RedactTB.Font = new Font(documents1.Paragraphs[i + 1].Range.Font.Name, documents1.Paragraphs[i + 1].Range.Font.Size);
                            Program.RedactTB.AppendText(documents1.Paragraphs[i + 1].Range.Text.ToString());
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        documents1.Close();
                        application1.Quit();
                    }
                    break;
                }
            }
            else
            {
                MessageBox.Show("Выберите файл",
                                "Текстовый реадктор",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        private void новыйToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Readactor readactor = new Readactor();

            readactor.Form_Create("New_file", this);
        }