Click here to Skip to main content
15,906,626 members
Home / Discussions / C#
   

C#

 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie21-Jul-05 6:35
rcurrie21-Jul-05 6:35 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie21-Jul-05 12:46
rcurrie21-Jul-05 12:46 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]21-Jul-05 15:56
[Marc]21-Jul-05 15:56 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie22-Jul-05 7:29
rcurrie22-Jul-05 7:29 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]22-Jul-05 9:00
[Marc]22-Jul-05 9:00 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie22-Jul-05 9:06
rcurrie22-Jul-05 9:06 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]22-Jul-05 9:28
[Marc]22-Jul-05 9:28 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie25-Jul-05 14:02
rcurrie25-Jul-05 14:02 
Here's the translated C# code if anyones interested...

using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace WindowsApplication3<br />
{<br />
	public class Form1 : System.Windows.Forms.Form<br />
	{<br />
		private System.Windows.Forms.Label label3;<br />
		private System.Windows.Forms.Label label1;<br />
<br />
		private bool LeftMouseDown = false;<br />
		private Point MouseDownPos;<br />
		private Rectangle DragRect;<br />
		private ArrayList FinalRects;<br />
<br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public Form1()<br />
		{<br />
			InitializeComponent();<br />
<br />
			this.MouseDownPos = new Point( 0,0 );<br />
			this.FinalRects = new ArrayList();<br />
<br />
			this.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);<br />
			this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);<br />
			this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
		}<br />
<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.label3 = new System.Windows.Forms.Label();<br />
			this.label1 = new System.Windows.Forms.Label();<br />
			this.label3.SuspendLayout();<br />
			this.SuspendLayout();<br />
			// <br />
			// label3<br />
			// <br />
			this.label3.BackColor = System.Drawing.Color.Transparent;<br />
			this.label3.Controls.Add(this.label1);<br />
			this.label3.Dock = System.Windows.Forms.DockStyle.Fill;<br />
			this.label3.Location = new System.Drawing.Point(0, 0);<br />
			this.label3.Name = "label3";<br />
			this.label3.Size = new System.Drawing.Size(292, 266);<br />
			this.label3.TabIndex = 0;<br />
			this.label3.Paint += new System.Windows.Forms.PaintEventHandler(this.label3_Paint);<br />
			// <br />
			// label1<br />
			// <br />
			this.label1.BackColor = System.Drawing.Color.Transparent;<br />
			this.label1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
			this.label1.Location = new System.Drawing.Point(0, 0);<br />
			this.label1.Name = "label1";<br />
			this.label1.Size = new System.Drawing.Size(292, 266);<br />
			this.label1.TabIndex = 1;<br />
			this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint);<br />
			this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);<br />
			this.label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);<br />
			this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);<br />
			// <br />
			// Form1<br />
			// <br />
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
			this.BackColor = System.Drawing.SystemColors.Control;<br />
			this.ClientSize = new System.Drawing.Size(292, 266);<br />
			this.Controls.Add(this.label3);<br />
			this.Name = "Form1";<br />
			this.Text = "Form1";<br />
			this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);<br />
			this.label3.ResumeLayout(false);<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
<br />
		[STAThread]<br />
		static void Main() <br />
		{<br />
			Application.Run(new Form1());<br />
		}<br />
<br />
		protected override void OnPaintBackground(PaintEventArgs pevent)<br />
		{<br />
			base.OnPaintBackground (pevent);<br />
		}<br />
<br />
		private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
		{<br />
			if( e.Button == MouseButtons.Left )<br />
			{<br />
				Console.WriteLine("Panel2_MouseDown");<br />
				MouseDownPos = new Point(e.X, e.Y);          <br />
				LeftMouseDown = true;<br />
				DragRect = new Rectangle(e.X, e.Y, 0, 0);<br />
				this.label1.Invalidate();<br />
			}		<br />
		}<br />
<br />
		private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
		{<br />
			if( e.Button == MouseButtons.Left )<br />
			{<br />
				Console.WriteLine("Panel2_MouseMove");<br />
				DragRect = CalcDragRect(e.X, e.Y);<br />
				this.label1.Invalidate();<br />
			}		<br />
		}<br />
