KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

LedControl - Scrollable Control
Goto page 1, 2  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 26, 2006 2:21 am    Post subject: LedControl - Scrollable Control Reply with quote

Just thought I would take this discussion over here. Assuming the LED control will drive the scrolling, trying to think of a way to create a Timer object and somehow (in the Tick event) identify which particular LedControl the Timer belongs to ... the Timer doesn't have a Tag property to tag it. hmmm
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jan 26, 2006 12:54 pm    Post subject: Reply with quote

If you are building the timer into the control would you not then just assign default values to it, and have it so the user (me) could then change those values.

Ex:
$Led1.Scroll="True"
$Led1.Speed=1000
$Led1.Move="Left"
$Led1.Text="whatever"
$Led1.Backcolor="Red"
$Led1.Forecoler="Pink"


As for the Timer piece is it possible to build the timer into the control? Would that mess up other timers built into a script?

And I may be asking for more than I really know here, but would the bitmaps of the characters be built into the control? If they are would there be a .style available to have different bitmaps display.

In my opinion the more that you can put into the control itself and make available to the user as part of the control the eaier it will be for users to implement.

Then again I may asking for the imposssible.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 26, 2006 2:27 pm    Post subject: Reply with quote

In terms of this stuff ...

$Led1.Scroll="True"
$Led1.Speed=1000

Can't really do that because the LedControl is based on the PictureBox, and the PictureBox doesn't support those properties.

The Timer control is built into the Control (kinda), the timer can be referenced through the Control.Tag property ... but ... its the "other way round" I'm trying to find a solution to ... given a Timer, how can you tell which Control it belongs to ... the Timer object doesn't have a Tag property, or any other member that can be used to store temp. data.

I found a work-around ... I'm creating a global variable named after the "class" called $_LedControl, and in there I'm have an ArrayList of all the currently active LedControls, then in the Timer event, passing the index of the LedControl to the Timer.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 26, 2006 3:01 pm    Post subject: Reply with quote

Ok, heres a first pass .. I added another parameter to the LedControl called "scroll" and the settings are:

0 = None
1 = Left
2 = Right

It also supports a new kind of Width and Height ... if Width is a negative value, it indicates one wants to create an LedControl with said number of "LED's" - same for height, a minus value indicates the number of LED Rows - not the actual pixel height of the control, so ... to create an LedControl that is 16 segments wide, by 2 segments high and scrolls left, one would say:

LedControl(0,0,-16,-2,4,1)

btw - the "4" indicates the scale or size of the individual led "pixel" segments ...

btw2 - you should set the text string to equal the actual size of the LedControl - even if you have to pad-out the string, for example, if the LedControl is 10 segments wide, and you want to scroll the string "Hello", use this:

$LedControl.Text = "Hello "


Code:

Break On

$System = CreateObject("Kixforms.System")

$Form = $System.Form()
$Form.Text = "LED Driver"
$Form.FormBorderStyle = $System.FormBorderStyle_FixedDialog
$Form.MaximizeBox = 0

$LedControl1 = $Form.Controls.Add(LedControl(0,0,-16,-1,4,1))
$LedControl1.Text = "Scroll Left...  "
$LedControl1.BackColor = $System.Color.FromRgb(103,30,0)
$LedControl1.ForeColor = $System.Color.FromRgb(255,60,0)

$LedControl2 = $Form.Controls.Add(LedControl(0,0,-16,-1,4,2))
$LedControl2.Top = $LedControl1.Bottom;
$LedControl2.Text = "Scroll Right... "
$LedControl2.BackColor = $System.Color.FromRgb(0,103,30)
$LedControl2.ForeColor = $System.Color.FromRgb(0,255,50)

$LedControl3 = $Form.Controls.Add(LedControl(0,0,-16,-1,4,1))
$LedControl3.Top = $LedControl2.Bottom;
$LedControl3.Text = "Scroll Left...  "
$LedControl3.BackColor = $System.Color.FromRgb(23,64,103)
$LedControl3.ForeColor = $System.Color.FromRgb(63,181,255)

$Form.ClientWidth = $LedControl1.Width
$Form.ClientHeight = $LedControl3.Bottom

$Form.Center
$Form.Show

While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 0

Break On

;
; LEDCONTROL
;

