|
Oh, thank you. That was too cool to work
Ok so unless I am missing something obvious it's not as easy as it looks...
IConvertible Add<T>(T x, T y) where T : IConvertible
{
return (IConvertible)(x.ToDouble(CultureInfo.InvariantCulture)+y.ToDouble(CultureInfo.InvariantCulture));
}
Doesn't look that bad, but that's still not it. I don't want to return IConvertible but T, I want T to be only int, float or double (looks like this is impossible with where ).
Whatever, why not do just
int Add(int x, int y){return x+y};
double Add(double x, double y){return x+y};
...
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Thank u for helping me.
I need ur help that code is not working properly.
Give me the full source and ( where) what is the use of that one in generic.
I expect get soon
Continue...
|
|
|
|
|
Unfortunately I was wrong as Mark pointed out.
where doesn't allow specific structs as type constraint. See http://msdn2.microsoft.com/en-us/library/d5x73970(VS.80).aspx[^]. Because int etc. are structures, you can't do this
However, from what you said, it looks like easiest (and sufficient) thing to do is to have 3 overloads of Add(x,y) method - one for int, one for float, etc...
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
hi all
how can i use the graphics object of the form to store
its contents as an image
thanks
Generator
|
|
|
|
|
You can't.
Use the DrawToBitmap method of the form, or create an Image and use the Graphics.CopyFromScreen method on a Graphics object for the image.
---
single minded; short sighted; long gone;
|
|
|
|
|
ok
what about if i want to draw in empty image by my self
dawing some images and some shapes
thanx
Generator
|
|
|
|
|
Create a Bitmap object and a Graphics object from it, then draw using the Graphics object.
---
single minded; short sighted; long gone;
|
|
|
|
|
sorry,
but can i have some explanation
i want to draw some objects in image then
save this image in disk
the save is not a problem
thanx
Generator
|
|
|
|
|
hi
Bitmap workSpaceBitmap = new Bitmap(tabctrlMain.SelectedTab.Width, tabctrlMain.SelectedTab.Height);<br />
tabctrlMain.SelectedTab.DrawToBitmap(workSpaceBitmap, tabctrlMain.SelectedTab.Bounds);<br />
workSpaceBitmap.Save("c:\\image.jpeg", ImageFormat.Jpeg);
i write this code and thanx very much for ur help(DrawToBitmap u told me about it) thanx alot
but one question if there is a scroll bar is this code will draw disappeared parts of screen to image or not
Generator
|
|
|
|
|
Hi All..
Can u please help me in displaying parent and child records in a single datagridview. My requirement is like a "+" sign should be there in a grid. On click of that + sign child rows should get displayed. How can i achieve that in windows forms. Please help me in this regard.
If anyone knows the solution, please mail me at shwethak32@yahoo.co.in or reply to this forum
Regards
Shwetha
|
|
|
|
|
I'm looking for a Windows Forms control that acts as a sort of "danger meter." Basically a ProgressBar that gradiates from green (when the "progress" is low) to red (when high). But basically I just can't find the right keywords; everything I search for gives me a totally different type of control.
Any ideas?
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
Check out
http://www.codeproject.com/cs/system/CpuUsage.asp[^]
This is a control which monitors CPU usage and shows a progress bar accordignly - like the Task Manager thing.
I'm sure you can adapt the code to be able to monitor whatever you need - changing the color of the control depending on a particular level should be pretty easy....
|
|
|
|
|
|
First of all I see that you have posted this same question on the Windows Forms forum as well - be careful because you'll just annoy people if you do,
As for the issue - check out
http://www.codeproject.com/cpp/rwformulaparser.asp[^]
I did a quick search for "formula" and guess what there's about 50 items on it on here alone. That was one of the items and it seems to be able to do more than you need,
Check that out and then if you have any questions we'll more than happy to help - but you have to put some of the effort in....
|
|
|
|
|
Wow - I just noticed that you asked the same question 5 hours ago.....
Dude - you have to do some of the work here - no-one is going to write all of the code for you - which part are you having the most trouble with?
|
|
|
|
|
iam getting trouble with columns of the table.
so pls dont mistake me.
|
|
|
|
|
Hi guys!
I got a general problem here with UDP multicasts not reaching the server I want to reach.
Perhaps there's a general misconception on my side, perhaps it's just a configuration thing, hope someone can help me out.
I want to create a dynamic service discovery. A client wants to use a service, but doesn't know which server is offering the service.
So I developed a class a service process can use to listen for service discovery requests on a given port and another class for the client to find these services. For this to work I thought I'd use UDP multicasts.
The service joins a multicast group (I've tried 224.0.0.1, 225.0.0.1, 225.1.1.1 and a few more), the client sends a datagram to one of these IP adresses, the service receives the datagram and can reply with an "I'm here" response.
This works fine if I try it within my LAN, but doesn't work if the server and client are located in different subnets. These subnets are connected via a VPN with Zyxel ZyWalls (the ZyWalls are capable of IP multicast according to the specs), yet the packets don't seem to reach the service.
If I don't send the request to a multicast address but use a subnet-specific broadcast or the real target IP, the service gets notified, but that's not what I need - I don't want to make any assumption on the subnet a service is on.
I thought multicast groups were especially designed for such a scenario? According to the documentation I found, members of multicast groups don't have to be part of the same network, so it looks like a routing problem. But unfortunately I don't have any idea what to modify to allow multicast packages to be routed to the other subnets.
Can anyone help?
Thanks in advance,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi
I am trying to check if a file is being written by another process.
I am using teh FileInfo (size) to see if the size (it is a log file) is changing.
When another process is writing to the file my application is stuck.
string fPath = @"c:\temp\build.log";<br />
FileInfo FI = new FileInfo(fPath);<br />
while (1>0)<br />
{<br />
if (lastvalue - FI.Length == 0)<br />
{<br />
iCounter++;<br />
lastvalue = FI.Length;<br />
if (iCounter > 20)<br />
{<br />
MessageBox.Show("times up");<br />
break;<br />
}<br />
<br />
}<br />
else<br />
iCounter = 0;<br />
lastvalue = FI.Length;<br />
<br />
<br />
Thread.Sleep(SleepTime);<br />
}
Any idea could help.
Have a nice Day
|
|
|
|
|
Hi!
One idea that's working fine in some of my programs is trying to open the target file exclusively (with FileShare.None ).
If the file can be opened, no other process is accessing the file and thus the file has been created completely. If you get an IOException then sleep for a few ms and try again. Just don't forget to close the file afterwards and include a timeout mechanism so your program doesn't lock up if the file isn't closed because of a bug in the other application.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks for the quick reply.
I understand your suggestion but the problem is that the process holding the file is loading a message box and until i press "ok" the file is still open by it.
The messagebox is not always present .
I want to get a message when the file is not updated anymore .
Have a nice Day
|
|
|
|
|
I fear you're out of luck in this case.
As long as the file is held open by the other application, this other application is free to modify the contents of the file at any given time. So you can never be sure that the other app will not write anything to the file. Depending on the architecture of the other app it could very well be that a background thread still writes to the file even though a message box is being displayed.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi use the FileSystemWatcher class
|
|
|
|
|
Thanks a lot i will try
Have a nice Day
|
|
|
|
|
Hi,
I would like to stream the desktop image of one computer to another, over the internet. My idea is to do a screen capture at regular intervals, and send it to the receiver.
In order to reduce network load, I would like to compress each frame in function of the previous one (i.e., only the parts of the picture that have changed between two successive frames should be sent, and those parts are compressed before sending).
I suppose there must be an easy way (e.g., using a codec) to do this, but I can't seem to find it on the web/forums.
Can anyone help me out?
Thanks !
ZeJibe
|
|
|
|
|
There are no easy ways, you have to calc the diff of 2 images yourself.
|
|
|
|