예제 #1
2
        public ViewChart(Group current)
        {
            this.model = new PlotModel("Postęp nauki dla "+current.Name);
            LineSeries basicSerie =  new LineSeries("Postęp nauki");
            LinearAxis ax = new LinearAxis();
            ax.Unit = "%";
            ax.Title = "Poprawne odpowiedzi";
            model.Axes.Add(ax);

            SqlAccess sql = new SqlAccess();
            basicSerie.Smooth = true;
            List<double> list = sql.GetStatsForGroup(current);
            int i = 1;
            if(list.Count>0)
            basicSerie.Points.Add(new DataPoint(0.0,0));
            basicSerie.MarkerType = MarkerType.Circle;
            basicSerie.MarkerSize = 3;
            basicSerie.SelectionMode = SelectionMode.Single;

            foreach (double d in list)
            {

                basicSerie.Points.Add(new DataPoint(i,d));
                i++;
            }

            this.model.Series.Add(basicSerie);
        }
예제 #2
0
 void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     progressBar1.Value = progressBar1.Maximum;
     SqlAccess sql = new SqlAccess();
     sql.GetGroups(true);
     this.Close();
     MessageBox.Show("Udało się zaimportować "+importedWords+" słówek." +(failedWords>0?" Błedy wystąpiły przy "+failedWords+ " słowach.":""));
 }
예제 #3
0
 private void button2_Click(object sender, RoutedEventArgs e)
 {
     SqlAccess sql = new SqlAccess();
     foreach (Group g in listBox1.SelectedItems)
     {
         sql.DeleteWordsFromGroup(g.Id);
     }
     MessageBox.Show("Grupa została wyczyszczona.");
 }
예제 #4
0
        public addGroup()
        {
            InitializeComponent();

            SqlAccess sql = new SqlAccess();
            comboBox1.ItemsSource = sql.GetLanguages();
            comboBox1.SelectedIndex = 0;
            List<Group> temp = sql.GetGroups(false);
            temp.Insert(0,new Group("", 0));
            comboBox2.ItemsSource = temp;

            comboBox2.SelectionChanged += new SelectionChangedEventHandler(comboBox2_SelectionChanged);
        }
예제 #5
0
 public ChartWindow(Group g)
 {
     plotModel = new ViewChart(g);
     DataContext = plotModel;
     InitializeComponent();
     SqlAccess sql = new SqlAccess();
     label2.Content = sql.GetAttendsForGroup(g);
     TimeSpan timeSpan = sql.GetAvgOfDurationForGroup(g);
     avgduration.Content = string.Format("{0:D2}h:{1:D2}m:{2:D2}s",
         timeSpan.Hours,
         timeSpan.Minutes,
         timeSpan.Seconds);
     ShowDialog();
 }
예제 #6
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            SqlAccess sql = new SqlAccess();
            Queue<Group> temporary = new Queue<Group>();
            foreach (Group g in listBox1.SelectedItems)
            {
                sql.DeleteGroup(g.Id);
                temporary.Enqueue(g);

            }
            foreach(Group p in temporary)
                MainWindow.groups.Remove(p);
            MessageBox.Show("Grupa została usunięta.");
        }
예제 #7
0
        void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            List<Word> lines = (List<Word>)e.Argument;

            SqlAccess sql = new SqlAccess();
            foreach (Word wordsFromFile in lines)
            {
                App.Current.Dispatcher.Invoke((Action)delegate()
                {
                    bool t = sql.InsertWord(wordsFromFile.Id_group, wordsFromFile.Foregin, wordsFromFile.Basic);
                    progressBar1.Value=progressBar1.Value+1;

                });

            }
        }
