Skip to content

Commit

Permalink
Double-click tag type in tags tab to browse
Browse files Browse the repository at this point in the history
  • Loading branch information
electroly committed Nov 28, 2024
1 parent 5d323ec commit 6da7029
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
29 changes: 20 additions & 9 deletions src/J.App/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ TagsControl tagsControl
_tagsControl.Dock = DockStyle.Fill;
_tagsControl.TagTypeChanged += EditTagsControl_TagTypeChanged;
_tagsControl.TagChanged += EditTagsControl_TagChanged;
_tagsControl.TagTypeActivated += TagsControl_TagTypeActivated;
_tagsControl.TagActivated += TagsControl_TagActivated;
}

Expand Down Expand Up @@ -436,15 +437,6 @@ TagsControl tagsControl
KeyPreview = true;
}

private void TagsControl_TagActivated(object? sender, TagsControl.TagActivatedEventArgs e)
{
var query = HttpUtility.ParseQueryString("");
query["sessionPassword"] = _client.SessionPassword;
query["tagId"] = e.Id.Value;
SwitchTab(_browserTabButton);
Navigate($"/tag.html?{query}");
}

private void AboutButton_Click(object? sender, EventArgs e)
{
var assembly = typeof(MainForm).Assembly;
Expand Down Expand Up @@ -1460,4 +1452,23 @@ private void SwitchTab(ToolStripButton tab)
else if (isBrowser)
_browser.Focus();
}

private void TagsControl_TagTypeActivated(object? sender, TagsControl.TagTypeActivatedEventArgs e)
{
var query = HttpUtility.ParseQueryString("");
query["sessionPassword"] = _client.SessionPassword;
query["type"] = "TagType";
query["tagTypeId"] = e.Id.Value;
SwitchTab(_browserTabButton);
Navigate($"/list.html?{query}");
}

private void TagsControl_TagActivated(object? sender, TagsControl.TagActivatedEventArgs e)
{
var query = HttpUtility.ParseQueryString("");
query["sessionPassword"] = _client.SessionPassword;
query["tagId"] = e.Id.Value;
SwitchTab(_browserTabButton);
Navigate($"/tag.html?{query}");
}
}
7 changes: 6 additions & 1 deletion src/J.App/TagsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ public sealed class TagsControl : UserControl
public event EventHandler? TagTypeChanged;
public event EventHandler? TagChanged;

public readonly record struct TagTypeActivatedEventArgs(TagTypeId Id);

public readonly record struct TagActivatedEventArgs(TagId Id);

public event EventHandler<TagTypeActivatedEventArgs>? TagTypeActivated;
public event EventHandler<TagActivatedEventArgs>? TagActivated;

public TagsControl(LibraryProviderAdapter libraryProvider, IServiceProvider serviceProvider)
Expand Down Expand Up @@ -318,7 +321,9 @@ private void LeftNewGroupButton_Click(object? sender, EventArgs e)

private void LeftGrid_CellDoubleClick(object? sender, DataGridViewCellEventArgs e)
{
RenameTagType();
var tagType = GetSelectedTagType();
if (tagType.HasValue)
TagTypeActivated?.Invoke(this, new(tagType.Value.Id));
}

private void LeftRenameGroupButton_Click(object? sender, EventArgs e)
Expand Down

0 comments on commit 6da7029

Please sign in to comment.