Пример #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "")
            {
                string newTrans = "";
                if (masterTable.Columns.Count > 2)
                {
                    string tempTrans = transDict[textBox3.Text];
                    string tempScript = dictionary[textBox3.Text];
                    newTrans = AddDifference(textBox2.Text, tempScript, tempTrans);
                }

                SaidFile altHandler = new SaidFile(textBox1.Text, newTrans, textBox2.Text);
                altHandler.Inflection = GuessInflection(altHandler.Script);
                saidFiles.Add(altHandler);

                scripted.Add(textBox1.Text);
                statusTimer(String.Format("{0} was added", textBox1.Text), 3000);

                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();

                listBox2.Items.Clear();

                //find the alts again
                alternates = FindAlts(fileList, scripted);
                if (alternates != null)
                {
                    foreach (string alt in alternates)
                    {
                        listBox2.Items.Add(alt);
                    }
                }

                label3.Text = saidFiles.Count.ToString();

                if (listBox2.Items.Count !=0)
                {
                    listBox2.SetSelected(0, true);
                }
            }

            else
            {
                MessageBox.Show("Info is missing. File can't be added.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #2
0
        public void SetFromForm2(DataTable heresIt)
        {
            //------------------------
            //This section clears our variables for new data
            saidFiles.Clear();
            dictionary.Clear();
            label3.Text = "0";
            masterTable = null;
            //------------------------

            masterTable = heresIt;

            for (int yo = 0; yo < heresIt.Rows.Count - 1; yo++)
            {
                //pull the first element from our table as the fID.
                String fileIDTemp = ReplaceWordChars(heresIt.Rows[yo][0].ToString().Trim());
                //remove commas from fileID as this will throw off the SAID import.
                fileIDTemp = fileIDTemp.Replace(',', '_');

                //pull the second element from our table as the script.
                String scriptTemp = ReplaceWordChars(heresIt.Rows[yo][1].ToString().Trim());

                //create new SaidFile object with our table data.
                SaidFile temp = new SaidFile(fileIDTemp, scriptTemp);

                //add file ID to our scripted list for later comparisons.
                scripted.Add(temp.FileID);

                //If there is a translation we need to include that in our object
                if (heresIt.Columns.Count > 2)
                {
                    temp.Translation = ReplaceWordChars(heresIt.Rows[yo][2].ToString().Trim());
                    temp.HasTranslation = true;
                    if (!transDict.ContainsKey(temp.FileID))
                        transDict.Add(temp.FileID, temp.Translation);
                    //If there is a translation, we want to guess inflections with the trans instead of script.
                    temp.Inflection = GuessInflection(temp.Translation);
                }
                else
                {
                    //If there is no translation, guess based on the Script field.
                    temp.Inflection = GuessInflection(temp.Script);
                }

                //check for duplicate IDs.
                if (!dictionary.ContainsKey(temp.FileID))
                {
                    dictionary.Add(temp.FileID, temp.Script);
                    saidFiles.Add(temp);
                }
                else
                {
                    MessageBox.Show(String.Format("File ID {0} appears to be duplicated on the script.\r\n This file can be dealt with as an Alternate", temp.FileID), "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            if (fileList.Count != 0)
            {
                listBox2.Items.Clear();

                //find the alts
                alternates = FindAlts(fileList, scripted);
                List<string> altList = alternates.ToList();
                if (altList.Count > 0)
                {
                    statusTimer("Script Loaded. -- " + altList.Count + " ALTs Found.", 5000);

                    foreach (string alt in alternates)
                    {
                        listBox2.Items.Add(alt);
                    }
                }

                else
                {
                    statusTimer("Script Loaded. -- No ALTs Found.", 5000);
                }

                if (listBox2.Items.Count != 0)
                {
                    listBox2.SetSelected(0, true);
                }
            }

            else
                MessageBox.Show("Data Missing. Could not search for Alts.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            label3.Text = saidFiles.Count.ToString();

            label9.Text = "Script Loaded.";
            label9.ForeColor = Color.Red;
        }