diff --git a/LibationWinForm/LibationWinForm.csproj b/LibationWinForm/LibationWinForm.csproj
index 194f5e60..c30a32f0 100644
--- a/LibationWinForm/LibationWinForm.csproj
+++ b/LibationWinForm/LibationWinForm.csproj
@@ -5,6 +5,7 @@
netcoreapp3.0
true
libation.ico
+ Libation
diff --git a/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.Designer.cs b/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.Designer.cs
index ddb03029..6d255828 100644
--- a/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.Designer.cs
+++ b/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.Designer.cs
@@ -202,7 +202,6 @@
this.libationFilesCustomRb.TabIndex = 3;
this.libationFilesCustomRb.TabStop = true;
this.libationFilesCustomRb.UseVisualStyleBackColor = true;
- this.libationFilesCustomRb.CheckedChanged += new System.EventHandler(this.libationFilesCustomRb_CheckedChanged);
//
// libationFilesMyDocsRb
//
diff --git a/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.cs b/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.cs
index 7c65f6c8..336cb837 100644
--- a/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.cs
+++ b/LibationWinForm/UNTESTED/Dialogs/SettingsDialog.cs
@@ -18,7 +18,11 @@ namespace LibationWinForm
public SettingsDialog()
{
InitializeComponent();
- audibleLocaleCb.SelectedIndex = 0;
+ this.libationFilesCustomTb.TextChanged += (_, __) =>
+ {
+ if (!string.IsNullOrWhiteSpace(libationFilesCustomTb.Text))
+ this.libationFilesCustomRb.Checked = true;
+ };
exeRoot = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Exe.FileLocationOnDisk), "Libation"));
myDocs = Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Libation"));
@@ -34,10 +38,16 @@ namespace LibationWinForm
this.decryptKeyTb.Text = config.DecryptKey;
this.decryptKeyDescLbl.Text = desc(nameof(config.DecryptKey));
- this.booksLocationTb.Text = config.Books;
+ this.booksLocationTb.Text
+ = !string.IsNullOrWhiteSpace(config.Books)
+ ? config.Books
+ : Path.GetDirectoryName(Exe.FileLocationOnDisk);
this.booksLocationDescLbl.Text = desc(nameof(config.Books));
- this.audibleLocaleCb.Text = config.LocaleCountryCode;
+ this.audibleLocaleCb.Text
+ = !string.IsNullOrWhiteSpace(config.LocaleCountryCode)
+ ? config.LocaleCountryCode
+ : "us";
libationFilesDescLbl.Text = desc(nameof(config.LibationFiles));
this.libationFilesRootRb.Text = "In the same folder that Libation is running from\r\n" + exeRoot;
@@ -80,13 +90,11 @@ namespace LibationWinForm
break;
}
- libationFiles_Changed(this, null);
+ libationFiles_Changed(this, null);
}
private void libationFiles_Changed(object sender, EventArgs e)
{
- Check_libationFilesCustom_RadioButton();
-
var libationFilesDir
= libationFilesRootRb.Checked ? exeRoot
: libationFilesMyDocsRb.Checked ? myDocs
@@ -101,14 +109,7 @@ namespace LibationWinForm
private void booksLocationSearchBtn_Click(object sender, EventArgs e) => selectFolder("Search for books location", this.booksLocationTb);
- private void libationFilesCustomBtn_Click(object sender, EventArgs e)
- {
- Check_libationFilesCustom_RadioButton();
- selectFolder("Search for Libation Files location", this.libationFilesCustomTb);
- }
- private void libationFilesCustomRb_CheckedChanged(object sender, EventArgs e) => Check_libationFilesCustom_RadioButton();
-
- private void Check_libationFilesCustom_RadioButton() => this.libationFilesCustomRb.Checked = true;
+ private void libationFilesCustomBtn_Click(object sender, EventArgs e) => selectFolder("Search for Libation Files location", this.libationFilesCustomTb);
private static void selectFolder(string desc, TextBox textbox)
{
diff --git a/LibationWinForm/UNTESTED/Form1.cs b/LibationWinForm/UNTESTED/Form1.cs
index e46f4032..6b1e486a 100644
--- a/LibationWinForm/UNTESTED/Form1.cs
+++ b/LibationWinForm/UNTESTED/Form1.cs
@@ -54,14 +54,43 @@ namespace LibationWinForm
}
}
- #region bottom: qty books visible
- public void SetVisibleCount(int qty, string luceneSearchString = null)
+ #region reload grid
+ bool isProcessingGridSelect = false;
+ private void reloadGrid()
{
- visibleCountLbl.Text = string.Format(visibleCountLbl_Format, qty);
+ // suppressed filter while init'ing UI
+ var prev_isProcessingGridSelect = isProcessingGridSelect;
+ isProcessingGridSelect = true;
+ setGrid();
+ isProcessingGridSelect = prev_isProcessingGridSelect;
- //if (!string.IsNullOrWhiteSpace(luceneSearchString))
- // visibleCountLbl.Text += " | " + luceneSearchString;
- }
+ // UI init complete. now we can apply filter
+ doFilter(lastGoodFilter);
+ }
+
+ ProductsGrid currProductsGrid;
+ private void setGrid()
+ {
+ SuspendLayout();
+ {
+ if (currProductsGrid != null)
+ {
+ gridPanel.Controls.Remove(currProductsGrid);
+ currProductsGrid.VisibleCountChanged -= setVisibleCount;
+ currProductsGrid.Dispose();
+ }
+
+ currProductsGrid = new ProductsGrid { Dock = DockStyle.Fill };
+ currProductsGrid.VisibleCountChanged += setVisibleCount;
+ gridPanel.Controls.Add(currProductsGrid);
+ currProductsGrid.Display();
+ }
+ ResumeLayout();
+ }
+ #endregion
+
+ #region bottom: qty books visible
+ private void setVisibleCount(object _, int qty) => visibleCountLbl.Text = string.Format(visibleCountLbl_Format, qty);
#endregion
#region bottom: backup counts
@@ -172,41 +201,8 @@ namespace LibationWinForm
}
#endregion
- #region reload grid
- bool isProcessingGridSelect = false;
- private void reloadGrid()
- {
- // suppressed filter while init'ing UI
- var prev_isProcessingGridSelect = isProcessingGridSelect;
- isProcessingGridSelect = true;
- setGrid();
- isProcessingGridSelect = prev_isProcessingGridSelect;
-
- // UI init complete. now we can apply filter
- doFilter(lastGoodFilter);
- }
-
- ProductsGrid currProductsGrid;
- private void setGrid()
- {
- SuspendLayout();
- {
- if (currProductsGrid != null)
- {
- gridPanel.Controls.Remove(currProductsGrid);
- currProductsGrid.Dispose();
- }
-
- currProductsGrid = new ProductsGrid(this) { Dock = DockStyle.Fill };
- gridPanel.Controls.Add(currProductsGrid);
- currProductsGrid.Display();
- }
- ResumeLayout();
- }
- #endregion
-
- #region filter
- private void filterHelpBtn_Click(object sender, EventArgs e) => new Dialogs.SearchSyntaxDialog().ShowDialog();
+ #region filter
+ private void filterHelpBtn_Click(object sender, EventArgs e) => new Dialogs.SearchSyntaxDialog().ShowDialog();
private void AddFilterBtn_Click(object sender, EventArgs e)
{
@@ -247,8 +243,7 @@ namespace LibationWinForm
MessageBox.Show($"Bad filter string:\r\n\r\n{ex.Message}", "Bad filter string", MessageBoxButtons.OK, MessageBoxIcon.Error);
// re-apply last good filter
- filterSearchTb.Text = lastGoodFilter;
- doFilter();
+ doFilter(lastGoodFilter);
}
}
#endregion
diff --git a/LibationWinForm/UNTESTED/ProductsGrid.cs b/LibationWinForm/UNTESTED/ProductsGrid.cs
index c55ed5e3..d97ab57b 100644
--- a/LibationWinForm/UNTESTED/ProductsGrid.cs
+++ b/LibationWinForm/UNTESTED/ProductsGrid.cs
@@ -22,13 +22,11 @@ namespace LibationWinForm
// - click on Data Sources > ProductItem. drowdown: DataGridView
// - drag/drop ProductItem on design surface
public partial class ProductsGrid : UserControl
- {
- private DataGridView dataGridView;
+ {
+ public event EventHandler VisibleCountChanged;
- private Form1 parent;
+ private DataGridView dataGridView;
- // this is a simple ctor for loading library and wish list. can expand later for other options. eg: overload ctor
- public ProductsGrid(Form1 parent) : this() => this.parent = parent;
public ProductsGrid() => InitializeComponent();
private bool hasBeenDisplayed = false;
@@ -54,7 +52,7 @@ namespace LibationWinForm
dataGridView.CellFormatting += replaceFormatted;
dataGridView.CellFormatting += hiddenFormatting;
// sorting breaks filters. must reapply filters after sorting
- dataGridView.Sorted += (_, __) => Filter();
+ dataGridView.Sorted += (_, __) => filter();
{ // add tag buttons
var editUserTagsButton = new DataGridViewButtonColumn { HeaderText = "Edit Tags" };
@@ -119,7 +117,7 @@ namespace LibationWinForm
//
// FILTER
//
- Filter();
+ filter();
}
private void paintEditTag_TextAndImage(object sender, DataGridViewCellPaintingEventArgs e)
@@ -184,7 +182,7 @@ namespace LibationWinForm
// needed to update text colors
dataGridView.InvalidateRow(e.RowIndex);
- Filter();
+ filter();
}
private static int saveChangedTags(Book book, string newTags)
@@ -232,11 +230,14 @@ namespace LibationWinForm
#region filter
string _filterSearchString;
- public void Filter() => Filter(_filterSearchString);
+ private void filter() => Filter(_filterSearchString);
public void Filter(string searchString)
{
_filterSearchString = searchString;
+ if (dataGridView.Rows.Count == 0)
+ return;
+
var searchResults = new LibationSearchEngine.SearchEngine().Search(searchString);
var productIds = searchResults.Docs.Select(d => d.ProductId).ToList();
@@ -248,11 +249,9 @@ namespace LibationWinForm
dataGridView.Rows[r].Visible = productIds.Contains(getGridEntry(r).GetBook().AudibleProductId);
}
currencyManager.ResumeBinding();
+ VisibleCountChanged?.Invoke(this, dataGridView.Rows.Cast().Count(r => r.Visible));
var luceneSearchString_debug = searchResults.SearchString;
-
- // after applying filters, display new visible count
- parent.SetVisibleCount(dataGridView.Rows.Cast().Count(r => r.Visible), luceneSearchString_debug);
}
#endregion
diff --git a/LibationWinForm/UNTESTED/Program.cs b/LibationWinForm/UNTESTED/Program.cs
index 73afaccf..c685e83c 100644
--- a/LibationWinForm/UNTESTED/Program.cs
+++ b/LibationWinForm/UNTESTED/Program.cs
@@ -5,29 +5,39 @@ namespace LibationWinForm
{
static class Program
{
- ///
- /// The main entry point for the application.
- ///
[STAThread]
static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
- if (string.IsNullOrWhiteSpace(FileManager.Configuration.Instance.Books))
- {
- var welcomeText = @"
+ if (!createSettings())
+ return;
+
+ Application.Run(new Form1());
+ }
+
+ private static bool createSettings()
+ {
+ if (!string.IsNullOrWhiteSpace(FileManager.Configuration.Instance.Books))
+ return true;
+
+ var welcomeText = @"
This appears to be your first time using Libation. Welcome.
-Please fill fill in a few settings on the following page. You can also change these settings later.
+Please fill in a few settings on the following page. You can also change these settings later.
After you make your selections, get started by importing your library.
Go to Import > Scan Library
".Trim();
- MessageBox.Show(welcomeText, "Welcom to Libation", MessageBoxButtons.OK);
- new SettingsDialog().ShowDialog();
+ MessageBox.Show(welcomeText, "Welcom to Libation", MessageBoxButtons.OK);
+ var dialogResult = new SettingsDialog().ShowDialog();
+ if (dialogResult != DialogResult.OK)
+ {
+ MessageBox.Show("Initial set up cancelled.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return false;
}
- Application.Run(new Form1());
- }
- }
+ return true;
+ }
+ }
}
diff --git a/WinFormsDesigner/WinFormsDesigner.csproj b/WinFormsDesigner/WinFormsDesigner.csproj
index 50f2f26a..fe3609f7 100644
--- a/WinFormsDesigner/WinFormsDesigner.csproj
+++ b/WinFormsDesigner/WinFormsDesigner.csproj
@@ -170,11 +170,4 @@
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
\ No newline at end of file
diff --git a/__TODO.txt b/__TODO.txt
index 83bb60d2..97176baa 100644
--- a/__TODO.txt
+++ b/__TODO.txt
@@ -1,4 +1,19 @@
-- begin BETA ---------------------------------------------------------------------------------------------------------------------
+if db present but no search files -- re-create
+
+make sure the new "if (dataGridView.Rows.Count == 0)" doesn't break filtering if all are invisible
+- load products. do a search with 0 results. do a search with results
+
+libation errors on another computer:
+ copy pw, LibationSettings.json
+ file not found. probably about file locations. the bottom right and bottom left counts don't update
+ ONLY file in libation files: IdentityTokens.json. no other files OR folders
+exception after library scan
+ file not found. same file?
+no mdf,ldf files created in C:\Users\[username]
+
+throttle needed for downloading images, pdf.s
+
Warn of known performance issues
- Library import
- Tag add/edit
@@ -6,6 +21,7 @@ Warn of known performance issues
- get decrypt key -- unavoidable
Create release version and installer
+https://dotnetcoretutorials.com/2019/06/20/publishing-a-single-exe-file-in-net-core-3-0/
-- end BETA ---------------------------------------------------------------------------------------------------------------------
-- begin ENHANCEMENT, IMPORT UI ---------------------------------------------------------------------------------------------------------------------