|
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 />
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 />
private System.ComponentModel.Container components = null;<br />
<br />
public frmAspect()<br />
{<br />
InitializeComponent();<br />
<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.pb = new System.Windows.Forms.PictureBox();<br />
this.lblMessage = new System.Windows.Forms.Label();<br />
this.SuspendLayout();<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 />
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 />
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 />
<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 />
|
|
|
|
|
Hi there,
I'm trying to check whether a string contains numbers. Here is my code, which obviously doesn't work. How do I check properly for matches? In this example, I've been using the Match.Length property. As well I tried with the Match.Success property but it doesn't seem to work either.
string sEx = "[0-9]*";
string sText = "hi t 2 o all of you!";
Match m = Regex.Match(sText, sEx);
if (m.Length > 0)
Console.WriteLine("worked");
else
Console.WriteLine("didn't work");
Any help is greatly appreceated!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
The regex will "[0-9]*" will search for zero or more digits, so it will find zero digits in any string. (in your example, it will find the zero-length string in front of "hi")
Use 'Regex.IsMatch(sText, "[0-9]")', which will return true as soon as one digit is found.
|
|
|
|
|
Hi Daniel,
thanks a lot, that helped.
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
Hello,
I have windows form i need to apply a skin to it by already designed image ,it is possible?
|
|
|
|
|
Hai every body,
I am working on project related to industrial security.
I have to display the camera input in a windows form.
Is there any control available for live video display in dotnet frame work.
If no control is aavailable in the dotnet frame work please suggest me a good third party control.
Please healp me.
Varmag
varmag
|
|
|
|
|
I have a simple question but couldnt find an answer from the web yet...
How can i plot a set of points with known x and y values on a windows form?
Using Graphics? Pen?
|
|
|
|
|
You create an event handler for the paint event of the element where you want them drawn. Invalidate the element to cause it to be redrawn.
---
b { font-weight: normal; }
|
|
|
|
|
hi,
i have a problem.i'm usin Component one TrueDbGrid. Also i have dragged a dateTimePicker on it..as per the samples which Component One had, i wrote the code for a particular column to be of type "dateTimpicker"..ther code comes in RowColChange event of the trueDbGrid...
private void c1TrueDBGrid1_RowColChange(object sender, C1.Win.C1TrueDBGrid.RowColChangeEventArgs e)
{
// position the datetime picker on the "BirthDate" column only
C1.Win.C1TrueDBGrid.C1DataColumn col = this.c1TrueDBGrid1.Splits[0].DisplayColumns[this.c1TrueDBGrid1.Col].DataColumn;
if( col.DataField == "BirthDate" )
{
// get the area of the cell
Rectangle r = this.c1TrueDBGrid1.Splits[0].GetCellBounds(this.c1TrueDBGrid1.Row, this.c1TrueDBGrid1.Col);
// change to screen coordiantes
r = this.c1TrueDBGrid1.RectangleToScreen(r);
// map the screen coordinates to the forms client coordinates
this.dateTimePicker1.Location = this.RectangleToClient(r).Location;
// size it to fit inside the cell
this.dateTimePicker1.Size = r.Size;
// default the dateTimePicker to the date in the cell
this._bIgnoreChange = true;
this.dateTimePicker1.Text = col.CellText(this.c1TrueDBGrid1.Row);
this._bIgnoreChange = false;
// display it
this.dateTimePicker1.Visible = true;
}
else
this.dateTimePicker1.Visible = false;
}
so here if the col == "BirthDate", then tat field where i've clicked, becomes of dateTimPicker...but my problem is the dateTimepicker is visible but it doesn't get the correct size and location...y this happens i dont understand...
plz..help me..m stuck...
|
|
|
|
|
is there a fix for this so called bug ?
i am getting my icons from Win32.SHGetFileInfo(), then adding it to an imagelist on a treeview, but they appear black where they should be transparent. i am not setting any transparent colour, but form what i remember last time i tried this it didnt do anything anyway.
is there a solution ?
kind regards,
g00fy
|
|
|
|
|
how can i find all the ZIP files in a particular directory and its subdirectories.
|
|
|
|
|
System.IO.Directory and System.IO.DirectoryInfo have methods for returning files and subdirectories (GetDirectories(), GetFiles() etc.) which you can use for this.
Are you looking for ZIP files just in the immediate subdirectories, or in all subdirectories of subdirectories of subdirectories etc?
Rob Philpott
|
|
|
|
|
|
It would be helpful if you informed us about the reason for your inability to convert the string.
If the string contains anything that can be converted to an int, it's easy:
myInt = Convert.ToInt32(myString)
---
b { font-weight: normal; }
|
|
|
|
|
Hello
May be you need to try this:
int.Parse( str )
or this:
Convert.ToInt32( str )
With best regards,
Andrew Kirillov, MCP x 3
Prize winner, August 2005
|
|
|
|
|
Hi all,
I have a richtextbox and a vertical scrollbar on the form
now when i enter text into the richtextbox after it exceeds it's height
the scrollbar for the richtext is shown and we can scroll the contents of the
richtext,
Now i want to hide this scrollbar and want the contents to be scrolled
using the vertical scrollbar that i have put on the form.
Any code or hint will be helpful
Thanks and Regards,
Pramod
|
|
|
|
|
set your scrollbars to 'none' and use the SendMessage API call to control the scrolling
e.g.,
<br />
using System.Runtime.InteropServices;<br />
<br />
private const int WM_SCROLL = 276;
private const int WM_VSCROLL = 277;
private const int SB_LINEUP = 0;
private const int SB_LINELEFT = 0;
private const int SB_LINEDOWN = 1;
private const int SB_LINERIGHT = 1;
private const int SB_PAGEUP = 2;
private const int SB_PAGELEFT = 2;
private const int SB_PAGEDOWN = 3;
private const int SB_PAGERIGTH = 3;
private const int SB_PAGETOP = 6;
private const int SB_LEFT = 6;
private const int SB_PAGEBOTTOM = 7;
private const int SB_RIGHT = 7;
private const int SB_ENDSCROLL = 8;
<br />
[DllImport("user32.dll",CharSet=CharSet.Auto)]<br />
private static extern int SendMessage(IntPtr hWnd, int wMsg,IntPtr wParam, IntPtr lParam);<br />
then call SendMessage() and the way you want to scroll
hope that helps
g00fy
|
|
|
|
|
Thanks for ur reply
but i want to know when we use the default scroll bar of
the richtextbox then how to know whether the scroll is up or down
hope u get ny problem
Thanks and Regards,
Pramod
|
|
|
|
|
Override the WndProc of your RichTextBox and catch the scrollin messages there.
Regards,
mav
|
|
|
|
|
Hi mav,
i have done the same thing but i'm not
able to catch the scrolling event of richtextbox there
it capture's the scroll event of the vertical scroll bar
that i have placed on the form
can u give any idea to catch the scroll event of
the Richtextbox in the wndProc Method
Thanks
Pramod
|
|
|
|
|
hi to all,
i am writing an app that lets users browse a folder. so they can perform several file/folder tasks on that folder and its subfolder/file.
i would like to be able to display teh folder stats when they open the top level folder.
at the moment, i am using directoryinfo and fileinfo and recursivley iterating the entire structure from the top level folder down, jsut to get the filesize.
is there a way to grab this from windows any quicker than this, cause if they select a drive ... well u know whats going to happen. i am also only building the tree structure that reflects the filesystem to a certain depth until they click to that depth i dont go any further.
if there is no other way to get folder size i might try creating the entire tree structure in the same recursive loop and see if the overhead is too much
any ideas pls??
regards,
g00fy
|
|
|
|
|
The total size of the contents of a folder is not stored anywhere. If you can get that information from the system, it will be doing exactly what you are doing yourself, recursively looping through every subfolder to sum up the file sizes.
---
b { font-weight: normal; }
|
|
|
|
|
thans for the reply,
i thought that after i posted, as i tried it on a folder and watched the count go up.
i just optimised my recursion and its working quite well now, it seems to beat the windows effort for the same folder on the same machine and i'm generating the tree for the structure as well. maybe windows is doing some indexing on the first size check as the next time you do it, it is faster.
thanx again,
g00fy
|
|
|
|
|
The reason it's faster on the second go, is that the most of the clusters containing the directory information is still in the disk cache. On the first go all the clusters has to be retrieved from the disk.
---
b { font-weight: normal; }
|
|
|
|
|
hi
I'm a complete learner about c# programming,I need some source code with the algorithm of case-based resoning.
pls help me
thanks in advance
|
|
|
|