Skip to content

Commit 7299bd3

Browse files
committed
Changed Navigate Forward/Backward buttons to split buttons with dropdown history
1 parent cf6150c commit 7299bd3

File tree

5 files changed

+750
-662
lines changed

5 files changed

+750
-662
lines changed

Controls/NavigationBar.cs

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
using ASCompletion.Settings;
55
using NavigationBar.Helpers;
66
using PluginCore;
7+
using PluginCore.Controls;
78
using PluginCore.Helpers;
89
using PluginCore.Localization;
910
using ScintillaNet;
1011
using System;
1112
using System.Collections.Generic;
1213
using System.Drawing;
14+
using System.Drawing.Drawing2D;
1315
using System.Reflection;
1416
using System.Windows.Forms;
1517

1618
namespace NavigationBar.Controls
1719
{
18-
public partial class NavigationBar : ToolStrip, IDisposable
20+
public partial class NavigationBar : ToolStripEx, IDisposable
1921
{
20-
private static ImageList _icons = null;
22+
private static Bitmap[] _icons = null;
2123
private bool _updating = false;
2224
private int _lastPosition = -1;
2325
private bool _textChanged = false;
@@ -91,54 +93,55 @@ private void InitializeComponent()
9193
_dropDownSearchTimer.Tick += new EventHandler(dropDownSearchTimer_Tick);
9294
_dropDownSearchKey = "";
9395

94-
//
96+
//
9597
// importComboBox
96-
//
98+
//
9799
importComboBox.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
98100
importComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
101+
importComboBox.Margin = new Padding(0, 0, 0, 0);
99102
importComboBox.MaxDropDownItems = 25;
100103
importComboBox.Name = "importComboBox";
101104
importComboBox.ComboBox.DrawItem += new DrawItemEventHandler(comboBox_DrawItem);
102105
importComboBox.ComboBox.SelectionChangeCommitted += new EventHandler(comboBox_SelectionChangeCommitted);
103106
importComboBox.KeyPress += new KeyPressEventHandler(comboBox_KeyPress);
104107
importComboBox.DropDownClosed += new EventHandler(comboBox_DropDownClosed);
105-
//
108+
//
106109
// classComboBox
107-
//
110+
//
108111
classComboBox.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
109112
classComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
113+
classComboBox.Margin = new Padding(0, 0, 0, 0);
110114
classComboBox.MaxDropDownItems = 25;
111115
classComboBox.Name = "classComboBox";
112116
classComboBox.ComboBox.DrawItem += new DrawItemEventHandler(comboBox_DrawItem);
113117
classComboBox.ComboBox.SelectionChangeCommitted += new EventHandler(comboBox_SelectionChangeCommitted);
114118
classComboBox.KeyPress += new KeyPressEventHandler(comboBox_KeyPress);
115119
classComboBox.DropDownClosed += new EventHandler(comboBox_DropDownClosed);
116-
//
120+
//
117121
// memberComboBox
118-
//
122+
//
119123
memberComboBox.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
120124
memberComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
125+
memberComboBox.Margin = new Padding(0, 0, 0, 0);
121126
memberComboBox.MaxDropDownItems = 25;
122127
memberComboBox.Name = "memberComboBox";
123-
memberComboBox.Padding = new Padding(0, 0, 0, 1);
124128
memberComboBox.ComboBox.DrawItem += new DrawItemEventHandler(comboBox_DrawItem);
125129
memberComboBox.ComboBox.SelectionChangeCommitted += new EventHandler(comboBox_SelectionChangeCommitted);
126130
memberComboBox.KeyPress += new KeyPressEventHandler(comboBox_KeyPress);
127131
memberComboBox.DropDownClosed += new EventHandler(comboBox_DropDownClosed);
128-
//
132+
//
129133
// updateTimer
130-
//
134+
//
131135
updateTimer.Tick += new EventHandler(updateTimer_Tick);
132-
//
136+
//
133137
// NavigationBar
134-
//
138+
//
135139
CanOverflow = false;
136140
Dock = DockStyle.Top;
137141
GripStyle = ToolStripGripStyle.Hidden;
138142
Items.AddRange(new ToolStripItem[] {
139143
importComboBox, classComboBox, memberComboBox });
140144
Name = "NavigationBar";
141-
Padding = new Padding(1, 1, 2, 2);
142145
Stretch = true;
143146
Visible = false;
144147
ResumeLayout(false);
@@ -176,46 +179,43 @@ private void InitializeContextMenu()
176179
private void InitializeIcons()
177180
{
178181
//Pull the member icons from the resources;
179-
_icons = new ImageList();
180-
_icons.TransparentColor = Color.Transparent;
181-
_icons.ImageSize = ScaleHelper.Scale(new Size(16, 16));
182-
_icons.Images.AddRange(new Bitmap[] {
183-
new Bitmap(PluginUI.GetStream("FilePlain.png")),
184-
new Bitmap(PluginUI.GetStream("FolderClosed.png")),
185-
new Bitmap(PluginUI.GetStream("FolderOpen.png")),
186-
new Bitmap(PluginUI.GetStream("CheckAS.png")),
187-
new Bitmap(PluginUI.GetStream("QuickBuild.png")),
188-
new Bitmap(PluginUI.GetStream("Package.png")),
189-
new Bitmap(PluginUI.GetStream("Interface.png")),
190-
new Bitmap(PluginUI.GetStream("Intrinsic.png")),
191-
new Bitmap(PluginUI.GetStream("Class.png")),
192-
new Bitmap(PluginUI.GetStream("Variable.png")),
193-
new Bitmap(PluginUI.GetStream("VariableProtected.png")),
194-
new Bitmap(PluginUI.GetStream("VariablePrivate.png")),
195-
new Bitmap(PluginUI.GetStream("VariableStatic.png")),
196-
new Bitmap(PluginUI.GetStream("VariableStaticProtected.png")),
197-
new Bitmap(PluginUI.GetStream("VariableStaticPrivate.png")),
198-
new Bitmap(PluginUI.GetStream("Const.png")),
199-
new Bitmap(PluginUI.GetStream("ConstProtected.png")),
200-
new Bitmap(PluginUI.GetStream("ConstPrivate.png")),
201-
new Bitmap(PluginUI.GetStream("Const.png")),
202-
new Bitmap(PluginUI.GetStream("ConstProtected.png")),
203-
new Bitmap(PluginUI.GetStream("ConstPrivate.png")),
204-
new Bitmap(PluginUI.GetStream("Method.png")),
205-
new Bitmap(PluginUI.GetStream("MethodProtected.png")),
206-
new Bitmap(PluginUI.GetStream("MethodPrivate.png")),
207-
new Bitmap(PluginUI.GetStream("MethodStatic.png")),
208-
new Bitmap(PluginUI.GetStream("MethodStaticProtected.png")),
209-
new Bitmap(PluginUI.GetStream("MethodStaticPrivate.png")),
210-
new Bitmap(PluginUI.GetStream("Property.png")),
211-
new Bitmap(PluginUI.GetStream("PropertyProtected.png")),
212-
new Bitmap(PluginUI.GetStream("PropertyPrivate.png")),
213-
new Bitmap(PluginUI.GetStream("PropertyStatic.png")),
214-
new Bitmap(PluginUI.GetStream("PropertyStaticProtected.png")),
215-
new Bitmap(PluginUI.GetStream("PropertyStaticPrivate.png")),
216-
new Bitmap(PluginUI.GetStream("Template.png")),
217-
new Bitmap(PluginUI.GetStream("Declaration.png"))
218-
});
182+
_icons = new Bitmap[] {
183+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("FilePlain.png"))),
184+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("FolderClosed.png"))),
185+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("FolderOpen.png"))),
186+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("CheckAS.png"))),
187+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("QuickBuild.png"))),
188+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Package.png"))),
189+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Interface.png"))),
190+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Intrinsic.png"))),
191+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Class.png"))),
192+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Variable.png"))),
193+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("VariableProtected.png"))),
194+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("VariablePrivate.png"))),
195+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("VariableStatic.png"))),
196+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("VariableStaticProtected.png"))),
197+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("VariableStaticPrivate.png"))),
198+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Const.png"))),
199+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("ConstProtected.png"))),
200+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("ConstPrivate.png"))),
201+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Const.png"))),
202+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("ConstProtected.png"))),
203+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("ConstPrivate.png"))),
204+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Method.png"))),
205+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("MethodProtected.png"))),
206+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("MethodPrivate.png"))),
207+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("MethodStatic.png"))),
208+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("MethodStaticProtected.png"))),
209+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("MethodStaticPrivate.png"))),
210+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Property.png"))),
211+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("PropertyProtected.png"))),
212+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("PropertyPrivate.png"))),
213+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("PropertyStatic.png"))),
214+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("PropertyStaticProtected.png"))),
215+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("PropertyStaticPrivate.png"))),
216+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Template.png"))),
217+
ScaleHelper.Scale(new Bitmap(PluginUI.GetStream("Declaration.png")))
218+
};
219219
}
220220