Function LedControl(
   optional $left,
   optional $top,
   optional $width,
   optional $height,
   optional $scale,
   optional $scroll)

 If Not $scale
  $scale = 3
 Endif

 $cx = (($scale+1)*5)+$scale
 $cy = (($scale+1)*7)+$scale

 If $width < 0
  $width = abs($width) * $cx
 Endif

 If $height < 0
  $height = abs($height) * $cy
 Endif

 $LedControl = $System.PictureBox()
 $LedControl.Left = $left
 $LedControl.Top = $top
 $LedControl.Width = $width
 $LedControl.Height = $height
 $LedControl.BackColor = $System.Color.DarkGreen
 $LedControl.ForeColor = $System.Color.LightGreen

 ;
 ; Make the LED bitmap...
 ;

 dim $maptab[127]
 $maptab[00] = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ; *
 $maptab[32] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;   (SPACE)
 $maptab[33] = 0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0 ; !
 $maptab[39] = 0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; '
 $maptab[44] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0 ; , (COMMA)
 $maptab[46] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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ab[86] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0 ; V
 $maptab[87] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0 ; W
 $maptab[88] = 1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1 ; X
 $maptab[89] = 1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0 ; Y
 $maptab[90] = 1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,1,1 ; Z

 Dim $ArrayList
 $ArrayList = $System.ArrayList()

 $= $ArrayList.Add($scale)
 $= $ArrayList.Add($maptab)
 $= $ArrayList.Add($scroll)

 If Not $_LedControl
  $_LedControl = $System.ArrayList()
 Endif

 If $scroll
  Dim $Timer
  $Timer = $System.Timer()
  $Timer.Interval = 400
  $Timer.Start
  $index = $_LedControl.IndexOf($_LedControl.Add($LedControl))
  $Timer.Tick = "LedControlTimerTick($index)"
 Endif

 $LedControl.Tag = $ArrayList

 $LedControl.TextChanged = "LedTextChanged($$System.Sender, $$System.EventArgs)"

 LedTextChanged($LedControl, 0)

EndFunction

Function LedControlTimerTick($index)

 Dim $scale
 Dim $control
 Dim $text

 $control = $_LedControl.Item($index)

 $text = $control.Text
 $scroll = $control.Tag.Item(2)

 If $scroll = 1
  $text = SUBSTR($text,2)+LEFT($text,1)
 Else
  $text = RIGHT($text,1) + SUBSTR($text,1,LEN($text)-1)
 Endif

 $control.Text = $text

EndFunction

Function LedTextChanged($sender, $e)

 $ArrayList = $sender.Tag

 $pix = $ArrayList.Item(0)
 $cx = (($pix+1)*5)+$pix
 $cy = (($pix+1)*7)+$pix

 $LedBitmap = $System.Bitmap.FromSize($System.Size($cx,$cy))
 $LedGraphics = $System.Graphics.FromImage($LedBitmap)
 $LedGraphics.Clear($System.Color.Black)

 Dim $BackColorBrush
 $BackColorBrush = $System.SolidBrush($Sender.BackColor)

 For $y = 1 To $LedBitmap.Height-$pix Step $pix + 1
  For $x = 1 To $LedBitmap.Width-$pix Step $pix + 1
   $LedGraphics.FillRectangle($BackColorBrush,$x,$y,$pix,$pix)
  Next
 Next

 Dim $TextureBrush
 $TextureBrush = $System.TextureBrush($LedBitmap)

 Dim $Bitmap
 $Bitmap = $System.Bitmap.FromSize($sender.ClientSize)

 $BitmapGraphics = $System.Graphics.FromImage($Bitmap)

 $BitmapGraphics.FillRectangle($TextureBrush,0,0,$sender.ClientWidth,$sender.ClientHeight)

 Dim $maptab
 $maptab = $ArrayList.Item(1)

 $br = $System.SolidBrush($sender.ForeColor)

 $xoff = 1
 $yoff = 1
 dim $x
 dim $y

 $str = UCase(CStr($sender.Text))

 For $i = 1 To Len($str)
  $chr = substr($str,$i,1)
  $asc = asc($chr)
  Select
   Case $asc = 13
    $yoff = $yoff + $cy
    $xoff = 1
   Case $asc = 10
    $xoff = 1
   Case 1
    $map = $maptab[asc($chr)]
    If UBound($map) = -1
     $map = $maptab[0]
    Endif
    $n=0
    For $y = $yoff To ($yoff + $cy) - ($pix+1) Step $pix+1
     For $x = $xoff To ($xoff + $cx ) - ($pix+1) Step $pix+1
      If $map[$n] = 1
       $BitmapGraphics.FillRectangle($br,$x,$y,$pix,$pix)
      Endif
      $n=$n+1
     Next
    Next
    $xoff = $xoff + ($cx)
  EndSelect
 Next

 $sender.Image = $Bitmap

