Skip to content

Commit 9859691

Browse files
author
slavara
committed
Merge branch 'feature/124' into develop
2 parents 1d09e79 + fe0a44a commit 9859691

File tree

8 files changed

+97
-42
lines changed

8 files changed

+97
-42
lines changed

QuickNavigate.Tests/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("SlavaRa")]
1111
[assembly: AssemblyProduct("QuickNavigate.Tests")]
12-
[assembly: AssemblyCopyright("FlashDevelop.org 2014-2015")]
12+
[assembly: AssemblyCopyright("FlashDevelop.org 2014-2016")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

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.Designer.cs

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QuickNavigate/Forms/OpenRecentProjectsForm.cs

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,27 @@ public sealed partial class OpenRecentProjectsForm : Form
1515
{
1616
[NotNull] readonly Settings settings;
1717
[NotNull] [ItemNotNull] readonly List<string> recentProjects = ProjectManager.PluginMain.Settings.RecentProjects.Where(File.Exists).ToList();
18-
18+
1919
public OpenRecentProjectsForm([NotNull] Settings settings)
2020
{
2121
this.settings = settings;
2222
Font = PluginBase.Settings.DefaultFont;
2323
InitializeComponent();
2424
if (settings.RecentProjectsSize.Width > MinimumSize.Width) Size = settings.RecentProjectsSize;
2525
InitializeTree();
26+
InitializeContextMenu();
2627
InitializeTheme();
28+
openInNewWindow.Visible = PluginBase.MainForm.MultiInstanceMode;
2729
RefrestTree();
2830
}
2931

30-
[CanBeNull]
31-
public string SelectedItem => tree?.SelectedNode.Text;
32+
[CanBeNull] ContextMenuStrip contextMenu;
3233

34+
public bool InNewWindow { get; private set; }
35+
36+
[CanBeNull]
37+
public string SelectedItem => tree.SelectedNode?.Text;
38+
3339
void InitializeTree()
3440
{
3541
tree.ImageList = new ImageList
@@ -41,6 +47,15 @@ void InitializeTree()
4147
tree.ItemHeight = tree.ImageList.ImageSize.Height;
4248
}
4349

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+
4459
void InitializeTheme()
4560
{
4661
input.BackColor = PluginBase.MainForm.GetThemeColor("TextBox.BackColor", SystemColors.Window);
@@ -49,6 +64,8 @@ void InitializeTheme()
4964
tree.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
5065
open.BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
5166
open.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
67+
openInNewWindow.BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
68+
openInNewWindow.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
5269
cancel.BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
5370
cancel.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
5471
BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
@@ -62,10 +79,16 @@ void RefrestTree()
6279
tree.Nodes.Clear();
6380
FillTree();
6481
if (tree.Nodes.Count > 0) tree.SelectedNode = tree.Nodes[0];
65-
else open.Enabled = false;
82+
else RefreshButtons();
6683
tree.EndUpdate();
6784
}
6885

86+
void RefreshButtons()
87+
{
88+
open.Enabled = false;
89+
openInNewWindow.Enabled = false;
90+
}
91+
6992
void FillTree()
7093
{
7194
var search = input.Text;
@@ -83,6 +106,21 @@ void Navigate()
83106
DialogResult = DialogResult.OK;
84107
}
85108

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+
86124
protected override void OnKeyDown(KeyEventArgs e)
87125
{
88126
switch (e.KeyCode)
@@ -98,6 +136,10 @@ protected override void OnKeyDown(KeyEventArgs e)
98136
input.SelectAll();
99137
}
100138
break;
139+
case Keys.Apps:
140+
e.Handled = true;
141+
ShowContextMenu();
142+
break;
101143
}
102144
}
103145

@@ -165,5 +207,7 @@ void OnTreeDrawNode(object sender, DrawTreeNodeEventArgs e)
165207
x += graphics.MeasureString(text, font).Width;
166208
graphics.DrawString($"({path})", font, moduleBrush, x, bounds.Top, StringFormat.GenericDefault);
167209
}
210+
211+
void OnOpenInNewWindowClick(object sender, EventArgs e) => NavigateInNewWindow();
168212
}
169213
}

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;

QuickNavigate/PluginMain.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using ASCompletion.Completion;
88
using ASCompletion.Context;
99
using ASCompletion.Model;
10+
using JetBrains.Annotations;
1011
using PluginCore;
1112
using PluginCore.Helpers;
1213
using PluginCore.Managers;
@@ -30,6 +31,7 @@ public class ShortcutId
3031

3132
public class PluginMain : IPlugin
3233
{
34+
const string ProjectManagerGUID = "30018864-fadd-1122-b2a5-779832cbbf23";
3335
string settingFilename;
3436
ControlClickManager controlClickManager;
3537
ToolStripMenuItem typeExplorerItem;
@@ -208,10 +210,10 @@ void UpdateMenuItems()
208210

209211
void ShowRecentFiles()
210212
{
211-
var form = new OpenRecentFilesForm((Settings)Settings);
213+
var form = new OpenRecentFilesForm((Settings) Settings);
212214
form.KeyUp += FormOnKeyUp;
213215
if (form.ShowDialog() != DialogResult.OK) return;
214-
var plugin = (ProjectManager.PluginMain)PluginBase.MainForm.FindPlugin("30018864-fadd-1122-b2a5-779832cbbf23");
216+
var plugin = (ProjectManager.PluginMain)PluginBase.MainForm.FindPlugin(ProjectManagerGUID);
215217
form.SelectedItems.ForEach(plugin.OpenFile);
216218
}
217219

@@ -222,8 +224,9 @@ void ShowRecentProjets()
222224
var form = new OpenRecentProjectsForm((Settings) Settings);
223225
form.KeyUp += FormOnKeyUp;
224226
if (form.ShowDialog() != DialogResult.OK) return;
225-
var plugin = (ProjectManager.PluginMain) PluginBase.MainForm.FindPlugin("30018864-fadd-1122-b2a5-779832cbbf23");
226-
plugin.OpenFile(form.SelectedItem);
227+
var plugin = (ProjectManager.PluginMain) PluginBase.MainForm.FindPlugin(ProjectManagerGUID);
228+
if (form.InNewWindow) ProcessHelper.StartAsync(Application.ExecutablePath, form.SelectedItem);
229+
else plugin.OpenFile(form.SelectedItem);
227230
}
228231