221221
public static System.IO.Stream GetStream(string name)
@@ -296,7 +296,7 @@ private void UpdateSortMenu()
296296
_sortSortedItem.Checked = _settings.MemberSortMethod == OutlineSorting.Sorted ? true : false;
297297
_sortByKindItem.Checked = _settings.MemberSortMethod == OutlineSorting.SortedByKind ||
298298
_settings.MemberSortMethod == OutlineSorting.SortedGroup ? true : false;
299-
_sortSmartItem.Checked = _settings.MemberSortMethod == OutlineSorting.SortedSmart ? true : false;
299+
_sortSmartItem.Checked = _settings.MemberSortMethod == OutlineSorting.SortedSmart ? true : false;
300300
}
301301

302302
#endregion
@@ -388,7 +388,7 @@ void updateTimer_Tick(object sender, EventArgs e)
388388

389389
void _scintella_UpdateUI(ScintillaControl sender)
390390
{
391-
// The caret may have moved
391+
// The caret may have moved
392392
UpdateNavigationBar();
393393
}
394394

@@ -461,23 +461,23 @@ private void comboBox_DrawItem(object sender, DrawItemEventArgs e)
461461
{
462462
MemberTreeNode node = comboBox.Items[e.Index] as MemberTreeNode;
463463

464-
int imageWidth = _icons.ImageSize.Width;
465-
int imageHeight = _icons.ImageSize.Height;
464+
int imageWidth = _icons[0].Width;
465+
int imageHeight = _icons[0].Height;
466466

467467
// Clear the old background
468468
if ((e.State & DrawItemState.ComboBoxEdit) == 0)
469469
e.Graphics.FillRectangle(new SolidBrush(comboBox.BackColor), e.Bounds.Left + imageWidth, e.Bounds.Top, e.Bounds.Width - imageWidth, e.Bounds.Height);
470470

471471
// Draw the item image
472-
e.Graphics.DrawImage(_icons.Images[node.ImageIndex], new Rectangle(e.Bounds.Left, e.Bounds.Top, imageWidth, imageHeight));
472+
e.Graphics.DrawImage(_icons[node.ImageIndex], new Rectangle(e.Bounds.Left, e.Bounds.Top, imageWidth, imageHeight));
473473

474474
// Is this item being hovered over?
475475
if ((e.State & DrawItemState.Focus) != 0 ||
476476
(e.State & DrawItemState.Selected) != 0)
477477
{
478478
// Draw a selection box and label in the selection text color
479-
e.Graphics.FillRectangle(new SolidBrush(SystemColors.Highlight), e.Bounds.Left + imageWidth, e.Bounds.Top, e.Bounds.Width - imageWidth - 1, e.Bounds.Height - 1);
480-
e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), e.Bounds.Left + imageWidth, e.Bounds.Top, e.Bounds.Width - imageWidth - 1, e.Bounds.Height - 1);
479+
e.Graphics.FillRectangle(new SolidBrush(SystemColors.Highlight), e.Bounds.Left + imageWidth + 1, e.Bounds.Top + 1, e.Bounds.Width - imageWidth - 2, e.Bounds.Height - 2);
480+
e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), e.Bounds.Left + imageWidth + 1, e.Bounds.Top + 1, e.Bounds.Width - imageWidth - 2, e.Bounds.Height - 2);
481481

482482
e.Graphics.DrawString(node.Label, comboBox.Font, new SolidBrush(SystemColors.HighlightText), new Point(e.Bounds.Left + imageWidth + 1, e.Bounds.Top));
483483
}

0 commit comments

Comments
 (0)