Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
GeneralRe: This problem again Pin
Guffa15-Oct-05 5:56
Guffa15-Oct-05 5:56 
QuestionControl with Wizard Pin
acastano15-Oct-05 5:09
acastano15-Oct-05 5:09 
QuestionCapture Mouse Event in a USERCONTROL at Design Time Pin
acastano15-Oct-05 4:58
acastano15-Oct-05 4:58 
Questionopening webpage with post data? Pin
Afief15-Oct-05 4:50
Afief15-Oct-05 4:50 
AnswerRe: opening webpage with post data? Pin
Rob Philpott15-Oct-05 11:39
Rob Philpott15-Oct-05 11:39 
QuestionKeep aspect ratio when drawing rectangle Pin
Gulfraz Khan15-Oct-05 3:52
Gulfraz Khan15-Oct-05 3:52 
AnswerRe: Keep aspect ratio when drawing rectangle Pin
Afief15-Oct-05 6:09
Afief15-Oct-05 6:09 
GeneralRe: Keep aspect ratio when drawing rectangle Pin
Gulfraz Khan17-Oct-05 4:28
Gulfraz Khan17-Oct-05 4:28 
Hello Afief!

Thank you for replying, but, I did not understand your code, you have declared the variable "ratio" but you have not used it any where. I will be pleased if you read my code and modify it for Aspect Ratio functionality.
I will be grateful to you.
Here is my code
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
<br />
namespace WinApp<br />
{<br />
	/// <summary><br />
	/// Summary description for frmAspect.<br />
	/// </summary><br />
	public class frmAspect : System.Windows.Forms.Form<br />
	{<br />
		private int StartX = 0, StartY = 0, EndX = 0, EndY = 0;<br />
		private bool bMouseDown = false;<br />
		Rectangle rctRubber = Rectangle.Empty;<br />
		<br />
<br />
		private System.Windows.Forms.PictureBox pb;<br />
		private System.Windows.Forms.Label lblMessage;<br />
		/// <summary><br />
		/// Required designer variable.<br />
		/// </summary><br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public frmAspect()<br />
		{<br />
			//<br />
			// Required for Windows Form Designer support<br />
			//<br />
			InitializeComponent();<br />
<br />
			//<br />
			// TODO: Add any constructor code after InitializeComponent call<br />
			//<br />
		}<br />
<br />
		/// <summary><br />
		/// Clean up any resources being used.<br />
		/// </summary><br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			if( disposing )<br />
			{<br />
				if(components != null)<br />
				{<br />
					components.Dispose();<br />
				}<br />
			}<br />
			base.Dispose( disposing );<br />
		}<br />
<br />
		#region Windows Form Designer generated code<br />
		/// <summary><br />
		/// Required method for Designer support - do not modify<br />
		/// the contents of this method with the code editor.<br />
		/// </summary><br />
		private void InitializeComponent()<br />
		{<br />
			this.pb = new System.Windows.Forms.PictureBox();<br />
			this.lblMessage = new System.Windows.Forms.Label();<br />
			this.SuspendLayout();<br />
			// <br />
			// pb<br />
			// <br />
			this.pb.Location = new System.Drawing.Point(16, 56);<br />
			this.pb.Name = "pb";<br />
			this.pb.Size = new System.Drawing.Size(336, 256);<br />
			this.pb.TabIndex = 0;<br />
			this.pb.TabStop = false;<br />
			this.pb.Paint += new System.Windows.Forms.PaintEventHandler(this.pb_Paint);<br />
			this.pb.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pb_MouseUp);<br />
			this.pb.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pb_MouseMove);<br />
			this.pb.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pb_MouseDown);<br />
			// <br />
			// lblMessage<br />
			// <br />
			this.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;<br />
			this.lblMessage.Location = new System.Drawing.Point(368, 0);<br />
			this.lblMessage.Name = "lblMessage";<br />
			this.lblMessage.Size = new System.Drawing.Size(288, 256);<br />
			this.lblMessage.TabIndex = 1;<br />
			// <br />
			// frmAspect<br />
			// <br />
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
			this.ClientSize = new System.Drawing.Size(680, 566);<br />
			this.Controls.Add(this.lblMessage);<br />
			this.Controls.Add(this.pb);<br />
			this.Name = "frmAspect";<br />
			this.Text = "frmAspect";<br />
			this.Load += new System.EventHandler(this.frmAspect_Load);<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
