예제 #1
0
 public void Reset()
 {
     panel1.Controls.Clear();
     MyCheckBoxEx.checkBoxesList.Clear();
     curSlovo           = null;
     SlovoView_LBL.Text = "";
 }
예제 #2
0
        public static List <Slovo> Randomize_ListOfSlovo(List <Slovo> slovList)
        {
            List <Slovo> randomedList = new List <Slovo>();

            for (int p = 0; p < slovList.Count; p++)
            {
                randomedList.Add(slovList[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);
                Slovo sl     = randomedList[number];
                randomedList.RemoveAt(number);
                randomedList.Insert(i, sl);
            }

            return(randomedList);
        }
예제 #3
0
        public static List <Slovo> FillSlovaFromRasskazy(List <Slovo> listSlov, List <MultiLineObject> mobList)
        {
            List <Slovo> slovaByRasskazy = new List <Slovo>();
            ArrayList    al = new ArrayList();

            if (mobList != null && listSlov != null)
            {
                Category curCat = null;
                if (mobList.Count > 0)
                {
                    curCat = mobList[0].BaseCategory;
                }
                foreach (Slovo slv in listSlov)
                {
                    TextObjectByCategory tob = new TextObjectByCategory(slv.GetText(), curCat);
                    if (!al.Contains(tob))
                    {
                        al.Add(tob);
                    }
                }

                foreach (MultiLineObject mob in mobList)
                {
                    Category curCategory = mob.BaseCategory;
                    foreach (string s_orig in mob.ContentList)
                    {
                        //тут получаем предложение
                        string[] s = s_orig.Split(new char[] { ',', '.', ';', '!', '?', '"', '(', ')', '\r', '\n', ' ', '-', ':' });
                        if (s != null && s.Length > 0)
                        {
                            for (int is1 = 0; is1 < s.Length; is1++)
                            {
                                string sn = s[is1].Trim();
                                if (Lib.IsStringCorrect(sn))
                                {
                                    TextObjectByCategory tob = new TextObjectByCategory(sn, curCategory);
                                    Slovo nsl = new Slovo(sn, -1, curCategory);
                                    if (!String.IsNullOrEmpty(sn) && sn.Length > 2 && !al.Contains(tob) && !listSlov.Contains(nsl))
                                    {
                                        al.Add(tob);
                                    }
                                }
                            }
                        }
                    }
                }

                if (al != null && al.Count > 0)
                {
                    foreach (TextObjectByCategory tob in al)
                    {
                        Category curCat2 = tob.BaseCategory;
                        string   s       = tob.Text;
                        slovaByRasskazy.Add(new Slovo(s, -1, curCat2));
                    }
                }
            }
            return(slovaByRasskazy);
        }
예제 #4
0
        public void SetSlovo(Slovo slovo)
        {
            panel1.Controls.Clear();
            MyCheckBoxEx.checkBoxesList.Clear();

            curSlovo = slovo;

            if (slovo.IsHasAccent && !String.IsNullOrEmpty(slovo.TextWithAccent))
            {
                SlovoView_LBL.Text = slovo.TextWithAccent;
            }
            else
            {
                SlovoView_LBL.Text = slovo.OriginalText;
            }

            SlovoView_LBL.ForeColor = Color.Blue;

            int slovoLength = curSlovo.OriginalText.Length;

            int x_loc_start = 10;
            int y_loc_start = 10;

            int btnWidth  = 40;
            int btnHeight = 50;

            for (int i = 0; i < slovoLength; i++)
            {
                if (i > 0)
                {
                    x_loc_start += btnWidth + 5;
                }
                bool is_checked = false;
                if (slovo.IsHasAccent && slovo.AccentIndex >= 0 && slovo.AccentIndex == i)
                {
                    is_checked = true;
                }
                MyCheckBoxEx.countCheckBtns++;

                Bukva        bk  = curSlovo.FindBukvuByIndex(i);
                MyCheckBoxEx mcb = new MyCheckBoxEx(i, bk, curSlovo.OriginalText[i].ToString(), is_checked);
                mcb.Appearance      = Appearance.Button;
                mcb.Font            = new Font("Arial", 24);
                mcb.CheckedChanged += new EventHandler(mcb_CheckedChanged);
                mcb.Size            = new Size(btnWidth, btnHeight);
                mcb.Location        = new Point(x_loc_start, y_loc_start);

                MyCheckBoxEx.checkBoxesList.Add(mcb);
            }

            for (int i = 0; i < MyCheckBoxEx.checkBoxesList.Count; i++)
            {
                panel1.Controls.Add(MyCheckBoxEx.checkBoxesList[i]);
            }
        }
예제 #5
0
        private void Slova_LB_SelectedIndexChanged(object sender, EventArgs e)
        {
            //найдем выбранную категорию
            Category cat = Lib.FindCategory(Categories_LB.SelectedItem.ToString(), Form2.lib);

            if (cat != null)
            {
                Slovo sl = cat.FindSlovoByOriginalText(Slova_LB.SelectedItem.ToString().Replace(Settings.AccentStr, ""), false);
                if (sl != null)
                {
                    accent_UC1.SetSlovo(sl);
                }
            }
        }
예제 #6
0
        public static List <Slovo> GetListByFilterBukv(int filter, List <Slovo> sourceList)
        {
            List <Slovo> lst = new List <Slovo>();

            for (int i = 0; i < sourceList.Count; i++)
            {
                Slovo sl = sourceList[i];
                if (sl.OriginalText.Length <= filter)
                {
                    lst.Add(sl);
                }
            }
            return(lst);
        }
예제 #7
0
        public void ReadSlova()
        {
            string catFolder = Lib.LibFolderName + "\\" + name;

            string[] fl = Directory.GetFiles(catFolder, "Слова.txt");

            if (fl != null && fl.Length > 0 && File.Exists(fl[0]))
            {
                FileStream   fs = File.Open(fl[0], FileMode.Open);
                StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(1251));

                if (slova != null)
                {
                    slova.Clear();
                }
                if (slovaNonFiltered != null)
                {
                    slovaNonFiltered.Clear();
                }

                Category baseCat = this;

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

                    string[] lnv         = ln.Split(new char[] { ' ' });
                    int      accentIndex = -1;
                    if (lnv.Length > 1)
                    {
                        int.TryParse(lnv[1], out accentIndex);
                    }

                    if (Settings.BukvFilter >= lnv[0].Length)
                    {
                        Slovo sl = new Slovo(lnv[0], accentIndex, baseCat);
                        slova.Add(sl);
                    }

                    Slovo sl2 = new Slovo(lnv[0], accentIndex, baseCat);
                    slovaNonFiltered.Add(sl2);
                }

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

                FillRandomedList();
            }
        }
