Beispiel #1
0
        private void StatusFrm_Load(object sender, EventArgs e)
        {
            ItemCount            = VocabularyFrm.AppConfig.ListOfLearnItem.Count;
            CurrentDisplayedItem = VocabularyFrm.AppConfig.ItemShowedIndex;
            LearnItem currItem = VocabularyFrm.AppConfig.ListOfLearnItem[CurrentDisplayedItem];

            ItemId = currItem.Id;

            String msg = String.Format("Total Item: {0}\nDisplay at time: {1}\nItem ID: {2}\nDeleted Item:{3}", ItemCount, CurrentDisplayedItem, ItemId, VocabularyFrm.AppConfig.ListOfRemovedLearnItem.Count);

            this.lblStatus.Text = msg;

            Timer timer = new Timer();

            timer.Interval = 4000;
            timer.Tick    += CloseApp;
            timer.Start();
        }
Beispiel #2
0
        private List <LearnItem> ParseStringArray(string[] lines, LearningLanguage Term1Language, LearningLanguage Term2Language)
        {
            List <LearnItem> listitem = new List <LearnItem>();
            int ItemCount             = lines.Count();

            if (ItemCount == 0)
            {
                return(listitem);
            }

            //List<string> contents = File.ReadAllLines(path).ToList<string>();
            if (Term1Language != LearningLanguage.VN)
            {
                for (int i = 0; i < ItemCount; i++)
                {
                    string[] itemInLine = lines[i].Split('\t');
                    if (itemInLine.Count() >= 2)
                    {
                        LearnItem item = new LearnItem(itemInLine[0], itemInLine[1], (itemInLine.Count() >= 3 ? itemInLine[2] : null));
                        item.Content1Lang = Term1Language;
                        item.Content2Lang = Term2Language;
                        //Find tails
                        if (i < ItemCount - 1)
                        {
                            for (; i < ItemCount - 1; i++)
                            {
                                if (lines[i + 1].Contains('\t'))
                                {
                                    break;
                                }
                                else
                                {
                                    item.Content2 += "\n" + lines[i + 1];
                                }
                            }
                        }
                        listitem.Add(item);
                    }
                }
            }
            else
            {
                for (int x = 0; x < ItemCount; x++)
                {
                    string multiLineTerm = "";
                    for (; x < ItemCount - 1; x++)
                    {
                        string[] splitedItem = lines[x].Split('\t');
                        if (splitedItem.Count() < 2)
                        {
                            multiLineTerm += lines[x] + "\n";
                        }
                        else
                        {
                            LearnItem li = new LearnItem(multiLineTerm + splitedItem[0],
                                                         splitedItem[1], (splitedItem.Count() >= 3? splitedItem[2] : null));
                            li.Content1Lang = Term1Language;
                            li.Content2Lang = Term2Language;
                            listitem.Add(li);
                            multiLineTerm = "";
                        }
                    }
                }
            }
            return(listitem);
        }
        private List<LearnItem> ParseStringArray(string[] lines, LearningLanguage Term1Language, LearningLanguage Term2Language)
        {
            List<LearnItem> listitem = new List<LearnItem>();
            int ItemCount = lines.Count();
            if (ItemCount == 0)
                return listitem;

            //List<string> contents = File.ReadAllLines(path).ToList<string>();
            if (Term1Language != LearningLanguage.VN)
            {
                for (int i = 0; i < ItemCount; i++)
                {
                    string[] itemInLine = lines[i].Split('\t');
                    if (itemInLine.Count() >= 2)
                    {
                        LearnItem item = new LearnItem(itemInLine[0], itemInLine[1], (itemInLine.Count() >= 3 ? itemInLine[2] : null));
                        item.Content1Lang = Term1Language;
                        item.Content2Lang = Term2Language;
                        //Find tails
                        if (i < ItemCount - 1)
                        {
                            for (; i < ItemCount - 1; i++)
                            {
                                if (lines[i + 1].Contains('\t'))
                                {
                                    break;
                                }
                                else
                                {
                                    item.Content2 += "\n" + lines[i + 1];
                                }
                            }
                        }
                        listitem.Add(item);
                    }
                }
            }
            else
            {
                for (int x = 0; x < ItemCount; x++)
                {
                    string multiLineTerm = "";
                    for (; x < ItemCount - 1; x++)
                    {
                        string[] splitedItem = lines[x].Split('\t');
                        if (splitedItem.Count() < 2)
                        {
                            multiLineTerm +=lines[x] + "\n";
                        }
                        else
                        {
                            LearnItem li = new LearnItem(multiLineTerm + splitedItem[0],
                                                        splitedItem[1], (splitedItem.Count() >= 3? splitedItem[2] : null));
                            li.Content1Lang = Term1Language;
                            li.Content2Lang = Term2Language;
                            listitem.Add(li);
                            multiLineTerm = "";
                        }
                    }
                }
            }
            return listitem;
        }
