public static List <ListViewItem> cycleadd()
        {
            List <ListViewItem> listItems = new List <ListViewItem> {
            };
            string fileNamePath           = VarsConsts.folderPath() + "MyWords.txt";

            if (File.Exists(fileNamePath))
            {
                string[] Mass = File.ReadAllLines(fileNamePath, System.Text.Encoding.UTF8);
                for (int i = 0; i < Mass.Count(); i++)
                {
                    Label label = new Label();
                    label.Name = "label" + i.ToString();
                    label.Text = Mass[i];
                    string engWord  = label.Text;
                    string lastword = engWord.Substring(engWord.LastIndexOf('/') + 1);
                    engWord = engWord.Substring(0, engWord.LastIndexOf('/'));
                    listItems.Add(newItem(engWord, lastword));
                }
                return(listItems);
            }
            else //if (!File.Exists(fileNamePath) || File.ReadAllText(fileNamePath).Length < 10)
            {
                listItems.Add(newItem("Add something here first", "Сначала что-нибудь добавь"));
                return(listItems);
            }
        }
Esempio n. 2
0
 //
 private void Form1_Load(object sender, EventArgs e)
 {
     toggleNotify.Checked     = VarsConsts.toggleToggler("toggleNotify");
     toggleSort.Checked       = VarsConsts.sortState();
     checkBoxMultiSel.Checked = VarsConsts.toggleMultiSelection();
     numUDTestInt.Value       = VarsConsts.interval("TestInterval");
     numUPNotifyInt.Value     = VarsConsts.interval("NotifyInterval");
     numUPFont.Value          = VarsConsts.fontSizeValue();
     timer1.Interval          = (int)numUDTestInt.Value * 3000;
     this.Size         = new Size(530, 584);
     mListView1.Anchor = (AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom);
     randitem();
     addItemsInListView();
     mListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
Esempio n. 3
0
 private void MetroButtonEditOK_Click(object sender, EventArgs e)
 {
     if (mTbEditEng.Text != "" && mTbEditRu.Text != "")
     {
         removeitem(false);
         newItemInList(mTbEditEng.Text, mTbEditRu.Text);
         File.AppendAllText(VarsConsts.folderPath() + "MyWords.txt", mTbEditEng.Text + "/" + mTbEditRu.Text + "\r\n");
         var t = new Thread(() => testx(metroButtonEditOK, "Saved!!", true));
         t.Start();
         panelCloser(mPanelEdit);
     }
     else
     {
         MetroMessageBox.Show(this, "The fields must not be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 4
0
 void adderNew()
 {
     if (mTextBoxEng.Text != "" && mTextBoxRus.Text != "")
     {
         var t = new Thread(() => testx(mButtonAdd, "Added!", false));
         t.Start();
         if (!File.Exists(VarsConsts.folderPath() + "MyWords.txt"))
         {
             mListView1.Items.Clear();
         }
         newItemInList(mTextBoxEng.Text, mTextBoxRus.Text);
         File.AppendAllText(VarsConsts.folderPath() + "MyWords.txt", mTextBoxEng.Text + "/" + mTextBoxRus.Text + "\r\n");
         buttonClear.PerformClick();
     }
     else
     {
         MetroMessageBox.Show(this, "The fields must not be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 5
0
        //void cycleadd()
        //{
        //    if (File.Exists(VarsConsts.folderPath() + "MyWords.txt"))
        //    {
        //        string[] Mass = File.ReadAllLines(@VarsConsts.folderPath() + "MyWords.txt", System.Text.Encoding.UTF8);
        //        for (int i = 0; i < Mass.Count(); i++)
        //        {
        //            Label label = new Label();
        //            label.Name = "label" + i.ToString();
        //            label.Text = Mass[i];
        //            string akks = label.Text;
        //            string lastword = akks.Substring(akks.LastIndexOf('/') + 1);
        //            akks = akks.Substring(0, akks.LastIndexOf('/'));
        //            newItem(akks, lastword);
        //        }
        //    }
        //    else if (!File.Exists(VarsConsts.folderPath() + "MyWords.txt"))
        //        mListView1.Items.Add("Add something here first").SubItems.Add("Сначала что-нибудь добавь");
        //}
        void removeitem(bool learnedToggle)
        {
            int count = mListView1.SelectedItems.Count;

            if (count > 0)
            {
                List <ListViewItem> itemsToRemove = new List <ListViewItem> {
                };
                for (int i = 0; i < count; i++)
                {
                    string tsxt = mListView1.SelectedItems[i].Text;
                    if (learnedToggle)
                    {
                        File.AppendAllText(VarsConsts.folderPath() + "LearnedWords.txt", tsxt + "\r\n");
                    }
                    itemsToRemove.Add(mListView1.SelectedItems[i]);
                }
                foreach (ListViewItem itm in itemsToRemove)
                {
                    mListView1.Items.Remove(itm);
                }
                using (StreamWriter sw = new StreamWriter(VarsConsts.folderPath() + "MyWords.txt"))
                {
                    foreach (ListViewItem item in mListView1.Items)
                    {
                        sw.WriteLine(item.Text + "/" + item.SubItems[1].Text);
                    }
                    sw.Close();
                }
                if (learnedToggle)
                {
                    panelShoweer(mPanelRemove);
                    new Thread(mPanelRemoverHidder).Start();
                }
            }
        }
Esempio n. 6
0
 private void MetroButton2_Click_1(object sender, EventArgs e)
 {
     System.Diagnostics.Process.Start(VarsConsts.folderPath() + "LearnedWords.txt");
     //System.Diagnostics.Process.Start(@"C:\Program Files\Sublime Text 3\sublime_text.exe", VarsConsts.folderPath() + "LearnedWords.txt");
 }