EndFunction
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jan 26, 2006 3:32 pm    Post subject: Reply with quote

Sometimes you are just amazing at how fast you get these things rolled out.

I will play with this tonight when I get home from work.

Many thanks.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Thu Jan 26, 2006 3:33 pm    Post subject: Reply with quote

this is very Kool!
_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 26, 2006 3:58 pm    Post subject: Reply with quote

well, other than the Timer - if you look really close - you will see that it wasn't that hard ... just a bit of string minipulation really, take char from front and move it to back kinda stuff.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 26, 2006 4:08 pm    Post subject: Reply with quote

lol, here's another cool configuration ...

Code:

Break On

$System = CreateObject("Kixforms.System")

$Form = $System.Form()
$Form.Text = "LED Driver"
$Form.FormBorderStyle = $System.FormBorderStyle_FixedDialog
$Form.MaximizeBox = 0

$Form.Width = $System.Screen.WorkingArea.Width
$Form.Top = $System.Screen.WorkingArea.Top

$LedControl1 = $Form.Controls.Add(LedControl(0,0,$Form.ClientWidth,-1,2,1))

$LedControl1.Text = "Welcome to KiXforms ... The next generation of KiXtart scripting. " +
   "Please visit the KiXforms.NET discussion forum! "

$LedControl1.BackColor = $System.Color.FromRgb(0,103,30)
$LedControl1.ForeColor = $System.Color.FromRgb(0,255,50)

$Form.ClientHeight = $LedControl1.Height

$Form.Show

While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 0

Break On

;
; LEDCONTROL
;

Function LedControl(
   optional $left,
   optional $top,
   optional $width,
   optional $height,
   optional $scale,
   optional $scroll)

 If Not $scale
  $scale = 3
 Endif

 $cx = (($scale+1)*5)+$scale
 $cy = (($scale+1)*7)+$scale

 If $width < 0
  $width = abs($width) * $cx
 Endif

 If $height < 0
  $height = abs($height) * $cy
 Endif

 $LedControl = $System.PictureBox()
 $LedControl.Left = $left
 $LedControl.Top = $top
 $LedControl.Width = $width
 $LedControl.Height = $height
 $LedControl.BackColor = $System.Color.DarkGreen
 $LedControl.ForeColor = $System.Color.LightGreen

 ;
 ; Make the LED bitmap...
 ;

 dim $maptab[127]
 $maptab[00] = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ; *
 $maptab[32] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;   (SPACE)
 $maptab[33] = 0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0 ; !
 $maptab[39] = 0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; '
 $maptab[44] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0 ; , (COMMA)
 $maptab[46] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0 ; . (PERIOD)
 $maptab[47] = 0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0 ; /
 $maptab[48] = 0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,0,1,0,1,1,1,0,0,1,1,0,0,0,1,0,1,1,1,0 ; 0
 $maptab[49] = 0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,1,1,1,0 ; 1
 $maptab[50] = 0,1,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,1 ; 2
 $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0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,1,1 ; Z

 Dim $ArrayList
 $ArrayList = $System.ArrayList()

 $= $ArrayList.Add($scale)
 $= $ArrayList.Add($maptab)
 $= $ArrayList.Add($scroll)

 If Not $_LedControl
  $_LedControl = $System.ArrayList()
 Endif

 If $scroll
  Dim $Timer
  $Timer = $System.Timer()
  $Timer.Interval = 400
  $Timer.Start
  $index = $_LedControl.IndexOf($_LedControl.Add($LedControl))
  $Timer.Tick = "LedControlTimerTick($index)"
 Endif

 $LedControl.Tag = $ArrayList

 $LedControl.TextChanged = "LedTextChanged($$System.Sender, $$System.EventArgs)"

 LedTextChanged($LedControl, 0)

EndFunction

Function LedControlTimerTick($index)

 Dim $scale
 Dim $control
 Dim $text

 $control = $_LedControl.Item($index)

 $text = $control.Text
 $scroll = $control.Tag.Item(2)

 If $scroll = 1
  $text = SUBSTR($text,2)+LEFT($text,1)
 Else
  $text = RIGHT($text,1) + SUBSTR($text,1,LEN($text)-1)
 Endif

 $control.Text = $text