Beispiel #4
0
        private void NextItem(object sender, EventArgs e)
        {
            Console.WriteLine(DateTime.Now.ToString("HH:mm:ss tt") + " ->Next Item");
            //++ Mod (20150821 NguyenPT) Modify list keep current learn item
            //if (AppConfig.ListOfLearnItem.Count == 0)
            if (this.m_ListOfLearnItem.Count == 0)
            //-- Mod (20150821 NguyenPT)
            {
                timerControl.Stop();
                MessageBox.Show("Data record is empty. Application will be closed!\nPlease check your data.");
                this.CloseApp();
            }
            AppConfig.ItemShowedIndex++;
            if (AppConfig.ItemShowedIndex < 0)
            {
                AppConfig.ItemShowedIndex = 0;
            }
            //++ Mod (20150821 NguyenPT) Modify list keep current learn item
            //if (AppConfig.ItemShowedIndex < AppConfig.ListOfLearnItem.Count)
            if (AppConfig.ItemShowedIndex < this.m_ListOfLearnItem.Count)
            //-- Mod (20150821 NguyenPT)
            {
                if (AppConfig.ConfirmMode && timerDisplay.Enabled)
                {
                    lblContent2.Visible = false;
                    timerDisplay.Stop();
                    timerDisplay.Start();
                }
                //++ Mod (20150821 NguyenPT) Modify list keep current learn item
                //LearnItem li = AppConfig.ListOfLearnItem[AppConfig.ItemShowedIndex];
                LearnItem li = this.m_ListOfLearnItem[AppConfig.ItemShowedIndex];
                //-- Mod (20150821 NguyenPT)
                if (AppConfig.IncludedImage && li.ImageSource != null)
                {
                    // NguyenPT
                    try
                    {
                        // Change method load image
                        //this.picImage.Load(li.ImageSource);
                        this.picImage.WaitOnLoad = false;
                        this.picImage.LoadAsync(li.ImageSource);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(li.ImageSource);
                    }
                    // NguyenPT
                }
                else
                {
                    // NguyenPT
                    // If last image is not null -> reset it
                    if (this.picImage.Image != null)
                    {
                        this.picImage.CancelAsync();
                        this.picImage.Image.Dispose();
                        this.picImage.Image = null;
                    }
                    // NguyenPT
                }
                if (li.Content1Lang != LearningLanguage.VN)
                {
                    this.lblContent1.Text = li.Content1;
                    this.lblContent2.Text = li.Content2;
                }
                else
                {
                    this.lblContent1.Text = li.Content2;
                    this.lblContent2.Text = li.Content1;
                }

                if (this.Visible == false)
                {
                    //this.AppearShow();
                    this.Show();
                    this.TopMost = true;
                }
            }
            //Repeat
            else if (AppConfig.PlayRepeat)
            {
                AppConfig.ItemShowedIndex = 0;
                if (AppConfig.RandomSort)
                {
                    AppConfig.ShuffleRandomListItem();
                }
            }
            else
            {
                timerControl.Stop();
                this.CloseApp();
            }
        }