Exemplo n.º 1
0
        public static string GetFileByRichTextBox(string fileName)
        {
            if (File.Exists(fileName))
            {
                RichTextBox m_tx = new RichTextBox();
                if (fileName.ToLower().EndsWith(".txt") || fileName.ToLower().EndsWith(GlobalOptions.LessonFileExtension))
                {
                    return(FileManager.GetStringFrоmFile(fileName));
                }
                else
                {
                    try
                    {
                        m_tx.LoadFile(fileName);
                    }
                    // TODO: уйти от RichEdit
                    catch (System.ArgumentException ex)
                    {
                        throw ex;
                        //if (ex.Message.Equals("File format is not valid."))
                        //    MessageBox.Show(string.Format("File '{0}' format is not valid.", fileName), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//                            throw new ApplicationException("The file being loaded is not an RTF document.", ex);
                    }
                }
                return(m_tx.Text);
            }
            else
            {
                MessageBox.Show(string.Format("File '{0}' not found", fileName));
                return(string.Empty);
            }
        }
Exemplo n.º 2
0
        public static List <Sentence> GetSentencesForTutor(string fileName)
        {
            string[] sentenses =
                FileManager.GetStringFrоmFile(fileName).Split(
                    new string[] { SentenceParser.Delimeter }, StringSplitOptions.None);

            List <Sentence> sents = new List <Sentence>(5)
            {
            };
            int i = 0;

            foreach (string line in sentenses)
            {
                if (i > 5)
                {
                    DialogResult dr = MessageBox.Show("You are using trial version of 'Easy-Learn'." + Environment.NewLine +
                                                      "You can't open more than five sentences." + Environment.NewLine + Environment.NewLine +
                                                      "To give a more information?",
                                                      Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dr == DialogResult.Yes)
                    {
                        SentenceListWithVideo.ShowLearnWordsArticle();
                    }
                    break;
                }

                if (!string.IsNullOrEmpty(line.Trim('\n')))
                {
                    sents.Add(new SentenceForTutor(line, sents));
                }
                ++i;
            }
            return(sents);
        }
Exemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string html = FileManager.GetStringFrоmFile(@"E:\FM\ForceMem\Test2\html\subtitle_for_ted_without_script.html");

            webParser.LoadAndParse(html, SubtitleCreator.JsSelector);
            webParser.webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
        }
Exemplo n.º 4
0
        public static List <Sentence> GetLessonSentences(string fileName)
        {
            string[]        sentenses = FileManager.GetStringFrоmFile(fileName).Split(new string[] { SentenceParser.Delimeter }, StringSplitOptions.None);
            List <Sentence> sents     = new List <Sentence> {
            };

            foreach (string line in sentenses)
            {
                if (!string.IsNullOrEmpty(line.Trim('\n')))
                {
                    sents.Add(new SentenceForLesson(line, sents));
                }
            }
            return(sents);
        }