WPF? Pah!
I'm sitting in Joseph Cooney's (excellent) session on WPF at CodeCampOz, and it seems to me that the canonical demo of WPF is an animated button bouncing around a form. Of course, this is something VFP has been able to do for ever:
**************************************************
*-- Form: form1
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 04/01/07 02:18:00 PM
*
DEFINE CLASS form1 AS form
DoCreate = .T.
Caption = "Form1"
llanimating = .F.
ndirection = 0
nspeed = 0
Name = "Form1"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 60, ;
Left = 108, ;
Height = 109, ;
Width = 157, ;
Caption = "Command1", ;
Name = "Command1"
ADD OBJECT timer1 AS timer WITH ;
Top = 216, ;
Left = 336, ;
Height = 23, ;
Width = 23, ;
Interval = 50, ;
Name = "Timer1"
PROCEDURE llanimating_assign
LPARAMETERS vNewVal
*To do: Modify this routine for the Assign method
THIS.llAnimating = m.vNewVal
this.Timer1.Enabled = this.llanimating
IF ! this.llAnimating
this.ResetButton
ELSE
this.nDirection = RAND() * 2 * PI()
this.nSpeed = INT(RAND() * 10) + 1
this.Command1.BackColor = RAND() * 0xFFFFFF
endif
ENDPROC
PROCEDURE resetbutton
* Reset the button to default values
this.Command1.Top = INT(this.Height/2 - this.Command1.Height/2)
this.Command1.Left = INT(this.Width/2 - this.Command1.Width/2)
this.Command1.ResetToDefault("BackColor")
ENDPROC
PROCEDURE movebutton
WITH this.Command1
* move the button by (nSpeed) in the (nDirection) direction
.top = .top + (.Parent.nSpeed * COS(.Parent.nDirection))
.Left = .Left + (.Parent.nSpeed * SIN(.Parent.nDirection))
* check to see whether we've hit a wall
IF .Left < 0
.Parent.nDirection = 2* PI() - .Parent.nDirection
.BackColor = RAND() * 0xFFFFFF
ENDIF
IF .Top < 0
.Parent.nDirection = PI() - .Parent.nDirection
.BackColor = RAND() * 0xFFFFFF
ENDIF
IF .Left + .Width > .Parent.Width
.Parent.nDirection = 2* PI() - .Parent.nDirection
.BackColor = RAND() * 0xFFFFFF
ENDIF
IF .top + .height > .Parent.Height
.Parent.nDirection = PI() - .Parent.nDirection
.BackColor = RAND() * 0xFFFFFF
ENDIF
endwith
ENDPROC
PROCEDURE command1.Click
thisform.llAnimating = !thisform.llanimating
ENDPROC
PROCEDURE timer1.Timer
thisform.movebutton()
ENDPROC
ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Enjoy!
Comments
- Anonymous
March 31, 2007
CodeCampOZ 2007 was on this weekend in Wagga Wagga at the Charles Sturt University campus. I'm seeing - Anonymous
March 31, 2007
CodeCampOZ 2007 was on this weekend in Wagga Wagga at the Charles Sturt University campus. I'm seeing - Anonymous
April 01, 2007
Bouncing? PAH! Any old presentation platform can bounce a button around, but it takes something truly revolutionary to allow the button to SPIN as well as bounce. I await your spinning and bouncing VFP demo with anticipation. - Anonymous
April 01, 2007
is there a CTP for the BBD in VFP? (BBD=bouncing button demo)Or should I wait for an RTW or an RTM?;-)