|
You should create separate UserControls for each 'panel'. Design and code each one separately. Then add the custom control to your tabcontrol, showing and closing the tab with the menu.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Ok, I'll read up on the userControls. Thanks for the pointer.
|
|
|
|
|
Yes, UserControls were going to be my recommendation. A user control is a class (that inherits from UserControl) so all its internal code goes in its own file. You should then expose events, properties and methods to allow UI interaction with other parts of the application, and some way of hooking up a data model for interaction with the business tier (might be very minimal if your app is basically just a wrapper for several existing ones, as that's essentially a UI only problem).
|
|
|
|
|
Or possibly as some sort of plug-in system where each utility has its own Panel or TabPage in its DLL.
|
|
|
|
|
Hi,
I have a function that converts r(red), g(green) and b(blue) values to a uint (same as RGB macro in C++).
If I implement as follows I get no errors or warnings:
private uint rgb(byte r, byte g, byte b)
{
return ((uint)((r|((uint)(g)<<8))|(((uint)b)<<16)));
}
However, if I implement like this:
private uint rgb(byte r, byte g, byte b)
{
return ((uint)((r|((ushort)(g)<<8))|(((uint)b)<<16)));
}
I get a warning "Bitwise or operator used on a sign extended operand".
But ushort is un-signed, so why am I getting the warning?
Thanks - John.
|
|
|
|
|
ushort will be being expanded to uint because b is still being shifted as a uint (as it must be). That will cause the ushort to be 'sign extended' i.e. the new bits to be filled with the top bit, I suppose, though that doesn't really make sense (an unsigned type should always be zero extended).
|
|
|
|
|
It would appear that the logical expression is yielding an int value which is,by definition, signed. You should cast each part of the expression to uint as in the first case. you should also review your use of parentheses around your expressions, a better expression would be:
return (uint)(r | (((uint)g) << 8) | (((uint)b) << 16));
return (uint)(r | (g << 8) | (b << 16));
|
|
|
|
|
Thanks Guys,
I would have expected an expression containing unsigned variables to yield an unsigned, but I must be wrong and by default it yields an int.
return (uint)(r | (g << 8) | (b << 16));
...Seems like the best option.
Thanks again.
|
|
|
|
|
The documentation[^] is a little bit ambiguous, but the implication is that a left shift will return int (Int32 ) by default, hence the problems you encountered. I am sure there is a more explicit rule somewhere in the depths of the language specification if you care to look (but hey, life is short!).
|
|
|
|
|
hi
i had an set of x and y coordinates , it is a closed loop of polygon, so how we can find the area so please give me the idea
|
|
|
|
|
This may not be easy depending on the polygon[^].
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
Triangulate the polygon (you can find this algorithm in lots of places) and add up the area of all the triangles.
|
|
|
|
|
Exactly what I would have recommended. The better algorithms can even deal with concave polygons or 'holes'.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
There is a better algorithm than adding triangles
It is quite straight forward you need calculate two sums
sum1 = sum of ( pt[i].x * pt[i+1 % n].y)
sum2 = sum of ( pt[i+1 % n].x * pt[i].y)
then the area is sum1 - sum2
http://www.mathopenref.com/coordpolygonarea.html[^]
|
|
|
|
|
Excellent.
|
|
|
|
|
Be aware that this method does not work with polygons with crossovers. Mind you, that is true of simplistic triangulators too.
This is a good link if the OP does not need the triangulated form for other purposes (e.g. collision detection).
|
|
|
|
|
Excellent answer, and an interesting site, thanks +5 !
It appears this algorithm will work on polygons that have areas that "go inward," as long as they do not cross.
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
I need to get the free physical memory available so I don't get OutOfMemory Exception.
I have tried GlobalMemoryStatusEx but it seems the windows swaps out ram to virtual and the value is unreliable and ultimately results in out of memory also.
Any thoughts?
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|
|
You might want to have a look at MemoryFailPoint Class[^].
Creating an instance of a MemoryFailPoint class creates a memory gate. A memory gate is a check for sufficient resources prior to initiating an activity requiring a large amount of memory. Failing the check throws an InsufficientMemoryException[^] that avoids starting an operation, reducing the possibility of an application failing during execution due to lack of resources. This allows an application to decrease its performance in an effort to avoid an OutOfMemoryException[^] and any state corruption that may result from improper handling of an OutOfMemoryException[^] in arbitrary locations in code.
0100000101101110011001000111001011101001
|
|
|
|
|
Getting the free Physical memory will not necessarily help avoid an OutOfMemory exception - .NET is perfectly happy using virtual memory.
Have a look at this article: it covers the OOM problem in some depth. http://msdn.microsoft.com/en-us/magazine/cc163528.aspx[^]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
And running out of physical memory is not the only way to throw an OutOfMemory exception. Try running the handle pool dry and you'll do the same thing, even though there's plenty of free memory.
You can do this by creating and NOT disposing of Brushs, Pens, Graphics objects, Forms shown with ShowDialog, ...
|
|
|
|
|
I'm a relatively new c# programmer (transitioning from C++)and am working with a grid application. I've successfully bound the grid to a data structure but would now like to get rid of 0s in the rows. There must be an easy way to tell the grid to show nothing if the default value (or user input is 0) but I haven't found it. Also, I'd like to know if there's an easy way to do data validation on individual columns (ie non-negative int, double, etc.) Thank you.
|
|
|
|
|
Tom Paronis wrote: There must be an easy way to tell the grid to show nothing if the default value
(or user input is 0) but I haven't found it.
There's an event that you could use; CellFormatting[^], and there's a how to[^] article on MSDN explaining formatting that would be helpfull.
There's also a walktrough[^] available on MSDN.
Bastard Programmer from Hell
|
|
|
|
|
Thanks. This is the second time I've been bailed out by the Bastard programmer from Hell. I owe you a drink.
|
|
|
|
|
You're welcome, and thanks for the coffee
|
|
|
|