I created two contextmenustrips, one called backhistorystrip and forwardhistorystrip, the former stores a list of urls the user has navigated to and the latter stores urls that the user has navigated to only the user has gone back already so it takes one and puts it in the other.
But the problem is, a user cannot click on these urls, which are menustripitems, to navigate to a previously visited page and most of all, I want them to display the documenttitle as the textbut navigate to a url when clicked upon.
A minor problem is that when a user has a page or more listed in forwardhistorystrip, and they go back and navigate the a url, I am not sure how to erase that, or rather when to erase it. Do I match it with the url its navigating to? If so, should I put that in browser1_navigating and see if it fails to match the url/uri at that point?
Current code:
//Going Back
private void btnBack_Click(object sender, EventArgs e)
{
try
{
browser1.GoBack();
}
catch
{
btnBack.BackgroundImage = Properties.Resources.btnBackDisabled;
btnBack.Enabled = false;
}
try
{
forwardhistorystrip.Items.Insert(0, backhistorystrip.Items[0]);
}
catch
{
}
try
{
backhistorystrip.Items.RemoveAt(0);
}
catch
{
}
//Going Forward
private void btnForward_Click(object sender, EventArgs e)
{
try
{
browser1.GoForward();
}
catch
{
btnForward.BackgroundImage = Properties.Resources.btnForwardDisabled;
btnForward.Enabled = false;
}
try
{
if(browser1.Url.AbsoluteUri == forwardhistorystrip.Items[0].Text)
{
forwardhistorystrip.Items.RemoveAt(0);
}
}
catch
{
}
} private void browser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
//Back history
ToolStripMenuItem newitem = new ToolStripMenuItem();
if (backhistorystrip.Items.Count != 0)
{
if (browser1.Url.AbsoluteUri != backhistorystrip.Items[0].Text)
{
backhistorystrip.Items.Insert(0, newitem);
}
}
else
{
backhistorystrip.Items.Insert(0, newitem);
}
try
{
if (browser1.Url.AbsoluteUri == forwardhistorystrip.Items[0].Text)
{
forwardhistorystrip.Items.RemoveAt(0);
}
}
catch
{
}
newitem.Text = browser1.Url.AbsoluteUri;
foreach (ToolStripMenuItem backhistorypage in backhistorystrip.Items)
{
//backhistorypage.Click += new System.EventHandler(backhistorypage_Click);
}
}
I am not sure what to put into bachistorypage_Click;Ivan