PDA

View Full Version : system.drawing.pen?


PEN
09-09-2009, 08:56 PM
What am I doing wrong here?

aColor = dotNetClass "system.drawing.color"
aPen = dotNetObject "system.drawing.pen" aColor 2

denisT
09-09-2009, 09:07 PM
-- aColor = dotNetClass "system.drawing.color"
aColor = (dotNetClass "system.drawing.color").yellow -- it must be the object
aPen = dotNetObject "system.drawing.pen" aColor 2


...

VVaari
09-09-2009, 09:07 PM
You need to set color first.


aColor = dotNetClass "system.drawing.color"
aColor = aColor.fromargb 255 255 255
aPen = dotNetObject "system.drawing.pen" aColor 2

LoneRobot
09-09-2009, 09:07 PM
you probably need to pass it an actual color from the .fromARGB method rather than the class.

How come you get your own dotnet class paul?

PEN
09-09-2009, 09:09 PM
now I know I'm tired:S What an idiot, thanks guys.

PEN
09-09-2009, 09:16 PM
OK next questions I have a label, I want to draw a line in it. I'm using sender.createGraphics() and then creating a pen and drawing the line. Works only for a second. I get a flash of the line and then it is gone. Any idea what is wrong?

denisT
09-09-2009, 09:25 PM
OK next questions I have a label, I want to draw a line in it. I'm using sender.createGraphics() and then creating a pen and drawing the line. Works only for a second. I get a flash of the line and then it is gone. Any idea what is wrong?

draw in bitmap and use this bitmap as label's image...

PEN
09-09-2009, 09:27 PM
I would rather not have to draw in a bitMap. I should just be able to draw into the label as I am and have it stay.

I'm doing it in a function that is being called from the mouseDown handler.

denisT
09-09-2009, 09:56 PM
you are doing everything right... i don't see a problem

try(destroydialog drawRol) catch()
rollout drawRol "Draw in Label"
(
dotNetControl lb "System.Windows.Forms.Label" width:180 height:30 pos:[10, 10]

local pen = dotNetObject "system.drawing.pen" (dotNetClass "system.drawing.color").red 2
on lb mouseDown s e do
(
g = s.createGraphics()
g.DrawLine pen 0 e.y s.bounds.width e.y
)
)
createdialog drawRol width:200 height:50


something forces labels redraw...

PEN
09-09-2009, 10:01 PM
Look like I have to do it with the paint event. As soon as I did that it stays.
So I'm using the labels paint event and the arg.graphics to keep it updated.

PEN
09-09-2009, 10:27 PM
This is very slow to update. What do I call to stop the display until it is drawn?

magicm
09-09-2009, 11:00 PM
Have you tried s.Invalidate() in the mouseDown handler? That should force it to update in the next drawing cycle.

Martijn

LoneRobot
09-09-2009, 11:08 PM
hi Paul,

I did a bit of research into the paint event stuff here (http://lonerobot.net/?p=267) and found it generally quite slow via MXS. You could use the .focused property to only fire the paint event when the label is clicked but that might not fit in with what you are trying to do. There are a load of paint drawing methods that i experimented with to look at in the download at the end of the page i linked above.

In a few of my dotnet user controls i have used the paint event and there isn't the slowdown that i see within direct use in Max. However you are bound to using the external assembly which isnt ideal for many.

If you need help with an inherited control, let me know.

PEN
09-10-2009, 01:15 AM
I definitely have a problem then. I need to be able to replicate some thing like the time line in Max. I need it to be scalable as it is in Max and I need to have it support up to and above 10k of frames. There are a few optimizations that I can do like only drawing in the visible area and maybe drawing less lines.

What is the faster way of drawing that you are thinking of Pete?

PEN
09-10-2009, 01:47 AM
In looking at your site and script Pete I think that I'm going about it the same way. Nice script that you have there and thanks for sharing that. I looked at it before but didn't understand as much as I do now.

CGTalk Moderation
09-10-2009, 01:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.