From ad858266d5a592a2ac1082deb7b333622cdb2fca Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 23 Nov 2017 15:10:01 +0100 Subject: [PATCH] StandardCamera.TestStartEndForm : Image rotation, ver. 2.17.749 --- .../StandardCamera/TestStartEndForm.cs | 60 ++++++++++++++++++- .../TestStartEndForm.designer.cs | 20 ++++++- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- TestBenchFramework/Resources/Strings.de.resx | 2 +- 4 files changed, 78 insertions(+), 8 deletions(-) diff --git a/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs b/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs index 6db7786de..0a7bbf262 100644 --- a/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs +++ b/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.cs @@ -20,6 +20,15 @@ namespace TBF.BenchControl.DataEntry.StandardCamera Deferred, } + enum Rotation + { + R0, + R90, + R180, + R270, + Count + } + public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted { private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm)); @@ -51,7 +60,8 @@ namespace TBF.BenchControl.DataEntry.StandardCamera string lastImageName; Bitmap lastImage; /// non-zoomed image - Bitmap zoomedImage; + static Rotation imageRotation; + Bitmap zoomedImage; bool zoom; @@ -677,7 +687,24 @@ namespace TBF.BenchControl.DataEntry.StandardCamera /// Load the image in a way is does not lock the file on the disk using (var tempBmp = new Bitmap(lastImageName)) { - pictureBox1.Image = lastImage = new Bitmap(tempBmp); + switch (imageRotation) + { + case Rotation.R0: + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(160, 0, 960, 960), tempBmp.PixelFormat)); + break; + case Rotation.R90: + tempBmp.RotateFlip(RotateFlipType.Rotate270FlipNone); + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(0, 160, 960, 960), tempBmp.PixelFormat)); + break; + case Rotation.R180: + tempBmp.RotateFlip(RotateFlipType.Rotate180FlipNone); + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(160, 0, 960, 960), tempBmp.PixelFormat)); + break; + case Rotation.R270: + tempBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(0, 160, 960, 960), tempBmp.PixelFormat)); + break; + } } } zoom = false; @@ -794,5 +821,34 @@ namespace TBF.BenchControl.DataEntry.StandardCamera return string.Format("{0} l", 1 / pulsesPerLtr); } } + + private void rotateImageButton_Click(object sender, EventArgs e) + { + if (++imageRotation == Rotation.Count) imageRotation = Rotation.R0; + /// Load the image in a way is does not lock the file on the disk + + /// Load the image in a way is does not lock the file on the disk + using (var tempBmp = new Bitmap(lastImageName)) + { + switch (imageRotation) + { + case Rotation.R0: + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(160, 0, 960, 960), tempBmp.PixelFormat)); + break; + case Rotation.R90: + tempBmp.RotateFlip(RotateFlipType.Rotate270FlipNone); + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(0, 160, 960, 960), tempBmp.PixelFormat)); + break; + case Rotation.R180: + tempBmp.RotateFlip(RotateFlipType.Rotate180FlipNone); + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(160, 0, 960, 960), tempBmp.PixelFormat)); + break; + case Rotation.R270: + tempBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); + pictureBox1.Image = lastImage = new Bitmap(tempBmp.Clone(new Rectangle(0, 160, 960, 960), tempBmp.PixelFormat)); + break; + } + } + } } } diff --git a/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.designer.cs b/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.designer.cs index c109c3c89..5fbb9f1ea 100644 --- a/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.designer.cs +++ b/TestBenchFramework/BenchControl/DataEntry/StandardCamera/TestStartEndForm.designer.cs @@ -133,6 +133,7 @@ namespace TBF.BenchControl.DataEntry.StandardCamera this.endTextBox13 = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.rotateImageButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -191,7 +192,7 @@ namespace TBF.BenchControl.DataEntry.StandardCamera // this.okButton.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.okButton.ForeColor = System.Drawing.Color.Black; - this.okButton.Location = new System.Drawing.Point(976, 42); + this.okButton.Location = new System.Drawing.Point(937, 54); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(98, 63); this.okButton.TabIndex = 100; @@ -1414,20 +1415,32 @@ namespace TBF.BenchControl.DataEntry.StandardCamera // // pictureBox1 // - this.pictureBox1.Location = new System.Drawing.Point(261, 5); + this.pictureBox1.Location = new System.Drawing.Point(335, 5); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(640, 480); + this.pictureBox1.Size = new System.Drawing.Size(480, 480); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.TabIndex = 101; this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); // + // rotateImageButton + // + this.rotateImageButton.Font = new System.Drawing.Font("Arial", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.rotateImageButton.Location = new System.Drawing.Point(826, 435); + this.rotateImageButton.Name = "rotateImageButton"; + this.rotateImageButton.Size = new System.Drawing.Size(50, 50); + this.rotateImageButton.TabIndex = 102; + this.rotateImageButton.Text = "↺"; + this.rotateImageButton.UseVisualStyleBackColor = true; + this.rotateImageButton.Click += new System.EventHandler(this.rotateImageButton_Click); + // // TestStartEndForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.DarkGoldenrod; this.ClientSize = new System.Drawing.Size(1146, 885); + this.Controls.Add(this.rotateImageButton); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.exclamation24); this.Controls.Add(this.startTextBox24); @@ -1646,6 +1659,7 @@ namespace TBF.BenchControl.DataEntry.StandardCamera private System.Windows.Forms.TextBox endTextBox13; private System.Windows.Forms.Label label13; private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button rotateImageButton; } } \ No newline at end of file diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 52b66f52f..75352d6db 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.17.748.0")] -[assembly: AssemblyFileVersion("2.17.748.0")] +[assembly: AssemblyVersion("2.17.749.0")] +[assembly: AssemblyFileVersion("2.17.749.0")] diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 20de160da..41a8b63d5 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -1060,7 +1060,7 @@ Ref.durchfluss [m3/h]: - Ref.Frekvenz [Hz]: + Ref.Frequenz [Hz]: Ref.Impulse: