TBF : 'Previous' / 'Next' buttons in PreviousResultsDlg, ver. 2.18.1118

This commit is contained in:
Milan Hanajik
2019-01-22 15:50:37 +01:00
parent 2037f8bbe7
commit 8b2d01a5ac
7 changed files with 104 additions and 10 deletions
+26
View File
@@ -30,6 +30,8 @@
{ {
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.closeButton = new System.Windows.Forms.Button(); this.closeButton = new System.Windows.Forms.Button();
this.previousButton = new System.Windows.Forms.Button();
this.nextButton = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// flowLayoutPanel1 // flowLayoutPanel1
@@ -52,12 +54,34 @@
this.closeButton.UseVisualStyleBackColor = true; this.closeButton.UseVisualStyleBackColor = true;
this.closeButton.Click += new System.EventHandler(this.closeButton_Click); this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
// //
// previousButton
//
this.previousButton.Location = new System.Drawing.Point(1079, 82);
this.previousButton.Name = "previousButton";
this.previousButton.Size = new System.Drawing.Size(103, 37);
this.previousButton.TabIndex = 2;
this.previousButton.Text = "Previous";
this.previousButton.UseVisualStyleBackColor = true;
this.previousButton.Click += new System.EventHandler(this.previousButton_Click);
//
// nextButton
//
this.nextButton.Location = new System.Drawing.Point(1079, 125);
this.nextButton.Name = "nextButton";
this.nextButton.Size = new System.Drawing.Size(103, 37);
this.nextButton.TabIndex = 3;
this.nextButton.Text = "Next";
this.nextButton.UseVisualStyleBackColor = true;
this.nextButton.Click += new System.EventHandler(this.nextButton_Click);
//
// PreviousResultsDlg // PreviousResultsDlg
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.closeButton; this.CancelButton = this.closeButton;
this.ClientSize = new System.Drawing.Size(1194, 892); this.ClientSize = new System.Drawing.Size(1194, 892);
this.Controls.Add(this.nextButton);
this.Controls.Add(this.previousButton);
this.Controls.Add(this.closeButton); this.Controls.Add(this.closeButton);
this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.flowLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@@ -74,5 +98,7 @@
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button closeButton; private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Button previousButton;
private System.Windows.Forms.Button nextButton;
} }
} }
+40 -8
View File
@@ -19,6 +19,8 @@ namespace TBF.Forms
ISession session; ISession session;
int currentBatchNr; int currentBatchNr;
int lastDisplayedBatchNr;
const int LinesCount = 25;
IList<Batch> batches; IList<Batch> batches;
bool reloadEn; bool reloadEn;
@@ -54,20 +56,17 @@ namespace TBF.Forms
session = Results.DB.CreateSession(); session = Results.DB.CreateSession();
batches = session.QueryOver<Batch>() lastDisplayedBatchNr = currentBatchNr - 1;
.WhereRestrictionOn(x => x.BatchNr) DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr);
.IsBetween(Math.Max(1, currentBatchNr - 25)) UpdateButtons();
.And(Math.Max(1, currentBatchNr - 1))
.OrderBy(x => x.BatchNr).Asc
.List<Batch>();
Redraw();
} }
void Localize() void Localize()
{ {
Text = Strings.Previous_results; Text = Strings.Previous_results;
closeButton.Text = TBF.Resources.Strings.CloseBtnText; closeButton.Text = TBF.Resources.Strings.CloseBtnText;
previousButton.Text = TBF.Resources.Strings.Previous;
nextButton.Text = TBF.Resources.Strings.Next;
} }
@@ -250,6 +249,18 @@ namespace TBF.Forms
} }
void DrawBatches(int from, int to)
{
batches = session.QueryOver<Batch>()
.WhereRestrictionOn(x => x.BatchNr)
.IsBetween(Math.Max(1, from))
.And(Math.Min(to, currentBatchNr - 1))
.OrderBy(x => x.BatchNr).Asc
.List<Batch>();
Redraw();
}
void Redraw() void Redraw()
{ {
SuspendLayout(); SuspendLayout();
@@ -288,8 +299,29 @@ namespace TBF.Forms
private void closeButton_Click(object sender, EventArgs e) private void closeButton_Click(object sender, EventArgs e)
{ {
if (session != null) session.Close();
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
private void previousButton_Click(object sender, EventArgs e)
{
lastDisplayedBatchNr = Math.Max(lastDisplayedBatchNr - LinesCount, LinesCount);
DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr);
UpdateButtons();
}
private void nextButton_Click(object sender, EventArgs e)
{
lastDisplayedBatchNr = Math.Min(lastDisplayedBatchNr + LinesCount, currentBatchNr - 1);
DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr);
UpdateButtons();
}
private void UpdateButtons()
{
nextButton.Enabled = (lastDisplayedBatchNr < currentBatchNr - 1);
previousButton.Enabled = (lastDisplayedBatchNr > LinesCount);
}
} }
} }
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.18.1116.0")] [assembly: AssemblyVersion("2.18.1118.0")]
[assembly: AssemblyFileVersion("2.18.1116.0")] [assembly: AssemblyFileVersion("2.18.1118.0")]
+18
View File
@@ -2589,6 +2589,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Next.
/// </summary>
internal static string Next {
get {
return ResourceManager.GetString("Next", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Next test volume. /// Looks up a localized string similar to Next test volume.
/// </summary> /// </summary>
@@ -3030,6 +3039,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Previous.
/// </summary>
internal static string Previous {
get {
return ResourceManager.GetString("Previous", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Previous results. /// Looks up a localized string similar to Previous results.
/// </summary> /// </summary>
+6
View File
@@ -1359,4 +1359,10 @@
<data name="Enable_Remark" xml:space="preserve"> <data name="Enable_Remark" xml:space="preserve">
<value>Zobrazit poznámku</value> <value>Zobrazit poznámku</value>
</data> </data>
<data name="Next" xml:space="preserve">
<value>Následující</value>
</data>
<data name="Previous" xml:space="preserve">
<value>Předešlé</value>
</data>
</root> </root>
+6
View File
@@ -1452,4 +1452,10 @@
<data name="Reload_previous_results" xml:space="preserve"> <data name="Reload_previous_results" xml:space="preserve">
<value>Vorherige Ergebnisse Herunterladen</value> <value>Vorherige Ergebnisse Herunterladen</value>
</data> </data>
<data name="Next" xml:space="preserve">
<value>Nächste</value>
</data>
<data name="Previous" xml:space="preserve">
<value>Vorherige</value>
</data>
</root> </root>
+6
View File
@@ -1912,4 +1912,10 @@
<data name="Reload_previous_results" xml:space="preserve"> <data name="Reload_previous_results" xml:space="preserve">
<value>Reload previous results</value> <value>Reload previous results</value>
</data> </data>
<data name="Next" xml:space="preserve">
<value>Next</value>
</data>
<data name="Previous" xml:space="preserve">
<value>Previous</value>
</data>
</root> </root>