At this point I’m thinking that it isn’t the dotNetControl but the time it take to get values from the parameters, or some combination. It will be interesting to see what happens with yours. I only see it once I have it all connected up to a character, on it’s own or in a simple scene it works great. This is with only one control working as well. It isn’t like I have 10 of then trying to redraw all at the same time.
Just tried
senderArg.Invalidate()
senderArg.update()
and it works, I had tried update() on it’s own and it was even slow but looks like you need to call the invalidate and then the update and it forces it. Thanks, reading that bit you found may have done it for me.
I had the same issue with mine Paul, as invalidate only flags an update it queues it until the next redraw. This is usually pretty quick but on a fast updating user control you need it to do it immediately.
One issue with repeated repaint calls apart from speed is the flicker issue which i have come across also with this method. The flash is caused by the control erasing the image and displaying a blank background before it redraws the control. It is possible in dotnet to override the paint method to do nothing and perform the redraw elsewhere.
the other option is to use the SetStyle() method on a dotnet form to set the AllPaintingInWmPaint property to true. This will allow the form to disregard paint calls.
One option to try might be to try using this SetStyle method is possible, and move the redraw to the mouse move event rather than the paint event. At the moment the paint it is passing the redraw from the event to the other. The mouse event invalidates so it redraws, then sends the coordinates to the drawtarget function which invalidates and redraws again. perhaps you could avoid this double redraw by removing the paint call, doing all the work in the mouse move, sending that to the drawtarget sub and invalidate finally at the end when all the drawing is done.
The other property of use would most certainly be doublebuffering. with this, the image is built in memory instead on the control and then drawn on after onto the form. It takes the same amount of time to do this but dramatically reduces flicker.
Well all sounds good. At the moment I’m not getting any flicker. How ever I would like to get rid of the paint event as I think it is the cause of other issues that I ran in to and have been trying to correct. The paint calls are being called when the dialog goes behind another dialog and then gets focus again. This causes some very strange results.
So, how do I go about painting without the paint event? I have been looking but not seen anything that jumps out at me at the moment. Also removing the paint event would simplify the code just that much more and give me a bit more control as to when painting happens.
Thanks for all the help. I’ll post a final working control when I know that it isn’t doing anything nasty.
Looks like I will need “system.drawing.graphics” but not sure how to apply it with out the paint event.
You can create a graphics object yourself by invoking the .CreateGraphics method of a control:
local g = MyControl.CreateGraphics()
g.FillRectangle brush rect
g.Dispose()
Cheers,
Martijn
Doh, wasn’t looking there. Good stuff. I have it working as it is so I will poke around with this and see if I can simplify it later. So far it is responding quickly on my lap top without flashing and I have an old lap top. Unfortunitly I’m sitting in the emergency room with my wife trying to get work done. We might get free medical care in Canada but you sure do have to wait for it, 6 hours+ so far today.
So how did everything progress with this ? It would be a cool thing to know how to do.
Much of it is posted here, but here is a basic over view of what I needed to do.
I loaded a image in to the backgroundImage property. For the target I created another BMP with a backGround color that was the same color as the backGroundColor property of the dotnet pictureBox controls, this is what is used as the transperent color.
To draw the target I’m using the GDI drawing methods that have been duscussed here to place the target BMP where the mouse is.
I have several event handlers for each of the joy stuck controls. The paint event that calls the drawing of the target function, mouseDown, mouseUp and mouseOut I think. I would have to have a look. With the way that I did it I now have the ability to multi select controls so that they can be reset and keyed through a RC menu as well as create groups of controls for saving poses just like PENAttribute Holder 2 but on streoids. For the pose capture I have a treeView and you can just scrub on the items in the tree and again I use GDI drawing, this time just using a filled rectangle as the slider. To show the selections of controls I use a system.drawing.pen and out line the control in yellow.
All in all it works well, it is a little slow to draw all the controls at once when scrubbing animation but it is acceptable. To get the controls to update durring scrubbing I’m using a timeChange callBack that gets the values from the parameters and applies them back to the poictureBox controls. I store an array of structs that hold the information about which parameters are to work with which pictureBox controls.
I can’t show the final results as the client will not allow it at this point. It is working very well and they love the tool and find it very easy to use. One cool feature that I added was being able to copy and paste values from one to the other with the ability to mirror the value on the X. I have other feature like being able to contrain the control to either X or Y depending on shift, ctrl alt being pressed and several other options. All the poses are store in an XML file on the server so that when some one saves a pose every one gets it.
That sounds really cool Paul, and looks great too from the images you’ve posted…:applause:
Hello,
This post is very very interesting , thanks for all the stuff and ideas discussed!
it was a very great help for me
I am using the dotnet4Controls previously posted here and it works very well for me. Although i have a little problem. When i move the orange pointer, it leaves a trail. It seems that the dotnet label doesn’t update very well.
Here is the source code previously posted :
(
/*
DotNet Joystick Test.
Usage:
Hold SHIFT while dragging to allow X movement only
Hold CONTROL while dragging to allow Y movement only
Right click while dragging to cancel and revert to previous position
Double click to reset stick
To add a joystick:
1. Add another "System.Windows.Forms.Label" dotNetControl below
2. Add 4 event handlers (see 'Joystick_01 MouseDown' etc below)
3. Add the control to the 'Joysticks' and 'JoystickTitles' arrays (in the rollout's open handler)
*/
rollout JoystickRollout "DotNet Joystick Test" width:184 height:184
(
local Joysticks
local JoystickTitles
dotNetControl Joystick_01 "System.Windows.Forms.Label" pos:[8,8] width:80 height:80
dotNetControl Joystick_02 "System.Windows.Forms.Label" pos:[96,8] width:80 height:80
dotNetControl Joystick_03 "System.Windows.Forms.Label" pos:[8,96] width:80 height:80
dotNetControl Joystick_04 "System.Windows.Forms.Label" pos:[96,96] width:80 height:80
/*
Moves stick to the specified position.
*/
fn Joystick_Position s pos =
(
local x = if keyboard.controlPressed then s.Tag.X else (if pos.x < 0 then 0 else if pos.x > s.Width - 2 then s.Width - 2 else pos.x)
local y = if keyboard.shiftPressed then s.Tag.Y else (if pos.y < 0 then 0 else if pos.y > s.Height - 2 then s.Height - 2 else pos.y)
s.Controls.Item[0].Location.X = x - 4
s.Controls.Item[0].Location.Y = y - 4
/* Uncomment below two lines to view joystick outputs in listener. */
local i = findItem Joysticks s
format "Joystick % : [%, %]
" i (x as float / (s.Width - 2)) (y as float / (s.Height - 2))
)
/*
Event delegates for joysticks.
*/
fn Joystick_MouseDown s e =
(
if (dotNet.CompareEnums e.Button e.Button.Left) then
(
s.Tag = s.Controls.Item[0].Location
Joystick_Position s [e.X, e.Y]
)
if (dotNet.CompareEnums e.Button e.Button.Right) and s.Tag != undefined then
(
s.Controls.Item[0].Location = s.Tag
s.Tag = undefined
)
)
fn Joystick_MouseMove s e =
(
if (dotNet.CompareEnums e.Button e.Button.Left) and s.Tag != undefined then
Joystick_Position s [e.X, e.Y]
)
fn Joystick_MouseUp s e =
(
if (dotNet.CompareEnums e.Button e.Button.Left) and s.Tag != undefined then
s.Tag = undefined
)
fn Joystick_DoubleClick s e =
(
Joystick_Position s [(s.Width - 2) / 2, (s.Height - 2) / 2]
)
/*
Event handlers for joysticks.
*/
on Joystick_01 MouseDown s e do Joystick_MouseDown s e
on Joystick_01 MouseMove s e do Joystick_MouseMove s e
on Joystick_01 MouseUp s e do Joystick_MouseUp s e
on Joystick_01 DoubleClick s e do Joystick_DoubleClick s e
on Joystick_02 MouseDown s e do Joystick_MouseDown s e
on Joystick_02 MouseMove s e do Joystick_MouseMove s e
on Joystick_02 MouseUp s e do Joystick_MouseUp s e
on Joystick_02 DoubleClick s e do Joystick_DoubleClick s e
on Joystick_03 MouseDown s e do Joystick_MouseDown s e
on Joystick_03 MouseMove s e do Joystick_MouseMove s e
on Joystick_03 MouseUp s e do Joystick_MouseUp s e
on Joystick_03 DoubleClick s e do Joystick_DoubleClick s e
on Joystick_04 MouseDown s e do Joystick_MouseDown s e
on Joystick_04 MouseMove s e do Joystick_MouseMove s e
on Joystick_04 MouseUp s e do Joystick_MouseUp s e
on Joystick_04 DoubleClick s e do Joystick_DoubleClick s e
/*
Initialize joysticks when rollout is opened.
*/
on JoystickRollout open do
(
-- Array containing joystick controls and their captions.
Joysticks = #(Joystick_01, Joystick_02, Joystick_03, Joystick_04)
JoystickTitles = #("Joystick", "Another one", "Yet another joystick", "Last one")
-- Initialize joysticks.
for i = 1 to Joysticks.count do
(
-- Setup joystick background.
Joysticks[i].ForeColor = (dotNetClass "System.Drawing.Color").FromARGB 164 164 164
Joysticks[i].BackColor = (dotNetClass "System.Drawing.Color").FromARGB 255 255 255
Joysticks[i].BorderStyle = (dotNetClass "System.Windows.Forms.BorderStyle").FixedSingle
Joysticks[i].Padding = dotNetObject "System.Windows.Forms.Padding" 2 2 2 2
Joysticks[i].TextAlign = (dotNetClass "System.Drawing.ContentAlignment").TopCenter
Joysticks[i].Text = JoystickTitles[i]
-- Setup "stick".
Stick = dotNetObject "System.Windows.Forms.Label"
Stick.Enabled = false
Stick.Size = dotNetObject "System.Drawing.Size" 8 8
Stick.BackColor = (dotNetClass "System.Drawing.Color").FromARGB 255 128 0
Stick.BorderStyle = (dotNetClass "System.Windows.Forms.BorderStyle").FixedSingle
Stick.Location = dotNetObject "System.Drawing.Point" (((Joysticks[i].Width - 2) / 2) - 4) (((Joysticks[i].Height - 2) / 2) - 4)
-- Add "stick" to joystick.
Joysticks[i].Controls.Add Stick
)
)
)
createDialog JoystickRollout
)
This happens only when i output value to the listener by uncommenting this two lines.
local i = findItem Joysticks s
format "Joystick % : [%, %]
" i (x as float / (s.Width - 2)) (y as float / (s.Height - 2))
It happens also when i link the X and Y values to an object in my scene.
Strangely, i don’t see this sort of trails on my computer at home.
I have roughly the same PC than at work. Vista pro, 3dsmax 2008.
Does someone have an idea ? Is it happening on your computer ?
Can it be graphic card drivers or windows configuration ?