|
Actually my program didn't stop, it just doesn't work. When I press the button to start the TCP connection, it just shows nothing.
Should I paste all the code for your reference ?
|
|
|
|
|
Then you are probably catching the exception. You should only do that if you can reliably clean up, which in your case is not so. So remove the try/catch blocks and look at the actual exception being thrown, else you will get nowhere.
|
|
|
|
|
Hi leppie,
Thank you again for your assistance.
The following is the exception details I got:
System.Net.Sockets.SocketException was unhandled
Message="An error message cannot be displayed because an optional resource assembly containing it cannot be found"
ErrorCode=10061
NativeErrorCode=10061
StackTrace:
at System.Net.Sockets.Socket.ConnectNoCheck()
at System.Net.Sockets.Socket.Connect()
at System.Net.Sockets.TcpClient.Connect()
at System.Net.Sockets.TcpClient.Connect()
at FYP.Form1.button1_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at FYP.Program.Main()
|
|
|
|
|
10061 is the error for port not responding or port not allowed. You sure the DNS is setup correctly on the mobile device? Have you tried connecting using the ip of the server instead? Have you verified the mobile device has actual network access?
|
|
|
|
|
Hi Leppie,
The IP address I specified for this fuction was 127.0.0.1. I specifed this IP address since I want the simulator to connect back to my own computer PC (which it contains a program that relays webcam images back to the simulator). I checked the connection for the simulator it seems it is not on the internet. How could I resolve the problem ?
Second, sinec this program will be running on a HSDPA phone, will specifying Tcpclient is not enough ? I Googled some code and it requires some other C# class to enable the GPRS function :
http://blogs.msdn.com/anthonywong/archive/2006/03/13/550686.aspx[^]
Thanks for your help leppie.
|
|
|
|
|
leslie wu wrote: The IP address I specified for this fuction was 127.0.0.1.
That will connect straight back to the device. You need to specify the network address of your PC (eg 192.168.0.3).
|
|
|
|
|
Hi everybody
Now I am doing a topic about JPEG compression. I read a lots of material but I feel it is very difficult. So If anyone has done about that please help me. Thank you very much for helping me
I known, JPEG uses Cosine Transform, wavelet,...
but now I am studying Cosine transform
Please help me!
|
|
|
|
|
What exactly do you want to do???
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
It IS difficult. You'll have to read quite a lot until you get the grasp of it. Start with wikipedia and some beginner's guides, but you still have to put some effort into it. Good luck.
|
|
|
|
|
Thank you for your reply and your suggestion. I read it and felt it very useful.
I'll read more to understand it.
Maybe I will have to need your help more, please help me, OK?
I will try my best.
|
|
|
|
|
I'm not that much of an expert in this field really, but if you want to email me, add '@gmail.com' after my CP username.
|
|
|
|
|
I'm trying to do some performance enhancements to my project, and, I've discovered that frequently my animation (custom) control is getting painted twice for each distinct frame.
I've traced all calls that I make to Invalidate(), but it seems that something else must be invalidating my control - for every Invalidate call that I make, there are always two calls to OnPaint.
Problem is, Control.Invalidate is not marked virtual, so I cannot trap all calls to base Invalidates, which I suspect is what is causing the seemingly unneccessary Invalidates.
Anyone know of a diagnostic technique that will allow me to establish why my control gets painted, for each call?
|
|
|
|
|
Can't you trap the calls from the overriden OnPaint() method? Or by overriding OnInvalidated()?
|
|
|
|
|
|
Thanks both, I'd not seen that event before.
This has shed a bit more light on the matter: my control is only getting invalidated once. However, OnPaint is called twice - any idea why?
|
|
|
|
|
I want to draw an image over a background but not the whole image but only the actual content.
I want to specify a color of the foreground image which is transparent and won't be drawn onto the background.
I thought of using a ColorMatrix but I don't really know how I'd do it with this class.
I already used the class to change the alpha value for a whole image, but not for a single color of an image.
How do you use the ColorMatrix to draw a single color transparently?
Or is another approach better?
Thanks in advance.
|
|
|
|
|
|
Thanks, that works great!
|
|
|
|
|
Hi,
I have got a big topographical jpg file that I want to display in a form on a picturebox in its real coordinates that ranges X from 50 000 to 75 000 and Y from 2 800 000 to 2 825 000. this will make it very easy for me to get the mouse coords in real coords as the user invokes the Mousedown event. It will also make it easier for me to draw real features in its real coordinates.
I have got the code:
Image image = Image.FromFile(@"C:\Images\2529DA.jpg");
Pen myPen = new Pen(Color.Black);
Graphics formGraphics = this.picGrid.CreateGraphics();
formGraphics.Clear(picGrid.BackColor);
formGraphics.DrawImage(image, 0, 0, 1000, 1000);
This shows the topomap nicely on the screen but with the local picturebox coords from 0 to 1000. If I change the code to
formGraphics.DrawImage(image, 50000, 2800000, 25000, 25000);
This previous code then puts the map WAY offscreen to the south-east !
I tried fiddling with the following code but no luck.
formGraphics.DrawImageUnscaled(image,0, 0);
formGraphics.DrawImageUnscaledAndClipped(image, rect1);
please help !
cheers
Ian
|
|
|
|
|
You want to fit a 25000x25000 bitmap in a 1000x1000 bitmap without losing precision?
|
|
|
|
|
Yes, (I mean yes, I want to loose the precision in order to know where he is) I need to get the user to select an area he wants to zoom into with the mouse. I want to get the e.X and e.Y of the beginning and end of his zoom and redraw the image meaning i have to move and scale the image with this new info.
I checked later and saw that the image has a resolution of 6500 x 6500 although it covers and area of 25 kilometers by 25 kilometers.
Does this help ?
Ian
|
|
|
|
|
Use the following class
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace some_namespace
{
class Transformation
{
Matrix matrix_world;
Matrix inv_matrix_world;
Matrix matrix_bitmap;
Matrix inv_matrix_bitmap;
Size bitmap_size;
Size screen_size;
public Transformation(PointF worldOrigin, SizeF worldSize,
Size bitmapSize, Size screenSize)
{
matrix_world = new Matrix();
matrix_bitmap = new Matrix();
bitmap_size = bitmapSize;
screen_size = screenSize;
matrix_world.Scale(worldSize.Width / (float)bitmap_size.Width,
worldSize.Height / (float)bitmap_size.Height);
matrix_world.Translate(worldOrigin.X,
worldOrigin.Y , MatrixOrder.Append);
inv_matrix_world = matrix_world.Clone();
inv_matrix_world.Invert();
Reset();
}
public void Reset()
{
matrix_bitmap.Reset();
matrix_bitmap.Scale((float)bitmap_size.Width / (float)screen_size.Width,
(float)bitmap_size.Height / (float)screen_size.Height);
inv_matrix_bitmap = matrix_bitmap.Clone();
inv_matrix_bitmap.Invert();
}
public void Transform(PointF displayOrigin, SizeF displaySize)
{
matrix_bitmap.Reset();
matrix_bitmap.Scale(displaySize.Width / (float)screen_size.Width,
displaySize.Height / (float)screen_size.Height);
matrix_bitmap.Translate(displayOrigin.X, displayOrigin.Y, MatrixOrder.Append);
inv_matrix_bitmap = matrix_bitmap.Clone();
inv_matrix_bitmap.Invert();
}
public void ScreenToBitmap(Point[] points)
{
matrix_bitmap.TransformPoints(points);
}
public void BitmapToScreen(Point[] points)
{
inv_matrix_bitmap.TransformPoints(points);
}
public void BitmapToWorld(Point[] points)
{
matrix_world.TransformPoints(points);
}
public void WorldToBitmap(Point[] points)
{
inv_matrix_world.TransformPoints(points);
}
public void ScreenToWorld(Point[] points)
{
ScreenToBitmap(points);
BitmapToWorld(points);
}
public void WorldToScreen(Point[] points)
{
WorldToBitmap(points);
BitmapToScreen(points);
}
}
}
Initialize the class by passing the appropriate sizes for your world (25,000x25,000) your bitmap (6,500x6,500) your picture box (1000x1000) and your origin point (a few milions if i remember well from your prevous post). In the initial state you must have your image drawn in the picture box by the graphics.DrawImage(bitmap, 0,0,1000,1000) call. When you want to zoom into a rectangle specified by two points taken from the mouse input (e.g pointMouseDown, pointMouseUp) first you transform these points to the original bitmap coords.
Point[] pts = new Point[]{pointMouseDown,pointMouseUp};
transformation.ScreenToBitmap(pts);
graphics.DrawImage(bitmap,new Rectangle(0,0,1000,1000), pts[0].X,pts[0].Y,pts[1].X-pts[0].X,
pts[1].Y-pts.[0].Y,GraphicUnit.Pixel);
transformation.Transform(pts[0],new Size(pts[1].X-pts[0].X,ts[1].Y-pts.[0].Y);
Whenever you want you can get the world coords of a screen point with the ScreenToWorld method and vice versa.
If you want to zoom out to the initial state just graphics.DrawImage(bitmap, 0,0,1000,1000) and call the Reset method of the transformation object.
\
Regards
|
|
|
|
|
Awesome,
Thanks a lot - the whole matrix issue was a bit daunting but it makes more sense now. I will dig in right now and try it out.
cheers
Ian
|
|
|
|
|
Father class how to use the special sub-category type (such as the sub-class form TableAdapter of a table), the current idea is traversal all the things on the form(such as traversing all controls on the sub-form), if found what I need, I want to transform its type into I want. But now what trouble me is i could not get the type neither trying to change the object into the type I needed nor using reflection to get the type. Thanks a lot.
Code is as follows:
private void findcontrol(Control.ControlCollection controls)
{
foreach (Control ctrl in controls)
{
if (ctrl.GetType().Name == "XXTableAdapter")
{
}
findcontrol(ctrl.Controls);
}
}
|
|
|
|
|
Did you run your question through an automatic translator or something? I can hardly understand a thing.
Try again...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|