<br />
		private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
		{<br />
			if( LeftMouseDown )<br />
			{<br />
				 Console.WriteLine("Panel2_MouseUp");<br />
				LeftMouseDown = false;<br />
				DragRect = CalcDragRect(e.X, e.Y);			<br />
				this.label1.Invalidate();<br />
				FinalRects.Add(DragRect);<br />
			}<br />
		}<br />
<br />
		private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
		{<br />
			if( LeftMouseDown )<br />
			{<br />
				Pen pen = new Pen(Color.Blue);<br />
				pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;<br />
				DrawRect(e.Graphics, DragRect, pen);<br />
				pen.Dispose();<br />
			}		<br />
		}<br />
<br />
		private void label3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
		{<br />
			foreach( Rectangle rect in FinalRects )<br />
			{<br />
				DrawRect(e.Graphics, rect, Pens.Red);<br />
			}<br />
		}<br />
<br />
		public void DrawRect(Graphics g, Rectangle rect, Pen pen)<br />
		{<br />
			if (rect.Width == 0 && rect.Height == 0) <br />
			{<br />
				g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Y + (float)0.01);<br />
			}<br />
			else if (rect.Width > 0 && rect.Height == 0) <br />
			{<br />
				g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);<br />
			}<br />
			else if (rect.Width == 0 && rect.Height > 0) <br />
			{<br />
				g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);<br />
			}<br />
			else //if (rect.Width > 0 && rect.Height > 0)<br />
			{<br />
				g.DrawRectangle(pen, rect);<br />
			}<br />
		}<br />
<br />
		private System.Drawing.Rectangle CalcDragRect(int mouseX, int mouseY)<br />
		{<br />
			return Rectangle.FromLTRB( System.Math.Min(mouseX, MouseDownPos.X),<br />
										System.Math.Min(mouseY, MouseDownPos.Y),<br />
										System.Math.Max(mouseX, MouseDownPos.X),<br />
										System.Math.Max(mouseY, MouseDownPos.Y) <br />
									);<br />
		}<br />
<br />
		private void Form1_SizeChanged(object sender, System.EventArgs e)<br />
		{ <br />
			base.OnSizeChanged(e);<br />
			this.Invalidate();	<br />
		}<br />
	}<br />
}<br />


*sigh* still working on this one. Dead | X|
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]26-Jul-05 7:55
[Marc]26-Jul-05 7:55 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie2-Aug-05 14:04
rcurrie2-Aug-05 14:04 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]3-Aug-05 1:05
[Marc]3-Aug-05 1:05 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie4-Aug-05 11:20
rcurrie4-Aug-05 11:20 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]4-Aug-05 14:08
[Marc]4-Aug-05 14:08 
GeneralRadio_Buttons Pin
_Sirrius20-Jul-05 11:58
_Sirrius20-Jul-05 11:58 
Generalinitializing data members in a class Pin
Dragan Matic20-Jul-05 11:41
Dragan Matic20-Jul-05 11:41 
GeneralRe: initializing data members in a class Pin
Alomgir Miah20-Jul-05 12:07
Alomgir Miah20-Jul-05 12:07 
GeneralC# newbie question Pin
Tom Wright20-Jul-05 11:20
Tom Wright20-Jul-05 11:20 
GeneralRe: C# newbie question Pin
Christian Graus20-Jul-05 12:48
protectorChristian Graus20-Jul-05 12:48 
GeneralDatagrid question Pin
Tom Wright20-Jul-05 10:47
Tom Wright20-Jul-05 10:47 
GeneralRe: Datagrid question Pin
Alomgir Miah20-Jul-05 12:01
Alomgir Miah20-Jul-05 12:01 
GeneralReading custom attributes in ReflectionOnly mode Pin
Daniel Grunwald20-Jul-05 10:18
Daniel Grunwald20-Jul-05 10:18 
GeneralRe: Reading custom attributes in ReflectionOnly mode Pin
leppie20-Jul-05 10:35
leppie20-Jul-05 10:35 
GeneralRe: Reading custom attributes in ReflectionOnly mode Pin
Daniel Grunwald20-Jul-05 10:49
Daniel Grunwald20-Jul-05 10:49 
GeneralTabControl Question Pin
zaboboa20-Jul-05 9:05
zaboboa20-Jul-05 9:05 
GeneralRe: TabControl Question Pin
Alomgir Miah20-Jul-05 10:19
Alomgir Miah20-Jul-05 10:19 

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.