/* 26.2.2019*/ private void button3_Click(object sender, EventArgs e) { try { if (isFirstLaunch) { // d2.Location = new Point(this.Location.X, this.Location.Y + this.Height); d3.Location = new Point(this.Location.X, this.Location.Y + this.Height); isFirstLaunch = false; // d2.Show(); d3.Show(); } else { //d2.Show(); d3.Show(); } List <String> names = XmlMethods.getTheNames(FileAdress.Text); d3.listContacts.DataSource = names; } catch (Exception) { } d3.filenameonfliy.Text = FileAdress.Text; }
private void welcome_Load(object sender, EventArgs e) { /*28.2.2019*/ r = new welcome(); //modified 28.2.2019 for MainForm try { FileAdress.Text = Settings.GetTheValueOFNode(SettingSaveFileName, parentName, "DefaultFile"); defaultfile = FileAdress.Text; bool boolDefault = Convert.ToBoolean(Settings.GetTheValueOFNode(SettingSaveFileName, parentName, "isDefault")); if (FileAdress.Text == string.Empty) { checkDefault.Enabled = false; } checkDefault.Checked = boolDefault; label2.Text = MainForm.ShowHowmanyNumbers(defaultfile); //show number of contact on flie List <String> names = XmlMethods.getTheNames(FileAdress.Text); d3.listContacts.DataSource = names; } catch (Exception) { Console.WriteLine("Some thing is wrong!"); } }
/* implemented 22.2.2019*/ private string ShowHowmanyNumbersAreTheir() { string ans = XmlMethods.getNumberOfElement(filename).ToString() + " contacts"; Console.WriteLine(ans); return(ans); }
private void Save(object Sender, EventArgs e) { if (txtName.Text == "" | txtNumber.Text == "") { CustomeDialogBox Caution = new CustomeDialogBox("Please Enter A Number", true); Caution.Location = new Point(this.Location.X + (this.Width - Caution.Width) / 2, 12 + this.Location.Y + (this.Height - Caution.Height) / 2); Caution.ShowDialog(); } else { XmlMethods.InsertNewField(filename, txtName.Text, txtNumber.Text, txtWhatsAppNumber.Text); //textBox1.Text = XmlMethods.GetXDocument().ToString(); MessageBox.Show("Saved"); } List <String> names = XmlMethods.getTheNames(filename); listBox1.DataSource = names; //showDatainDataGrid("contact.xml"); //number of contact. txtNumberOfContact.Text = ShowHowmanyNumbersAreTheir(); txtContactSearch.AutoCompleteCustomSource.AddRange(names.ToArray <string>()); }
private void updateToolStripMenuItem_Click(object sender, EventArgs e) { List <String> names = XmlMethods.getTheNames(filename); listBox1.DataSource = names; }
private void Form1_Load(object sender, EventArgs e) { // textBox1.Text = XmlMethods.GetXDocument().ToString(); XmlMethods.LoadXDocumnet(filename); /* code for listbox */ List <String> names = XmlMethods.getTheNames(filename); listBox1.DataSource = names; // showDatainDataGrid("contact.xml"); //start the auto update every 10000 mil // timerAutoSave.Start(); //get the number of contact. txtNumberOfContact.Text = ShowHowmanyNumbersAreTheir(); //Console.WriteLine(res); txtContactSearch.AutoCompleteCustomSource.AddRange(names.ToArray <string>()); }
/* implemented 24.2.2019 */ private void txtContactSearch_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { XmlMethods.GetTheNumber(filename, txtContactSearch); } }
private void Button_Del(object sender, EventArgs e) { Object names = listBox1.SelectedItem; //return the selected items String Name = names.ToString(); DialogResult deleteDialong = MessageBox.Show("Do You Want To Delelet The Contact " + Name, "delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); // int index = listBox1.SelectedIndex; // Console.WriteLine(index); if (deleteDialong == DialogResult.Yes) { XmlMethods.DeleteField(filename, Name); List <String> NewName = XmlMethods.getTheNames(filename); listBox1.DataSource = NewName; // showDatainDataGrid("contact.xml"); } /* * XmlMethods.DeleteField("contact.xml", Name); * List<String> NewName = XmlMethods.getTheNames("contact.xml"); * listBox1.DataSource = NewName;*/ txtNumberOfContact.Text = ShowHowmanyNumbersAreTheir(); List <String> name = XmlMethods.getTheNames(filename); listBox1.DataSource = name; }
/* unused*/ private void timerAutoSave_Tick(object sender, EventArgs e) { List <String> name = XmlMethods.getTheNames(filename); listBox1.DataSource = name; txtContactSearch.AutoCompleteCustomSource.AddRange(name.ToArray <string>()); txtContactSearch.AutoCompleteSource = AutoCompleteSource.CustomSource; }
/* Show Numbers and Names in a tool tip for 800 mil sec*/ private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { // int index = listBox1.SelectedIndex; String Name = (string)listBox1.SelectedItem; // Console.WriteLine("you choose "+listBox1.SelectedItem); toolTip1.Show(Name + "\n" + XmlMethods.GetTheNumber(filename, listBox1) + "Whatsapp\n" + XmlMethods.GetTheWhatsappNumber(filename, listBox1), listBox1, 800); }
private void loadOtherListToolStripMenuItem_Click(object sender, EventArgs e) { filename = FileModificatioclasses.LoadXMLFile_Click(); if (filename == string.Empty) { } else { List <String> names = XmlMethods.getTheNames(filename); listBox1.DataSource = names; txtNumberOfContact.Text = ShowHowmanyNumbersAreTheir(); // FileNameBar.Text = "file: "+filename; } }
/* Implemented 23.2.2019 */ private void NewDataBase_Click(object sender, EventArgs e) { String FileNametoBeCr = FileAdress.Text; DialogResult newFileCreate = MessageBox.Show("Do you want to create a new file?\n" + FileNametoBeCr, "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (newFileCreate == DialogResult.Yes) { if (FileNametoBeCr != String.Empty) { XmlMethods.creatXmlDocument(FileNametoBeCr + ".xml"); MessageBox.Show("SuccesFull"); } else { MessageBox.Show("File Name Can't Be Empty"); } } }
/** Implemented 23.2.2019 * This button load file by opening the Openfile Dialog box * 'LoadNewFileEx' open a new dialog box and copy the selected file path to a string * The string is a file path then send back to mainform * which load the content from the file and update the listbox * it also copy the path to address bar * */ public void LoadXMLFile_Click(object sender, EventArgs e) { p = FileModificatioclasses.LoadNewFileFromEx(); //p in declaration Console.WriteLine(p); MainForm.filename = p; FileAdress.Text = p; /* -----------------modified 28.2.2019--------------------*/ if (FileAdress.Text != String.Empty || FileAdress.Text != defaultfile) //added for default file Option 28.2.2019 { checkDefault.Enabled = true; checkDefault.Checked = false; FileAdress.Text = p; //stop from emptying the fileadress textbox if (FileAdress.Text != string.Empty) { label2.Text = MainForm.ShowHowmanyNumbers(p); //throw arg exception List <String> names = XmlMethods.getTheNames(FileAdress.Text); /* Should use update*/ d3.listContacts.DataSource = names; } } if (FileAdress.Text == string.Empty) //when file address in Empty { FileAdress.Text = defaultfile; checkDefault.Checked = false; checkDefault.Enabled = false; } if (FileAdress.Text == defaultfile) //when nothing select from load dialong { FileAdress.Text = defaultfile; checkDefault.Checked = true; checkDefault.Enabled = true; } /* -----------------modified 28.2.2019--------------------*/ }
/* Some Method */ public static string ShowHowmanyNumbers(string filename) { string ans = XmlMethods.getNumberOfElement(filename).ToString() + " contacts stored"; return(ans); }
private void findNumbers_Click(object sender, EventArgs e) { XmlMethods.GetTheNumber(filename, txtName); }