private void FileSystemWatcher_Changed(object sender, FileSystemEventArgs e) { LerLog(); this.Invoke(new Action(() => { LogBox.Focus(); LogBox.Select(LogBox.Text.Length, 0); })); }
private void ServerSelectBox_SelectedIndexChanged(object sender, EventArgs e) { if (connectedHost != null) { foreach (ServerInfo server in connectedHost.GetServerInfos()) { if (ServerSelectBox.SelectedItem != null && ServerSelectBox.SelectedItem.ToString() == server.ServerName) { selectedServer = server; ServerInfoBox.Text = server.ServerName; LogBox.Text = selectedServer.ConsoleBuffer.ToString(); LogBox.Select(LogBox.Text.Length, 0); ComponentEnableManager(); } } } }
private void Login_Click(object sender, RoutedEventArgs e) { LoginButton.IsEnabled = false; using (DBContext db = new DBContext()) { if (LogBox.Text.Length == 0) { MessageBox.Show("Enter an email."); LogBox.Focus(); } else if (!Regex.IsMatch(LogBox.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { MessageBox.Show("Enter a valid email."); LogBox.Select(0, LogBox.Text.Length); LogBox.Focus(); } else { string email = LogBox.Text; string password = PassBox.Password; if (db.Users.Any(s => s.Email == email && s.Password == password)) { Shop sp = new Shop(); sp.NameBlock.Text = db.Users.FirstOrDefault(s => s.Email == email && s.Password == password).Email; if (db.Users.FirstOrDefault(s => s.Email == email && s.Password == password).Admin == true) { sp.Administration.Visibility = Visibility.Visible; } sp.Show(); Close(); } else { MessageBox.Show("Sorry! Please enter existing email/password."); } } } LoginButton.IsEnabled = true; }
private void LerLog() { string newFileLines = ""; using (FileStream stream = File.Open(caminholog, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (StreamReader reader = new StreamReader(stream)) { newFileLines = reader.ReadToEnd(); } } LogBox.Invoke(new Action(() => { LogBox.Focus(); LogBox.Select(LogBox.Text.Length, 0); LogBox.Text += LogBox.Text + "\n" + newFileLines; LogBox.Focus(); LogBox.Select(LogBox.Text.Length, 0); })); }
private void GoTopMenuItem_Click(object sender, EventArgs e) { LogBox.Select(0, 0); LogBox.ScrollToCaret(); }
/// <summary> /// /// </summary> /// <param name="message"></param> void Trace_OnTrace(string message) { LogBox.AppendText(message); LogBox.Select(LogBox.Text.Length, 0); LogBox.ScrollToCaret(); }