Esempio n. 1
0
        public static void Randomize_ListOfMob(ref List <MultiLineObject> mobList)
        {
            List <MultiLineObject> randomedList = new List <MultiLineObject>();

            for (int p = 0; p < mobList.Count; p++)
            {
                randomedList.Add(mobList[p]);
            }

            Random rs = new Random();

            int seed = rs.Next(1, 255);

            Random r = new Random(seed);

            for (int i = 0; i < randomedList.Count; i++)
            {
                int             number = r.Next(0, randomedList.Count);
                MultiLineObject sl     = randomedList[number];
                randomedList.RemoveAt(number);
                randomedList.Insert(i, sl);
            }

            mobList = randomedList;
        }
Esempio n. 2
0
        static List <MultiLineObject> FillRandomMobList(List <MultiLineObject> mobList)
        {
            List <MultiLineObject> rList = new List <MultiLineObject>();

            foreach (MultiLineObject mob in mobList)
            {
                rList.Add(mob);
            }

            Random r = new Random(7);

            for (int i = 0; i < rList.Count; i++)
            {
                int             number = r.Next(0, rList.Count);
                MultiLineObject mob    = rList[number];
                rList.RemoveAt(number);
                rList.Insert(i, mob);
            }

            return(rList);
        }
Esempio n. 3
0
        List <string> GetListElements()
        {
            List <string> list = new List <string>();

            currentListMobs = new List <MultiLineObject>();
            Category cat = GetSelectedCategory();

            switch (Settings.Read_Mode)
            {
            case ReadMode.Slova:
                //вывод слов
                //заполнить список с нефильтрованными словами из выбранной категории
                if (Categories_CB.SelectedIndex != 0)
                {
                    if (cat != null)
                    {
                        if (!AddSlovaByRasskazy_CB.Checked)
                        {
                            if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                                cat.SlovaNonFiltered        = Lib.Randomize_ListOfSlovo(cat.SlovaNonFiltered);
                                Mix_CB.Checked = false;
                            }
                            else
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                            }

                            SetCountLibObject(cat.SlovaNonFiltered.Count, Color.Green, SlovsCount_LBL);
                            foreach (Slovo sl in cat.SlovaNonFiltered)
                            {
                                if (sl.OriginalText.Length <= Settings.BukvFilter)
                                {
                                    list.Add(sl.GetText());
                                }
                            }
                        }
                        else
                        {
                            if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                                cat.SlovaByRasskazy         = Lib.Randomize_ListOfSlovo(cat.SlovaByRasskazy);
                                Mix_CB.Checked = false;
                            }
                            else
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                            }

                            SetCountLibObject(cat.SlovaByRasskazy.Count, Color.Green, SlovsCount_LBL);
                            foreach (Slovo sl in cat.SlovaByRasskazy)
                            {
                                if (sl.OriginalText.Length <= Settings.BukvFilter)
                                {
                                    list.Add(sl.GetText());
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (!AddSlovaByRasskazy_CB.Checked)
                    {
                        if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                        {
                            Settings.MixElementsEnabled = Mix_CB.Checked;
                            lib.Slova      = Lib.Randomize_ListOfSlovo(lib.Slova);
                            Mix_CB.Checked = false;
                        }
                        else
                        {
                            Settings.MixElementsEnabled = Mix_CB.Checked;
                        }

                        SetCountLibObject(lib.Slova.Count, Color.Green, SlovsCount_LBL);
                        //заполнить список словами из всех категорий
                        foreach (Slovo sl in lib.Slova)
                        {
                            if (sl.OriginalText.Length <= Settings.BukvFilter)
                            {
                                list.Add(sl.GetText());
                            }
                        }
                    }
                    else
                    {
                        if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                        {
                            Settings.MixElementsEnabled = Mix_CB.Checked;
                            lib.SlovaByRasskazy         = Lib.Randomize_ListOfSlovo(lib.SlovaByRasskazy);
                            Mix_CB.Checked = false;
                        }
                        else
                        {
                            Settings.MixElementsEnabled = Mix_CB.Checked;
                        }

                        SetCountLibObject(lib.SlovaByRasskazy.Count, Color.Green, SlovsCount_LBL);
                        foreach (Slovo sl in lib.SlovaByRasskazy)
                        {
                            if (sl.OriginalText.Length <= Settings.BukvFilter)
                            {
                                list.Add(sl.GetText());
                            }
                        }
                    }
                }
                SetCountLibObject(list.Count, Color.Blue, SlovsFilteredByBukvCount_LBL);
                break;

            case ReadMode.Predlogenie:
                //вывод предложений
                if (Categories_CB.SelectedIndex != 0)
                {
                    //заполнить список предложениями из выбранной категории
                    cat = GetSelectedCategory();
                    if (cat != null)
                    {
                        if (!AddPredlogenyaByRasskazy_CB.Checked)
                        {
                            if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                                cat.Predlogenia             = Lib.Randomize_ListOfStrings(cat.Predlogenia);
                                Mix_CB.Checked = false;
                            }
                            else
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                            }

                            SetCountLibObject(cat.Predlogenia.Count, Color.Green, CountPredlogen_LBL);
                            foreach (string p in cat.Predlogenia)
                            {
                                list.Add(p);
                            }
                        }
                        else
                        {
                            if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                                cat.PredlogeniaByRasskazy   = Lib.Randomize_ListOfStrings(cat.PredlogeniaByRasskazy);
                                Mix_CB.Checked = false;
                            }
                            else
                            {
                                Settings.MixElementsEnabled = Mix_CB.Checked;
                            }

                            SetCountLibObject(cat.PredlogeniaByRasskazy.Count, Color.Green, CountPredlogen_LBL);
                            foreach (string p in cat.PredlogeniaByRasskazy)
                            {
                                list.Add(p);
                            }
                        }
                    }
                }
                else
                {
                    if (!AddPredlogenyaByRasskazy_CB.Checked)
                    {
                        if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                        {
                            Settings.MixElementsEnabled      = Mix_CB.Checked;
                            lib.PredlogeniaFromAllCategories = Lib.Randomize_ListOfStrings(lib.PredlogeniaFromAllCategories);
                            Mix_CB.Checked = false;
                        }
                        else
                        {
                            Settings.MixElementsEnabled = Mix_CB.Checked;
                        }

                        SetCountLibObject(lib.PredlogeniaFromAllCategories.Count, Color.Green, CountPredlogen_LBL);
                        foreach (string p in lib.PredlogeniaFromAllCategories)
                        {
                            list.Add(p);
                        }
                    }
                    else
                    {
                        if (Mix_CB.Checked)    //если включена перемешка - выполним рандомное перемешивание
                        {
                            Settings.MixElementsEnabled = Mix_CB.Checked;
                            lib.PredlogeniaFromAllCategoriesByRasskazy = Lib.Randomize_ListOfStrings(lib.PredlogeniaFromAllCategoriesByRasskazy);
                            Mix_CB.Checked = false;
                        }
                        else
                        {
                            Settings.MixElementsEnabled = Mix_CB.Checked;
                        }

                        SetCountLibObject(lib.PredlogeniaFromAllCategoriesByRasskazy.Count, Color.Green, CountPredlogen_LBL);
                        foreach (string p in lib.PredlogeniaFromAllCategoriesByRasskazy)
                        {
                            list.Add(p);
                        }
                    }
                }
                break;

            case ReadMode.Sloga:
                //генерация и вывод слогов
                int allSlogsCount = Slog.ListSlog_Glas_Glas.Count + Slog.ListSlog_Glas_Soglas.Count + Slog.ListSlog_Soglas_Glas.Count;
                SetCountLibObject(allSlogsCount, Color.Green, FullSlogsCount_LBL);

                switch (Settings.SlogCurrentType)
                {
                case SlogType.Slogs_All:
                    List <Slog> lstAll = Slog.ListAllSlogTypes;
                    SetCountLibObject(lstAll.Count, Color.Green, SlogCountByType_LBL);
                    list = Slog.ConverSlogListToStringList(lstAll);
                    break;

                case SlogType.Slog2_Glas_Glas:
                    SetCountLibObject(Slog.ListSlog_Glas_Glas.Count, Color.Green, SlogCountByType_LBL);
                    list = Slog.ConverSlogListToStringList(Slog.ListSlog_Glas_Glas);
                    break;

                case SlogType.Slog2_glas_Soglas:
                    SetCountLibObject(Slog.ListSlog_Glas_Soglas.Count, Color.Green, SlogCountByType_LBL);
                    list = Slog.ConverSlogListToStringList(Slog.ListSlog_Glas_Soglas);
                    break;

                case SlogType.Slog2_Soglas_Glas:
                    SetCountLibObject(Slog.ListSlog_Soglas_Glas.Count, Color.Green, SlogCountByType_LBL);
                    list = Slog.ConverSlogListToStringList(Slog.ListSlog_Soglas_Glas);
                    break;
                }

                SetCountLibObject(list.Count, Color.Green, SlogCountByZvuk_LBL);
                break;

            case ReadMode.Stishki:
                if (StihNames_CB.SelectedIndex >= 0)
                {
                    if (Categories_CB.SelectedIndex != 0)
                    {
                        if (cat != null)
                        {
                            MultiLineObject mob = Lib.FindMobInListByNameObj(StihNames_CB.SelectedItem.ToString(), cat.Stishki);
                            if (mob != null)
                            {
                                list = mob.ContentList;
                            }
                        }
                    }
                    else
                    {
                        MultiLineObject mob = Lib.FindMobInListByNameObj(StihNames_CB.SelectedItem.ToString(), lib.StishkiFromAllCategories);
                        if (mob != null)
                        {
                            list = mob.ContentList;
                        }
                    }
                }
                break;

            case ReadMode.Skorogovorki:
                if (Categories_CB.SelectedIndex != 0)
                {
                    if (cat != null)
                    {
                        SetCountLibObject(cat.Skorogovorki.Count, Color.Green, FullCountSkorogovorki_LBL);
                        currentListMobs = cat.Skorogovorki;
                    }
                }
                else
                {
                    SetCountLibObject(lib.SkorogovorkiFromAllCategories.Count, Color.Green, FullCountSkorogovorki_LBL);
                    currentListMobs = lib.SkorogovorkiFromAllCategories;
                }
                break;

            case ReadMode.Schitalki:
                if (Categories_CB.SelectedIndex != 0)
                {
                    if (cat != null)
                    {
                        SetCountLibObject(cat.Schitalki.Count, Color.Green, FullSchitalkiCount_LBL);
                        currentListMobs = cat.Schitalki;
                    }
                }
                else
                {
                    SetCountLibObject(lib.SchitalkiFromAllCategories.Count, Color.Green, FullSchitalkiCount_LBL);
                    currentListMobs = lib.SchitalkiFromAllCategories;
                }
                break;

            case ReadMode.Rasskazy:
                if (RasskazyNames_CB.SelectedIndex >= 0)
                {
                    if (Categories_CB.SelectedIndex != 0)
                    {
                        if (cat != null)
                        {
                            MultiLineObject mob = Lib.FindMobInListByNameObj(RasskazyNames_CB.SelectedItem.ToString(), cat.Rasskazy);
                            if (mob != null)
                            {
                                list = mob.ContentList;
                            }
                        }
                    }
                    else
                    {
                        MultiLineObject mob = Lib.FindMobInListByNameObj(RasskazyNames_CB.SelectedItem.ToString(), lib.RasskazyFromAllCategories);
                        if (mob != null)
                        {
                            list = mob.ContentList;
                        }
                    }
                }
                break;

            case ReadMode.Songs:
                if (SongNames_CB.SelectedIndex >= 0)
                {
                    if (Categories_CB.SelectedIndex != 0)
                    {
                        if (cat != null)
                        {
                            MultiLineObject mob = Lib.FindMobInListByNameObj(SongNames_CB.SelectedItem.ToString(), cat.Songs);
                            if (mob != null)
                            {
                                list = mob.ContentList;
                            }
                        }
                    }
                    else
                    {
                        MultiLineObject mob = Lib.FindMobInListByNameObj(SongNames_CB.SelectedItem.ToString(), lib.SongsFromAllCategories);
                        if (mob != null)
                        {
                            list = mob.ContentList;
                        }
                    }
                }
                break;
            }

            if (Settings.Read_Mode != ReadMode.Rasskazy &&
                Settings.Read_Mode != ReadMode.Songs &&
                Settings.Read_Mode != ReadMode.Stishki &&
                Settings.Read_Mode != ReadMode.Schitalki &&
                Settings.Read_Mode != ReadMode.Skorogovorki)
            {
                //if (Mix_CB.Checked)//если включена перемешка - выполним рандомное перемешивание
                //{
                //    Settings.MixElementsEnabled = Mix_CB.Checked;
                //    Lib.Randomize_ListOfStrings(ref list);
                //    Mix_CB.Checked = false;
                //}
                //else
                //    Settings.MixElementsEnabled = Mix_CB.Checked;
            }
            return(list);
        }
