Skip to content

Commit 5798719

Browse files
author
SlavaRa
committed
WIP
1 parent 7083760 commit 5798719

File tree

6 files changed

+41
-36
lines changed

6 files changed

+41
-36
lines changed

QuickNavigate/Forms/ClassHierarchyForm.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,10 @@ namespace QuickNavigate.Forms
88
public class ClassModelExplorerForm : QuickForm
99
{
1010
[NotNull] protected readonly Settings Settings;
11-
[NotNull] protected readonly ContextMenu InputEmptyContextMenu = new ContextMenu();
1211

1312
public ClassModelExplorerForm([NotNull] Settings settings)
1413
{
1514
Settings = settings;
16-
InitializeContextMenu();
17-
}
18-
19-
protected override void Dispose(bool disposing)
20-
{
21-
if (disposing)
22-
{
23-
InputEmptyContextMenu.Dispose();
24-
}
25-
base.Dispose(disposing);
26-
}
27-
28-
protected virtual void InitializeContextMenu()
29-
{
30-
ContextMenuStrip = new ContextMenuStrip {Renderer = new DockPanelStripRenderer(false)};
31-
}
32-
33-
protected virtual void Navigate()
34-
{
3515
}
3616

3717
/// <summary>

QuickNavigate/Forms/QuickOutlineForm.cs

Lines changed: 1 addition & 2 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,7 +167,7 @@ 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
}

QuickNavigate/Forms/TypeExplorerForm.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ public abstract class QuickForm : Form
1818
/// The currently selected tree node, or null if nothing is selected.
1919
/// </summary>
2020
[CanBeNull] public virtual TreeNode SelectedNode { get; }
21+
22+
protected virtual void Navigate()
23+
{
24+
}
2125
}
2226

2327
class FormHelper
2428
{
29+
[NotNull] internal static readonly ContextMenu EmptyContextMenu = new ContextMenu();
30+
2531
public static bool IsFileOpened([NotNull] string fileName)
2632
{
2733
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

0 commit comments

Comments
 (0)