예제 #8
0
        public MainWindow()
        {
            SQLiteFunction.RegisterFunction(typeof(SQLiteCaseInsensitiveCollation));
            InitializeComponent();
            SqlAccess sql = new SqlAccess();
            sql.GetGroups(true);
            listBox1.ItemsSource = groups;
            listBox2.ItemsSource = groups;
            listBox3.ItemsSource = groups;
            if (groups.Count > 0)
            {
                listBox2.SelectedIndex = 0;
                listBox3.SelectedIndex = 0;
                listBox1.SelectedIndex = 0;
            }

            listBox3.MouseDoubleClick+=new MouseButtonEventHandler(listBox3_MouseDoubleClick);
        }
예제 #9
0
        public LearningWindow(String style, int type, ListBox list, ComboBox choosenType)
        {
            InitializeComponent();
            selectedStyle.Content = style;
            ts = DateTime.Now;
            this.type = type;
            this.selectedType = choosenType.SelectedIndex;
            foreach(object ob in list.SelectedItems)
                selectedGroups.Add((Group)ob);
            if(selectedGroups.Count==1)
                basicLanguage.KeyDown += new KeyEventHandler(basicLanguage_KeyDown);
            else if (selectedGroups.Count > 1)
            {
                foreach (Group p in selectedGroups)
                    groupsWithResult.Add(p, new Result());
                basicLanguage.KeyDown += new KeyEventHandler(basicLanguageMultiple_KeyDown);
            }
            SqlAccess sql = new SqlAccess();

            if (this.type == 1) {

                Random random = new Random();
                words = sql.getWordsFromGroups(selectedGroups);
                howMuchAll.Content = words.Count;
                progressBar1.Maximum = words.Count;
                badAnsv.Content = 0;
                goodAnsv.Content = 0;
                indexOfCurrentWord = random.Next(0, words.Count);
                if(selectedType==0)
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Basic;
                else
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Foregin;

            }
            else if (this.type == 2)
            {

                Random random = new Random();
                //int randomNumber = random.Next(0, 100);
                words = sql.getWordsFromGroups(selectedGroups);
                howMuchAll.Content = words.Count;
                progressBar1.Maximum = words.Count;
                badAnsv.Content = 0;
                goodAnsv.Content = 0;
                indexOfCurrentWord = random.Next(0, words.Count);
                if (selectedType == 0)
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Basic;
                else
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Foregin;

            }
            else if (this.type == 3) {
                label5.Visibility = Visibility.Visible;

                Random random = new Random();
                //int randomNumber = random.Next(0, 100);
                words = sql.getWordsFromGroups(selectedGroups);
                howMuchAll.Content = words.Count;
                progressBar1.Maximum = words.Count;
                badAnsv.Content = 0;
                goodAnsv.Content = 0;
                indexOfCurrentWord = random.Next(0, words.Count);
                label5.MouseDown += new MouseButtonEventHandler(label5_MouseDown );
                if (selectedType == 0)
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Basic;
                else
                    foreginWord.Text = words.ElementAt<Word>(indexOfCurrentWord).Foregin;
            }
        }