EndFunction

Function LedTextChanged($sender, $e)

 $ArrayList = $sender.Tag

 $pix = $ArrayList.Item(0)
 $cx = (($pix+1)*5)+$pix
 $cy = (($pix+1)*7)+$pix

 $LedBitmap = $System.Bitmap.FromSize($System.Size($cx,$cy))
 $LedGraphics = $System.Graphics.FromImage($LedBitmap)
 $LedGraphics.Clear($System.Color.Black)

 Dim $BackColorBrush
 $BackColorBrush = $System.SolidBrush($Sender.BackColor)

 For $y = 1 To $LedBitmap.Height-$pix Step $pix + 1
  For $x = 1 To $LedBitmap.Width-$pix Step $pix + 1
   $LedGraphics.FillRectangle($BackColorBrush,$x,$y,$pix,$pix)
  Next
 Next

 Dim $TextureBrush
 $TextureBrush = $System.TextureBrush($LedBitmap)

 Dim $Bitmap
 $Bitmap = $System.Bitmap.FromSize($sender.ClientSize)

 $BitmapGraphics = $System.Graphics.FromImage($Bitmap)

 $BitmapGraphics.FillRectangle($TextureBrush,0,0,$sender.ClientWidth,$sender.ClientHeight)

 Dim $maptab
 $maptab = $ArrayList.Item(1)

 $br = $System.SolidBrush($sender.ForeColor)

 $xoff = 1
 $yoff = 1
 dim $x
 dim $y

 $str = UCase(CStr($sender.Text))

 For $i = 1 To Len($str)
  $chr = substr($str,$i,1)
  $asc = asc($chr)
  Select
   Case $asc = 13
    $yoff = $yoff + $cy
    $xoff = 1
   Case $asc = 10
    $xoff = 1
   Case 1
    $map = $maptab[asc($chr)]
    If UBound($map) = -1
     $map = $maptab[0]
    Endif
    $n=0
    For $y = $yoff To ($yoff + $cy) - ($pix+1) Step $pix+1
     For $x = $xoff To ($xoff + $cx ) - ($pix+1) Step $pix+1
      If $map[$n] = 1
       $BitmapGraphics.FillRectangle($br,$x,$y,$pix,$pix)
      Endif
      $n=$n+1
     Next
    Next
    $xoff = $xoff + ($cx)
  EndSelect
 Next

 $sender.Image = $Bitmap

EndFunction
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Thu Jan 26, 2006 4:13 pm    Post subject: Reply with quote

You are TOO FUNNY!
_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 26, 2006 5:42 pm    Post subject: Reply with quote

Was just analyzing the "performance" for that last script, for each tick trying to see where in the function is spending most of its time...

On my 1.5ghz laptop with the Timer Interval set to 400msecs ...

Each tick takes about 110 msecs ... so my laptop does support a 400msec tick rate. The biggest chunk (virtually all) of that 110 msec is spent in that big for/next loop that paints the pixels... Of that loop, about half the time is spent looping, and the other half is spent inside the Graphics.FillRectangle funtion.

Trying to think of ways to maybe optimize this ... saving things like the Bitmap and the Brush aint going to help any (I thought it would).
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Jan 27, 2006 1:15 pm    Post subject: Reply with quote

Well started playing with this, and ran into a bunch of returns to the screen

"Kixforms_System.Bitmap"

Have not found where it is coming from as of yet but still digging.

Also how would I place the form in the center of the screen?

I had thought that I could change $Form.Top = $System.Screen.WorkingArea.Center

But that does not work, and no I have not read the docs yet.... But I will.

Edited to add:

Oh and the timer portion is killing me. I am currently running on a P3 700, where should I look to figure out the timing? How do I adjust to make it work for different machines?

Geuss I should add that I changed this from a standalone script to a function within my script and that caused a few changes to be made to the original code.

Here is what I came up with...
Code:

Function LEDPanel($Text)
   $Form = $System.Form()
   $Form.Text = "Message"
   $Form.FormBorderStyle = $System.FormBorderStyle_FixedDialog
   $Form.MaximizeBox = 0
   
   $Form.Width = 700
   $Form.Top = $System.Screen.WorkingArea.Center ;fix this
   
   $LedControl1 = $Form.Controls.Add(LedControl(0,0,$Form.ClientWidth,-1,2,1))
   
   $LedControl1.Text = $Text
   
   $LedControl1.BackColor = $System.Color.FromRgb(0,103,30)
   $LedControl1.ForeColor = $System.Color.FromRgb(0,255,50)
   
   $Form.ClientHeight = $LedControl1.Height
   
   $Form.Show
   
   While $Form.Visible
   $= Execute($Form.DoEvents)
   Loop
   
   Exit 0
   
   Break On
EndFunction
;
; LEDCONTROL
;

Function LedControl( optional $left, optional $top, optional $width, optional $height, optional $scale, optional $scroll)

 If Not $scale
  $scale = 3
 EndIf

 $cx = (($scale+1)*5)+$scale
 $cy = (($scale+1)*7)+$scale

 If $width < 0
  $width = Abs($width) * $cx
 EndIf

 If $height < 0
  $height = Abs($height) * $cy
 EndIf

 $LedControl = $System.PictureBox()
 $LedControl.Left = $left
 $LedControl.Top = $top
 $LedControl.Width = $width
 $LedControl.Height = $height
 $LedControl.BackColor = $System.Color.DarkGreen
 $LedControl.ForeColor = $System.Color.LightGreen

 ;
 ; Make the LED bitmap...
 ;

 Dim $maptab[127]
 $maptab[00] = 1,1,1,1,1,1,1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,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0 ; P
 $maptab[81] = 0,1,1,1,0,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0,1,1,0,0,1,0,0,1,1,0,1 ; Q
 $maptab[82] = 1,1,1,1,0,1,0,0,0,1,1,0,0,0,1,1,1,1,1,0,1,0,1,0,0,1,0,0,1,0,1,0,0,0,1 ; R
 $maptab[83] = 0,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,0 ; S
 $maptab[84] = 1,1,1,1,1,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0 ; T
 $maptab[85] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,0,1,1,1,0 ; U
 $maptab[86] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0 ; V
 $maptab[87] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0 ; W
 $maptab[88] = 1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1 ; X
 $maptab[89] = 1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0 ; Y
 $maptab[90] = 1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,1,1 ; Z

 Dim $ArrayList
 $ArrayList = $System.ArrayList()

 $= $ArrayList.Add($scale)
 $= $ArrayList.Add($maptab)
 $= $ArrayList.Add($scroll)

 If Not $_LedControl
  $_LedControl = $System.ArrayList()
 EndIf

 If $scroll
  Dim $Timer
  $Timer = $System.Timer()
  $Timer.Interval =10
  $Timer.Start
  $index = $_LedControl.IndexOf($_LedControl.Add($LedControl))
  $Timer.Tick = "LedControlTimerTick($index)"
 EndIf

 $LedControl.Tag = $ArrayList

 $LedControl.TextChanged = "LedTextChanged($System.Sender, $System.EventArgs)"

 LedTextChanged($LedControl, 0)

EndFunction

Function LedControlTimerTick($index)

 Dim $scale
 Dim $control
 Dim $text

 $control = $_LedControl.Item($index)

 $text = $control.Text
 $scroll = $control.Tag.Item(2)

 If $scroll = 1
  $text = SubStr($text,2)+Left($text,1)
 Else
  $text = Right($text,1) + SubStr($text,1,Len($text)-1)
 EndIf

 $control.Text = $text

EndFunction