예제 #8
0
        public static List <Slovo> FillSlovaFromPredlogeniaByRasskazy(List <Slovo> listSlov, List <string> predlogenia, Category baseCategory)
        {
            List <Slovo> res = new List <Slovo>();

            ArrayList al = new ArrayList();

            if (predlogenia != null && listSlov != null)
            {
                foreach (string predl in predlogenia)
                {
                    if (!String.IsNullOrEmpty(predl) && Lib.IsStringCorrect(predl))
                    {
                        //тут получаем предложение
                        string[] s = predl.Split(new char[] { ',', '.', ';', '!', '?', '"', '(', ')', '\r', '\n', ' ', '-', ':' });
                        if (s != null && s.Length > 0)
                        {
                            for (int is1 = 0; is1 < s.Length; is1++)
                            {
                                string sn = s[is1].Trim();
                                if (Lib.IsStringCorrect(sn))
                                {
                                    TextObjectByCategory tob = new TextObjectByCategory(sn, baseCategory);
                                    Slovo nsl = new Slovo(sn, -1, baseCategory);
                                    if (!String.IsNullOrEmpty(sn) && sn.Length > 2 && !al.Contains(tob) && !listSlov.Contains(nsl))
                                    {
                                        al.Add(tob);
                                    }
                                }
                            }
                        }
                    }
                }

                if (al != null && al.Count > 0)
                {
                    foreach (TextObjectByCategory tob in al)
                    {
                        Category curCat = tob.BaseCategory;
                        string   s      = tob.Text;
                        res.Add(new Slovo(s, -1, curCat));
                    }
                }
            }

            return(res);
        }
예제 #9
0
        void FillRandomedList()
        {
            slovaRandomed = new List <Slovo>();
            foreach (Slovo sl in slovaNonFiltered)
            {
                slovaRandomed.Add(sl);
            }

            Random r = new Random(7);

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