예제 #10
0
        void basicLanguage_KeyDown(object sender, KeyEventArgs e)
        {
            //event for single group

            if (e.Key == Key.Enter)
            {

                if (this.type == 1)
                {
                    if (words.Count != 0)
                    {
                        Word current = words.ElementAt<Word>(indexOfCurrentWord);
                        lastWord = current;
                        if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1))
                        {
                            words.Remove(current);

                            if (words.Count > 0)
                            {
                                progressBar1.Value++;
                                goodAnsv.Content = (int)goodAnsv.Content + 1;

                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);
                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                //SqlAccess sql = new SqlAccess();
                                //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts)));
                                this.Close();
                                ShowResult();
                            }
                        }
                        else
                        {

                            bad.Add(words.ElementAt<Word>(indexOfCurrentWord));

                            badAnsv.Content = (int)badAnsv.Content + 1;
                            Random r = new Random();
                            indexOfCurrentWord = r.Next(0, words.Count);
                            foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                            lastForeign.Text = lastWord.Basic;
                            lastBasic.Text = lastWord.Foregin;
                            lastForeign.Visibility = Visibility.Visible;
                            lastBasic.Visibility = Visibility.Visible;
                            label6.Visibility = Visibility.Visible;
                            label7.Visibility = Visibility.Visible;
                        }
                        basicLanguage.Text = "";
                    }
                    else
                    {

                       MessageBox.Show("Wybrana grupa nie ma slowek.");

                    }
                }
                else if (this.type == 2)
                {

                    if (words.Count != 0)
                    {
                        Word current = words.ElementAt<Word>(indexOfCurrentWord);
                        lastWord = current;
                        if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1))
                        {
                            words.Remove(current);
                            if (words.Count > 0)
                            {
                                progressBar1.Value++;
                                goodAnsv.Content = (int)goodAnsv.Content + 1;

                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);
                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                words.Remove(current);
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                            }
                            else {

                                SqlAccess sql = new SqlAccess();
                                sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts)));
                                this.Close();
                                ShowResult();
                            }
                        }
                        else
                        {
                            bad.Add(words.ElementAt<Word>(indexOfCurrentWord));
                            words.Remove(current);
                            if (words.Count > 0)
                            {
                                progressBar1.Value++;
                                badAnsv.Content = (int)badAnsv.Content + 1;
                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);

                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                            }
                            else {

                                SqlAccess sql = new SqlAccess();
                                sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts)));
                                this.Close();
                                ShowResult();
                            }
                        }
                        basicLanguage.Text = "";
                    }
                    else
                    {

                         MessageBox.Show("Wybrana grupa nie ma slowek.");

                    }
                }
                else if (this.type == 3)
                {
                    MessageBox.Show("3");
                    if (words.Count != 0)
                    {
                        Word current = words.ElementAt<Word>(indexOfCurrentWord);
                        lastWord = current;
                        if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1))
                        {
                            words.Remove(current);
                            if (words.Count > 0)
                            {
                                progressBar1.Value++;
                                goodAnsv.Content = (int)goodAnsv.Content + 1;

                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);
                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                            }
                            else {

                                //SqlAccess sql = new SqlAccess();
                                //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts)));
                                this.Close();
                                ShowResult();
                            }
                        }
                        else
                        {

                            bad.Add(words.ElementAt<Word>(indexOfCurrentWord));
                            badAnsv.Content = (int)badAnsv.Content + 1;
                            Random r = new Random();
                            indexOfCurrentWord = r.Next(0, words.Count);
                            foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                            lastForeign.Text = lastWord.Basic;
                            lastBasic.Text = lastWord.Foregin;
                            lastForeign.Visibility = Visibility.Visible;
                            lastBasic.Visibility = Visibility.Visible;
                            label6.Visibility = Visibility.Visible;
                            label7.Visibility = Visibility.Visible;
                        }
                        basicLanguage.Text = "";
                    }
                    else
                        MessageBox.Show("Wybrana grupa nie ma dodanych slow.");

                }

            }
        }
