Skip to content

Commit fe0a44a

Browse files
author
slavara
committed
closes #124
1 parent 5a6c5e1 commit fe0a44a

File tree

4 files changed

+49
-39
lines changed

4 files changed

+49
-39
lines changed

QuickNavigate/Forms/OpenRecentFilesForm.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ namespace QuickNavigate.Forms
1212
{
1313
public sealed partial class OpenRecentFilesForm : Form
1414
{
15-
[NotNull]
16-
readonly Settings settings;
15+
[NotNull] readonly Settings settings;
1716

18-
[NotNull]
19-
readonly List<string> recentFiles;
17+
[NotNull] readonly List<string> recentFiles;
2018

21-
[NotNull]
22-
readonly List<string> openedFiles;
19+
[NotNull] readonly List<string> openedFiles;
2320

2421
public OpenRecentFilesForm([NotNull] Settings settings)
2522
{

QuickNavigate/Forms/OpenRecentProjectsForm.cs

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,29 @@ namespace QuickNavigate.Forms
1313
{
1414
public sealed partial class OpenRecentProjectsForm : Form
1515
{
16+
[NotNull] readonly Settings settings;
1617
[NotNull] [ItemNotNull] readonly List<string> recentProjects = ProjectManager.PluginMain.Settings.RecentProjects.Where(File.Exists).ToList();
1718

1819
public OpenRecentProjectsForm([NotNull] Settings settings)
1920
{
21+
this.settings = settings;
22+
Font = PluginBase.Settings.DefaultFont;
2023
InitializeComponent();
24+
if (settings.RecentProjectsSize.Width > MinimumSize.Width) Size = settings.RecentProjectsSize;
2125
InitializeTree();
26+
InitializeContextMenu();
2227
InitializeTheme();
23-
Settings = settings;
28+
openInNewWindow.Visible = PluginBase.MainForm.MultiInstanceMode;
2429
RefrestTree();
2530
}
2631

32+
[CanBeNull] ContextMenuStrip contextMenu;
33+
2734
public bool InNewWindow { get; private set; }
2835

2936
[CanBeNull]
30-
public string SelectedItem => tree?.SelectedNode.Text;
31-
32-
[NotNull] Settings settings;
33-
34-
[NotNull]
35-
public Settings Settings
36-
{
37-
get { return settings; }
38-
set
39-
{
40-
settings = value;
41-
if (settings.RecentProjectsSize.Width > MinimumSize.Width) Size = settings.RecentProjectsSize;
42-
Font = PluginBase.Settings.DefaultFont;
43-
openInNewWindow.Visible = PluginBase.MainForm.MultiInstanceMode;
44-
}
45-
}
46-
37+
public string SelectedItem => tree.SelectedNode?.Text;
38+
4739
void InitializeTree()
4840
{
4941
tree.ImageList = new ImageList
@@ -55,6 +47,15 @@ void InitializeTree()
5547
tree.ItemHeight = tree.ImageList.ImageSize.Height;
5648
}
5749

50+
void InitializeContextMenu()
51+
{
52+
if (!PluginBase.MainForm.MultiInstanceMode) return;
53+
input.ContextMenu = new ContextMenu();
54+
contextMenu = new ContextMenuStrip {Renderer = new DockPanelStripRenderer(false)};
55+
contextMenu.Items.Add("Open in new Window").Click += (s, args) => NavigateInNewWindow();
56+
contextMenu.Items[0].Select();
57+
}
58+
5859
void InitializeTheme()
5960
{
6061
input.BackColor = PluginBase.MainForm.GetThemeColor("TextBox.BackColor", SystemColors.Window);
@@ -105,6 +106,21 @@ void Navigate()
105106
DialogResult = DialogResult.OK;
106107
}
107108

109+
void NavigateInNewWindow()
110+
{
111+
InNewWindow = SelectedItem != null;
112+
Navigate();
113+
}
114+
115+
void ShowContextMenu()
116+
{
117+
var selectedNode = tree.SelectedNode;
118+
if (selectedNode == null) return;
119+
ShowContextMenu(new Point(selectedNode.Bounds.X, selectedNode.Bounds.Bottom));
120+
}
121+
122+
void ShowContextMenu([NotNull] Point position) => contextMenu?.Show(tree, position);
123+
108124
protected override void OnKeyDown(KeyEventArgs e)
109125
{
110126
switch (e.KeyCode)
@@ -120,6 +136,10 @@ protected override void OnKeyDown(KeyEventArgs e)
120136
input.SelectAll();
121137
}
122138
break;
139+
case Keys.Apps:
140+
e.Handled = true;
141+
ShowContextMenu();
142+
break;
123143
}
124144
}
125145

@@ -188,10 +208,6 @@ void OnTreeDrawNode(object sender, DrawTreeNodeEventArgs e)
188208
graphics.DrawString($"({path})", font, moduleBrush, x, bounds.Top, StringFormat.GenericDefault);
189209
}
190210

191-
void OnOpenInNewWindowClick(object sender, EventArgs e)
192-
{
193-
InNewWindow = SelectedItem != null;
194-
Navigate();
195-
}
211+
void OnOpenInNewWindowClick(object sender, EventArgs e) => NavigateInNewWindow();
196212
}
197213
}

QuickNavigate/Forms/QuickOutlineForm.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QuickNavigate/Forms/QuickOutlineForm.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ namespace QuickNavigate.Forms
1414
{
1515
public sealed partial class QuickOutlineForm : Form
1616
{
17-
[NotNull]
18-
readonly Settings settings;
19-
readonly ContextMenuStrip contextMenu = new ContextMenuStrip();
17+
[NotNull] readonly Settings settings;
18+
readonly ContextMenuStrip contextMenu = new ContextMenuStrip { Renderer = new DockPanelStripRenderer(false) };
2019
readonly ContextMenu inputEmptyContextMenu = new ContextMenu();
2120
readonly List<Button> filters = new List<Button>();
2221
readonly Dictionary<Keys, Button> keysToFilter = new Dictionary<Keys, Button>();
2322
readonly Dictionary<Button, string> filterToEnabledTip = new Dictionary<Button, string>();
2423
readonly Dictionary<Button, string> filterToDisabledTip = new Dictionary<Button, string>();
25-
readonly Dictionary<FlagType, Button> flagToFilter = new Dictionary<FlagType, Button>();
24+
readonly Dictionary<FlagType, Button> flagToFilter = new Dictionary<FlagType, Button>();
2625

2726
/// <summary>
2827
/// Initializes a new instance of the QuickNavigate.Controls.QuickOutlineForm
@@ -44,11 +43,9 @@ public QuickOutlineForm([NotNull] FileModel inFile, [CanBeNull] ClassModel inCla
4443
RefreshTree();
4544
}
4645

47-
[CanBeNull]
48-
public event ShowInHandler ShowInClassHierarchy;
46+
[CanBeNull] public event ShowInHandler ShowInClassHierarchy;
4947

50-
[CanBeNull]
51-
ToolTip filterToolTip;
48+
[CanBeNull] ToolTip filterToolTip;
5249

5350
[NotNull]
5451
public FileModel InFile { get; }
@@ -242,7 +239,7 @@ void RefreshFilterTip(Button filter)
242239
protected override void OnKeyDown(KeyEventArgs e)
243240
{
244241
var keyCode = e.KeyCode;
245-
if (keysToFilter.ContainsKey(keyCode) && e.Alt)
242+
if (e.Alt && keysToFilter.ContainsKey(keyCode))
246243
{
247244
CurrentFilter = keysToFilter[keyCode];
248245
return;

0 commit comments

Comments
 (0)