Permalink
Browse files

Add context menu to delete job in batch job grid.

  • Loading branch information...
1 parent 7eb2d1f commit 86e7ffba26f3350aaf1b12f154914fceba9a516e @Nandaka committed Mar 16, 2012
Showing with 80 additions and 28 deletions.
  1. +42 −20 DanbooruDownloader3/FormMain.Designer.cs
  2. +30 −7 DanbooruDownloader3/FormMain.cs
  3. +6 −0 DanbooruDownloader3/FormMain.resx
  4. +2 −1 readme.txt
@@ -128,13 +128,15 @@ private void InitializeComponent()
this.btnStopBatchJob = new System.Windows.Forms.Button();
this.btnStartBatchJob = new System.Windows.Forms.Button();
this.btnAddBatchJob = new System.Windows.Forms.Button();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
+ this.dgvBatchJob = new System.Windows.Forms.DataGridView();
this.colBatchId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colBatchTagQuery = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colBatchLimit = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colBatchProviders = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colBatchSaveFolder = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colBatchStatus = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.contextMenuStrip5 = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.deleteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.chkMinimizeTray = new System.Windows.Forms.CheckBox();
@@ -202,7 +204,8 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.dgvDownload)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
this.tabPage5.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.dgvBatchJob)).BeginInit();
+ this.contextMenuStrip5.SuspendLayout();
this.tabPage2.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -1141,7 +1144,7 @@ private void InitializeComponent()
this.tabPage5.Controls.Add(this.btnStopBatchJob);
this.tabPage5.Controls.Add(this.btnStartBatchJob);
this.tabPage5.Controls.Add(this.btnAddBatchJob);
- this.tabPage5.Controls.Add(this.dataGridView1);
+ this.tabPage5.Controls.Add(this.dgvBatchJob);
this.tabPage5.Location = new System.Drawing.Point(4, 22);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
@@ -1226,30 +1229,32 @@ private void InitializeComponent()
this.btnAddBatchJob.UseVisualStyleBackColor = true;
this.btnAddBatchJob.Click += new System.EventHandler(this.btnAddBatchJob_Click);
//
- // dataGridView1
+ // dgvBatchJob
//
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.AllowUserToDeleteRows = false;
- this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ this.dgvBatchJob.AllowUserToAddRows = false;
+ this.dgvBatchJob.AllowUserToDeleteRows = false;
+ this.dgvBatchJob.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.dgvBatchJob.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
+ this.dgvBatchJob.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dgvBatchJob.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colBatchId,
this.colBatchTagQuery,
this.colBatchLimit,
this.colBatchProviders,
this.colBatchSaveFolder,
this.colBatchStatus});
- this.dataGridView1.Location = new System.Drawing.Point(8, 35);
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.ShowCellErrors = false;
- this.dataGridView1.ShowCellToolTips = false;
- this.dataGridView1.ShowEditingIcon = false;
- this.dataGridView1.ShowRowErrors = false;
- this.dataGridView1.Size = new System.Drawing.Size(918, 311);
- this.dataGridView1.TabIndex = 0;
+ this.dgvBatchJob.ContextMenuStrip = this.contextMenuStrip5;
+ this.dgvBatchJob.Location = new System.Drawing.Point(8, 35);
+ this.dgvBatchJob.Name = "dgvBatchJob";
+ this.dgvBatchJob.ShowCellErrors = false;
+ this.dgvBatchJob.ShowCellToolTips = false;
+ this.dgvBatchJob.ShowEditingIcon = false;
+ this.dgvBatchJob.ShowRowErrors = false;
+ this.dgvBatchJob.Size = new System.Drawing.Size(918, 311);
+ this.dgvBatchJob.TabIndex = 0;
+ this.dgvBatchJob.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dgvBatchJob_MouseDown);
//
// colBatchId
//
@@ -1306,6 +1311,20 @@ private void InitializeComponent()
this.colBatchStatus.Name = "colBatchStatus";
this.colBatchStatus.ReadOnly = true;
//
+ // contextMenuStrip5
+ //
+ this.contextMenuStrip5.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.deleteToolStripMenuItem1});
+ this.contextMenuStrip5.Name = "contextMenuStrip5";
+ this.contextMenuStrip5.Size = new System.Drawing.Size(108, 26);
+ //
+ // deleteToolStripMenuItem1
+ //
+ this.deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1";
+ this.deleteToolStripMenuItem1.Size = new System.Drawing.Size(107, 22);
+ this.deleteToolStripMenuItem1.Text = "Delete";
+ this.deleteToolStripMenuItem1.Click += new System.EventHandler(this.deleteToolStripMenuItem1_Click);
+ //
// tabPage2
//
this.tabPage2.Controls.Add(this.groupBox2);
@@ -1845,7 +1864,8 @@ private void InitializeComponent()
this.contextMenuStrip1.ResumeLayout(false);
this.tabPage5.ResumeLayout(false);
this.tabPage5.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.dgvBatchJob)).EndInit();
+ this.contextMenuStrip5.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
@@ -1998,7 +2018,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem addSelectedRowsToolStripMenuItem;
private System.Windows.Forms.TabPage tabPage5;
private System.Windows.Forms.Button btnAddBatchJob;
- private System.Windows.Forms.DataGridView dataGridView1;
+ private System.Windows.Forms.DataGridView dgvBatchJob;
private System.Windows.Forms.Button btnStartBatchJob;
private System.Windows.Forms.Button btnStopBatchJob;
private System.Windows.Forms.CheckBox chkProxyLogin;
@@ -2016,6 +2036,8 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnPauseBatchJob;
private System.Windows.Forms.Button btnClearCompleted;
private System.Windows.Forms.Button btnClearAll;
+ private System.Windows.Forms.ContextMenuStrip contextMenuStrip5;
+ private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem1;
}
}
@@ -456,7 +456,7 @@ private void btnAddBatchJob_Click(object sender, EventArgs e)
batchJob = new BindingList<DanbooruBatchJob>();
}
batchJob.Add(job);
- dataGridView1.DataSource = batchJob;
+ dgvBatchJob.DataSource = batchJob;
}
}
@@ -486,7 +486,7 @@ private void btnStopBatchJob_Click(object sender, EventArgs e)
//StopBatchJobs();
batchJobThread.Abort();
ToggleBatchJobButton(true);
- dataGridView1.Refresh();
+ dgvBatchJob.Refresh();
}
}
@@ -672,6 +672,7 @@ public void DoBatchJob(BindingList<DanbooruBatchJob> batchJob)
catch (Exception ex)
{
batchJob[i].isError = true;
+ batchJob[i].isCompleted = false;
providerStatus += " Error: " + ex.Message + Environment.NewLine;
if (ex.Message.Contains("(403)") || ex.Message.Contains("(500)") || ex.Message.Contains("resolved"))
{
@@ -713,14 +714,14 @@ public void DoBatchJob(BindingList<DanbooruBatchJob> batchJob)
public delegate void UpdateUiDelegate();
public void UpdateUi()
{
- foreach (DataGridViewRow row in dataGridView1.Rows)
+ foreach (DataGridViewRow row in dgvBatchJob.Rows)
{
if (batchJob[row.Index].isError)
row.DefaultCellStyle.BackColor = Color.Red;
else if (batchJob[row.Index].isCompleted)
row.DefaultCellStyle.BackColor = Color.Lime;
}
- dataGridView1.Refresh();
+ dgvBatchJob.Refresh();
}
public delegate void UpdateUiDelegate2(int current, int total);
@@ -745,7 +746,7 @@ public void UpdateUi(int current, int total)
tsProgressBar.Visible = false;
}
statusStrip1.Refresh();
- dataGridView1.Refresh();
+ dgvBatchJob.Refresh();
}
public delegate void ToggleBatchJobButtonDelegate(bool enabled);
@@ -1217,13 +1218,35 @@ private void btnClearCompleted_Click(object sender, EventArgs e)
--i;
}
}
- dataGridView1.Refresh();
+ dgvBatchJob.Refresh();
}
private void btnClearAll_Click(object sender, EventArgs e)
{
batchJob.Clear();
- dataGridView1.Refresh();
+ dgvBatchJob.Refresh();
}
+
+ private void deleteToolStripMenuItem1_Click(object sender, EventArgs e)
+ {
+ if (dgvBatchJob.SelectedRows.Count > 0)
+ {
+ dgvBatchJob.Rows.Remove(dgvBatchJob.SelectedRows[0]);
+ }
+ }
+
+ private void dgvBatchJob_MouseDown(object sender, MouseEventArgs e)
+ {
+ if (e.Button == System.Windows.Forms.MouseButtons.Right)
+ {
+ var hti = dgvBatchJob.HitTest(e.X, e.Y);
+ dgvBatchJob.ClearSelection();
+ if (hti.RowIndex >= 0)
+ {
+ dgvBatchJob.Rows[hti.RowIndex].Selected = true;
+ }
+ }
+ }
+
}
}
@@ -242,6 +242,9 @@
<metadata name="colBatchStatus.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
+ <metadata name="contextMenuStrip5.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 96</value>
+ </metadata>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>561, 56</value>
</metadata>
@@ -854,6 +857,9 @@
AAAAAAAP//+AAAAAAB///8AAAAAAP///////////////////////////////////////////
</value>
</data>
+ <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>136</value>
+ </metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAUAEBAAAAAAIABoBAAAVgAAABgYAAAAACAAiAkAAL4EAAAgIAAAAAAgAKgQAABGDgAAMDAAAAAA
View
@@ -3,8 +3,9 @@ Changelog:
- DanbooruDownloader201203xx
- Add Clear All Batch Job as requested by Xemnarth.
- Fix Start Batch Job button state if abort on error is checked.
- - Add background color for batch job state.
+ - Add background color for batch job state (red == error, green == completed).
- Retain last entered job information (cleared when closing the application).
+ - Add context menu to delete job in batch job grid.
- DanbooruDownloader20120309
- Fix batch download limit detection as reported by Q.

0 comments on commit 86e7ffb

Please sign in to comment.