Function LedTextChanged($sender, $e)

 $ArrayList = $sender.Tag

 $pix = $ArrayList.Item(0)
 $cx = (($pix+1)*5)+$pix
 $cy = (($pix+1)*7)+$pix

 $LedBitmap = $System.Bitmap.FromSize($System.Size($cx,$cy))
 $LedGraphics = $System.Graphics.FromImage($LedBitmap)
 $LedGraphics.Clear($System.Color.Black)

 Dim $BackColorBrush
 $BackColorBrush = $System.SolidBrush($Sender.BackColor)

 For $y = 1 to $LedBitmap.Height-$pix Step $pix + 1
  For $x = 1 to $LedBitmap.Width-$pix Step $pix + 1
   $LedGraphics.FillRectangle($BackColorBrush,$x,$y,$pix,$pix)
  Next
 Next

 Dim $TextureBrush
 $TextureBrush = $System.TextureBrush($LedBitmap)

 Dim $Bitmap
 $Bitmap = $System.Bitmap.FromSize($sender.ClientSize)

 $BitmapGraphics = $System.Graphics.FromImage($Bitmap)

 $BitmapGraphics.FillRectangle($TextureBrush,0,0,$sender.ClientWidth,$sender.ClientHeight)

 Dim $maptab
 $maptab = $ArrayList.Item(1)

 $br = $System.SolidBrush($sender.ForeColor)

 $xoff = 1
 $yoff = 1
 Dim $x
 Dim $y

 $str = Ucase(Cstr($sender.Text))

 For $i = 1 to Len($str)
  $chr = SubStr($str,$i,1)
  $asc = Asc($chr)
  Select
   Case $asc = 13
    $yoff = $yoff + $cy
    $xoff = 1
   Case $asc = 10
    $xoff = 1
   Case 1
    $map = $maptab[Asc($chr)]
    If Ubound($map) = -1
     $map = $maptab[0]
    EndIf
    $n=0
    For $y = $yoff to ($yoff + $cy) - ($pix+1) Step $pix+1
     For $x = $xoff to ($xoff + $cx ) - ($pix+1) Step $pix+1
      If $map[$n] = 1
       $BitmapGraphics.FillRectangle($br,$x,$y,$pix,$pix)
      EndIf
      $n=$n+1
     Next
    Next
    $xoff = $xoff + ($cx)
  EndSelect
 Next

 $sender.Image = $Bitmap

EndFunction

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Jan 27, 2006 2:04 pm    Post subject: Reply with quote

I can tell right off the bat that your not running the lastest and greatest development build ... in fact, your build is real old. This here:

"Kixforms_System.Bitmap"

is a few builds old.
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Fri Jan 27, 2006 2:51 pm    Post subject: Reply with quote

Gargoyle,
get the latest kf.net build and give this a try:
Code:
Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf

LEDPanel("KiXforms.Net is the only way to go!")

Function LEDPanel($Text)
   
   $Form = $System.Form()
   $Form.Text = "Message"
   $Form.FormBorderStyle = $System.FormBorderStyle_FixedDialog
   $Form.MaximizeBox = 0
   
   $Form.StartPosition = 1  ;FormStartPosition_CenterScreen
   
   $LEDScale = 2
   $LEDWidth = (($LEDScale+1)*5)+$LEDScale
   
   $TextLength = Len($Text)
   If $TextLength < 7
      $TextWidth = $LEDWidth * 7
      $spc = 7-$TextLength
      For $x = 1 to $spc
         $Text = $Text + Chr(32)
      Next
   Else
      $TextWidth = $LEDWidth * $TextLength
   EndIf
   $TextLength = Len($Text) - 2
   For $x = 1 to $TextLength
      $Text = Chr(32) + $Text
   Next
   
   $LedControl1 = $Form.Controls.Add(LedControl(0,0,$TextWidth,-1,$LEDScale,1))
   
   $LedControl1.Text = $Text
   
   $LedControl1.BackColor = $System.Color.FromRgb(0,103,30)
   $LedControl1.ForeColor = $System.Color.FromRgb(0,255,50)
   
   $Form.ClientWidth = $LedControl1.Width
   $Form.ClientHeight = $LedControl1.Height
   
   $Form.Show
   
   While $Form.Visible
      $= Execute($Form.DoEvents)
   Loop
   
   Exit 0
   
EndFunction

;
; LEDCONTROL
;

Function LedControl(
   optional $left,
   optional $top,
   optional $width,
   optional $height,
   optional $scale,
   optional $scroll)

 If Not $scale
  $scale = 3
 EndIf

 $cx = (($scale+1)*5)+$scale
 $cy = (($scale+1)*7)+$scale

 If $width < 0
  $width = Abs($width) * $cx
 EndIf

 If $height < 0
  $height = Abs($height) * $cy
 EndIf

 $LedControl = $System.PictureBox()
 $LedControl.Left = $left
 $LedControl.Top = $top
 $LedControl.Width = $width
 $LedControl.Height = $height
 $LedControl.BackColor = $System.Color.DarkGreen
 $LedControl.ForeColor = $System.Color.LightGreen

 ;
 ; Make the LED bitmap...
 ;

 Dim $maptab[127]
 $maptab[00] = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ; *
 $maptab[32] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;   (SPACE)
 $maptab[33] = 0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0 ; !
 $maptab[39] = 0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; '
 $maptab[44] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0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maptab[85] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,0,1,1,1,0 ; U
 $maptab[86] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0 ; V
 $maptab[87] = 1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0 ; W
 $maptab[88] = 1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1 ; X
 $maptab[89] = 1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0 ; Y
 $maptab[90] = 1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,1,1 ; Z

 Dim $ArrayList
 $ArrayList = $System.ArrayList()

 $= $ArrayList.Add($scale)
 $= $ArrayList.Add($maptab)
 $= $ArrayList.Add($scroll)

 If Not $_LedControl
  $_LedControl = $System.ArrayList()
 EndIf

 If $scroll
  Dim $Timer
  $Timer = $System.Timer()
  $Timer.Interval = 400
  $Timer.Start
  $index = $_LedControl.IndexOf($_LedControl.Add($LedControl))
  $Timer.Tick = "LedControlTimerTick($index)"
 EndIf

 $LedControl.Tag = $ArrayList

 $LedControl.TextChanged = "LedTextChanged($$System.Sender, $$System.EventArgs)"

 LedTextChanged($LedControl, 0)