229232
void ShowTypeExplorer(object sender, EventArgs e) => ShowTypeExplorer();
@@ -276,13 +279,13 @@ void ShowTypeExplorer()
276279

277280
void ShowQuickOutline() => ShowQuickOutline(ASContext.Context.CurrentModel, ASContext.Context.CurrentClass);
278281

279-
void ShowQuickOutline(Form sender, ClassModel inClass)
282+
void ShowQuickOutline([NotNull] Form sender, [NotNull] ClassModel inClass)
280283
{
281284
sender.Close();
282285
((Control) PluginBase.MainForm).BeginInvoke((MethodInvoker) (() => ShowQuickOutline(inClass.InFile, inClass)));
283286
}
284287

285-
void ShowQuickOutline(FileModel inFile, ClassModel inClass)
288+
void ShowQuickOutline([NotNull] FileModel inFile, [NotNull] ClassModel inClass)
286289
{
287290
var form = new QuickOutlineForm(inFile, inClass, (Settings) Settings);
288291
form.ShowInClassHierarchy += ShowClassHierarchy;
@@ -313,13 +316,13 @@ void ShowClassHierarchy()
313316
ShowClassHierarchy(!curClass.IsVoid() ? curClass : context.CurrentModel.GetPublicClass());
314317
}
315318

316-
void ShowClassHierarchy(Form sender, ClassModel model)
319+
void ShowClassHierarchy([NotNull] Form sender, [NotNull] ClassModel model)
317320
{
318321
sender.Close();
319322
((Control) PluginBase.MainForm).BeginInvoke((MethodInvoker) (() => ShowClassHierarchy(model)));
320323
}
321324

322-
void ShowClassHierarchy(ClassModel model)
325+
void ShowClassHierarchy([NotNull] ClassModel model)
323326
{
324327
var form = new ClassHierarchyForm(model, (Settings) Settings);
325328
form.GotoPositionOrLine += OnGotoPositionOrLine;
@@ -344,27 +347,27 @@ static bool GetCanShowClassHierarchy()
344347
&& (!context.CurrentClass.IsVoid() || !context.CurrentModel.GetPublicClass().IsVoid());
345348
}
346349

347-
static void OnGotoPositionOrLine(Form sender, ClassModel model)
350+
static void OnGotoPositionOrLine([NotNull] Form sender, [NotNull] ClassModel model)
348351
{
349352
sender.Close();
350-
((Control)PluginBase.MainForm).BeginInvoke((MethodInvoker)delegate
353+
((Control)PluginBase.MainForm).BeginInvoke((MethodInvoker)(() =>
351354
{
352355
ModelsExplorer.Instance.OpenFile(model.InFile.FileName);
353356
PluginBase.MainForm.CallCommand("GoTo", null);
354-
});
357+
}));
355358
}
356359

357-
static void ShowInProjectManager(Form sender, ClassModel model)
360+
static void ShowInProjectManager([NotNull] Form sender, [NotNull] ClassModel model)
358361
{
359362
sender.Close();
360-
((Control) PluginBase.MainForm).BeginInvoke((MethodInvoker) delegate
363+
((Control) PluginBase.MainForm).BeginInvoke((MethodInvoker) (() =>
361364
{
362365
foreach (var pane in PluginBase.MainForm.DockPanel.Panes)
363366
{
364367
foreach (var dockContent in pane.Contents)
365368
{
366369
var content = (DockContent) dockContent;
367-
if (content.GetPersistString() != "30018864-fadd-1122-b2a5-779832cbbf23") continue;
370+
if (content.GetPersistString() != ProjectManagerGUID) continue;
368371
foreach (var ui in content.Controls.OfType<ProjectManager.PluginUI>())
369372
{
370373
content.Show();
@@ -373,13 +376,13 @@ static void ShowInProjectManager(Form sender, ClassModel model)
373376
}
374377
}
375378
}
376-
});
379+
}));
377380
}
378381

379-
static void ShowInFileExplorer(Form sender, ClassModel model)
382+
static void ShowInFileExplorer([NotNull] Form sender, [NotNull] ClassModel model)
380383
{
381384
sender.Close();
382-
((Control) PluginBase.MainForm).BeginInvoke((MethodInvoker) delegate
385+
((Control) PluginBase.MainForm).BeginInvoke((MethodInvoker) (() =>
383386
{
384387
foreach (var pane in PluginBase.MainForm.DockPanel.Panes)
385388
{
@@ -395,7 +398,7 @@ static void ShowInFileExplorer(Form sender, ClassModel model)
395398
}
396399
}
397400
}
398-
});
401+
}));
399402
}
400403

401404
#endregion

QuickNavigate/QuickNavigate.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<PlatformTarget>AnyCPU</PlatformTarget>
4343
<OutputPath>..\..\..\..\FlashDevelop\Bin\Debug\Plugins\</OutputPath>
4444
<DefineConstants>TRACE</DefineConstants>
45-
<Optimize>true</Optimize>
45+
<Optimize>false</Optimize>
4646
</PropertyGroup>
4747
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
4848
<PlatformTarget>AnyCPU</PlatformTarget>

0 commit comments

Comments
 (0)