<br />
		private void frmAspect_Load(object sender, System.EventArgs e)<br />
		{<br />
			pb.Image = Image.FromFile( @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg");<br />
			pb.SizeMode = PictureBoxSizeMode.StretchImage;<br />
		}<br />
<br />
		private void pb_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
		{<br />
			pb.Cursor = Cursors.Cross;<br />
			rctRubber.X = e.X;<br />
			rctRubber.Y = e.Y;<br />
			Cursor.Clip = pb.RectangleToScreen(pb.ClientRectangle);<br />
			bMouseDown = true;<br />
		}<br />
<br />
		private void pb_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
		{<br />
			Cursor.Clip = Rectangle.Empty;<br />
			bMouseDown = false;<br />
			pb.Cursor = Cursors.Default;<br />
		}<br />
<br />
		private void pb_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
		{<br />
			if (bMouseDown == false) {return;}<br />
			pb.Cursor = Cursors.Cross;<br />
			rctRubber.Width = Math.Max(e.X,rctRubber.X) - rctRubber.X;<br />
			rctRubber.Height = Math.Max(e.Y, rctRubber.Y) - rctRubber.Y;<br />
			<br />
			pb.Invalidate();<br />
			<br />
		}<br />
<br />
		private void pb_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
		{<br />
			if (bMouseDown == false)<br />
			{<br />
				return;<br />
			}<br />
			<br />
		<br />
			<br />
			<br />
			<br />
			//rctRubber.Height = Convert.ToInt16(rctRubber.Width * 1.37); <br />
<br />
<br />
<br />
			lblMessage.Text = "PB ClientRectange: " + pb.ClientRectangle.ToString()+ "\n" +<br />
							"Rubber Rectangle: " + rctRubber.ToString();<br />
		<br />
<br />
<br />
			<br />
			Pen pen = new Pen(Color.Red, 2);<br />
			pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;<br />
<br />
			e.Graphics.DrawRectangle(pen,rctRubber);<br />
<br />
<br />
		}<br />
	}<br />
}<br />

QuestionRegex simple question Pin
matthias s.15-Oct-05 3:29
matthias s.15-Oct-05 3:29 
AnswerRe: Regex simple question Pin
Daniel Grunwald15-Oct-05 3:40
Daniel Grunwald15-Oct-05 3:40 
GeneralRe: Regex simple question Pin
matthias s.15-Oct-05 3:44
matthias s.15-Oct-05 3:44 
QuestionMake Skin For C# Form Pin
raed15-Oct-05 1:14
raed15-Oct-05 1:14 
QuestionControl for live video display on windows form Pin
varmag15-Oct-05 0:44
varmag15-Oct-05 0:44 
QuestionPlotting set of points on a windows form Pin
ilkeru8415-Oct-05 0:24
ilkeru8415-Oct-05 0:24 
AnswerRe: Plotting set of points on a windows form Pin
Guffa15-Oct-05 4:45
Guffa15-Oct-05 4:45 
Questionusing C1TrueDBGrid Pin
deep714-Oct-05 23:59
deep714-Oct-05 23:59 
QuestionImagelist transparency bug Pin
g00fyman14-Oct-05 23:55
g00fyman14-Oct-05 23:55 
Questionsearch for files Pin
Mridang Agarwalla14-Oct-05 22:57
Mridang Agarwalla14-Oct-05 22:57 
AnswerRe: search for files Pin
Rob Philpott15-Oct-05 8:12
Rob Philpott15-Oct-05 8:12 
QuestionI can't convert a var string to a var int Pin
tinh cau14-Oct-05 21:32
tinh cau14-Oct-05 21:32 
AnswerRe: I can't convert a var string to a var int Pin
Guffa14-Oct-05 22:02
Guffa14-Oct-05 22:02 
AnswerRe: I can't convert a var string to a var int Pin
Andrew Kirillov14-Oct-05 22:05
Andrew Kirillov14-Oct-05 22:05 
QuestionRichtextbox scrolling Pin
Anonymous14-Oct-05 18:30
Anonymous14-Oct-05 18:30 
AnswerRe: Richtextbox scrolling Pin
g00fyman15-Oct-05 0:02
g00fyman15-Oct-05 0:02 
GeneralRe: Richtextbox scrolling Pin
AB777115-Oct-05 2:55
AB777115-Oct-05 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.