EndFunction

Function LedControlTimerTick($index)

 Dim $scale
 Dim $control
 Dim $text

 $control = $_LedControl.Item($index)

 $text = $control.Text
 $scroll = $control.Tag.Item(2)

 If $scroll = 1
  $text = SubStr($text,2)+Left($text,1)
 Else
  $text = Right($text,1) + SubStr($text,1,Len($text)-1)
 EndIf

 $control.Text = $text

EndFunction

Function LedTextChanged($sender, $e)

 $ArrayList = $sender.Tag

 $pix = $ArrayList.Item(0)
 $cx = (($pix+1)*5)+$pix
 $cy = (($pix+1)*7)+$pix

 $LedBitmap = $System.Bitmap.FromSize($System.Size($cx,$cy))
 $LedGraphics = $System.Graphics.FromImage($LedBitmap)
 $LedGraphics.Clear($System.Color.Black)

 Dim $BackColorBrush
 $BackColorBrush = $System.SolidBrush($Sender.BackColor)

 For $y = 1 to $LedBitmap.Height-$pix Step $pix + 1
  For $x = 1 to $LedBitmap.Width-$pix Step $pix + 1
   $LedGraphics.FillRectangle($BackColorBrush,$x,$y,$pix,$pix)
  Next
 Next

 Dim $TextureBrush
 $TextureBrush = $System.TextureBrush($LedBitmap)

 Dim $Bitmap
 $Bitmap = $System.Bitmap.FromSize($sender.ClientSize)

 $BitmapGraphics = $System.Graphics.FromImage($Bitmap)

 $BitmapGraphics.FillRectangle($TextureBrush,0,0,$sender.ClientWidth,$sender.ClientHeight)

 Dim $maptab
 $maptab = $ArrayList.Item(1)

 $br = $System.SolidBrush($sender.ForeColor)

 $xoff = 1
 $yoff = 1
 Dim $x
 Dim $y

 $str = Ucase(Cstr($sender.Text))

 For $i = 1 to Len($str)
  $chr = SubStr($str,$i,1)
  $asc = Asc($chr)
  Select
   Case $asc = 13
    $yoff = $yoff + $cy
    $xoff = 1
   Case $asc = 10
    $xoff = 1
   Case 1
    $map = $maptab[Asc($chr)]
    If Ubound($map) = -1
     $map = $maptab[0]
    EndIf
    $n=0
    For $y = $yoff to ($yoff + $cy) - ($pix+1) Step $pix+1
     For $x = $xoff to ($xoff + $cx ) - ($pix+1) Step $pix+1
      If $map[$n] = 1
       $BitmapGraphics.FillRectangle($br,$x,$y,$pix,$pix)
      EndIf
      $n=$n+1
     Next
    Next
    $xoff = $xoff + ($cx)
  EndSelect
 Next

 $sender.Image = $Bitmap

EndFunction

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Jan 27, 2006 3:43 pm    Post subject: Reply with quote

Will update the .Net tonight
Sorry Shawn you just roll them out so fast.. Laughing

Any suggestions on how to properly set the timer?

If I run it as a standalone script Shawns setting of 400 scrolls fairly nice, however when I add it to my existing script it scrolls very very slowly.

I assumed by adjusting the timer down it would resolve this issue, however it did not seem to make a difference in the execution at all.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Jan 27, 2006 3:54 pm    Post subject: Reply with quote

There's prolly just too much happening in your script. Kixtart can't keep up. I would suggest you stick with the non-scrollable LED maybe.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group