New feature #406 : Right Click Menu for Stop-Light Icon (Classic UI)
This commit is contained in:
parent
749173a463
commit
d1528a095b
@ -338,6 +338,7 @@ namespace ApplicationServices
|
||||
|
||||
#region remove books
|
||||
public static Task<List<LibraryBook>> RemoveBooksAsync(List<string> idsToRemove) => Task.Run(() => removeBooks(idsToRemove));
|
||||
public static List<LibraryBook> RemoveBook(string idToRemove) => removeBooks(new() { idToRemove });
|
||||
private static List<LibraryBook> removeBooks(List<string> idsToRemove)
|
||||
{
|
||||
using var context = DbContexts.GetContext();
|
||||
|
||||
@ -26,7 +26,7 @@ namespace LibationWinForms.GridView
|
||||
[Browsable(false)] public float SeriesIndex { get; protected set; }
|
||||
[Browsable(false)] public string LongDescription { get; protected set; }
|
||||
[Browsable(false)] public abstract DateTime DateAdded { get; }
|
||||
[Browsable(false)] protected Book Book => LibraryBook.Book;
|
||||
[Browsable(false)] public Book Book => LibraryBook.Book;
|
||||
|
||||
[Browsable(false)] public abstract bool IsSeries { get; }
|
||||
[Browsable(false)] public abstract bool IsEpisode { get; }
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
this.myRatingGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.miscGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.tagAndDetailsGVColumn = new LibationWinForms.GridView.EditTagsDataGridViewImageButtonColumn();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.showHideColumnsContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.syncBindingSource = new LibationWinForms.GridView.SyncBindingSource(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.syncBindingSource)).BeginInit();
|
||||
@ -76,7 +76,7 @@
|
||||
this.myRatingGVColumn,
|
||||
this.miscGVColumn,
|
||||
this.tagAndDetailsGVColumn});
|
||||
this.gridEntryDataGridView.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.gridEntryDataGridView.ContextMenuStrip = this.showHideColumnsContextMenuStrip;
|
||||
this.gridEntryDataGridView.DataSource = this.syncBindingSource;
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
|
||||
@ -224,10 +224,10 @@
|
||||
this.tagAndDetailsGVColumn.Resizable = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.tagAndDetailsGVColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
|
||||
//
|
||||
// contextMenuStrip1
|
||||
// showHideColumnsContextMenuStrip
|
||||
//
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
|
||||
this.showHideColumnsContextMenuStrip.Name = "contextMenuStrip1";
|
||||
this.showHideColumnsContextMenuStrip.Size = new System.Drawing.Size(181, 26);
|
||||
//
|
||||
// syncBindingSource
|
||||
//
|
||||
@ -251,7 +251,7 @@
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.DataGridView gridEntryDataGridView;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.ContextMenuStrip showHideColumnsContextMenuStrip;
|
||||
private SyncBindingSource syncBindingSource;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn removeGVColumn;
|
||||
private LiberateDataGridViewImageButtonColumn liberateGVColumn;
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using ApplicationServices;
|
||||
using DataLayer;
|
||||
using Dinah.Core.WindowsDesktop.Forms;
|
||||
using LibationFileManager;
|
||||
@ -102,7 +103,9 @@ namespace LibationWinForms.GridView
|
||||
|
||||
private void gridEntryDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
|
||||
{
|
||||
var dgv = (DataGridView)sender;
|
||||
// header
|
||||
if (e.RowIndex < 0)
|
||||
return;
|
||||
|
||||
// cover
|
||||
if (e.ColumnIndex == coverGVColumn.Index)
|
||||
@ -116,6 +119,7 @@ namespace LibationWinForms.GridView
|
||||
{
|
||||
try
|
||||
{
|
||||
var dgv = (DataGridView)sender;
|
||||
var text = dgv[e.ColumnIndex, e.RowIndex].Value.ToString();
|
||||
InteropFactory.Create().CopyTextToClipboard(text);
|
||||
}
|
||||
@ -132,19 +136,54 @@ namespace LibationWinForms.GridView
|
||||
if (entry.IsSeries)
|
||||
return;
|
||||
|
||||
// \Visual Studio 2022\Libation\Source\LibationAvalonia\Views\ProductsDisplay.axaml
|
||||
/*
|
||||
<ContextMenu IsVisible="{Binding !Liberate.IsSeries}">
|
||||
<MenuItem Header="Item 1" Click="ContextMenuItem1_Click" />
|
||||
<MenuItem Header="Item 2" Click="ContextMenuItem2_Click" />
|
||||
<MenuItem Header="Item 3" Click="ContextMenuItem3_Click" />
|
||||
</ContextMenu>
|
||||
*/
|
||||
//var contextMenu = new ContextMenuStrip();
|
||||
//contextMenu.Items.Add("Item 1");
|
||||
//contextMenu.Items.Add("Item 2");
|
||||
//contextMenu.Items.Add("Item 3");
|
||||
//e.ContextMenuStrip = contextMenu;
|
||||
var stopLightContextMenu = new ContextMenuStrip();
|
||||
e.ContextMenuStrip = stopLightContextMenu;
|
||||
{
|
||||
var menuItem = new ToolStripMenuItem()
|
||||
{
|
||||
Text = "Set Download status to 'Downloaded'",
|
||||
Enabled = entry.Book.UserDefinedItem.BookStatus != LiberatedStatus.Liberated
|
||||
};
|
||||
menuItem.Click += (_, __) => entry.Book.UpdateBookStatus(LiberatedStatus.Liberated);
|
||||
stopLightContextMenu.Items.Add(menuItem);
|
||||
}
|
||||
{
|
||||
var menuItem = new ToolStripMenuItem()
|
||||
{
|
||||
Text = "Set Download status to 'Not Downloaded'",
|
||||
Enabled = entry.Book.UserDefinedItem.BookStatus != LiberatedStatus.NotLiberated
|
||||
};
|
||||
menuItem.Click += (_, __) => entry.Book.UpdateBookStatus(LiberatedStatus.NotLiberated);
|
||||
stopLightContextMenu.Items.Add(menuItem);
|
||||
}
|
||||
{
|
||||
var menuItem = new ToolStripMenuItem() { Text = "Remove from library" };
|
||||
menuItem.Click += (_, __) => LibraryCommands.RemoveBook(entry.AudibleProductId);
|
||||
stopLightContextMenu.Items.Add(menuItem);
|
||||
}
|
||||
{
|
||||
var menuItem = new ToolStripMenuItem() { Text = "Locate file..." };
|
||||
menuItem.Click += (_, __) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Title = $"Locate the audiofile for '{entry.Book.Title}'",
|
||||
Filter = "All files (*.*)|*.*",
|
||||
FilterIndex = 1
|
||||
};
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
FilePathCache.Insert(entry.AudibleProductId, openFileDialog.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = "Error saving book's location";
|
||||
MessageBoxLib.ShowAdminAlert(this, msg, msg, ex);
|
||||
}
|
||||
};
|
||||
stopLightContextMenu.Items.Add(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
private GridEntry getGridEntry(int rowIndex) => gridEntryDataGridView.GetBoundItem<GridEntry>(rowIndex);
|
||||
@ -362,8 +401,8 @@ namespace LibationWinForms.GridView
|
||||
gridEntryDataGridView.ColumnWidthChanged += gridEntryDataGridView_ColumnWidthChanged;
|
||||
gridEntryDataGridView.ColumnDisplayIndexChanged += gridEntryDataGridView_ColumnDisplayIndexChanged;
|
||||
|
||||
contextMenuStrip1.Items.Add(new ToolStripLabel("Show / Hide Columns"));
|
||||
contextMenuStrip1.Items.Add(new ToolStripSeparator());
|
||||
showHideColumnsContextMenuStrip.Items.Add(new ToolStripLabel("Show / Hide Columns"));
|
||||
showHideColumnsContextMenuStrip.Items.Add(new ToolStripSeparator());
|
||||
|
||||
//Restore Grid Display Settings
|
||||
var config = Configuration.Instance;
|
||||
@ -385,11 +424,11 @@ namespace LibationWinForms.GridView
|
||||
Tag = itemName
|
||||
};
|
||||
menuItem.Click += HideMenuItem_Click;
|
||||
contextMenuStrip1.Items.Add(menuItem);
|
||||
showHideColumnsContextMenuStrip.Items.Add(menuItem);
|
||||
|
||||
column.Width = gridColumnsWidths.GetValueOrDefault(itemName, column.Width);
|
||||
column.MinimumWidth = 10;
|
||||
column.HeaderCell.ContextMenuStrip = contextMenuStrip1;
|
||||
column.HeaderCell.ContextMenuStrip = showHideColumnsContextMenuStrip;
|
||||
column.Visible = visible;
|
||||
|
||||
//Setting a default ContextMenuStrip will allow the columns to handle the
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
<metadata name="removeGVColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<metadata name="showHideColumnsContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>171, 17</value>
|
||||
</metadata>
|
||||
<metadata name="syncBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user