public static void getxml() { string path = "\\User_Storage\\phone.xml"; count = 0; index = 0; XmlDocument phonexml = new XmlDocument(); // try { phonexml.Load(path); XmlNode xmlroot = phonexml.SelectSingleNode("root"); myphone = new phone[20]; foreach (XmlNode phonenode in xmlroot.ChildNodes) { myphone[count] = new phone(); string id = phonenode.ChildNodes[0].InnerText; myphone[count].id = int.Parse(id); myphone[count].name = phonenode.ChildNodes[1].InnerText; myphone[count].phonenum = phonenode.ChildNodes[2].InnerText; myphone[count].privatephone = bool.Parse(phonenode.ChildNodes[3].InnerText); count++; } } // catch { // MessageBox.Show("phone.xml错误,请检查软件配置"); } }
private void pictureBox7_Click(object sender, EventArgs e) { this.useractive(); this.panel1.Visible = !this.panel1.Visible; this.label4.Text = "请用方向箭头选择呼叫目标"; phonelist.getxml(); this.currentphone = phonelist.nextphone(); this.currentphone = phonelist.lastphone(); this.textBox1.Text = ""; this.textBox1.Visible = true; this.label6.Visible = true; this.label5.Visible = true; this.label5.Text = this.currentphone.name; if (!this.currentphone.privatephone) { this.label6.Text = this.currentphone.phonenum; this.label6.Visible = true; this.textBox1.Visible = false; } else { this.textBox1.Visible = true; this.textBox1.Focus(); this.label6.Visible = false; } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { this.useractive(); if ((e.KeyCode == Keys.Up) && this.panel1.Visible) { this.currentphone = phonelist.lastphone(); this.label5.Text = this.currentphone.name; if (!this.currentphone.privatephone) { this.label6.Text = this.currentphone.phonenum; this.label6.Visible = true; this.textBox1.Visible = false; } else { this.textBox1.Visible = true; this.textBox1.Focus(); this.label6.Visible = false; } } if ((e.KeyCode == Keys.Down) && this.panel1.Visible) { this.currentphone = phonelist.nextphone(); this.label5.Text = this.currentphone.name; if (!this.currentphone.privatephone) { this.label6.Text = this.currentphone.phonenum; this.label6.Visible = true; this.textBox1.Visible = false; } else { this.textBox1.Visible = true; this.textBox1.Focus(); this.label6.Visible = false; } } if ((e.KeyCode == Keys.Left) && this.panel1.Visible) { this.currentphone = phonelist.lastphone(); this.label5.Text = this.currentphone.name; if (!this.currentphone.privatephone) { this.label6.Text = this.currentphone.phonenum; this.label6.Visible = true; this.textBox1.Visible = false; } else { this.textBox1.Visible = true; this.textBox1.Focus(); this.label6.Visible = false; } } if ((e.KeyCode == Keys.Right) && this.panel1.Visible) { this.currentphone = phonelist.nextphone(); this.label5.Text = this.currentphone.name; if (!this.currentphone.privatephone) { this.label6.Text = this.currentphone.phonenum; this.label6.Visible = true; this.textBox1.Visible = false; } else { this.textBox1.Visible = true; this.textBox1.Focus(); this.label6.Visible = false; } } Keys keyCode = e.KeyCode; }
private void Form1_KeyDown(object sender, KeyEventArgs e) { useractive(); if ((e.KeyCode == System.Windows.Forms.Keys.Up)) { if (panel1.Visible == true) { currentphone = phonelist.lastphone(); label5.Text = currentphone.name; if (!currentphone.privatephone) { label6.Text = currentphone.phonenum; label6.Visible = true; textBox1.Visible = false; } else { textBox1.Visible = true; textBox1.Focus(); label6.Visible = false; } } } if ((e.KeyCode == System.Windows.Forms.Keys.Down)) { if (panel1.Visible == true) { currentphone = phonelist.nextphone(); label5.Text = currentphone.name; if (!currentphone.privatephone) { label6.Text = currentphone.phonenum; label6.Visible = true; textBox1.Visible = false; } else { textBox1.Visible = true; textBox1.Focus(); label6.Visible = false; } } } if ((e.KeyCode == System.Windows.Forms.Keys.Left)) { if (panel1.Visible == true) { currentphone = phonelist.lastphone(); label5.Text = currentphone.name; if (!currentphone.privatephone) { label6.Text = currentphone.phonenum; label6.Visible = true; textBox1.Visible = false; } else { textBox1.Visible = true; textBox1.Focus(); label6.Visible = false; } } } if ((e.KeyCode == System.Windows.Forms.Keys.Right)) { if (panel1.Visible == true) { currentphone = phonelist.nextphone(); label5.Text = currentphone.name; if (!currentphone.privatephone) { label6.Text = currentphone.phonenum; label6.Visible = true; textBox1.Visible = false; } else { textBox1.Visible = true; textBox1.Focus(); label6.Visible = false; } } } if ((e.KeyCode == System.Windows.Forms.Keys.Enter)) { // Enter } }