private void textBox1_MouseClick(object sender, MouseEventArgs e) { if (TBSearch.Focus() && flag) { TBSearch.Text = ""; } }
private void Form1_Load(object sender, EventArgs e) { InitializeSettings(); ToolTip.SetToolTip(this.RSearch, "Search for a random element."); ToolTip.SetToolTip(this.SearchButton, "Search for a element."); ToolTip.SetToolTip(this.pBox, "Image for element " + elementString.ToUpper() + "."); ToolTip.SetToolTip(this.AtomicTreeView, "Atomic tree-view."); this.FormClosing += delegate { try { if (!File.Exists("log.element")) { File.Create("log.element"); } if (Logger.GetLogData() != null) { using (StreamWriter sr = new StreamWriter("log.element")) { sr.WriteLine(("=============== " + DateTime.Now + " ===============").PadRight(20)); foreach (string l in Logger.GetLogData().Split(new char[] { '\n' })) { sr.WriteLine(l); } sr.Close(); } } } catch { return; } }; foreach (Control c in this.groupBox2.Controls.OfType <Label>()) { if (c.Name.Contains("Label")) { c.Visible = false; } } foreach (Control c in this.groupBox1.Controls.OfType <RadioButton>()) { RadioButton cb = c as RadioButton; cb.CheckedChanged += (object s, EventArgs args) => { if (this.numberCB.Checked) { SearchByName = false; } else { SearchByName = true; } }; } this.IsotopesButton.Enabled = false; this.BGWorker.ProgressChanged += (object sndr, ProgressChangedEventArgs args) => { this.pBar.Value = args.ProgressPercentage; this.StatusLabel.Text = (string)args.UserState; }; // TOOLSTRIP MENU ITEMS this.aboutGuilhermeAlmeidaToolStripMenuItem.Click += delegate { // abriria um site se eu tivesse um, haha... triste vida MessageBox.Show("Hi, I'm Guilherme, most people just go by 'Gui' so... go the way you wish.\nI am the guy who spent 2 days developing this program using C# and a Web Scraper.", "Hello, Olá", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); }; this.fontToolStripMenuItem.Click += delegate { FontDialog f = new FontDialog(); if (f.ShowDialog() != DialogResult.Cancel && f.Font.Size < 15) { foreach (Control ctrl in this.Controls) { ctrl.Font = f.Font; } foreach (Control ctrl in this.groupBox1.Controls) { ctrl.Font = f.Font; } foreach (Control ctrl in this.groupBox2.Controls) { ctrl.Font = f.Font; } } Logger.LogData("Changed current font to " + Font.Name); Scrapper.Properties.Settings.Default.font_custom = f.Font; }; this.colorToolStripMenuItem.Click += delegate { ColorDialog c = new ColorDialog(); if (c.ShowDialog() != DialogResult.Cancel) { foreach (Control ctrl in this.Controls) { ctrl.ForeColor = c.Color; } foreach (Control ctrl in this.groupBox1.Controls) { ctrl.ForeColor = c.Color; } foreach (Control ctrl in this.groupBox2.Controls) { ctrl.ForeColor = c.Color; } } Logger.LogData("Changed current color to to " + c.Color.ToArgb().ToString()); Scrapper.Properties.Settings.Default.color_custom = c.Color; }; this.saveToolStripMenuItem.Click += delegate { Scrapper.Properties.Settings.Default.Save(); this.StatusLabel.Text = "Settings Saved"; Logger.LogData("Settings Saved."); }; this.resetToolStripMenuItem.Click += delegate { Scrapper.Properties.Settings.Default.color_custom = Scrapper.Properties.Settings.Default.color_default; Scrapper.Properties.Settings.Default.font_custom = Scrapper.Properties.Settings.Default.font_default_normal; Scrapper.Properties.Settings.Default.server_custom = Scrapper.Properties.Settings.Default.server_default; Scrapper.Properties.Settings.Default.Save(); ResetUI(); Logger.LogData("Setting Reset"); this.StatusLabel.Text = "Settings Reset"; }; TBSearch.KeyDown += (object a, KeyEventArgs b) => { if (b.KeyCode == Keys.Enter) { SearchButton.PerformClick(); } }; TBSearch.LostFocus += (object a, EventArgs b) => { TBSearch.Focus(); }; this.logToolStripMenuItem.Click += delegate { MessageBox.Show(Logger.GetLogData()); }; this.serverToolStripMenuItem.Click += delegate { ChangeServerForm svr = new ChangeServerForm(); svr.ShowDialog(); if (svr.serverResultString == "Invalid Server") { return; } }; this.getVariablesToolStripMenuItem.Click += delegate { string vars = ""; foreach (System.Configuration.SettingsProperty p in Scrapper.Properties.Settings.Default.Properties) { vars += string.Format("{0} = {1}**", p.Name, p.DefaultValue); } MessageBox.Show(vars.Replace("**", "\n")); }; this.getVariablesToolStripMenuItem.Click += (object a, EventArgs b) => { }; }
private void SearchEmployee(object sender, EventArgs e) { if ((sender is RadioButton) && sender != RBJob) { TBSearch.Focus(); } CBSearch.Visible = RBJob.Checked; TBSearch.Visible = !RBJob.Checked; visibleRows = 0; foreach (DataGridViewRow row in DGVEmployees.Rows) { if (CheckRBRegex(row.Index)) { visibleRows++; } } if (DGVEmployees.SelectedRows.Count > 0 && DGVEmployees.SelectedRows[0].Visible == false) { DGVEmployees.SelectedRows[0].Selected = false; } if (DGVEmployees.SelectedRows.Count == 0) { foreach (DataGridViewRow row in DGVEmployees.Rows) { if (row.Visible == true) { row.Selected = true; if (PEmployee.Visible == true) { DGVEmployees_CellClick(null, new DataGridViewCellEventArgs(8, row.Index)); } if (!RBJob.Checked) { TBSearch.Focus(); } else { CBJob.Focus(); } break; } } if (DGVEmployees.SelectedRows.Count == 0) { ClearControls(); } } if (PEmployee.Visible == true) { if (visibleRows < 15) { this.Size = new Size(980, 425); PEmployee.Location = new Point(766, 12); } else { this.Size = new Size(1000, 425); PEmployee.Location = new Point(786, 12); } } else { if (visibleRows < 15) { BNewEmployee.Location = new Point(656, 356); this.Size = new Size(795, 425); } else { BNewEmployee.Location = new Point(674, 356); this.Size = new Size(811, 425); } } }