Skip to content

Commit 806df16

Browse files
author
SlavaRa
committed
Merge branch 'feature/139' into develop
2 parents 7083760 + 3a69d57 commit 806df16

File tree

7 files changed

+81
-91
lines changed

7 files changed

+81
-91
lines changed

QuickNavigate/Forms/ClassHierarchyForm.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace QuickNavigate.Forms
1515
{
16-
public sealed partial class ClassHierarchyForm : ClassModelExplorerForm
16+
public sealed partial class ClassHierarchyForm : QuickForm
1717
{
1818
readonly ClassModel curClass;
1919
readonly Dictionary<string, List<ClassModel>> extendsToClasses;
@@ -62,9 +62,7 @@ static IEnumerable<ClassModel> GetExtends([NotNull] ClassModel theClass)
6262
public ClassHierarchyForm([NotNull] ClassModel model, [NotNull] Settings settings) : base(settings)
6363
{
6464
curClass = model;
65-
Font = PluginBase.Settings.DefaultFont;
6665
InitializeComponent();
67-
if (settings.HierarchyExplorerSize.Width > MinimumSize.Width) Size = settings.HierarchyExplorerSize;
6866
extendsToClasses = GetAllProjectExtendsClasses();
6967
InitializeTree();
7068
InitializeTheme();
@@ -214,6 +212,18 @@ protected override void Navigate()
214212

215213
#region Event Handlers
216214

215+
protected override void OnShown(EventArgs e)
216+
{
217+
base.OnShown(e);
218+
if (Settings != null && Settings.HierarchyExplorerSize.Width > MinimumSize.Width) Size = Settings.HierarchyExplorerSize;
219+
}
220+
221+
protected override void OnFormClosing(FormClosingEventArgs e)
222+
{
223+
if (Settings == null) return;
224+
Settings.HierarchyExplorerSize = Size;
225+
}
226+
217227
protected override void OnKeyDown(KeyEventArgs e)
218228
{
219229
switch (e.KeyCode)
@@ -239,8 +249,6 @@ protected override void OnKeyDown(KeyEventArgs e)
239249
}
240250
}
241251

242-
protected override void OnFormClosing(FormClosingEventArgs e) => Settings.HierarchyExplorerSize = Size;
243-
244252
protected override void OnTreeNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
245253
{
246254
var node = e.Node as TypeNode;
@@ -290,7 +298,7 @@ void OnInputTextChanged(object sender, EventArgs e)
290298

291299
void OnInputPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
292300
{
293-
if (e.KeyCode == Keys.Apps) input.ContextMenu = SelectedNode != null ? InputEmptyContextMenu : null;
301+
if (e.KeyCode == Keys.Apps) input.ContextMenu = SelectedNode != null ? FormHelper.EmptyContextMenu : null;
294302
}
295303

296304
void OnInputKeyDown(object sender, KeyEventArgs e)

QuickNavigate/Forms/ClassModelExplorerForm.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

QuickNavigate/Forms/QuickOutlineForm.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public QuickOutlineForm([NotNull] FileModel inFile, [CanBeNull] ClassModel inCla
3434
InFile = inFile;
3535
InClass = inClass ?? ClassModel.VoidClass;
3636
this.settings = settings;
37-
Font = PluginBase.Settings.DefaultFont;
3837
InitializeComponent();
3938
if (settings.QuickOutlineSize.Width > MinimumSize.Width) Size = settings.QuickOutlineSize;
4039
InitializeTree();
@@ -168,18 +167,18 @@ void AddMembers(TreeNodeCollection nodes, MemberList members, bool isHaxe, bool
168167
tree.SelectedNode = nodes[0];
169168
}
170169

171-
void Navigate()
170+
protected override void Navigate()
172171
{
173172
if (SelectedNode != null) DialogResult = DialogResult.OK;
174173
}
175174

176-
void ShowContextMenu()
175+
protected override void ShowContextMenu()
177176
{
178177
if (!(SelectedNode is TypeNode)) return;
179178
ShowContextMenu(new Point(SelectedNode.Bounds.X, SelectedNode.Bounds.Bottom));
180179
}
181180

182-
void ShowContextMenu(Point position)
181+
protected override void ShowContextMenu(Point position)
183182
{
184183
if (!(SelectedNode is TypeNode)) return;
185184
contextMenu.Items.Clear();
@@ -335,7 +334,7 @@ void OnInputKeyDown(object sender, KeyEventArgs e)
335334
e.Handled = true;
336335
}
337336

338-
void OnTreeNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
337+
protected override void OnTreeNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
339338
{
340339
if (e.Button != MouseButtons.Right) return;
341340
TreeNode node = e.Node as TypeNode;

QuickNavigate/Forms/TypeExplorerForm.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace QuickNavigate.Forms
1717
{
18-
public sealed partial class TypeExplorerForm : ClassModelExplorerForm
18+
public sealed partial class TypeExplorerForm : QuickForm
1919
{
2020
[NotNull] readonly List<string> closedTypes = new List<string>();
2121
[NotNull] readonly List<string> openedTypes = new List<string>();
@@ -34,17 +34,11 @@ public sealed partial class TypeExplorerForm : ClassModelExplorerForm
3434
/// <param name="settings"></param>
3535
public TypeExplorerForm([NotNull] Settings settings) : base(settings)
3636
{
37-
Font = PluginBase.Settings.DefaultFont;
3837
InitializeComponent();
39-
if (settings.TypeExplorerSize.Width > MinimumSize.Width) Size = settings.TypeExplorerSize;
40-
searchingInExternalClasspaths.Checked = settings.TypeExplorerSearchExternalClassPath;
4138
CreateItemsList();
4239
InitializeTree();
4340
InitializeTheme();
4441
RefreshTree();
45-
timer.Interval = PluginBase.MainForm.Settings.DisplayDelay;
46-
timer.Tick += OnTimerTick;
47-
timer.Start();
4842
}
4943

5044
[CanBeNull] ToolTip filterToolTip;
@@ -335,7 +329,20 @@ protected override void OnKeyDown(KeyEventArgs e)
335329
break;
336330
}
337331
}
338-
332+
333+
protected override void OnShown(EventArgs e)
334+
{
335+
base.OnShown(e);
336+
if (Settings != null)
337+
{
338+
if (Settings.TypeExplorerSize.Width > MinimumSize.Width) Size = Settings.TypeExplorerSize;
339+
searchingInExternalClasspaths.Checked = Settings.TypeExplorerSearchExternalClassPath;
340+
}
341+
timer.Interval = PluginBase.MainForm.Settings.DisplayDelay;
342+
timer.Tick += OnTimerTick;
343+
timer.Start();
344+
}
345+
339346
protected override void OnFormClosing(FormClosingEventArgs e)
340347
{
341348
timer.Stop();
@@ -398,7 +405,7 @@ void OnTreeDrawNode(object sender, DrawTreeNodeEventArgs e)
398405

399406
void OnInputPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
400407
{
401-
if (e.KeyCode == Keys.Apps) input.ContextMenu = SelectedNode != null ? InputEmptyContextMenu : null;
408+
if (e.KeyCode == Keys.Apps) input.ContextMenu = SelectedNode != null ? FormHelper.EmptyContextMenu : null;
402409
}
403410

404411
void OnInputKeyDown(object sender, KeyEventArgs e)

QuickNavigate/Helpers/FormHelper.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Drawing;
23
using System.Linq;
34
using System.Windows.Forms;
45
using ASCompletion;
@@ -8,20 +9,58 @@
89
using PluginCore;
910
using PluginCore.Localization;
1011
using ProjectManager.Controls;
12+
using QuickNavigate.Forms;
1113
using WeifenLuo.WinFormsUI.Docking;
1214

1315
namespace QuickNavigate.Helpers
1416
{
15-
public abstract class QuickForm : Form
17+
public class QuickForm : Form
1618
{
19+
protected QuickForm() { }
20+
21+
protected QuickForm([NotNull] Settings settings)
22+
{
23+
Settings = settings;
24+
}
25+
26+
[CanBeNull] protected Settings Settings;
27+
1728
/// <summary>
1829
/// The currently selected tree node, or null if nothing is selected.
1930
/// </summary>
2031
[CanBeNull] public virtual TreeNode SelectedNode { get; }
32+
33+
protected virtual void Navigate()
34+
{
35+
}
36+
37+
/// <summary>
38+
/// Displays the shortcut menu.
39+
/// </summary>
40+
protected virtual void ShowContextMenu()
41+
{
42+
}
43+
44+
/// <summary>
45+
/// Displays the shortcut menu.
46+
/// </summary>
47+
protected virtual void ShowContextMenu(Point position)
48+
{
49+
}
50+
51+
protected virtual void OnTreeNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
52+
{
53+
if (e.Button != MouseButtons.Right) return;
54+
var node = e.Node as TypeNode;
55+
if (node == null) return;
56+
ShowContextMenu(new Point(e.Location.X, node.Bounds.Bottom));
57+
}
2158
}
2259

2360
class FormHelper
2461
{
62+
[NotNull] internal static readonly ContextMenu EmptyContextMenu = new ContextMenu();
63+
2564
public static bool IsFileOpened([NotNull] string fileName)
2665
{
2766
return PluginBase.MainForm.Documents.Any(it => it.FileName == fileName);

QuickNavigate/PluginMain.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,12 @@ void OnFormKeyUp(object sender, KeyEventArgs e)
434434
((Control) PluginBase.MainForm).BeginInvoke(invoker);
435435
}
436436

437-
void OnFormShown(object sender, EventArgs eventArgs) => openedForm = (QuickForm)sender;
437+
void OnFormShown(object sender, EventArgs eventArgs)
438+
{
439+
openedForm = (QuickForm) sender;
440+
openedForm.Font = PluginBase.Settings.DefaultFont;
441+
openedForm.ContextMenuStrip = new ContextMenuStrip {Renderer = new DockPanelStripRenderer(false)};
442+
}
438443

439444
void OnFormClosing(object sender, CancelEventArgs cancelEventArgs) => openedForm = null;
440445

QuickNavigate/QuickNavigate.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,11 @@
7979
</ItemGroup>
8080
<ItemGroup>
8181
<Compile Include="ControlClickManager.cs" />
82-
<Compile Include="Forms\ClassHierarchyForm.cs">
83-
<SubType>Form</SubType>
84-
</Compile>
82+
<Compile Include="Forms\ClassHierarchyForm.cs" />
8583
<Compile Include="Forms\ClassHierarchyForm.Designer.cs">
8684
<DependentUpon>ClassHierarchyForm.cs</DependentUpon>
8785
</Compile>
8886
<Compile Include="Collections\Comparers.cs" />
89-
<Compile Include="Forms\ClassModelExplorerForm.cs">
90-
<SubType>Form</SubType>
91-
</Compile>
9287
<Compile Include="Forms\Nodes.cs" />
9388
<Compile Include="Forms\OpenRecentProjectsForm.cs">
9489
<SubType>Form</SubType>

0 commit comments

Comments
 (0)