Esempio n. 4
0
        void ReadMultiLineTypedContent(string fileName, string dirName, bool isHasSplitter, MultiLineContentType contentType)
        {
            List <MultiLineObject> mobList = new List <MultiLineObject>();
            string catFolder = Lib.LibFolderName + "\\" + name + "\\" + dirName;

            if (!isHasSplitter)
            {
                if (Directory.Exists(catFolder))
                {
                    string[] fl = Directory.GetFiles(catFolder, fileName);
                    if (fl != null && fl.Length > 0)
                    {
                        Hashtable ht = new Hashtable();
                        for (int i = 0; i < fl.Length; i++)
                        {
                            List <string> contentList = new List <string>();
                            string        flName      = fl[i];
                            if (File.Exists(flName))
                            {
                                ht.Add(flName, null);
                                FileStream   fs = File.Open(flName, FileMode.Open);
                                StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(1251));

                                while (!sr.EndOfStream)
                                {
                                    string ln = sr.ReadLine();
                                    contentList.Add(ln);
                                }

                                ht[flName] = contentList;

                                sr.Close();
                                fs.Close();
                            }
                        }

                        foreach (string key in ht.Keys)
                        {
                            List <string>   contentList = (List <string>)ht[key];
                            MultiLineObject mob         = new MultiLineObject(key, contentList, this);
                            mobList.Add(mob);
                        }
                    }
                }
            }
            else
            {
                if (Directory.Exists(catFolder))
                {
                    string[] fl = Directory.GetFiles(catFolder, fileName);
                    if (fl != null && fl.Length > 0)
                    {
                        Hashtable ht = new Hashtable();
                        for (int i = 0; i < fl.Length; i++)
                        {
                            List <string> contentList = new List <string>();
                            string        flName      = fl[i];
                            if (File.Exists(flName))
                            {
                                ht.Add(flName, null);
                                FileStream   fs = File.Open(flName, FileMode.Open);
                                StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(1251));

                                while (!sr.EndOfStream)
                                {
                                    string ln = sr.ReadLine();
                                    if (!String.IsNullOrEmpty(ln) && ln == "@")
                                    {
                                        MultiLineObject mob = new MultiLineObject(flName, contentList, this);
                                        mobList.Add(mob);
                                        contentList = new List <string>();
                                    }
                                    else
                                    {
                                        contentList.Add(ln);
                                    }
                                }

                                ht[flName] = contentList;

                                sr.Close();
                                fs.Close();
                            }
                        }

                        foreach (string key in ht.Keys)
                        {
                            List <string>   contentList = (List <string>)ht[key];
                            MultiLineObject mob         = new MultiLineObject(key, contentList, this);
                            mobList.Add(mob);
                        }
                    }
                }
            }

            switch (contentType)
            {
            case MultiLineContentType.Schitalki:
                if (!Settings.MixElementsEnabled)
                {
                    schitalki = mobList;
                }
                else
                {
                    //надо перемешать считалки
                    schitalki = Category.FillRandomMobList(mobList);
                }
                break;

            case MultiLineContentType.Skorogovorki:
                if (!Settings.MixElementsEnabled)
                {
                    skorogovorki = mobList;
                }
                else
                {
                    //надо перемешать скороговорки
                    skorogovorki = Category.FillRandomMobList(mobList);
                }
                break;

            case MultiLineContentType.Stishki:
                stishki = mobList;
                break;

            case MultiLineContentType.Songs:
                songs = mobList;
                break;

            case MultiLineContentType.Rasskazy:
                rasskazy = mobList;
                break;
            }
        }