예제 #11
0
        void basicLanguageMultiple_KeyDown(object sender, KeyEventArgs e)
        {
            //event for multiplie selected groups

            if (e.Key == Key.Enter)
            {

                //something smart to recognize which word is connected to which group and save pos/neg ansv.
                if (this.type == 1)
                {
                    if (words.Count != 0)
                    {
                        Word current = words.ElementAt<Word>(indexOfCurrentWord);
                        if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1))
                        {
                            words.Remove(current);
                            lastWord = current;
                            if (words.Count > 0)
                            {
                                progressBar1.Value++;
                                goodAnsv.Content = (int)goodAnsv.Content + 1;

                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);
                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                //SqlAccess sql = new SqlAccess();
                                //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts)));
                                this.Close();
                                ShowResult();
                            }
                        }
                        else
                        {

                            bad.Add(words.ElementAt<Word>(indexOfCurrentWord));

                            badAnsv.Content = (int)badAnsv.Content + 1;
                            Random r = new Random();
                            indexOfCurrentWord = r.Next(0, words.Count);
                            foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                            lastForeign.Text = lastWord.Basic;
                            lastBasic.Text = lastWord.Foregin;
                            lastForeign.Visibility = Visibility.Visible;
                            lastBasic.Visibility = Visibility.Visible;
                            label6.Visibility = Visibility.Visible;
                            label7.Visibility = Visibility.Visible;
                        }
                        basicLanguage.Text = "";
                    }
                    else
                    {

                        MessageBox.Show("Wybrana grupa nie ma slowek.");

                    }
                }
                else if (this.type == 2)
                {

                    if (words.Count != 0)
                    {
                        Word current = words.ElementAt<Word>(indexOfCurrentWord);
                        if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1))
                        {
                            words.Remove(current);
                            lastWord = current;
                            if (words.Count > 0)
                            {
                                progressBar1.Value++;
                                goodAnsv.Content = (int)goodAnsv.Content + 1;

                                Result currResult = groupsWithResult[ selectedGroups.ElementAt<Group>(selectedGroups.IndexOf( Group.getFromID(current.Id_group)))];
                                currResult.positiveAnsw++;
                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);
                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                                words.Remove(current);
                            }
                            else
                            {

                                SqlAccess sql = new SqlAccess();
                                sql.UpdateStats(groupsWithResult, DateTime.Now.Subtract(ts));
                                this.Close();
                                ShowResult();
                            }
                        }
                        else
                        {
                            bad.Add(words.ElementAt<Word>(indexOfCurrentWord));
                            words.Remove(current);
                            if (words.Count > 0)
                            {
                                Result currResult = groupsWithResult[selectedGroups.ElementAt<Group>(selectedGroups.IndexOf(Group.getFromID(current.Id_group)))];
                                currResult.negativeAnsw++;
                                progressBar1.Value++;
                                badAnsv.Content = (int)badAnsv.Content + 1;
                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);

                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                            }
                            else
                            {

                                SqlAccess sql = new SqlAccess();
                                sql.UpdateStats(groupsWithResult, DateTime.Now.Subtract(ts));
                                this.Close();
                                ShowResult();
                            }
                        }
                        basicLanguage.Text = "";
                    }
                    else
                    {

                        MessageBox.Show("Wybrana grupa nie ma slowek.");

                    }
                }
                else if (this.type == 3)
                {
                    if (words.Count != 0)
                    {
                        Word current = words.ElementAt<Word>(indexOfCurrentWord);
                        if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1))
                        {
                            words.Remove(current);
                            lastWord = current;
                            if (words.Count > 0)
                            {
                                progressBar1.Value++;
                                goodAnsv.Content = (int)goodAnsv.Content + 1;

                                Random r = new Random();
                                indexOfCurrentWord = r.Next(0, words.Count);
                                foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                                lastForeign.Text = lastWord.Basic;
                                lastBasic.Text = lastWord.Foregin;
                                lastForeign.Visibility = Visibility.Visible;
                                lastBasic.Visibility = Visibility.Visible;
                                label6.Visibility = Visibility.Visible;
                                label7.Visibility = Visibility.Visible;
                            }
                            else
                            {

                                //SqlAccess sql = new SqlAccess();
                                //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts)));
                                this.Close();
                                ShowResult();
                            }
                        }
                        else
                        {

                            bad.Add(words.ElementAt<Word>(indexOfCurrentWord));
                            badAnsv.Content = (int)badAnsv.Content + 1;
                            Random r = new Random();
                            indexOfCurrentWord = r.Next(0, words.Count);
                            foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin;
                            lastForeign.Text = lastWord.Basic;
                            lastBasic.Text = lastWord.Foregin;
                            lastForeign.Visibility = Visibility.Visible;
                            lastBasic.Visibility = Visibility.Visible;
                            label6.Visibility = Visibility.Visible;
                            label7.Visibility = Visibility.Visible;
                        }
                        basicLanguage.Text = "";
                    }
                    else
                        MessageBox.Show("Wybrana grupa nie ma dodanych slow.");

                }
            }
        }
