Skip to content

Get a notification from each tab that the page is loaded #59

Description

@it19862

How do I get a notification from each tab that a page is loaded?

I created a form to control the browser.
Logic:

    • open the browser;
  • open multiple links in a separate tab;

Question.

  1. How do I get a notification from each tab that the download is finished and the page is fully loaded?

Form1.cs
`namespace CefSharpWinFormsAndSharpBrowser
{
public partial class Form1 : Form
{
BrowserService browserService = new BrowserService();

    public Form1()
    {
        InitializeComponent();
        // Form1Tests form1Tests = new Form1Tests(this);
        // form1Tests.Owner = this;
    }

   
    /// <summary>
    /// Open browser
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button1_Click(object sender, EventArgs e)
    {
        browserService.OpenBrowser();
    }
   
    /// <summary>
    /// Goto URL
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button10_Click(object sender, EventArgs e)
    {
        List<string> urls = new List<string>()
        {
            "github.com",
            "stackoverflow.com",
            "habr.com"
        };

        foreach (string url in urls)
        {
            browserService.AddNewBrowser(url);
            // browserService.LoadURL(url);
        }
    }
}

}
`

BrowserService.cs
`using SharpBrowser;
using SharpBrowser.BrowserTabStrip;

using System.IO;

namespace CefSharpWinFormsAndSharpBrowser.Services
{
public class BrowserService
{
// Form _formBrowser;

    MainForm mainForm = new MainForm();

    SharpTab SharpTab = new SharpTab();

    FileService fileService = new FileService();        

    private SharpBrowser.BrowserTabStrip.BrowserTabStrip TabPages = new SharpBrowser.BrowserTabStrip.BrowserTabStrip();

    public BrowserService()
    {
        

    }

    public void OpenBrowser()
    {
        mainForm.Show();

    }
    

    public void AddNewBrowser(string url)
    {
        mainForm.AddNewBrowserTab(url);
    }       


    public void LoadURL(string url)
    {
        mainForm.LoadURLPublic(url);
    }
}

}`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions