Ejemplo n.º 1
0
        private MyWord[][] getWords(string txt, out int nRow)
        {
            var reg   = new Regex(@"[\w]+");
            var mc    = reg.Matches(txt);
            var tDict = new Dictionary <string, UInt64>();

            foreach (Match m in mc)
            {
                if (tDict.ContainsKey(m.Value))
                {
                    continue;
                }
                tDict.Add(m.Value, 0);
            }

            var arr = new MyWord[tDict.Count][];

            nRow = 0;
            foreach (var key in tDict.Keys)
            {
                var lst = new List <MyWord>();
                if (m_db.ContainsKey(key))
                {
                    arr[nRow++] = m_db[key].ToArray();
                }
            }

            return(arr);
        }
Ejemplo n.º 2
0
        private void InitElements()
        {
            textblockword.Text = currentMyWord.Word;
            MyWord[]   arrMw  = new MyWord[] { currentMyWord, GetRandoMyWord() };
            List <int> random = MyTools.GetRandomInt(new List <int>()
            {
                0, 1
            }, 2);

            for (int i = 0; i < 2; i++)
            {
                MyWord mw = arrMw[random[i]];
                arrButtons[i].DataContext = mw;
                TextBlock textblock = (TextBlock)arrButtons[i].Content;
                textblock.Text = MyTools.GetTranslate(mw);
            }
            textblocktop.Text = (myWords.Count - currentIndex).ToString();
            if (isPlay)
            {
                FileInfo fi = FIleTools.SearchFile(currentMyWord.SoundName, FIleTools.NameDirectoryAudio);


                PlaySound(fi);
            }
        }