예제 #12
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (comboBox2.SelectedItem == null)
            {
                if (textBox2.Text.Equals("")) { MessageBox.Show("Podaj delimiter."); return; }
                if (textBox3.Text.Equals("")) { MessageBox.Show("Wybierz plik do wgrania."); return; }
                if (textBox1.Text.Equals("")) { MessageBox.Show("Podaj nazwę dla nowej grupy"); return; }
                button2.IsEnabled = false;
                Language lg = (Language)comboBox1.SelectedItem;
                SqlAccess sql = new SqlAccess();
                long newgroup = sql.InsertGroup(lg, textBox1.Text, textBox2.Text);

                progressBar1.Visibility = Visibility.Visible;//enable the progressbar
                BackgroundWorker bgw = new BackgroundWorker(); //new thread
                string file = textBox3.Text;
                string[] lines = System.IO.File.ReadAllLines(file, System.Text.Encoding.Default);
                List<Word> linesWithoutBlankLines = new List<Word>();
                string delimeter = textBox2.Text;
                foreach (string line in lines)
                {

                    if (line == "") continue;
                    try
                    {
                        string[] words = line.Split(new string[] { delimeter }, StringSplitOptions.None);
                        linesWithoutBlankLines.Add(new Word(newgroup, words[0], words[1]));
                        importedWords++;
                    }
                    catch (Exception ex)
                    {

                        failedWords++;
                        continue;

                    }

                }

                progressBar1.Minimum = 0;
                progressBar1.Maximum = linesWithoutBlankLines.Count;

                bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
                bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);
                bgw.RunWorkerAsync(linesWithoutBlankLines);
            }
            else
            {
                //pre-asserts

                if (textBox2.Text.Equals("")) { MessageBox.Show("Podaj delimiter."); return; }
                if (textBox3.Text.Equals("")) { MessageBox.Show("Wybierz plik do wgrania."); return; }

                button2.IsEnabled = false;
                BackgroundWorker bgw = new BackgroundWorker();
                string file = textBox3.Text;
                string[] lines = System.IO.File.ReadAllLines(file, Encoding.Default);
                List<Word> linesWithoutBlankLines = new List<Word>();
                string delimeter = textBox2.Text;
                foreach (string line in lines)
                {
                    if (line == "") continue;
                    try
                    {

                        string[] words = line.Split(new string[] { delimeter }, StringSplitOptions.None);
                        linesWithoutBlankLines.Add(new Word(((Group)comboBox2.SelectedItem).Id, words[0], words[1]));
                        importedWords++;
                    }
                    catch (Exception ex)
                    {
                        failedWords++;
                        continue;

                    }
                }

                progressBar1.Minimum = 0;
                progressBar1.Maximum = linesWithoutBlankLines.Count;
                progressBar1.Visibility = Visibility.Visible;
                bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
                bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);
                bgw.RunWorkerAsync(linesWithoutBlankLines);

            }
        }
예제 #13
0
        void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Group selected = (Group)comboBox2.SelectedItem;
            if (!selected.Name.Equals(""))
            {
                textBox1.IsEnabled = false;

                SqlAccess sql = new SqlAccess();
                Language counterpart = sql.GetLanguageFromGroup(selected.Id);
                int i = 0;
                foreach (Language l in comboBox1.ItemsSource)
                {
                    if (l.Equals(counterpart))
                    {
                        comboBox1.SelectedIndex = i;
                        comboBox1.IsEnabled = false;
                        break;
                    }
                    else
                        i++;

                }
            }
            else
            {
                textBox1.IsEnabled = true;
                comboBox1.IsEnabled = true;
            }
        }