Fixed wrong coordinates problem

This commit is contained in:
2022-11-02 13:17:52 +01:00
parent ae677d4950
commit 11715e3bab
2 changed files with 29 additions and 1 deletions

View File

@@ -44,19 +44,22 @@
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.debugLBL = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pbxInput)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbxOutput)).BeginInit();
this.SuspendLayout();
//
// pbxInput
//
this.pbxInput.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pbxInput.Location = new System.Drawing.Point(12, 12);
this.pbxInput.Name = "pbxInput";
this.pbxInput.Size = new System.Drawing.Size(960, 540);
this.pbxInput.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbxInput.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbxInput.TabIndex = 0;
this.pbxInput.TabStop = false;
this.pbxInput.Click += new System.EventHandler(this.pbxInput_Click);
this.pbxInput.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pbxInput_MouseMove);
//
// pbxOutput
//
@@ -185,11 +188,21 @@
this.label4.TabIndex = 13;
this.label4.Text = "Computed result";
//
// debugLBL
//
this.debugLBL.AutoSize = true;
this.debugLBL.Location = new System.Drawing.Point(991, 525);
this.debugLBL.Name = "debugLBL";
this.debugLBL.Size = new System.Drawing.Size(44, 16);
this.debugLBL.TabIndex = 14;
this.debugLBL.Text = "label5";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1472, 783);
this.Controls.Add(this.debugLBL);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
@@ -230,6 +243,7 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label debugLBL;
}
}

View File

@@ -105,6 +105,7 @@ namespace TestVideo
float xRatio = (float)pbxInput.Image.Width / (float)pbxInput.Width;
float yRatio = (float)pbxInput.Image.Height / (float)pbxInput.Height;
Point tmpPoint = pbxInput.PointToClient(MousePosition);
Point testPoint = MousePosition;
//MouseEventArgs me = (MouseEventArgs)e;
//Point tmpPoint = me.Location;
Point newPoint = new Point(Convert.ToInt32((float)tmpPoint.X * xRatio),Convert.ToInt32((float)tmpPoint.Y * yRatio));
@@ -189,5 +190,18 @@ namespace TestVideo
{
}
}
private void pbxInput_MouseMove(object sender, MouseEventArgs e)
{
float xRatio = (float)pbxInput.Image.Width / (float)pbxInput.Width;
float yRatio = (float)pbxInput.Image.Height / (float)pbxInput.Height;
Point tmpPoint = pbxInput.PointToClient(new Point(MousePosition.X,MousePosition.Y));
Point testPoint = MousePosition;
//MouseEventArgs me = (MouseEventArgs)e;
//Point tmpPoint = me.Location;
Point newPoint = new Point(Convert.ToInt32((float)tmpPoint.X * xRatio), Convert.ToInt32((float)tmpPoint.Y * yRatio));
debugLBL.Text = "Absolute : " + testPoint.ToString() + Environment.NewLine + "Relative : " + tmpPoint.ToString();
}
}
}