|
Another homework question I expect - wrong forum, wrong website.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
ref PointF[][] P;
List<PointF> tP
How to assign TP values to jagged array P?
I tried P[0] = TP. but iam getting the following error.
error CS0029: Cannot implicitly convert type 'System.Collections.Generic.List<System.Drawing.PointF>' to 'System.Drawing.PointF[]'
Please solve this problem.
|
|
|
|
|
If your list holds intems of type PointF then how do you expect it to create a jagged array of PointFs from it.
You can create an array by
PointF[] pointFArray;
pointFArray = tP.ToArray();
If you want a jagged array - the only sensible thing would be
float[][] pointFJaggedArray;
If you do this, you'll need to set the pointFJaggedArray length to the same as the List and then iterate through the list and assign each x and y float value to each item in the array.
Dave
|
|
|
|
|
I have some FormDialog and on it i have minimize and maximize window.
How can i know ( if the window is in normal size ) if the user pressed minimize or maximize window ?
Thanks.
|
|
|
|
|
just check this
private void Form1_Resize(object sender, EventArgs e)<br />
{<br />
MessageBox.Show(WindowState.ToString());<br />
}
one enum is used
System.Windows.Forms.FormWindowState
FormWindowState has following value
Minimize<br />
Normal<br />
Maximize
Hope this will help you
|
|
|
|
|
Hi,
the current state of the Form is available as Form.WindowState
the relevant event would be Form.Resize
I trust all details are available in the documentation.
|
|
|
|
|
|
Hi All;
Please help me....
I want to develop a log in form using share-point work-flow .
How Can I Do That?;
Thanks All;
|
|
|
|
|
hi friends
i want to register the dll using C# how i can do this can any body tell me about that please
wasim khan
|
|
|
|
|
You want to register a COM dll ? Why ? You'd use process.start to call regsvr32, I suppose.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hey guys...
as you may or may not know im busy developing a couple of controls that do quite a bit of GDI drawing... Each control consists of 2 panels, on one it draws a clock, and data behind it in the form of pies(graphics.FillPie(); ) and lines on top of the pies. or in other cases a pie sweeping left and right in between two lines all this talk about pie is making me hungry!!!
anyway, the 2nd panel has some maskedTextBoxes, comboBoxes ect and behind it i draw a pretty elaborate time line.
lets talk about he 1st panel...
in its Paint handler i split the drawing up into two methods, drawData() and drawClock() like so...
private void clockPanel_Paint(object sender, PaintEventArgs e)
{
drawData(e.Graphics, clockPanel.ClientRectangle);
drawClock(e.Graphics, clockPanel.ClientRectangle);
}
as you can see i send the graphics object to these methods to draw with so here comes the question...
when im sending the grapics object like above does that make a copy of it or just send a reference to the original graphics object?
the reason im asking is im not sure where would it be best to dispose of it... should i dispose within clockPanel_Paint IE after drawData() and drawClock() OR should i dispose at within drawData() and drawClock() after they finished their drawing? or possibly both?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
It passes references, not copies.
The general rule of thumb is:
If you create a disposable object with new , its up to you to dispose it, or you can just wait for the GC to do it.
|
|
|
|
|
okay, so since i didnt explicitly create this graphics object like <coed>Grapics blah = this.CreateGraphics(); i dont have to worry about disposing it?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
HarveySaayman wrote: okay, so since i didnt explicitly create this graphics object like Grapics blah = this.CreateGraphics(); i dont have to worry about disposing it?
That is correct There might be few exceptions, but I wouldnt lose sleep over it, just let the GC handle them
|
|
|
|
|
cool, thanx bud
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
If you were to dispose of this graphics object, I am sure the app would blow up. It's being passed to you, what passes it, needs to deal with it.
NEVER rely on GC for GDI objects you create, that's a good way to kill your app
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: the app would blow up
oooh that sounds like it could be fun. maybe even useful as an "undocumented feature" to "take care" of difficult end users
Christian Graus wrote: NEVER rely on GC for GDI objects you create
yeah, the reason for the question is i remembered reading some ware here on CP that its important to dispose of graphics objects... but i cant remember whether the author was using the OnPaint's grapics object or a new 'ed one.
thanx for your insight
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Glad to help. The idea that GC means you don't have to worry about resources is easy to get from the literature, and it's very wrong.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: and it's very wrong
agreed, which is exactly why i asked the question. the one control(the one with a pie sweeping in between two lines) redraws as fast as it possibly can(im assuming this because i cant see a visible change of the speed when the timer is on 100 or on 1ms)
i was thinking that if there is a resource problem i might not even realize it with my 3Ghz & 2gig ram dev pc where as a users 1.5ghz & 512mb ram might crash or be very slow and i wouldnt know why...
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi Harvey,
HarveySaayman wrote: i cant see a visible change of the speed when the timer is on 100 or on 1ms
You may want to read my timers article then.
|
|
|
|
|
ill do just that
thanx Luc
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
It's passed as reference, and you shouldn't dispose it at all.
Only dispose Graphics objects that you create yourself (e.g. with a call to CreateGraphics()); the Graphics object in the Paint event is created by .NET and will be disposed by .NET after all event handlers are finished.
|
|
|
|
|
Hi! I want to know if is possible to select just the date from the DateTimePicker, I don't want the time, just the date, any help? Thx
|
|
|
|
|
dateTimePicker1.Value.Date returns a DateTime with just the date value - the time is set to 00:00:00. That's the closest you can get unless you create your own Date class.
Dave
|
|
|
|
|
thx...but I solved other way, I changed the format of the DateTimePicker to custom and then I declare in the customFormat field 'dd-MM-yyyy' and it works fine. But thx for the help anyway, have a nice day
|
|
|
|