|
yes, i know,
but
his idea was the best i had, and at this point i still don't compute how to make anything else better.....
i've got 6 books sitting here on the floor all dealing with hashing, salting or MD5, and i'm not sure where to start, my brain is fried, and all i want is to NOT see a string value of the date in my isoStore, his code made that happen even if it was vb, ....................................
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
Then take the function I gave you above, it does in fact convert the string and convert it back the next time through.
FYI, it's incredibly simple. It takes the string and a key, and it walks the key over and over, so if the string is 'this is it' and the key is 'fish', it's worked out like this:
this is it
saltsaltsa
The two values are XORed, which means that all bits are reversed. 10010011 becomes 01100011. Because all bits are reversed, doing it again restores the original value.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You might find the following, produced with our Instant C# VB.NET to C# converter, more useful (you can download a free limited version at www.instantvb.com):
//TODO: INSTANT C# TODO TASK: Insert the following converted event handlers at the end of the 'InitializeComponent' method for forms or into a constructor for other classes:
base.Load += new System.EventHandler(Form1_Load);
private string Crypt(string Text_Renamed, string Key)
{
int KeyLen = 0;
int i = 0;
int KeyPtr = 0;
short KeyChr = 0;
short TextChr = 0;
KeyLen = Key.Length;
//INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of Len(Text_Renamed) for every iteration:
int tempFor1 = Text_Renamed.Length;
for (i = 1; i <= tempFor1; i++)
{
TextChr = System.Convert.ToInt32(Text_Renamed[0]);
KeyChr = System.Convert.ToInt32(Key[0]);
Text_Renamed = Text_Renamed.Remove(i - 1, 1).Insert(i - 1, ((char)(TextChr ^ KeyChr)).ToString());
KeyPtr = ((KeyPtr + 1) % KeyLen);
}
return Text_Renamed;
}
private void Form1_Load(object eventSender, System.EventArgs eventArgs)
{
txtText.Text = System.Convert.ToString(System.DateTime.Now);
txtPath.Text = Support.GetPath + "\\DateTest.bin";
}
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
|
|
|
|
|
David Anton wrote:
for (i = 1; i <= tempFor1; i++)
This doesn't work. It looks like VB is 1 indexed, changing it to 0 and < tempFor1 fixes this.
David Anton wrote:
TextChr = System.Convert.ToInt32(Text_Renamed[0]);
KeyChr = System.Convert.ToInt32(Key[0]);
Gosh - this is a mess. Perhaps the source code being converted is the problem ? I've just done it by hand, and this needs to be i-1 with the indexes your using.
David Anton wrote:
Text_Renamed = Text_Renamed.Remove(i - 1, 1).Insert(i - 1, ((char)(TextChr ^ KeyChr)).ToString());
Yeah, this will work, it's correctly using i-1. I guess that's an example of how a conversion can work but not produce the worlds prettiest code.
I just did this by hand, and knowing how excellent these conversion tools are, I'd say at a guess his original source is a disaster, I would be surprised if your tool introduced these problems.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for noticing that - there was a bug in the conversion of the combination of Asc and Mid. It's fixed now in the latest build of Instant C#.
The for loop conversion is correct though - I'm not saying that the original code worked or not - I'm just speaking from a C# equivalency viewpoint. You are probably right that the loop itself needs to be different for the code to work (in VB or C#).
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
|
|
|
|
|
David Anton wrote:
You are probably right that the loop itself needs to be different for the code to work (in VB or C#).
Yeah - I thought that would be the case, I didn't think your product would have a bug that changed array indices
I'm glad I helped you find a bug though. I can only imagine how complex a product like yours would be to get absolutely right.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hello everyone.
I have a form that contain a panel i had design. and i have a button bellow this panel . Can i print this panel only ?
quangmogulasiaUNS
|
|
|
|
|
Hello.. i have a problem.. i have an application, and i want it to do smth when a key-combination is pressed... the problem is that i want it to do that even when it doesn't have focus.. i need smth like a "global hotkey", or i need to set up an event listener, that can listen for events even when my application doesn't have focus.. can anybody help? pls...
|
|
|
|
|
Ok in your app import the User32.dll function RegisterHotKey
[DllImport("user32.dll", SetLastError=true)]<br />
public static extern bool RegisterHotKey( IntPtr hWnd,
int id,
KeyModifiers fsModifiers,
Keys vk
);
Whilst Your at it - may as well import the Unregister one too
[DllImport("user32.dll", SetLastError=true)]<br />
public static extern bool UnregisterHotKey( IntPtr hWnd,
int id
);
In your MainForm constructor - register the hot key
RegisterHotKey(Handle, 100, KeyModifiers.Control | KeyModifiers.Shift, Keys.L);
In this case it's ctrl, shift and L - anything you want really.
Then override the WndProc for the main form and handle the event
protected override void WndProc(ref Message m)<br />
{<br />
const int WM_HOTKEY = 0x0312;<br />
<br />
switch(m.Msg)<br />
{<br />
case WM_HOTKEY:<br />
{<br />
break;<br />
}<br />
}<br />
<br />
base.WndProc (ref m);<br />
}
Remember to also unregister the hot key in the Form.OnClosed method
private void Form1_Closed(object sender, System.EventArgs e)<br />
{ <br />
UnregisterHotKey(Handle, 100);<br />
}
That should do what you want.
Mark.
|
|
|
|
|
Hey . Thanks a lot
|
|
|
|
|
still, i have a problem.... "KeyModifiers fsModifiers" the program throws an error when i attempt to build it..
" The type or namespace name 'KeyModifiers' could not be found (are you missing a using directive or an assembly reference?)" it's a common error.. pls help, the rest of the code is perfect
|
|
|
|
|
[Flags()]
public enum KeyModifiers
{
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}
Hope this helps you out!
|
|
|
|
|
Hey, thx !
|
|
|
|
|
You're welcome!
|
|
|
|
|
when i use find method of DataRowCollection, it returns DataRow. i need to know the row number of this returned DataRow in the DataRowCollection. but i cant. how should encounter with this DataRow to find that number?
thanks
Rastegar
|
|
|
|
|
Hello!
I just have a question regarding the transparency of a panel. I have tried this with Controls & Forms, but all to no avail.
What I am trying to accomplish is a 3 layered panel system, with an underlying form. The form could have a background image, for example, and I should be able to see through all 3 panel objects I have and see the underlying form. This is simple.
The tricky part is that I want the 3 panels to function in a sort of non-transparent fashion. I have all the panels nested inside each other. panel 1 inside panel 2, panel 2 inside panel 3.
Now when the user clicks, the hit control is handled by the inner most panel...panel 1. Then if the user drags out a box, for example, the box is drawn on the middle panel, panel 2. When the user releases the mouse button, the middle panel is cleared and the final box is drawn on the last panel, panel 3.
The problem I am having is that the panels are transparent, but see all the way through to the form. Therefore I have it drawing successfully on the middle panel, but you cannot see what is being drawn because panel one is 'transparent' through it. Sorry if that didn't make sense.
I have set all the style properties as best I can, to accept transparent background colors, etc. Yet I just can't think of a way to accomplish this little dilema. Any and all help, suggestions would be greatly appreciated! Thanks!
|
|
|
|
|
Hi rcurrie, i created this sample app, and it works pretty good! I thought it was a pretty cool idea to sort your problem out. I like a challenge . Instead of 3 Panels, i used 2 (changed them to Labels, because of the flickering). The box that the user drags is drawn on Panel1, and all previously drawn boxes are stored in FinalRects and drawn on Panel2.
But... i made it in VB, because i don't know how to program in C# . I tried converting with SharpDevelop, but errors everywhere...
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class TransPanelForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.UserPaint, True)
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Panel1 As System.Windows.Forms.Label
Friend WithEvents Panel2 As System.Windows.Forms.Label
Friend WithEvents Panel3 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Label
Me.Panel3 = New System.Windows.Forms.Label
Me.Panel3.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.Color.Transparent
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel1.Location = New System.Drawing.Point(0, 0)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(270, 244)
Me.Panel1.TabIndex = 0
'
'Panel3
'
Me.Panel3.BackColor = System.Drawing.Color.Transparent
Me.Panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel3.Controls.Add(Me.Panel1)
Me.Panel3.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel3.Location = New System.Drawing.Point(10, 10)
Me.Panel3.Name = "Panel3"
Me.Panel3.Size = New System.Drawing.Size(272, 246)
Me.Panel3.TabIndex = 0
'
'TransPanelForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Panel3)
Me.DockPadding.All = 10
Me.Name = "TransPanelForm"
Me.Text = "TransPanelForm"
Me.Panel3.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
''' <summary>The current rectangle that is dragged.</summary>
Private DragRect As Rectangle
''' <summary>A collection of rectangles.</summary>
Private FinalRects As New ArrayList
''' <summary>The position at which the mouse was pressed.</summary>
Private MouseDownPos As Point
''' <summary>Is the left mouse button down?</summary>
Private LeftMouseDown As Boolean
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaintBackground(e)
Dim rect As Rectangle = Me.ClientRectangle
Dim brush As New LinearGradientBrush(rect, Color.White, Color.LightSteelBlue, LinearGradientMode.ForwardDiagonal)
e.Graphics.FillRectangle(brush, rect)
brush.Dispose()
End Sub
Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
MyBase.OnSizeChanged(e)
Me.Invalidate()
End Sub
''' <summary>Calculates the DragRect.</summary>
Private Function CalcDragRect(ByVal mouseX As Integer, ByVal mouseY As Integer) As Rectangle
Return Rectangle.FromLTRB(Math.Min(mouseX, MouseDownPos.X), _
Math.Min(mouseY, MouseDownPos.Y), _
Math.Max(mouseX, MouseDownPos.X), _
Math.Max(mouseY, MouseDownPos.Y))
End Function
#Region " Panel1_Mouse... "
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
If e.Button = MouseButtons.Left Then
Debug.WriteLine("Panel1_MouseDown")
MouseDownPos = New Point(e.X, e.Y)
LeftMouseDown = True
DragRect = New Rectangle(e.X, e.Y, 0, 0)
Panel2.Invalidate()
End If
End Sub
Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
If LeftMouseDown Then
Debug.WriteLine("Panel1_MouseUp")
LeftMouseDown = False
DragRect = Me.CalcDragRect(e.X, e.Y)
Panel2.Invalidate()
FinalRects.Add(DragRect)
End If
End Sub
Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If e.Button = MouseButtons.Left Then
Debug.WriteLine("Panel1_MouseMove")
DragRect = Me.CalcDragRect(e.X, e.Y)
Panel1.Invalidate()
End If
End Sub
#End Region
''' <summary>Draws a rectangle.</summary>
''' <remarks>Instead of just doing 'g.DrawRectangle(pen, rect)',
''' this method draws a line if the width and/or height
''' of the rectangle is zero. This way a line is drawn,
''' instead of just nothing.</remarks>
Public Shared Sub DrawRect(ByVal g As Graphics, ByVal rect As Rectangle, ByVal pen As Pen)
If (rect.Width = 0) AndAlso (rect.Height = 0) Then
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Y + 0.01!)
ElseIf (rect.Width > 0) AndAlso (rect.Height = 0) Then
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y)
ElseIf (rect.Width = 0) AndAlso (rect.Height > 0) Then
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom)
Else '(rect.Width > 0) AndAlso (rect.Height > 0)
g.DrawRectangle(pen, rect)
End If
End Sub
Private Sub Panel2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint
For Each rect As Rectangle In FinalRects
DrawRect(e.Graphics, rect, Pens.Red)
Next
End Sub
Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
If LeftMouseDown Then
Dim pen As New Pen(Color.Blue)
pen.DashStyle = DashStyle.Dash
DrawRect(e.Graphics, DragRect, pen)
pen.Dispose()
End If
End Sub
End Class
|
|
|
|
|
Wow Absofukinlutely! Thanks so much for taking the time to work that out! I have a little VB.NET experience so I'll see if I can convert it to C# and see how it handles. Thanks again so much!!
|
|
|
|
|
Well I gave this a shot...and maybe it's my own inexperience, but it doesn't seem to be working the way I had hoped. That's a great example Absofukinlutely, but when I offset the Labels...the rectangles aren't being drawn on the outtermost label; instead they are all being drawn on the innermost label. I just can't for the life of me figure out this problem. I was just hoping there was something in Visual Studio that had the functionality I desire, but I just can't seem to find it.
Below = BAD
______
|........|
|.2.....|___
|...|********|
|...|********|
|...|********|
```|*****1**|
```|********|
Below = GOOD!
______
|........|
|.2.....|___
|...|....|*****|
|...|....|*****|
|...|....|*****|
```|*****1**|
```|********|
|
|
|
|
|
Your welcome! I'm glad you liked it, it was fun to make.
Well, now to the next problem:
If something has a transparent background, it's not really transparent, it just asks its parent to draw the background again. So if panel1 and panel2 both have the same parent (the form), they both draw the background of the form (the BAD example). But, if panel1 has panel2 as parent, it will show the background of panel2 (GOOD example).
I'm not sure what you want:
1: You want to drag the rectangle and draw the rectangle that is being dragged and draw all the previously dragged rectangles on the same panel.
In this case, get rid of panel1, add the panel1 painting to the panel2 painting, and change the mouse events of panel1 to that of panel2.
[Snapshot] [Code (Still in VB )]
2: You want to drag the rectangle and draw the rectangle on one panel, and draw all previously dragged rectangles on an other panel. If you want this, i think the best way is to move panel1 out of panel2 and on to the form.
[Snapshot] [Code]
3: Something else...
Mzl!
|
|
|
|
|
Thanks again Absofukinlutely for your continued help in this matter, I really do appreciate it very much! Your example really has made things clearer for me. I didn't grasp the fact that there wasn't 'true' transparency, but that it was simply the parent re-drawing itself. That makes sense on why my earlier attempts where not functioning.
On to explaining what I want...well I have been attempting to create a fairly simple project that has 3 frames. The top-most frame is my event frame, it handles all mouse click events, the second and third frame function exactly like your '2:' example above. As you drag out a box...that box is drawn, by itself, on the middle frame...the 'drag frame'. When the mouse button is released, the drag frame is cleared, and the dragged out box is then added to the list of rectangles and then drawn on the last frame, the 'render frame'.
The trouble is that all frames overlap...and currently (since their parents are all the underlying form) you can't see anything being drawn becuase they are all transparent and just see all the way through down to the form.
If I apply the parenting structure like you have in your example and then manage the OnPaint events better I should be able to achieve what I am looking for. So the overall parent would be the underlying form, which would then contain the 'render_frame'. The 'render_frame's child would be the 'drag_frame' and the 'drag_frame's child would be the 'event_frame'. Does this sound about right? That way it should function properly. I would have a changing background image in the parent form that you could effectively 'mark-up' using the boxes and frames.
Thanks again Absofukinlutely, I really do appreciate all the great explanations and examples!
~rcurrie
|
|
|
|
|
Again you're welcome!
One thing though: why don't you do the dragging and the drag-painting on the same panel? Seems easier to me, but you have to know for your self. Its your project of course.
If you have any problems, feel free to ask!
Cheers!
|
|
|
|
|
I do see the ease of handling the dragging and painting on a single panel, yet eventually the events frame will be built out to handle a few other events and more frames will be added, thus opening the possibilty of needing the events frame, but not the drag frame, for example. So that's partially why...the other reason is because that's what I've been tasked to do :P and so it's not entirely up to me.
But again, thanks! And I'll be sure and ask if anything further comes up.
~rcurrie
|
|
|
|
|
Well, i guess you've got to do what the boss says!
Good luck!
|
|
|
|
|
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 />
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 />
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 />
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 />
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
{<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.
|
|
|
|
|