|
humayunlalzad wrote: Would I have any reason to store all that information in the .config file
No. I always roll my own.
|
|
|
|
|
My personal preference for your problem is to use XML files, because I follow the simple rule,
'Use static configuration settings in App.Config file and Runtime settings in a separate file, preferably in XML format for easy reading and writing'.
|
|
|
|
|
Hi all,
i am working with webbrowser control.
is there any way to identify the network usage of IE.
for example:
from the time of IE open and till the end of IE Close,
just i want to calculate the entire network usage or page download and upload size(may be in bytes)
can we do it ondocument_complete event and ....
pls help me, if some one has any idea...
you can suggest some other idea also other than webbrowser
thanks in advance.
modified on Wednesday, September 9, 2009 5:31 AM
|
|
|
|
|
IE does not track these statistics.
You MAY be able to get some of this by using the Performance Counters, but I don't know if your going to be able to track it by application. I think you'll only get it on an Interface-by-Inerface basis. This will also pickup non-IE traffic and may affect the results you want.
AFAIK, the only way to track this would be to use a proxy server and point IE at it.
|
|
|
|
|
hi thank you for your suggestion
i am already using api hooking for this but my browser get hangs some time
so that i am trying to get it done in web browser itself and thank you for your suggestion if you come across any idea on that please let me know it
thank you
|
|
|
|
|
1) try to monitor the '80' port;
2) try to find the 'HttpAlicationRequest' object refer and so on, to get the stream.
3) if you want to get the 'web page' size, you can get the html text object to get it.
you can go to msdn to know more about webbrowser control.
modified 27-May-14 5:34am.
|
|
|
|
|
Hi all,
I am trying to crop an image based on a transparent panel that I have placed on the image. The transparent panel is placed on the image control based on certain coordinates (selected by a user based on mouse events). This works fine.
Now I want to try and crop the piece where the transparent panel is located on the image, but I keep receiving an exception: OutOfMemoryException => rect is outside of the source bitmap bounds.
But why is this happening? (note: The image Bounds value of X and Y is 0 and the transparent panel width and height is in bounds with the height and width of the image) The transparent panel is located within the picturebox, shouldn't it be able to get the correct position ??
Here is the code ...
...
TransparentPanel tmpPnl = e.ClickedItem.Tag as TransparentPanel;
Rectangle rec = tmpPnl.Bounds;
Bitmap bmpImage = new Bitmap(base.Image);
Bitmap bmpCrop = bmpImage.Clone(rec, bmpImage.PixelFormat);
...
FYI
That "out of memory" exception appears when you attempt to crop a piece of the image outside itself.
Eg: If the image is 800×600 and you go:
Bitmap b = CropBitmap(myPic, 700, 500, 200, 200);
That’ll try select from 700×500 to 900×700, which does not actually exist.
Many thanks in advance
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
modified on Wednesday, September 9, 2009 6:01 AM
|
|
|
|
|
Ok, so the new method doesn't cause an exception.
But the new cropped image's position is a bit out. It crops more to the right. What am I doing wrong?
public static Bitmap CropBitmap(Bitmap srcBitmap, int cropX, int cropY, int cropWidth, int cropHeight)
{
Bitmap bmp = new Bitmap(cropWidth, cropHeight);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(srcBitmap, new Rectangle(0, 0, cropWidth, cropHeight), cropX, cropY, cropWidth, cropHeight, GraphicsUnit.Pixel);
g.Dispose();
return bmp;
}
Thanks again.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
there is an error 'bmpImage.Clone(rec, bmpImage.PixelFormat);'.
i think it might be 'bmpImage.size'<'rec.size',
so bmpImage's memory < rec's memory ,and it caused the error .
modified 27-May-14 5:34am.
|
|
|
|
|
Hi, can you get the Clone to work if you hard-code the rectangle to say {0, 0, 50, 50}? Try putting a trace on tmpPnl.Bounds too, so you can see what's being passed to Clone - unless tmpPnl is a member of the pictureBox.Controls collection, it's bounds are likely to be relative to the pictureBox.Parent control. Also, wrap up bmpImage var in a using() block to ensure you don't leak memory.
Perhaps you could post the code that creates tmpPnl if this doesn't help
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Hi,
Thanks for the reply.
Rob Smiley wrote: can you get the Clone to work if you hard-code the rectangle to say {0, 0, 50, 50}?
Yes, it takes the top left-hand corner and computes the correct image result based on the width and the height.
Rob Smiley wrote: unless tmpPnl is a member of the pictureBox.Controls collection, it's bounds are likely to be relative to the pictureBox.Parent control
The transparent panel is part of the control collection of the image, so it should be in bounds. I think
Values of rec1 and rec2 are the same..
TransparentPanel tmpPnl = e.ClickedItem.Tag as TransparentPanel;
Rectangle rec1 = base.Controls[tmpPnl.Name].Bounds;
Rectangle rec2 = tmpPnl.Bounds;
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
ok, it sounds like the panel bounds are relative to the pictureBox... hmm. does the image take up the full space in the pictureBox? also have you set a sizeMode on it? e.g. an image smaller than the control area & a size mode of centre or stretch could allow you to have the rectangle appear over the image on screen, but give bounds that are outside the image area. Set sizeMode to normal (so image appears in top-left corner) & see what happens
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Thanks again for the reply.
Rob Smiley wrote: does the image take up the full space in the pictureBox?
Yes, I made the image to that it stretches the image.
Rob Smiley wrote: Set sizeMode to normal (so image appears in top-left corner) & see what happens
OK, when I change the size mode on the image to normal; all seems to be working. It crops the correct piece relevant to the transparent panel.When I change the size mode stretch Image, that's when the issue occurs with the cropped image.How can I accommodate for the stretched image, I must make use of the stretched size mode, otherwise it will cause problems with an image bigger that the pictureBox control?
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
to discover which part of the image you want, you have to apply to your cropping (i.e.mouse) coordinates the same transformation that are being applied to the entire image; so you have to mimick the stretching if you PictureBox is set to stretch mode.
That is one of the many problems a PictureBox causes. I almost never use that class, I rather use a simple Panel, and create a Paint handler for it; that way I choose the transformations I want (if any) and I can apply the same transformations to mouse operations. Also, I can then keep the aspect ratio, something a PictureBox isn't really capable of.
Conclusion:
- apply transformations to all coordinates you get (from mouse handlers)
- if possible, get rid of PictureBox
|
|
|
|
|
Thanks for the reply.
Luc Pattyn wrote: I rather use a simple Panel, and create a Paint handler for it
Hmmm ... I'll give it a shot
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi, you need to do as Luc suggests & scale the rectangle of your cropping area. This should do the trick:
float scaleX = (float)bmpImage.Width / (float)this.ClientSize.Width;
float scaleY = (float)bmpImage.Height / (float)this.ClientSize.Height;
rec = new Rectangle((int)(rec.X * scaleX), (int)(rec.Y * scaleY), (int)(rec.Width * scaleX), (int)(rec.Height * scaleY));
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
|
Hi, im making a Window Application in C# using Socket Programming. I have developed a Server & a Client. Both are working fine but the problem which im gettin is that when ever i send any message from CLIENT, its send perfectly and receives on SERVER but whenever i try to send any message from SERVER it doesn't send to Client, since at the beginning when a connection is built, server sends the message to client that "Connection Established" and received at Client perfectly,but later on server does not send any message to client!!! Could anyone please help me out ???????
Regards
Umair
|
|
|
|
|
Hi,
could you please send code, how client receives messages? Would help us, to help you.
bye
|
|
|
|
|
//this is the code at client side for receiving data
NetworkStream networkStream = new NetworkStream(server);
string input = textBoxUser.Text + ": " + textBoxWrite.Text;
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] inputByte = encoding.GetBytes(input);
if (networkStream.CanWrite)
{
networkStream.Write(inputByte, 0, inputByte.Length);
textBoxShow.Text = textBoxShow.Text +
Environment.NewLine + input;
textBoxWrite.Text = "";
networkStream.Flush();
}
|
|
|
|
|
looks like a sending code. You used NetworkStream.Write() . That might be the problem.
|
|
|
|
|
but i have also used server.send(AnyMessage);
this isn't working as well..
|
|
|
|
|
Okay, maybe this a problem in understanding:
you wrote code for receiving data at client side, right?
You used the method .Write() . This method writes bytes to the stream. I think in a receiving method you should use e.g. Read(byte[], int, int) , or am I wrong?
|
|
|
|
|
the problem has been resolved.. the message was not sending for the second time to client because i was using IF loop in client side that would take data from server just once, now on the client side i have replaced if by WHILE(true) and it receives the data until a break is performed send by server in the form of Disconnect..newys thank you guys
|
|
|
|
|
muhammad_umair wrote: newys
Syntax error. 'newys' does not exist in the english language.
|
|
|
|
|