Esempio n. 5
0
        void RenderMultiLinePart(bool isDirectionForvard)
        {
            if (listMobs == null)
            {
                return;
            }

            if (currentIndex >= listMobs.Count)
            {
                currentIndex = listMobs.Count - 1;
            }

            if (currentIndex >= 0 && currentIndex < listMobs.Count)
            {
                //отступ
                int countUpperOtstup = 0;
                if (Settings.UpperMargin > 0)
                {
                    for (int i = 0; i < Settings.UpperMargin; i++)
                    {
                        rich_TB.AppendText("\r\n");
                        countUpperOtstup++;
                    }
                }

                string leftIndentStr = "";
                if (Settings.CountLeftIndent > 0)
                {
                    for (int li = 0; li < Settings.CountLeftIndent; li++)
                    {
                        leftIndentStr += "\t";
                    }
                }

                //выводим нужное кол-во элементов
                int countPartsRedered = 0;
                int directionIndex    = 1;
                if (!isDirectionForvard)
                {
                    directionIndex = -1;
                }
                for (int i = currentIndex; i <= listMobs.Count && i >= -1; i += directionIndex)
                {
                    if (i == -1)
                    {
                        currentIndex = i = listMobs.Count - 1;
                    }
                    if (i == listMobs.Count)
                    {
                        currentIndex = i = 0;
                    }

                    if (countPartsRedered > 0)
                    {
                        //после отрисовки элемента сделать переход на новую строку
                        rich_TB.AppendText("\r\n");
                        if (Settings.Read_Mode != ReadMode.Stishki && Settings.Read_Mode != ReadMode.Songs && Settings.Read_Mode != ReadMode.Rasskazy)
                        {
                            if (Settings.BeforeLineMargin > 0)
                            {
                                //междустрочный интервал
                                for (int l = 0; l < Settings.BeforeLineMargin; l++)
                                {
                                    rich_TB.AppendText("\r\n");
                                }
                            }
                        }
                    }

                    //тут отрисуем элемент
                    MultiLineObject mob = listMobs[i];
                    for (int m = 0; m < mob.ContentList.Count; m++)
                    {
                        if (m > 0)
                        {
                            rich_TB.AppendText("\r\n");
                        }
                        string s = mob.ContentList[m];
                        if (Settings.IsUpperRegister)
                        {
                            s = s.ToUpper();
                        }
                        rich_TB.AppendText(String.Format("{0}{1}", leftIndentStr, s));
                    }

                    countPartsRedered++;


                    //currentIndex = i;
                    if (countPartsRedered == Settings.ElementsCount)
                    {
                        break;
                    }
                }

                //вделим все элементы и выровним
                rich_TB.SelectAll();
                rich_TB.SelectionAlignment = Settings.TextHorizontalAlignment;
                rich_TB.Select(0, 0);

                //подсвечиваем текст нужными цветами
                if (Settings.Read_Mode == ReadMode.Sloga || Settings.Read_Mode == ReadMode.Slova || Settings.Read_Mode == ReadMode.Predlogenie)
                {
                    ColorizeRederedText();
                }

                rich_TB.Select(0, 0);
            }
        }