public MainWindow() { InitializeComponent(); Button1.Click += Button1_Click; TextBox1.TextChanged += TextBox1_TextChanged; foreach (var ctl in new UIElement[] { Border1, Grid1, Button1, TextBlock1, TextBox1, }) { ctl.PreviewMouseDown += MouseButtonEventHandler; ctl.MouseDown += MouseButtonEventHandler; ctl.PreviewMouseUp += MouseButtonEventHandler; ctl.MouseUp += MouseButtonEventHandler; ctl.PreviewKeyDown += KeyEventHandler; ctl.KeyDown += KeyEventHandler; ctl.PreviewKeyUp += KeyEventHandler; ctl.KeyUp += KeyEventHandler; } //// 「添付イベント」として親要素でイベントを拾うことも可能。 //// XAML では次のように書く。 //// <Border x:Name="Border1" Button.Click="Button1_Click"> //// C# では、以下のように //Border1.AddHandler(Button.ClickEvent, new RoutedEventHandler(Button1_Click)); //Grid1.AddHandler(Button.ClickEvent, new RoutedEventHandler(Button1_Click)); // テスト用: 他アプリをアクティブにしてからこのアプリをアクティブにすると、表示をクリア this.Activated += (s, e) => Text1.Clear(); }
private void DeleteSetBtn_Click(object sender, EventArgs e) { ChooseSet.Text = ""; ChooseSet.Items.Remove(currentSet.SetName); Text1.Clear(); Text2.Clear(); Title1.Clear(); Title2.Clear(); PointerInput.Clear(); PointerVal.Text = ""; Querey querey = new Querey(); using (querey.connection = querey.NewConn) { string[][] tables = { new string[] { "Sets", "Id" }, new string[] { "Flashcards", "SetId" }, new string[] { "Permissions", "SetId" }, new string[] { "SetProgress", "SetId" } }; foreach (string[] table in tables) { using (querey.command = querey.NewComm) { querey.command.CommandText = "DELETE FROM " + table[0] + " WHERE " + table[1] + "= @setid;"; querey.AddParameter("@setid", currentCard.setId); querey.command.ExecuteNonQuery(); } } } currentSet = null; ChangeEdit(false); SaveChanges(); new MessageForm("deleted").Show(); }
private void Search_Click(object sender, EventArgs e) { Text1.Clear(); Book book = OurBook(); if (!LINQ_button.Checked && !DOM_button.Checked && !SAX_button.Checked) { MessageBox.Show("Ви повинні обрати спосіб пошуку (LINQ, DOM або SAX)"); } // MessageBox.Show(book.BookShop); if (LINQ_button.Checked) { ISearcher currentSearcher = new Linq(path); book.Algo = currentSearcher; final = book.Algorithm(book); OutPut(final); } if (DOM_button.Checked) { ISearcher currentSearcher = new DOM(path); book.Algo = currentSearcher; final = book.Algorithm(book); OutPut(final); } if (SAX_button.Checked) { ISearcher currentSearcher = new SAX(path); book.Algo = currentSearcher; final = book.Algorithm(book); OutPut(final); } }
// Actions on the person private void AddGuest_Click(object sender, EventArgs e) { personToEdit = false; Text1.Clear(); Text2.Clear(); Text3.Clear(); Text4.Clear(); TPDateOfBirth.Value = DateTime.Today; Panel_Reservation.Enabled = false; Panel_Guest.Visible = true; }
private void Add_Click(object sender, EventArgs e) { if (_num < 64) { _data[_num, 0] = Text1.Text; _data[_num, 1] = Text2.Text; _num++; } else { MessageForm errorForm = new MessageForm("You can have a maximum of 64 cards"); } Text1.Clear(); Text2.Clear(); }
private void Clear_Click(object sender, EventArgs e) { Text1.Clear(); checkBox_BookShop.Checked = false; checkBox_Name.Checked = false; checkBox_Author.Checked = false; checkBox_genre.Checked = false; checkBox_Year.Checked = false; checkBox_Language.Checked = false; BookShop.Text = null; Title.Text = null; Author.Text = null; Genre.Text = null; Year.Text = null; Language.Text = null; LINQ_button.Checked = false; DOM_button.Checked = false; SAX_button.Checked = false; }
private void button2_Click(object sender, EventArgs e) { if (!Text1.Text.Equals("") && !Text2.Text.Equals("")) { login = new LogIn(Text1.Text, Text2.Text); string attempt = login.LogInAttemptAdmin(); if (attempt.Equals("Failed")) { MessageBox.Show("Either your username or password is incorrect !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Logs.addLog(Text1.Text, " AdminLogin ", attempt + " "); } else if (attempt.Equals("Successful")) { AdminLoginForm f2 = new AdminLoginForm(); f2.ShowDialog(); // Shows register form Logs.addLog(Text1.Text, " AdminLogin ", attempt + " "); } else if (attempt.Equals("Too long")) { MessageBox.Show("Please enter maximum 20 characters for each field !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Failed to connect to database, please try again !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Logs.addLog(Text1.Text, " AdminLogin ", "Failed(database problems) "); } } else { MessageBox.Show("Please fill al the fields !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Text1.Clear(); Text2.Clear(); }
private void clear_Click(object sender, EventArgs e) { Text1.Clear(); listBox1.Items.Clear(); }