Skip to content

Commit 5a6c5e1

Browse files
author
slavara
committed
WIP
1 parent 1d09e79 commit 5a6c5e1

File tree

5 files changed

+73
-28
lines changed

5 files changed

+73
-28
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/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: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,37 @@ namespace QuickNavigate.Forms
1313
{
1414
public sealed partial class OpenRecentProjectsForm : Form
1515
{
16-
[NotNull] readonly Settings settings;
1716
[NotNull] [ItemNotNull] readonly List<string> recentProjects = ProjectManager.PluginMain.Settings.RecentProjects.Where(File.Exists).ToList();
18-
17+
1918
public OpenRecentProjectsForm([NotNull] Settings settings)
2019
{
21-
this.settings = settings;
22-
Font = PluginBase.Settings.DefaultFont;
2320
InitializeComponent();
24-
if (settings.RecentProjectsSize.Width > MinimumSize.Width) Size = settings.RecentProjectsSize;
2521
InitializeTree();
2622
InitializeTheme();
23+
Settings = settings;
2724
RefrestTree();
2825
}
2926

27+
public bool InNewWindow { get; private set; }
28+
3029
[CanBeNull]
3130
public string SelectedItem => tree?.SelectedNode.Text;
3231

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+
3347
void InitializeTree()
3448
{
3549
tree.ImageList = new ImageList
@@ -49,6 +63,8 @@ void InitializeTheme()
4963
tree.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
5064
open.BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
5165
open.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
66+
openInNewWindow.BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
67+
openInNewWindow.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
5268
cancel.BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
5369
cancel.ForeColor = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
5470
BackColor = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
@@ -62,10 +78,16 @@ void RefrestTree()
6278
tree.Nodes.Clear();
6379
FillTree();
6480
if (tree.Nodes.Count > 0) tree.SelectedNode = tree.Nodes[0];
65-
else open.Enabled = false;
81+
else RefreshButtons();
6682
tree.EndUpdate();
6783
}
6884

85+
void RefreshButtons()
86+
{
87+
open.Enabled = false;
88+
openInNewWindow.Enabled = false;
89+
}
90+
6991
void FillTree()
7092
{
7193
var search = input.Text;
@@ -165,5 +187,11 @@ void OnTreeDrawNode(object sender, DrawTreeNodeEventArgs e)
165187
x += graphics.MeasureString(text, font).Width;
166188
graphics.DrawString($"({path})", font, moduleBrush, x, bounds.Top, StringFormat.GenericDefault);
167189
}
190+
191+
void OnOpenInNewWindowClick(object sender, EventArgs e)
192+
{
193+
InNewWindow = SelectedItem != null;
194+
Navigate();
195+
}
168196
}
169197
}

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)