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

This commit is contained in:
Milan Hanajik 2019-01-22 13:07:36 +01:00
parent 2037f8bbe7
commit 8b2d01a5ac
7 changed files with 104 additions and 10 deletions

View File

@ -30,6 +30,8 @@
{
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.closeButton = new System.Windows.Forms.Button();
this.previousButton = new System.Windows.Forms.Button();
this.nextButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// flowLayoutPanel1
@ -52,12 +54,34 @@
this.closeButton.UseVisualStyleBackColor = true;
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.closeButton;
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.flowLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@ -74,5 +98,7 @@
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Button previousButton;
private System.Windows.Forms.Button nextButton;
}
}

View File

@ -19,6 +19,8 @@ namespace TBF.Forms
ISession session;
int currentBatchNr;
int lastDisplayedBatchNr;
const int LinesCount = 25;
IList<Batch> batches;
bool reloadEn;
@ -54,20 +56,17 @@ namespace TBF.Forms
session = Results.DB.CreateSession();
batches = session.QueryOver<Batch>()
.WhereRestrictionOn(x => x.BatchNr)
.IsBetween(Math.Max(1, currentBatchNr - 25))
.And(Math.Max(1, currentBatchNr - 1))
.OrderBy(x => x.BatchNr).Asc
.List<Batch>();
Redraw();
lastDisplayedBatchNr = currentBatchNr - 1;
DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr);
UpdateButtons();
}
void Localize()
{
Text = Strings.Previous_results;
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()
{
SuspendLayout();
@ -288,8 +299,29 @@ namespace TBF.Forms
private void closeButton_Click(object sender, EventArgs e)
{
if (session != null) session.Close();
DialogResult = DialogResult.Cancel;
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);
}
}
}

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.1116.0")]
[assembly: AssemblyFileVersion("2.18.1116.0")]
[assembly: AssemblyVersion("2.18.1118.0")]
[assembly: AssemblyFileVersion("2.18.1118.0")]

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>
/// Looks up a localized string similar to Next test volume.
/// </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>
/// Looks up a localized string similar to Previous results.
/// </summary>

View File

@ -1359,4 +1359,10 @@
<data name="Enable_Remark" xml:space="preserve">
<value>Zobrazit poznámku</value>
</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>

View File

@ -1452,4 +1452,10 @@
<data name="Reload_previous_results" xml:space="preserve">
<value>Vorherige Ergebnisse Herunterladen</value>
</data>
<data name="Next" xml:space="preserve">
<value>Nächste</value>
</data>
<data name="Previous" xml:space="preserve">
<value>Vorherige</value>
</data>
</root>

View File

@ -1912,4 +1912,10 @@
<data name="Reload_previous_results" xml:space="preserve">
<value>Reload previous results</value>
</data>
<data name="Next" xml:space="preserve">
<value>Next</value>
</data>
<data name="Previous" xml:space="preserve">
<value>Previous</value>
</data>
</root>