Ejemplo n.º 3
0
        public static List <MyWord> GetRandomListMyWord(int count)
        {
            List <int> listId = GetWordId();

            if (listId.Count <= count)
            {
                MessageBox.Show("Кол-во выбираемых слов превышает кол-во слов в БД " + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
            List <int>    listRandomId = MyTools.GetRandomInt(listId, count);
            List <MyWord> listRandom   = new List <MyWord>();

            using (var context = new ApplicationContext())
            {
                context.Configuration.LazyLoadingEnabled = false;
                try
                {
                    for (int i = 0; i < listRandomId.Count; i++)
                    {
                        MyWord myWord = context.MyWords.Find(listRandomId[i]);
                        context.Entry(myWord).Collection(x => x.MyTranslates).Load();
                        context.Entry(myWord).Collection(x => x.MyExamples).Load();
                        listRandom.Add(myWord);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + " " + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }
            }
            return(listRandom);
        }
Ejemplo n.º 4
0
        public WindowRepetition(List <MyWord> words)
        {
            mediaPlayer       = new MediaPlayer();
            myWords           = words;
            currentMyWord     = myWords[currentIndex];
            countMilisek      = App.dataVariable.CountMilisek;
            countMilisekDelay = App.dataVariable.CountMilisekDelay;
            CreateDispetherTime();
            CreateDispetherTimeNext();
            InitializeComponent();

            pr            = progressbar;
            random        = App.random;
            arrButtons    = new Button[2];
            arrButtons[0] = buttonleft;
            arrButtons[1] = buttonright;
            InitElements();
            templateDefault = buttonleft.Template;
            templateGreen   = (ControlTemplate)TryFindResource("buttonTemplateGreen");
            templateRed     = (ControlTemplate)TryFindResource("buttonTemplateRed");
            upDateState     = new List <MyWord>();


            //colorDefault = new SolidColorBrush(Color.FromRgb(221, 221, 221));
            //colorGreen = new SolidColorBrush(Color.FromRgb(158, 235, 142));
            //colorRed = new SolidColorBrush(Color.FromRgb(235, 152, 142));
        }
Ejemplo n.º 5
0
    const float _NodeDimentions = 0.08f; //update CreatureBehaviour -> NodeMapCollision -> PlayerManager


    void Awake()
    {
        MyWord.Setup();

        MyPos [0, 0] = ((transform.position.x - _NewMapCenter) / _NodeDimentions) - (((transform.position.x - _NewMapCenter) / _NodeDimentions) % 1);        //Calculating Object World Position In The Node Map
        MyPos [0, 1] = ((transform.position.y - _NewMapCenter) / _NodeDimentions) - (((transform.position.y - _NewMapCenter) / _NodeDimentions) % 1);        //Calculating Object World Position In The Node Map
        MyNode [0]   = new Nodes(MyPos, 0);
    }
Ejemplo n.º 6
0
        private void InitDbContext(MyWord w)
        {
            this.DataContext = w;
            FileInfo fi = FIleTools.SearchFile(w.SoundName, FIleTools.NameDirectoryAudio);

            textblockCountword.Text = (count + 1).ToString() + "/" + App.dataVariable.CountWordLearning;
            PlaySound(fi);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// возвращает рандомный перевод из MyWord
        /// </summary>
        /// <param name="mw"></param>
        /// <returns></returns>
        public static string GetTranslate(MyWord mw)
        {
            int count             = mw.MyTranslates.Count;
            List <MyTranslate> lt = mw.MyTranslates.ToList();
            MyTranslate        tr = lt[App.random.Next(count)];

            return(tr.Translate);
        }
Ejemplo n.º 8
0
 public WindowWordEdit(MyWord word, Button downButton)
 {
     MyWord = word;
     InitializeComponent();
     this.DataContext = MyWord;
     initElements();
     splitTranslate = new char[] { '\n', '.', ',', '!', ' ', ';', ':', '\r', '\t', '\v', '?', '/' };
     splitExample   = new char[] { '\n', '\r', '\t', '\v' };
     wordButton     = downButton;
 }
Ejemplo n.º 9
0
 private void NextCurrentMyWord()
 {
     if (currentIndex < (myWords.Count - 1))
     {
         currentMyWord = myWords[++currentIndex];
     }
     else
     {
         dispatcherTimerNext.Stop();
     }
 }
Ejemplo n.º 10
0
        private void buttonState_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Button         bt     = sender as Button;
            int            wordid = (int)bt.DataContext;
            MyWord         mw     = BdTools.FindMyWord(wordid);
            WindowWordEdit wwe    = new WindowWordEdit(mw, bt);

            if (wwe.ShowDialog() == true)
            {
            }
        }
    const float _NodeDimentions = 0.08f; //update CreatureBehaviour -> NodeMapCollision -> PlayerManager


    void Awake()
    {
        MyWord.Setup();

        MyPos [0, 0] = ((FeetPlacements.transform.position.x - _NewMapCenter) / _NodeDimentions) - (((FeetPlacements.transform.position.x - _NewMapCenter) / _NodeDimentions) % 1);        //Calculating Object World Position In The Node Map
        MyPos [0, 1] = ((FeetPlacements.transform.position.y - _NewMapCenter) / _NodeDimentions) - (((FeetPlacements.transform.position.y - _NewMapCenter) / _NodeDimentions) % 1);        //Calculating Object World Position In The Node Map
        MyNode [0]   = new Nodes(MyPos, 0);

        TheObject._CreateThePath   = new AStarPathfinding_RoomPaths(GameObject.FindGameObjectWithTag("GameManager").GetComponent <ClockTest>().RoomPathsCount);       //Performance Increase Is To Put This In A Different Script And Let Everyone Use That One Script, Insted Of One For Each Object
        TheObject._PersonalNodeMap = new CreatingObjectNodeMap(FeetPlacements.size, WalkingColliders.size.x, _NodeDimentions, TheObject.PathfindingNodeID, MyNode);
    }
Ejemplo n.º 12
0
 private void Init()
 {
     currentMyWord = myList[currentIndex];
     if (NextRandomBool())//если true то вставляем правильное значение
     {
         isCurrentBool = true;
         InitTextBloks(currentMyWord.Word, MyTools.GetTranslate(currentMyWord));
     }
     else
     {
         isCurrentBool = false;
         MyWord myWordRandom = MyTools.GetRandomMyWord(myList, currentIndex);
         InitTextBloks(currentMyWord.Word, MyTools.GetTranslate(myWordRandom));
     }
 }
Ejemplo n.º 13
0
        private void buttonState_Click(object sender, RoutedEventArgs e)
        {
            Button but = sender as Button;
            int    id  = (int)but.DataContext;

            MyWord mw = collection.Where(n => n.WordId == id).First();


            WindowStateChose wsc = new WindowStateChose(this, mw.State);

            if (wsc.ShowDialog() == true)
            {
                Image im = but.Content as Image;
                im.Source = InitBitMap();
                mw.State  = StateWord;
                BdTools.UpdateStateMyWord(id, StateWord);
            }
        }
Ejemplo n.º 14
0
        private void buttonfive_Click(object sender, RoutedEventArgs e)
        {
            if (!isEnabledButton)
            {
                return;
            }
            Button bt = sender as Button;
            MyWord mw = bt.DataContext as MyWord;

            if (trenings[count].WordId == mw.WordId)
            {
                MethodYes(bt);
            }
            else
            {
                MethodNo(bt);
            }
            isEnabledButton = false;
        }
Ejemplo n.º 15
0
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            Button but   = sender as Button;
            int    index = (int)but.DataContext;

            MyWord   wordDel  = BdTools.DeleteWord(index);
            FileInfo fileInfo = FIleTools.SearchFile(wordDel.SoundName, FIleTools.NameDirectoryAudio);

            collection.Remove(wordDel);
            try
            {
                File.Delete(fileInfo.FullName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + MethodBase.GetCurrentMethod().DeclaringType.FullName);
                return;
            }
        }
Ejemplo n.º 16
0
 private void buttonright_Click(object sender, RoutedEventArgs e)
 {
     if (isLock)
     {
         Button but = (Button)sender;
         MyWord mw  = (MyWord)but.DataContext;
         dispatcherTimer.Stop();
         if (mw.WordId == currentMyWord.WordId)
         {
             but.Template = templateGreen;
             AnswerTrue(but);
         }
         else
         {
             but.Template = templateRed;
             AnswerFalse(but);
         }
     }
 }
Ejemplo n.º 17
0
 private void Init()
 {
     try
     {
         curentMyWord = myWords[currentWord];
         wordTrue     = curentMyWord.Word.ToUpper();
         translate    = curentMyWord.MyTranslates.First().Translate;
         string str = Mix(wordTrue);
         AddButtons(str);
         textBlockWord.Text      = translate;
         buttonNext.Content      = strDef;
         buttonNext.Background   = backgroundButtonNextDefault;
         textblockCountword.Text = (currentWord + 1).ToString() + "/" + myWords.Count;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
 }
Ejemplo n.º 18
0
        public static MyWord UpdateStateMyWord(int id, int state)
        {
            MyWord mw = null;

            using (var context = new ApplicationContext())
            {
                try
                {
                    mw       = context.MyWords.Find(id);
                    mw.State = state;
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message + " " + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }
            }
            return(mw);
        }
Ejemplo n.º 19
0
        public static List <MyWord> GetRandomListMyWord(List <MyWord> sourse, int count)
        {
            if (sourse.Count < count)
            {
                MessageBox.Show(MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
            List <MyWord> listRandom = new List <MyWord>();

            for (int i = 0; i < count; i++)
            {
                int    index = App.random.Next(sourse.Count);
                MyWord mw    = sourse[index];
                listRandom.Add(mw);
                if (!sourse.Remove(mw))
                {
                    break;
                }
            }
            return(listRandom);
        }
Ejemplo n.º 20
0
        int wordDiff(MyWord w1, MyWord w2)
        {
            var a1 = new int[] {
                Convert.ToInt32(w1.titleId),
                Convert.ToInt32(w1.parId),
                w1.pos
            };
            var a2 = new int[] {
                Convert.ToInt32(w2.titleId),
                Convert.ToInt32(w2.parId),
                w2.pos
            };
            var c    = new int[] { 1000, 100, 10 };
            int diff = 0;

            for (int i = 0; i < 3; i++)
            {
                diff += Math.Abs(a1[i] - a2[i]) * c[i];
            }
            return(diff);
        }
Ejemplo n.º 21
0
 public static MyWord DeleteWord(int id)
 {
     using (var context = new ApplicationContext())
     {
         try
         {
             MyWord mw = context.MyWords.Find(id);
             if (mw != null)
             {
                 context.MyWords.Remove(mw);
                 context.SaveChanges();
             }
             return(mw);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message + " " + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
             return(null);
         }
     }
 }
Ejemplo n.º 22
0
 public static int AddNewWord(string word, DateTime insert, DateTime lastCall, string soundname = "", string partofspeach = "", string transcription = "", int state = 1)
 {
     using (var context = new ApplicationContext())
     {
         try
         {
             var words = new MyWord()
             {
                 Word = word, SoundName = soundname, PartOfSpeach = partofspeach, Transcription = transcription, State = state, DataTimeInsert = insert, DataTimeLastCall = lastCall
             };
             context.MyWords.Add(words);
             context.SaveChanges();
             context.Dispose();
             return(words.WordId);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
             return(0);
         }
     }
 }
Ejemplo n.º 23
0
        public static MyWord FindMyWord(int id)
        {
            MyWord mw = null;

            using (var context = new ApplicationContext())
            {
                context.Configuration.LazyLoadingEnabled = false;
                try
                {
                    mw = context.MyWords.Find(id);
                    context.Entry(mw).Collection(x => x.MyTranslates).Load();
                    context.Entry(mw).Collection(x => x.MyExamples).Load();
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message + " " + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }
            }
            return(mw);
        }
Ejemplo n.º 24
0
        private void DeleteWord(int wordId)
        {
            BdTools.DeleteWord(wordId);
            //MyWord myWord = collection.Where(n => n.WordId == wordId).Single();
            MyWord myWord = null;

            foreach (MyWord item in collection)
            {
                if (item.WordId == wordId)
                {
                    myWord = item;
                }
            }
            if (myWord == null)
            {
                MessageBox.Show("Слово не найдено!", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            collection.Remove(myWord);
            FileInfo fileInfo = FIleTools.SearchFile(myWord.SoundName, FIleTools.NameDirectoryAudio);

            if (fileInfo != null)
            {
                fileInfo.IsReadOnly = false;
                try
                {
                    File.Delete(fileInfo.FullName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Файл отсутствует в папке SoundFiles", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 25
0
 public static MyWord UpdateStateMyWord(MyWord mw, State state)
 {
     return(UpdateStateMyWord(mw.WordId, (int)state));
 }