예제 #1
0
        public ControllerNewVocab(MainWindow view, ModelToWrite dataWrite)
        {
            //this.dataWrite = dataWrite;
            this.dayArray = new ModelToWrite[30];

            dayArray[0] = new ModelToWrite();

            this.view = view;
            this.clearAll();
            this.fillVocabFileLists();
        }
예제 #2
0
        public void addToList()
        {
            // before add, need to check if the focus in on the right array element

            int day = int.Parse(this.view.txtDay.Text);
            bool newDay = false;

            if (this.dataWrite == null)
            {
                // there's one already
                if (this.dayArray[day] != null)
                {
                    this.dataWrite = this.dayArray[day ];
                }
                else // there's no one yet
                {
                    this.dayArray[day] = new ModelToWrite();
                    this.dataWrite = this.dayArray[day];
                    String fileName = null;
                    if (this.view.txtDay.Text.Length < 2)
                    {
                        fileName = "Chapter0" + this.view.txtDay.Text + ".txt";
                    }
                    else
                    {
                        fileName = "Chapter" + this.view.txtDay.Text + ".txt";
                    }
                    this.view.listDays.Items.Add(fileName);
                }
            }
            else
            {
                if (int.Parse(this.dataWrite.day) != day)
                {
                    // there's one already
                    if (this.dayArray[day ] != null)
                    {
                        this.dataWrite = this.dayArray[day ];
                    }
                    else // there's no one yet
                    {
                        this.dayArray[day ] = new ModelToWrite();
                        this.dataWrite = this.dayArray[day];
                        Console.WriteLine("asdkfjalsdjfaldf");
                        newDay = true;
                    }
                }
            }

            if (this.checkConventionForAdd())
            {
                // add the data to model
                this.dataWrite.day = this.view.txtDay.Text;
                this.dataWrite.listWord.Add(this.view.txtWord.Text);
                this.dataWrite.listWordType.Add(this.view.txtWordType.Text);
                this.dataWrite.listExample.Add(this.view.txtExample.Text);

                // update list box
                if (newDay)
                {
                    this.view.listWords.Items.Clear();
                    this.view.listWords.Items.Add(this.view.txtWord.Text);
                    this.saveList();
                    newDay = false;
                }
                this.view.listWords.Items.Add(this.view.txtWord.Text);

                // auto scroll
                this.autoScrollListBox(this.view.listWords);

                // reset the template
                String temp = this.view.txtDay.Text;
                this.clearAll();
                this.view.txtDay.Text = temp;
                this.view.txtWord.Focus();
             }
        }
예제 #3
0
        public void scatterToDayArray(string fileName)
        {
            Console.WriteLine(fileName);
            String strDay = fileName.Substring(7, 2);
            int day = int.Parse(strDay);

            this.dataWrite = this.dayArray[day];

            this.dataWrite.day = strDay;

            //this.view.txtDay.Text = this.dataWrite.day;
            if (true)
            {

                StreamReader fIn = new StreamReader(getVocabFolderAddr() + fileName);
                String temp;
                while (!fIn.EndOfStream)
                {
                    fIn.ReadLine(); // get rid of index
                    temp = fIn.ReadLine();
                    this.dataWrite.listWord.Add(temp);
                    //this.view.listWords.Items.Add(temp);
                    //this.autoScrollListBox(this.view.listWords);

                    temp = fIn.ReadLine();
                    this.dataWrite.listWordType.Add(temp);

                    //temp = fIn.ReadLine();
                    //this.dataWrite.listMean.Add(temp);
                    //temp = fIn.ReadLine();
                    //this.dataWrite.listRelation.Add(temp);
                    //temp = fIn.ReadLine();
                    //this.dataWrite.listRealtedTo.Add(temp);
                    temp = fIn.ReadLine();
                    this.dataWrite.listExample.Add(temp);
                }
                fIn.Close();
            }
        }
예제 #4
0
 public void scatterToListWords(object sender, EventArgs e)
 {
     String strDay = this.view.listDays.SelectedItem.ToString().Substring(7, 2);
     int day = int.Parse(strDay);
     this.dataWrite = this.dayArray[day];
     this.view.txtDay.Text = this.dataWrite.day;
     Console.WriteLine(this.dataWrite.listWord.Count);
     this.view.listWords.Items.Clear();
     for (int i = 0; i < this.dataWrite.listWord.Count; i++)
     {
         this.view.listWords.Items.Add(this.dataWrite.listWord.ElementAt(i));
         this.autoScrollListBox(this.view.listWords);
     }
 }
예제 #5
0
 /** Constructor
  *
  *
  */
 public MainWindow()
 {
     InitializeComponent();
     this._ModelToWrite = new ModelToWrite();
     this._ControllerNewVocab = new ControllerNewVocab(this, _ModelToWrite);
 }