|
"Empty"; as "IsEmpty" would be question and would indeed imply either a delegate or a method.
"Empty" is a property of the Polygon. "IsEmpty" would be a method that can be called from that property to fetch a value, but a property never begins with "Is".
The color of an apple is "Apple.Color", not "Apple.IsColor". Yes, you might be persuaded to prefix the "Is" because the property returns a bool. It shouldn't matter whether it returns a bool or an enum - if it's a property, then it'll have the name of a property - not the form a question.
Bastard Programmer from Hell
|
|
|
|
|
Thinking about the way structs such as Size , Point and Rectangle deal with this, I haven't checked, but I don't believe they don't provide a property for this. There is a static read only instance available called Empty that you can use for equality comparison to see if the one you have is empty. Overriding Equals(object) , GetHashCode() and providing operator overloads for == and != (and possibly implementing IEquatable<T> ) would be the way to do this.
I don't think I would use a property for this, I would use a method public bool IsEmpty() as you are asking for information about the object as a whole rather than a part of it which is IMO opinion the purpose of a property.
|
|
|
|
|
Hello everyone! I have a School Management Application that shows examination reports for students in a selected class. I used a Panel control to model a sheet of paper on which each student's results are shown. Thus for selected classes, the number of controls (Panels modeled as sheets) added to the tab page depends on the number of students in the class. Class student's are around 50 to 60.
When I first open reports for a class, all controls are created (as sheets) and no problem occurs. However, when I try to open examination reports for another class, I get a 'Win32Exception' with additional error information that 'Error creating window handle'.
Now I tried to open in another way. When I open the examination reports for the first which does not report any error, I close it before opening that of another class but the problem is that the error is still generated even when the first list of reports have been closed and removed from the TabControl. Any solution around this? Thanks in advance.
|
|
|
|
|
Posting some source code would help.
/ravi
|
|
|
|
|
Are you trying to do something in the wrong thread?
|
|
|
|
|
Ran into a weird Bitmap problem that I can't find in Google:
The Bitmap constructor crashes on a file with an alpha channel under Windows 7, but works perfectly under Windows XP.
The code couldn't be simpler:
Bitmap image = new Bitmap (fname);
The error is: "Parameter is not valid", and there's no inner exception.
If it failed in Windows XP too, I'd suspect a simple bug, but since it works there it implies it's something more complex.
Any ideas how a bitmap with an alpha channel can be loaded under Windows 7? Thanks!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
|
It's a TIFF file. I've loaded BMP files (without an alpha channel) with this same code with no problem.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
And the same file opens on XP?
|
|
|
|
|
Yes. The TIFF file with an alpha channel works perfectly under XP. Both BMP and TIFF files WITHOUT an alpha channel work under both OSes.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Possibly a problem with the TIFF codec in Windows 7 then I'm afraid. If I were you, I'd raise a report through Microsoft Connect.
|
|
|
|
|
Thanks!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
You're welcome. I'm just sorry I couldn't be of more assistance.
|
|
|
|
|
Hi everyone!
I'm looking for a library that allows me to load, save and edit .dxf documents. Preferably, it has to be free. I need to allow the user to define "zones" over the "graphic" through a visual interface.
Thank you in advance!
modified 8-Mar-12 11:57am.
|
|
|
|
|
|
Thank you very much. I will take a look to these libraries!
|
|
|
|
|
The autodesk API is not what I need. I understand that it is more about developing autocad plugins or using autocad functions remotely, but always having the main program installed. I will take a look to your second proposal...
|
|
|
|
|
hi all
i need an component that find all directory that can show in tree viewer.
|
|
|
|
|
It's part of the Framework (means it's already on you machine). You'd use the GetFilesMethod of the Directory[^] class and display it in a TreeView[^].
I'm sure that there are plenty examples on this on the internetz. What have you tried so far?
Bastard Programmer from Hell
|
|
|
|
|
A nice sample here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
I am getting an System.OutofmemoryException when using Filestream to load zip file. the file is 521MB. My code is:
//Insert using Filestream, file into SQL Server Table
private void btnInsert_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDlg = new OpenFileDialog();
openFileDlg.InitialDirectory = Directory.GetCurrentDirectory();
if (openFileDlg.ShowDialog() == DialogResult.OK)
{
FileInfo fi = new FileInfo(openFileDlg.FileName);
FileStream fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
BinaryReader rdr = new BinaryReader(fs);
byte[] fileData = rdr.ReadBytes((int)fs.Length);
rdr.Close();
fs.Close();
My program dies on this line: byte[] fileData = rdr.ReadBytes((int)fs.Length);
i have also attached the detail for the System.OutofMemoryException. (<a href="http://www.mediafire.com/?vk77dph2vjcq3vx">)
</a>[<a href="http://www.mediafire.com/?vk77dph2vjcq3vx" target="_blank" title="New Window">^</a>]
I am runing this on a Windows 7, 64bit machine.
thanks for your help.
Sharon
|
|
|
|
|
Sharonc7 wrote: byte[] fileData = rdr.ReadBytes((int)fs.Length);
You're reading the 521 Mb in a single call. How about reading a single megabyte, writing that and move on to the next one?
Bastard Programmer from Hell
|
|
|
|
|
Two possibilities:
1. you really ran out of memory. If your code fails right away, this is a likely cause.
2. a byte array is an object; objects larger than some 80KB get allocated on the "Large Object Heap". That heap does not get compacted, hence it may become a subject of fragmentation, which in turn could result in a big memory block not being available although maybe lots of smaller ones are. If your code succeeds a couple of times, and then starts to fail, this is a likely cause.
Now, as Eddy said, why do you want all that data in memory at once? Do you really need that, or are you just being lazy?
BTW: the line byte[] fileData=File.ReadAllBytes(openFileDialog.FullName); could easily replace six of your statements (assuming having all the data at once is really necessary). Notice how the word "Stream" did not show, as streaming means consuming data in chuncks, not getting it all in one. Your code is an example of "stream abuse".
|
|
|
|
|
Hi,
thanks for the help.
Hi,
As I mentioned I have a machine that has 8 GB of memory. I had to shut down my machine to take it home last night.
When I tried to load the file again today it loaded with no problem. Normally I will only be loading one file at a
time, but in this case I was testing my Development database and was loading 28 files one right after the other.
Now my question is, since it is working ok now, is there a problem I still need to fix?
Sharon
|
|
|
|
|
Sounds like a fragmentation issue then; and that could be tough, it may well be a fundamental weakness of the .NET memory management.
Sharonc7 wrote: Normally I will only be loading one file at a time Is that one file per run? if so, nothing needs to be done.
Otherwise "solutions" are (pick one or more):
1. when it happens, restart your app;
2. organize things so that you don't need those large objects, or at least reduce their number;
3. make sure you free the large objects as soon as you don't need them any more (and before allocating more of them). This may involve setting a reference to null AND calling GC.Collect() explicitly (which under normal circumstances should better not be done).
4. organize memory reuse, rather than forgetting about stale objects and allocating new ones. However, this can't be done for methods that return a (new) large object, such as your stream.Read or my File.ReadAllBytes.
|
|
|
|