private void button3_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { UserLibrary.nowUserLibrary = UserLibrary.loadFromName(listBox1.SelectedItem.ToString()); showNowUserAndSelectList(); SystemSetting.systemSetting.defaultUserName = UserLibrary.nowUserLibrary.userName; } }
private void Form1_Load(object sender, EventArgs e) { form2 = new Form2(); form3 = new Form3(); SystemSetting.loadSystemSetting(); UserLibrary.nowUserLibrary = UserLibrary.loadFromName(SystemSetting.systemSetting.defaultUserName); if (UserLibrary.nowUserLibrary == null) { UserLibrary.nowUserLibrary = new UserLibrary(); UserLibrary.nowUserLibrary.userName = "******"; UserLibrary.nowUserLibrary.save(); } updateUserName(); }
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < listBox1.Items.Count; i++) { var item = listBox1.Items[i]; if (item.ToString() == textBox1.Text) { MessageBox.Show("使用者已經存在"); return; } } listBox1.Items.Add(textBox1.Text); UserLibrary userLibrary = new UserLibrary(); userLibrary.userName = textBox1.Text; userLibrary.save(); }