From 49d10273a68ecde6d40e3139591d3f58e64ca8fa Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sat, 14 May 2022 20:44:53 -0600 Subject: [PATCH] Add button to hide queue --- Source/LibationWinForms/Form1.Designer.cs | 21 +++++++-- Source/LibationWinForms/Form1.ProcessQueue.cs | 46 +++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/Source/LibationWinForms/Form1.Designer.cs b/Source/LibationWinForms/Form1.Designer.cs index de58e88f..66f1cb4e 100644 --- a/Source/LibationWinForms/Form1.Designer.cs +++ b/Source/LibationWinForms/Form1.Designer.cs @@ -72,6 +72,7 @@ this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel(); this.addQuickFilterBtn = new System.Windows.Forms.Button(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.hideQueueBtn = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); this.processBookQueue1 = new LibationWinForms.ProcessQueue.ProcessQueueControl(); this.menuStrip1.SuspendLayout(); @@ -106,8 +107,8 @@ // filterBtn // this.filterBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.filterBtn.Location = new System.Drawing.Point(791, 27); - this.filterBtn.Margin = new System.Windows.Forms.Padding(4, 3, 15, 3); + this.filterBtn.Location = new System.Drawing.Point(750, 27); + this.filterBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.filterBtn.Name = "filterBtn"; this.filterBtn.Size = new System.Drawing.Size(88, 27); this.filterBtn.TabIndex = 2; @@ -122,7 +123,7 @@ this.filterSearchTb.Location = new System.Drawing.Point(194, 30); this.filterSearchTb.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.filterSearchTb.Name = "filterSearchTb"; - this.filterSearchTb.Size = new System.Drawing.Size(589, 23); + this.filterSearchTb.Size = new System.Drawing.Size(548, 23); this.filterSearchTb.TabIndex = 1; this.filterSearchTb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.filterSearchTb_KeyPress); // @@ -443,6 +444,7 @@ // // splitContainer1.Panel1 // + this.splitContainer1.Panel1.Controls.Add(this.hideQueueBtn); this.splitContainer1.Panel1.Controls.Add(this.panel1); this.splitContainer1.Panel1.Controls.Add(this.menuStrip1); this.splitContainer1.Panel1.Controls.Add(this.filterSearchTb); @@ -459,6 +461,18 @@ this.splitContainer1.SplitterWidth = 8; this.splitContainer1.TabIndex = 7; // + // hideQueueBtn + // + this.hideQueueBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.hideQueueBtn.Location = new System.Drawing.Point(846, 27); + this.hideQueueBtn.Margin = new System.Windows.Forms.Padding(4, 3, 15, 3); + this.hideQueueBtn.Name = "hideQueueBtn"; + this.hideQueueBtn.Size = new System.Drawing.Size(33, 27); + this.hideQueueBtn.TabIndex = 8; + this.hideQueueBtn.Text = "❰❰❰"; + this.hideQueueBtn.UseVisualStyleBackColor = true; + this.hideQueueBtn.Click += new System.EventHandler(this.HideQueueBtn_Click); + // // panel1 // this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -554,5 +568,6 @@ private System.Windows.Forms.SplitContainer splitContainer1; private LibationWinForms.ProcessQueue.ProcessQueueControl processBookQueue1; private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button hideQueueBtn; } } diff --git a/Source/LibationWinForms/Form1.ProcessQueue.cs b/Source/LibationWinForms/Form1.ProcessQueue.cs index f2379cd5..2954f224 100644 --- a/Source/LibationWinForms/Form1.ProcessQueue.cs +++ b/Source/LibationWinForms/Form1.ProcessQueue.cs @@ -2,6 +2,8 @@ using LibationFileManager; using LibationWinForms.ProcessQueue; using System; +using System.Linq; +using System.Threading.Tasks; using System.Windows.Forms; namespace LibationWinForms @@ -12,6 +14,42 @@ namespace LibationWinForms { productsGrid.LiberateClicked += (_, lb) => processBookQueue1.AddDownloadDecrypt(lb); processBookQueue1.popoutBtn.Click += ProcessBookQueue1_PopOut; + + Task.Run(() => + { + Task.Delay(3000).Wait(); + var lb = ApplicationServices.DbContexts.GetLibrary_Flat_NoTracking().Select(lb => lb.Book).ToList(); + + foreach (var b in lb) + { + b.UserDefinedItem.BookStatus = DataLayer.LiberatedStatus.NotLiberated; + } + LibraryCommands.UpdateUserDefinedItem(lb); + + }); + + } + + int WidthChange = 0; + private void HideQueueBtn_Click(object sender, EventArgs e) + { + if (splitContainer1.Panel2Collapsed) + { + WidthChange = WidthChange == 0 ? splitContainer1.Panel2.Width + splitContainer1.SplitterWidth : WidthChange; + Width += WidthChange; + splitContainer1.Panel2.Controls.Add(processBookQueue1); + splitContainer1.Panel2Collapsed = false; + processBookQueue1.popoutBtn.Visible = true; + hideQueueBtn.Text = "❰❰❰"; + } + else + { + WidthChange = splitContainer1.Panel2.Width + splitContainer1.SplitterWidth; + splitContainer1.Panel2.Controls.Remove(processBookQueue1); + splitContainer1.Panel2Collapsed = true; + Width -= WidthChange; + hideQueueBtn.Text = "❱❱❱"; + } } private void ProcessBookQueue1_PopOut(object sender, EventArgs e) @@ -26,6 +64,10 @@ namespace LibationWinForms dockForm.PassControl(processBookQueue1); dockForm.Show(); this.Width -= dockForm.WidthChange; + hideQueueBtn.Visible = false; + int deltax = filterBtn.Margin.Right + hideQueueBtn.Width + hideQueueBtn.Margin.Left; + filterBtn.Location= new System.Drawing.Point(filterBtn.Location.X + deltax, filterBtn.Location.Y); + filterSearchTb.Location = new System.Drawing.Point(filterSearchTb.Location.X + deltax, filterSearchTb.Location.Y); } private void DockForm_FormClosing(object sender, FormClosingEventArgs e) @@ -38,6 +80,10 @@ namespace LibationWinForms processBookQueue1.popoutBtn.Visible = true; dockForm.SaveSizeAndLocation(Configuration.Instance); this.Focus(); + hideQueueBtn.Visible = true; + int deltax = filterBtn.Margin.Right + hideQueueBtn.Width + hideQueueBtn.Margin.Left; + filterBtn.Location = new System.Drawing.Point(filterBtn.Location.X - deltax, filterBtn.Location.Y); + filterSearchTb.Location = new System.Drawing.Point(filterSearchTb.Location.X - deltax, filterSearchTb.Location.Y); } } }