protected override void OnMouseMove(MouseEventArgs e) { if (this.Enabled) { this.IsMouseOverRightButton = Rectangle.Intersect(new Rectangle(this.PointToClient(MousePosition), new Size(1, 1)), this.RightButtonBounds) != Rectangle.Empty && this.RightEnabled; this.IsMouseOverLeftButton = Rectangle.Intersect(new Rectangle(this.PointToClient(MousePosition), new Size(1, 1)), this.LeftButtonBounds) != Rectangle.Empty && this.LeftEnabled; this.IsMouseOverMenuButton = Rectangle.Intersect(new Rectangle(this.PointToClient(MousePosition), new Size(1, 1)), this.MenuButtonBounds) != Rectangle.Empty && !this.IsMouseOverRightButton && this.HasHistory; if (this.IsMouseOverRightButton && HistoryIndex - 1 >= 0) { ExplorerNavigationHistoryItem item = this.History[HistoryIndex - 1]; string caption = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Forward to {0}", item.Text); this.ToolTip.SetToolTip(this, caption); } else if (this.IsMouseOverLeftButton && HistoryIndex + 1 < this.History.Count) { ExplorerNavigationHistoryItem item = this.History[HistoryIndex + 1]; string caption = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Back to {0}", item.Text); this.ToolTip.SetToolTip(this, caption); } else { this.ToolTip.SetToolTip(this, string.Empty); } this.Invalidate(); } }
public ExplorerNavigation() { this.SetStyle( ControlStyles.ResizeRedraw | ControlStyles.StandardClick | ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; this.History = new ExplorerNavigationHistory(); this.ToolTip = new ToolTip(); this.HistoryMenu = new ContextMenuStrip(); this.HistoryMenu.AutoSize = true; base.Size = this.Size; if (!Areo.IsLegacyOS) { this.HistoryMenu.Renderer = new WindowsVistaRenderer(); } this.HistoryIndex = -1; this.ShowClearHistory = true; this.History.ItemAdded += delegate(object sender, EventArgs e) { BuildContextMenu(); }; this.History.ItemRemoved += delegate(object sender, EventArgs e) { BuildContextMenu(); }; //this.HistoryMenu.MinimumSize = new Size ( this.Width, this.HistoryMenu.MinimumSize.Width ); this.HistoryMenu.Opening += delegate(object sender, CancelEventArgs e) { foreach (ToolStripItem xitem in HistoryMenu.Items) { if (xitem is ToolStripMenuItem && xitem.Tag is ExplorerNavigationHistoryItem) { ExplorerNavigationHistoryItem hi = xitem.Tag as ExplorerNavigationHistoryItem; (xitem as ToolStripMenuItem).Checked = false; (xitem as ToolStripMenuItem).Font = new Font(xitem.Font, FontStyle.Regular); (xitem as ToolStripMenuItem).Image = hi.Image; } } if (HistoryIndex >= 0 && HistoryIndex < History.Count) { ToolStripMenuItem tsi = (this.HistoryMenu.Items[HistoryIndex] as ToolStripMenuItem); tsi.Checked = true; tsi.Font = new Font(tsi.Font, FontStyle.Bold); } this.IsMenuVisible = true; }; this.HistoryMenu.Closing += delegate(object sender, ToolStripDropDownClosingEventArgs e) { this.IsMenuVisible = false; this.Invalidate(); }; }
private void NavigateHistory(int historyIndex) { if (historyIndex < History.Count && historyIndex >= 0) { HistoryIndex = historyIndex; ExplorerNavigationHistoryItem item = this.History[historyIndex]; if (item.NavigateDelegate != null) { item.NavigateDelegate.Invoke(item, EventArgs.Empty); } this.Invalidate(); } }
public void AddHistory(ExplorerNavigationHistoryItem item, bool navigate) { if (navigate) { this.History.Insert(0, item); this.HistoryIndex = 0; } else { this.History.Add(item); } this.Invalidate(); }
public ExplorerNavigationHistoryItem Clone() { ExplorerNavigationHistoryItem i = this.MemberwiseClone() as ExplorerNavigationHistoryItem; if (this.Image != null) { i.Image = this.Image.Clone() as Image; } if (this.NavigateDelegate != null) { i.NavigateDelegate = this.NavigateDelegate.Clone() as EventHandler; } return(i); }
private void NavigateHistory(ExplorerNavigationHistoryItem item) { NavigateHistory(this.History.IndexOf(item)); }
private void BuildContextMenu() { this.HistoryMenu.Items.Clear(); foreach (var item in this.History) { ToolStripMenuItem tsmi = new ToolStripMenuItem(item.Text, item.Image, delegate(object s, EventArgs ea) { ToolStripMenuItem titem = (s as ToolStripMenuItem); if (titem != null) { ExplorerNavigationHistoryItem hi = titem.Tag as ExplorerNavigationHistoryItem; foreach (ToolStripItem xitem in HistoryMenu.Items) { if (xitem is ToolStripMenuItem && xitem.Tag is ExplorerNavigationHistoryItem) { (xitem as ToolStripMenuItem).Checked = false; (xitem as ToolStripMenuItem).Font = new Font(xitem.Font, FontStyle.Regular); (xitem as ToolStripMenuItem).Image = hi.Image; } } titem.Checked = true; titem.Font = new Font(titem.Font, FontStyle.Bold); NavigateHistory(hi); } }); tsmi.MouseEnter += delegate(object s, EventArgs e) { ToolStripMenuItem titem = (s as ToolStripMenuItem); if (!titem.Checked) { ExplorerNavigationHistoryItem i = titem.Tag as ExplorerNavigationHistoryItem; if (this.History.IndexOf(i) < this.HistoryIndex) { titem.Image = Properties.Resources.GoToNextHS; } else { titem.Image = Properties.Resources.GoToPrevious; } } }; tsmi.MouseLeave += delegate(object s, EventArgs e) { ToolStripMenuItem titem = (s as ToolStripMenuItem); if (!titem.Checked) { ExplorerNavigationHistoryItem i = titem.Tag as ExplorerNavigationHistoryItem; titem.Image = i.Image; } }; tsmi.Tag = item; this.HistoryMenu.Items.Add(tsmi); } if (this.HistoryMenu.Items.Count == 1) { ToolStripMenuItem tsi = (this.HistoryMenu.Items[0] as ToolStripMenuItem); tsi.Checked = true; tsi.Font = new Font(tsi.Font, FontStyle.Bold); HistoryIndex = 0; } if (this.HistoryMenu.Items.Count > 0 && this.ShowClearHistory) { this.HistoryMenu.Items.Add(new ToolStripSeparator()); this.HistoryMenu.Items.Add(new ToolStripMenuItem("&Clear History", null, delegate(object sender, EventArgs e) { this.ClearHistory(); }, "clearHistory")); } }
public void HistoryGo(ExplorerNavigationHistoryItem item) { NavigateHistory(item); }
public void AddHistory(ExplorerNavigationHistoryItem item) { AddHistory(item, false); }