-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: jonko0493 <[email protected]>
- Loading branch information
1 parent
62bc65b
commit 519f53c
Showing
12 changed files
with
411 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Eto.Forms; | ||
using HaruhiChokuretsuLib.Util; | ||
using SerialLoops.Lib; | ||
using SerialLoops.Lib.Items; | ||
using System; | ||
|
||
namespace SerialLoops.Controls | ||
{ | ||
internal class ItemContextMenu : ContextMenu | ||
{ | ||
|
||
private readonly ILogger _log; | ||
private readonly Project _project; | ||
|
||
private readonly EditorTabsPanel _tabs; | ||
private readonly ItemExplorerPanel _explorer; | ||
|
||
public ItemContextMenu(Project project, ItemExplorerPanel explorer, EditorTabsPanel tabs, ILogger log) | ||
{ | ||
_project = project; | ||
_tabs = tabs; | ||
_explorer = explorer; | ||
_log = log; | ||
|
||
Command openCommand = new(); | ||
openCommand.Executed += OpenCommand_OnClick; | ||
Items.Add(new ButtonMenuItem { Text = "Open", Command = openCommand }); | ||
|
||
Command findReferences = new(); | ||
findReferences.Executed += FindReferences_OnClick; | ||
Items.Add(new ButtonMenuItem { Text = "Find References...", Command = findReferences }); | ||
|
||
Command findReferencedBy = new(); | ||
findReferencedBy.Executed += FindReferencedBy_OnClick; | ||
Items.Add(new ButtonMenuItem { Text = "Find Referenced By...", Command = findReferencedBy }); | ||
} | ||
|
||
private void OpenCommand_OnClick(object sender, EventArgs args) | ||
{ | ||
ItemDescription item = _project.FindItem(_explorer.Viewer.SelectedItem?.Text); | ||
if (item != null) | ||
{ | ||
_tabs.OpenTab(item, _log); | ||
} | ||
} | ||
|
||
private void FindReferences_OnClick(object sender, EventArgs args) | ||
{ | ||
ShowReferences(ReferenceDialog.ReferenceMode.REFERENCES_TO); | ||
} | ||
|
||
private void FindReferencedBy_OnClick(object sender, EventArgs args) | ||
{ | ||
ShowReferences(ReferenceDialog.ReferenceMode.REFERENCED_BY); | ||
} | ||
|
||
private void ShowReferences(ReferenceDialog.ReferenceMode mode) | ||
{ | ||
ItemDescription item = _project.FindItem(_explorer.Viewer.SelectedItem?.Text); | ||
if (item != null) | ||
{ | ||
ReferenceDialog referenceDialog = new(item, mode, _project, _explorer, _tabs, _log); | ||
referenceDialog.ShowModal(_explorer); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Eto.Drawing; | ||
using Eto.Forms; | ||
using HaruhiChokuretsuLib.Util; | ||
using SerialLoops.Lib; | ||
using SerialLoops.Lib.Items; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SerialLoops.Controls | ||
{ | ||
public abstract class ItemListPanel : Scrollable | ||
{ | ||
public List<ItemDescription> Items | ||
{ | ||
protected get { return _items; } | ||
set | ||
{ | ||
_items = value; | ||
Viewer?.SetContents(GetSections(), _expandItems); | ||
} | ||
} | ||
public SectionListTreeGridView Viewer { get; private set; } | ||
|
||
protected ILogger _log; | ||
private readonly Size _size; | ||
private List<ItemDescription> _items; | ||
private readonly bool _expandItems; | ||
|
||
protected ItemListPanel(List<ItemDescription> items, Size size, bool expandItems, ILogger log) | ||
{ | ||
Items = items; | ||
_log = log; | ||
_size = size; | ||
_expandItems = expandItems; | ||
InitializeComponent(); | ||
} | ||
|
||
void InitializeComponent() | ||
{ | ||
Viewer = new SectionListTreeGridView(GetSections(), _size, _expandItems); | ||
MinimumSize = _size; | ||
Padding = 0; | ||
Content = new TableLayout(Viewer.Control); | ||
Viewer.Activated += ItemList_ItemClicked; | ||
} | ||
|
||
private IEnumerable<Section> GetSections() | ||
{ | ||
return Items.GroupBy(i => i.Type).OrderBy(g => g.Key) | ||
.Select(g => new Section($"{g.Key}s", g.Select(i => new Section() { Text = i.Name }), EditorTabsPanel.GetItemIcon(g.Key, _log))); | ||
} | ||
|
||
protected abstract void ItemList_ItemClicked(object sender, EventArgs e); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Eto.Drawing; | ||
using Eto.Forms; | ||
using HaruhiChokuretsuLib.Util; | ||
using SerialLoops.Lib; | ||
using SerialLoops.Lib.Items; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace SerialLoops.Controls | ||
{ | ||
public class ItemResultsPanel : ItemListPanel | ||
{ | ||
public FindItemsDialog Dialog; | ||
public ItemResultsPanel(List<ItemDescription> results, ILogger log) : base(results, new Size(280, 185), true, log) { } | ||
|
||
protected override void ItemList_ItemClicked(object sender, EventArgs e) | ||
{ | ||
if (sender is SectionListTreeGridView view) | ||
{ | ||
ItemDescription item = Dialog.Project.FindItem(view.SelectedItem?.Text); | ||
if (item != null) | ||
{ | ||
Dialog.Tabs.OpenTab(item, _log); | ||
} | ||
Dialog.Close(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Eto.Forms; | ||
using HaruhiChokuretsuLib.Util; | ||
using SerialLoops.Controls; | ||
using SerialLoops.Lib; | ||
using SerialLoops.Lib.Logging; | ||
using System; | ||
|
||
namespace SerialLoops | ||
{ | ||
public abstract class FindItemsDialog : Dialog | ||
{ | ||
public ILogger Log; | ||
public EditorTabsPanel Tabs; | ||
public ItemExplorerPanel Explorer; | ||
public Project Project; | ||
|
||
protected override void OnLoad(EventArgs e) | ||
{ | ||
if (Log is null) | ||
{ | ||
// We can't log that log is null, so we have to throw | ||
throw new LoggerNullException(); | ||
} | ||
if (Project is null) | ||
{ | ||
Log.LogError($"Project not provided to project creation dialog"); | ||
Close(); | ||
} | ||
if (Tabs is null) | ||
{ | ||
Log.LogError($"Editor Tabs not provided to project creation dialog"); | ||
Close(); | ||
} | ||
base.OnLoad(e); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using Eto.Forms; | ||
using Eto.Drawing; | ||
using System.Collections.Generic; | ||
|
||
namespace SerialLoops | ||
{ | ||
public partial class ReferenceDialog : FindItemsDialog | ||
{ | ||
public ReferenceDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
Oops, something went wrong.