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

Would someone PLEASE help me with the Listview Syntax.
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
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Thu Oct 04, 2007 11:39 pm    Post subject: Would someone PLEASE help me with the Listview Syntax. Reply with quote

Having populated my Listview I am still none the wiser how to select, Remove and Clear collections successfully and now I can't even get the Checked boxes to refresh...
I would like to be able to select a line or cell and return its content but I am not even sure if this is possible or how to index it.
Transferring data from an array INTO a listbox seems fairly fault free. Getting it out again is another matter. I can't see if I could edit data insitue, so I suspect I will have to open a new form for Editing = From ~ Until.
Have a look at the little functions below ListView and you will see what I am trying to do.
Code:

;XML Playlist Editor
Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
Global $INI
Global $Source
Global $Dest
Global $PresDir
Global $Header
Global $Footer
Global $MY
Global $PLIST
Global $Total
$INI=@scriptdir+"\MYsched.ini"
$MY="%DOMAIN%"
$ = ReadINI
$ = ReadXML
$ = MakeForm
$ = WriteXML
exit 0
;-----------------------------------------
Function MakeForm
Dim $CNT
$MYsched = $System.Form()
$MYsched.FormBorderStyle = 1  ;FormBorderStyle_FixedSingle
$MYsched.MaximizeBox = 0  ;False
$MYsched.ShowInTaskbar = 0  ;False
$MYsched.StartPosition = 0  ;FormStartPosition_Manual
$MYsched.Size = $System.Size(640,350) ;(Width,Height)
$MYsched.Text = "MY Presentation Scheduler"
$MYsched.center

$ = Listview

$AddBtn = $System.Button()
$AddBtn.Height = 25
$AddBtn.Left = 10
$AddBtn.Text = "Add"
$AddBtn.Top = 290
$AddBtn.Width = 60
$AddBtn.Click = "AddP"
$nul = $MYsched.Controls.Add($AddBtn)

$RemoveBtn = $System.Button()
$RemoveBtn.Height = 25
$RemoveBtn.Left = 85
$RemoveBtn.Text = "Remove"
$RemoveBtn.Top = 290
$RemoveBtn.Width = 60
$RemoveBtn.Click = "RemP"
$nul = $MYsched.Controls.Add($RemoveBtn)

$EditBtn = $System.Button()
$EditBtn.Height = 25
$EditBtn.Left = 160
$EditBtn.Text = "Edit"
$EditBtn.Top = 290
$EditBtn.Width = 60
$EditBtn.Click = "EditP"
$nul = $MYsched.Controls.Add($EditBtn)

$ClearAllBtn = $System.Button()
$ClearAllBtn.Height = 25
$ClearAllBtn.Left = 250
$ClearAllBtn.Text = "Clear All"
$ClearAllBtn.Top = 290
$ClearAllBtn.Width = 60
$ClearAllBtn.Click = "ClearAll"
$nul = $MYsched.Controls.Add($ClearAllBtn)

$SelAllBtn = $System.Button()
$SelAllBtn.Height = 25
$SelAllBtn.Left = 330
$SelAllBtn.Text = "Select All"
$SelAllBtn.Top = 290
$SelAllBtn.Width = 60
$SelAllBtn.Click = "SelectAll"
$nul = $MYsched.Controls.Add($SelAllBtn)

$NewSBtn = $System.Button()
$NewSBtn.Height = 25
$NewSBtn.Left = 425
$NewSBtn.Text = "New Schedule"
$NewSBtn.Top = 290
$NewSBtn.Width = 90
$NewSBtn.Click = "MakeNew"
$nul = $MYsched.Controls.Add($NewSBtn)

$PrefBtn = $System.Button()
$PrefBtn.Height = 25
$PrefBtn.Left = 530
$PrefBtn.Text = "Preferences"
$PrefBtn.Top = 290
$PrefBtn.Width = 90
$PrefBtn.click = "Preferences"
$nul = $MYsched.Controls.Add($PrefBtn)

$MYsched.Show  ;Displays the Form

While $MYsched.Visible
   $Nul = Execute($MYsched.DoEvents())
Loop
EndFunction
;-----------------------------------------
FUNCTION ListView ; Populate Listview with contents of Playlist.xml = $Plist[x,y]
$ListView1 = $System.ListView()
$ListView1.CheckBoxes = -1  ;True
$ListView1.Dock = 1  ;Top
$ListView1.GridLines = -1  ;True
$ListView1.Height = 285
$ListView1.MultiSelect = 0  ;False
$ListView1.Sorting = 2  ;Descending
$ListView1.View = $System.View_Details
;$ListView1.fullrowselect = -1    ;True
$ListView1.sorted = -1  ;True
$ListView1.doubleclick = 'ListViewItemClick("ListView1","MYsched")'
$ListView1.KeyPress = 'ListViewItemKey("ListView1","MYsched")'
$nul = $MYsched.Controls.Add($ListView1)

$ListView1Column0 = $ListView1.Columns.Add($System.ColumnHeader("Show",45,$System.HorizontalAlignment_Center))
$ListView1Column1 = $ListView1.Columns.Add($System.ColumnHeader("From",50,$System.HorizontalAlignment_Center))
$ListView1Column2 = $ListView1.Columns.Add($System.ColumnHeader("To",50,$System.HorizontalAlignment_Center))
$ListView1Column3 = $ListView1.Columns.Add($System.ColumnHeader("Presentation",485,$System.HorizontalAlignment_Left))

For $CNT = 0 to $TOTAL
$ = execute("$$ListView1Item$CNT = $$ListView1.Items.Add($$System.ListViewItem(''))")
If $PLIST[0,$CNT]='TRUE'
 $ = execute("$$ListView1Item$CNT.Checked = 1")
Else
 $ = execute("$$ListView1Item$CNT.Checked = 0")
Endif
 $ = execute("$$ListView1Item$CNT.ForeColor = $$System.Color.FromName('WindowText')")
 $ = execute("$$ListView1Item$CNT.UseItemStyleForSubItems = 1")  ;True

 $ = execute("$$ListView1Item$CNT = $$ListView1.Items.Item($$CNT).SubItems.Add($$System.ListViewSubItem($$PLIST[2,$$CNT]))")
 $ = execute("$$ListView1Item$CNT = $$ListView1.Items.Item($$CNT).SubItems.Add($$System.ListViewSubItem($$PLIST[3,$$CNT]))")
 $ = execute("$$ListView1Item$CNT = $$ListView1.Items.Item($$CNT).SubItems.Add($$System.ListViewSubItem($$PLIST[5,$$CNT]))")
next
EndFunction
;-----------------------------------------
FUNCTION ListViewItemKey($lv,$lvform) ; User Keyboard ENTER
 Dim $key,$LX
 $LX="$"+$LV
 $ = execute("$$key = $LX.KeyPressEventArgs.KeyChar")
  If $key = chr(13)
   $ = ListViewItemClick($lv,$lvform)
  ENDIF
ENDFUNCTION
;-----------------------------------------
FUNCTION ListViewItemClick($lv,$lvform) ; User Double Click Line
Dim $Pres
  $lv = "$"+$lv
  $lvform = "$"+$lvform
  $ = execute("$$Pres = $LV.SelectedItems.Item(3).Text")
$=messagebox($Pres,"Selected")
; Trying to return entry in Column 3 = Playlist item.
ENDFUNCTION
;-----------------------------------------
Function  AddP ; Add to List
EndFunction
;-----------------------------------------
Function  RemP ; Remove Selected line - How ?
Dim $x
 $X=$ListView1.FocusedItem.Text
 $=messagebox($X,"Selected")
EndFunction
;-----------------------------------------
Function  EditP ; Edit Entry in list
EndFunction
;-----------------------------------------
Function  ClearAll  ; Untick ALL
Dim $X
For $X = 0 to $Total
 $PLIST[0,$X]='False'
 $ = execute("$$ListView1Item$x.Checked = 0")
next
EndFunction
;-----------------------------------------
Function  SelectAll  ; Tick All
Dim $X
For $X = 0 to $Total
 $PLIST[0,$X]='TRUE'
 $ = execute("$$ListView1Item$x.Checked = 1")
next
EndFunction
;-----------------------------------------
Function MakeNew
 $Total=0
 redim $PLIST[5,0]
 $=WriteXML
 $=$ListView1.ListViewItemCollection.remove ; Does not clear contents
EndFunction
;-----------------------------------------
Function Preferences
EndFunction
;-----------------------------------------
Function ReadINI
 If open(5,$INI,2)=0
  $L=readline(5)
  While @error=0
   SELECT
    CASE $L='[Source]'
     $Source=readline(5)
    CASE $L='[Presentations]'
     $PresDir=readline(5)
    CASE $L='[Footer]'
     $Footer=readline(5)
    CASE $L='[Header]'
     while @error=0
      $Header=$Header+readline(5)+@crlf
     loop
   EndSelect
  $L=readline(5)
  Loop
  $=close(5)
 Else
   $=MakeINI
 EndIf
EndFunction
;-----------------------------------------
Function MakeINI
Dim $L
 If not exist($INI)
goto MI ; Cant get GUIDialog to return UNC paths when selecting a the PlayList.xml file + easier for demo ?? Is there a .net UDF version ?
  $L=GUIDialog("LOCATE 'PlayList.xml' file",$MY,16384)
  If @error=0 and left($L,12)='PlayList.xml'
   if exist($L)
    $source=$L
   Else
    Quit
  Endif

  $L=GUIDialog("LOCATE Default PRESENTATIONS folder",$MY)
  If not @error and exist($L)
   $PresDir=$L
  Else
   Quit
  Endif

  :MI
  $source=@scriptdir+"\PlayList.xml"
  $Dest=left($Source,-4)+"2.xml" ;don't alter master playlist during testing.
  $PresDir=@scriptdir

  $Footer='</NewDataSet>'

  $Header='<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="PlayList" msdata:CaseSensitive="False">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Show" type="xs:boolean" minOccurs="0" />
                <xs:element name="Index" type="xs:short" minOccurs="0" />
                <xs:element name="From" type="xs:string" minOccurs="0" />
                <xs:element name="Until" type="xs:string" minOccurs="0" />
                <xs:element name="UniqueName" type="xs:string" minOccurs="0" />
                <xs:element name="FileNames" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>'

  If open(5,$INI,5)=0
   $=writeline(5,'[Source]'+@crlf+$source+@crlf)
   $=writeline(5,'[Presentations]'+@crlf+$PresDir+@crlf)
   $=writeline(5,'[Footer]'+@crlf+$Footer+@crlf)
   $=writeline(5,'[Header]'+@crlf+$Header+@crlf)
   $=close(5)
  Else
   $=messagebox("Unable to READ or CREATE"+chr(10)+$INI+chr(10)+chr(10)+"Seek technical assistance !","E R R O R")
   Quit
  EndIf
 Else
  $=messagebox("Unable to READ or CREATE"+chr(10)+$INI+chr(10)+chr(10)+"Seek technical assistance !","E R R O R")
  Quit
 Endif
EndFunction
;-----------------------------------------
Function ReadXML
Dim $L,$CNT
If open(5,$Source,2)=0
$L=readline(5)
While @error = 0
 If trim($L)='<PlayList>'
  redim preserve $PLIST[5,$CNT]
  $PLIST[0,$CNT]=left(right(trim(readline(5)),-6),-7)
  $PLIST[1,$CNT]=left(right(trim(readline(5)),-7),-8)
  $PLIST[2,$CNT]=left(right(trim(readline(5)),-6),-7)
  $PLIST[3,$CNT]=left(right(trim(readline(5)),-7),-8)
  $PLIST[4,$CNT]=left(right(trim(readline(5)),-12),-13)
  $PLIST[5,$CNT]=left(right(trim(readline(5)),-11),-12)
  $CNT=$CNT+1
 EndIF
 $L=readline(5)
Loop
$=close(5)
$Total=$cnt-1
Else
 quit
Endif
EndFunction
;-----------------------------------------
Function WriteXML
If Open(5,$Dest,5)=0
$= WRITELINE(5,$Header+@crlf)
For $L = 0 to $Total ;ubound($PLIST,1)
 $= WRITELINE(5,' <PlayList>'+@crlf)
 $= WRITELINE(5,'  <Show>'+$PLIST[0,$L]+'</Show>'+@crlf)
 $= WRITELINE(5,'  <Index>'+$PLIST[1,$L]+'</Index>'+@crlf)
 If $PLIST[2,$L] <>""
  $= WRITELINE(5,'  <From>'+$PLIST[2,$L]+'</From>'+@crlf)
 Else
  $= WRITELINE(5,'  <From />'+@crlf)
 Endif
 If $PLIST[3,$L] <>""
  $= WRITELINE(5,'  <Until>'+$PLIST[3,$L]+'</Until>'+@crlf)
 Else
  $= WRITELINE(5,'  <Until />'+@crlf)
 Endif
 $= WRITELINE(5,'  <UniqueName>'+$PLIST[4,$L]+'</UniqueName>'+@crlf)
 $= WRITELINE(5,'  <FileNames>'+$PLIST[5,$L]+'</FileNames>'+@crlf)
 $= WRITELINE(5,' </PlayList>'+@crlf)
next
$= WRITELINE(5,$Footer+@crlf)
$=close(5)
EndIf
EndFunction
;-----------------------------------------
;FUNCTION   GUIDialog()
;AUTHOR   Lonkero
function GUIDialog($_title, optional $_root, optional $_mode)
 dim $
 $=createobject("shell.application")
 $GUIDialog=$.BrowseForFolder(0,$_title,0+$_mode,$_root).self.path
 if not len($GUIDialog) exit 1 endif
endfunction



PlayList.xml sample
Code:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="PlayList" msdata:CaseSensitive="False">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Show" type="xs:boolean" minOccurs="0" />
                <xs:element name="Index" type="xs:short" minOccurs="0" />
                <xs:element name="From" type="xs:string" minOccurs="0" />
                <xs:element name="Until" type="xs:string" minOccurs="0" />
                <xs:element name="UniqueName" type="xs:string" minOccurs="0" />
                <xs:element name="FileNames" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>
  <PlayList>
    <Show>false</Show>
    <Index>1</Index>
    <From />
    <Until />
    <UniqueName>P1</UniqueName>
    <FileNames>\\MyPc\PlayLists\TestList1.play</FileNames>
  </PlayList>
  <PlayList>
    <Show>true</Show>
    <Index>2</Index>
    <From />
    <Until />
    <UniqueName>P2</UniqueName>
    <FileNames>\\MyPc\PlayLists\TestList2.play</FileNames>
  </PlayList>
  <PlayList>
    <Show>true</Show>
    <Index>3</Index>
    <From>12:45</From>
    <Until>15:45</Until>
    <UniqueName>P3</UniqueName>
    <FileNames>\\MyPc\PlayLists\TestList3.play</FileNames>
  </PlayList>
  <PlayList>
    <Show>true</Show>
    <Index>4</Index>
    <From>15:45</From>
    <Until>16:45</Until>
    <UniqueName>P4</UniqueName>
    <FileNames>\\MyPc\PlayLists\TestList4.play</FileNames>
  </PlayList>
</NewDataSet>

________
LOLOL


Last edited by MACE1 on Fri Feb 18, 2011 5:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Fri Oct 05, 2007 6:37 pm    Post subject: Reply with quote

Haven't completely looked at your code yet. I just figured out how to run the dang thing Wink (had to put playlist.xml in @SCRIPTDIR).

But in the meantime, try running this code when you get a path returned from GUIDialog. It converts drive path to unc path

Code:

Function GetUNCPathFromMappedDrive($sPath)
;******************************************************************************************************
;Function : GetUNCPathFromMappedDrive
;Descr    : Converts mapped drive path to UNC Path
;Input    : $sPath
;Output   : UNC path if $sPath is a valid mapped drive path
;******************************************************************************************************
   Dim $sDriveLetter
   Dim $reg_read_rempath, $uncpath
   
   If SubStr($sPath, 2, 1) = ":"   
      $sDriveLetter = Left($sPath, 1)         
      If UCase($sDriveLetter) <> "C"
         $reg_read_rempath = ReadValue('HKEY_CURRENT_USER\Network\' + $sDriveLetter, 'RemotePath')         
         $uncpath = $reg_read_rempath + SubStr($sPath, 3)                     
         $GetUNCPathFromMappedDrive = $uncpath
      Else
         $GetUNCPathFromMappedDrive = $sPath         
      EndIf
   Else
      $GetUNCPathFromMappedDrive = $sPath                                                                                       
   EndIf                                       
EndFunction
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Fri Oct 05, 2007 6:51 pm    Post subject: Reply with quote

Btw, you have a very interesting way of developing scripts! Very Happy
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Fri Oct 05, 2007 6:59 pm    Post subject: Reply with quote

Have you thought about using ReadProfileString/WriteProfileString to manipulate INI files and Microsoft.XMLDOM object to manipulate XML files?
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Fri Oct 05, 2007 7:25 pm    Post subject: Reply with quote

Here's your code tweaked to get RemP, ClearAll, and SelectAll working.

I'm not sure what you mean by 'returning its content...or how to index it'

To clear items from Listview use

Code:

$ListView1.Items.Clear()


Code below...

Code:

;XML Playlist Editor
Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
Global $INI
Global $Source
Global $Dest
Global $PresDir
Global $Header
Global $Footer
Global $MY
Global $PLIST
Global $Total
$INI=@scriptdir+"\MYsched.ini"
$MY="%DOMAIN%"
$ = ReadINI
$ = ReadXML
$ = MakeForm
$ = WriteXML
Exit 0
;-----------------------------------------
Function MakeForm
Dim $CNT
$MYsched = $System.Form()
$MYsched.FormBorderStyle = 1  ;FormBorderStyle_FixedSingle
$MYsched.MaximizeBox = 0  ;False
$MYsched.ShowInTaskbar = 0  ;False
$MYsched.StartPosition = 0  ;FormStartPosition_Manual
$MYsched.Size = $System.Size(640,350) ;(Width,Height)
$MYsched.Text = "MY Presentation Scheduler"
$MYsched.center

$ = Listview

$AddBtn = $System.Button()
$AddBtn.Height = 25
$AddBtn.Left = 10
$AddBtn.Text = "Add"
$AddBtn.Top = 290
$AddBtn.Width = 60
$AddBtn.Click = "AddP"
$nul = $MYsched.Controls.Add($AddBtn)

$RemoveBtn = $System.Button()
$RemoveBtn.Height = 25
$RemoveBtn.Left = 85
$RemoveBtn.Text = "Remove"
$RemoveBtn.Top = 290
$RemoveBtn.Width = 60
$RemoveBtn.Click = "RemP"
$nul = $MYsched.Controls.Add($RemoveBtn)

$EditBtn = $System.Button()
$EditBtn.Height = 25
$EditBtn.Left = 160
$EditBtn.Text = "Edit"
$EditBtn.Top = 290
$EditBtn.Width = 60
$EditBtn.Click = "EditP"
$nul = $MYsched.Controls.Add($EditBtn)

$ClearAllBtn = $System.Button()
$ClearAllBtn.Height = 25
$ClearAllBtn.Left = 250
$ClearAllBtn.Text = "Clear All"
$ClearAllBtn.Top = 290
$ClearAllBtn.Width = 60
$ClearAllBtn.Click = "ClearAll"
$nul = $MYsched.Controls.Add($ClearAllBtn)

$SelAllBtn = $System.Button()
$SelAllBtn.Height = 25
$SelAllBtn.Left = 330
$SelAllBtn.Text = "Select All"
$SelAllBtn.Top = 290
$SelAllBtn.Width = 60
$SelAllBtn.Click = "SelectAll"
$nul = $MYsched.Controls.Add($SelAllBtn)

$NewSBtn = $System.Button()
$NewSBtn.Height = 25
$NewSBtn.Left = 425
$NewSBtn.Text = "New Schedule"
$NewSBtn.Top = 290
$NewSBtn.Width = 90
$NewSBtn.Click = "MakeNew"
$nul = $MYsched.Controls.Add($NewSBtn)

$PrefBtn = $System.Button()
$PrefBtn.Height = 25
$PrefBtn.Left = 530
$PrefBtn.Text = "Preferences"
$PrefBtn.Top = 290
$PrefBtn.Width = 90
$PrefBtn.click = "Preferences"
$nul = $MYsched.Controls.Add($PrefBtn)

$MYsched.Show  ;Displays the Form

While $MYsched.Visible
   $Nul = Execute($MYsched.DoEvents())
Loop
EndFunction
;-----------------------------------------
Function ListView ; Populate Listview with contents of Playlist.xml = $Plist[x,y]
$ListView1 = $System.ListView()
$ListView1.CheckBoxes = -1  ;True
$ListView1.Dock = 1  ;Top
$ListView1.GridLines = -1  ;True
$ListView1.Height = 285
$ListView1.MultiSelect = 0  ;False
$ListView1.Sorting = 2  ;Descending
$ListView1.View = $System.View_Details
;$ListView1.fullrowselect = -1    ;True
$ListView1.sorted = -1  ;True
$ListView1.doubleclick = 'ListViewItemClick("ListView1","MYsched")'
$ListView1.KeyPress = 'ListViewItemKey("ListView1","MYsched")'
$nul = $MYsched.Controls.Add($ListView1)

$ListView1Column0 = $ListView1.Columns.Add($System.ColumnHeader("Show",45,$System.HorizontalAlignment_Center))
$ListView1Column1 = $ListView1.Columns.Add($System.ColumnHeader("From",50,$System.HorizontalAlignment_Center))
$ListView1Column2 = $ListView1.Columns.Add($System.ColumnHeader("To",50,$System.HorizontalAlignment_Center))
$ListView1Column3 = $ListView1.Columns.Add($System.ColumnHeader("Presentation",485,$System.HorizontalAlignment_Left))

For $CNT = 0 to $TOTAL
$ = Execute("$$ListView1Item$CNT = $$ListView1.Items.Add($$System.ListViewItem(''))")
If $PLIST[0,$CNT]='TRUE'
 $ = Execute("$$ListView1Item$CNT.Checked = 1")
Else
 $ = Execute("$$ListView1Item$CNT.Checked = 0")
EndIf
 $ = Execute("$$ListView1Item$CNT.ForeColor = $$System.Color.FromName('WindowText')")
 $ = Execute("$$ListView1Item$CNT.UseItemStyleForSubItems = 1")  ;True

 $ = Execute("$$ListView1Item$CNT = $$ListView1.Items.Item($$CNT).SubItems.Add($$System.ListViewSubItem($$PLIST[2,$$CNT]))")
 $ = Execute("$$ListView1Item$CNT = $$ListView1.Items.Item($$CNT).SubItems.Add($$System.ListViewSubItem($$PLIST[3,$$CNT]))")
 $ = Execute("$$ListView1Item$CNT = $$ListView1.Items.Item($$CNT).SubItems.Add($$System.ListViewSubItem($$PLIST[5,$$CNT]))")
Next
EndFunction
;-----------------------------------------
Function ListViewItemKey($lv,$lvform) ; User Keyboard ENTER
 Dim $key,$LX
 $LX="$"+$LV
 $ = Execute("$$key = $LX.KeyPressEventArgs.KeyChar")
  If $key = Chr(13)
   $ = ListViewItemClick($lv,$lvform)
  EndIf
EndFunction
;-----------------------------------------
Function ListViewItemClick($lv,$lvform) ; User Double Click Line
Dim $Pres
  $lv = "$"+$lv
  $lvform = "$"+$lvform
  $ = Execute("$$Pres = $LV.SelectedItems.Item(3).Text")
$=MessageBox($Pres,"Selected")
; Trying to return entry in Column 3 = Playlist item.
EndFunction
;-----------------------------------------
Function  AddP ; Add to List
EndFunction
;-----------------------------------------
Function  RemP ; Remove Selected line - How ?
;Dim $x
 ;$X=$ListView1.FocusedItem.Text
 ;$=MessageBox($X,"Selected")
   Dim $item
   
   For Each $item in $ListView1.SelectedItems
      $ = $item.Remove()
   Next
EndFunction
;-----------------------------------------
Function  EditP ; Edit Entry in list
EndFunction
;-----------------------------------------
Function  ClearAll  ; Untick ALL
Dim $X
For $X = 0 to $Total
 $PLIST[0,$X]='False'
 $ListView1.Items.Item($X).Checked = 0
 ;$ = Execute("$$ListView1Item$x.Checked = 0")
Next
EndFunction
;-----------------------------------------
Function  SelectAll  ; Tick All
Dim $X
For $X = 0 to $Total
 $PLIST[0,$X]='TRUE'
 $ListView1.Items.Item($X).Checked = -1
 ;$ = Execute("$$ListView1Item$x.Checked = -1")
Next
EndFunction
;-----------------------------------------
Function MakeNew
 $Total=0
 ReDim $PLIST[5,0]
 $=WriteXML
 $=$ListView1.ListViewItemCollection.remove ; Does not clear contents
EndFunction
;-----------------------------------------
Function Preferences
EndFunction
;-----------------------------------------
Function ReadINI
 If Open(5,$INI,2)=0
  $L=ReadLine(5)
  While @error=0
   Select
    Case $L='[Source]'
     $Source=ReadLine(5)
    Case $L='[Presentations]'
     $PresDir=ReadLine(5)
    Case $L='[Footer]'
     $Footer=ReadLine(5)
    Case $L='[Header]'
     While @error=0
      $Header=$Header+ReadLine(5)+@crlf
     Loop
   EndSelect
  $L=ReadLine(5)
  Loop
  $=Close(5)
 Else
   $=MakeINI
 EndIf
EndFunction
;-----------------------------------------
Function MakeINI
Dim $L
 If Not Exist($INI)
Goto MI ; Cant get GUIDialog to return UNC paths when selecting a the PlayList.xml file + easier for demo ?? Is there a .net UDF version ?
  $L=GUIDialog("LOCATE 'PlayList.xml' file",$MY,16384)
  If @error=0 And Left($L,12)='PlayList.xml'
   If Exist($L)
    $source=$L
   Else
    Quit
  EndIf

  $L=GUIDialog("LOCATE Default PRESENTATIONS folder",$MY)
  If Not @error And Exist($L)
   $PresDir=$L
  Else
   Quit
  EndIf

  :MI
  $source=@scriptdir+"\PlayList.xml"
  $Dest=Left($Source,-4)+"2.xml" ;don't alter master playlist during testing.
  $PresDir=@scriptdir

  $Footer='</NewDataSet>'

  $Header='<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="PlayList" msdata:CaseSensitive="False">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Show" type="xs:boolean" minOccurs="0" />
                <xs:element name="Index" type="xs:short" minOccurs="0" />
                <xs:element name="From" type="xs:string" minOccurs="0" />
                <xs:element name="Until" type="xs:string" minOccurs="0" />
                <xs:element name="UniqueName" type="xs:string" minOccurs="0" />
                <xs:element name="FileNames" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>'

  If Open(5,$INI,5)=0
   $=WriteLine(5,'[Source]'+@crlf+$source+@crlf)
   $=WriteLine(5,'[Presentations]'+@crlf+$PresDir+@crlf)
   $=WriteLine(5,'[Footer]'+@crlf+$Footer+@crlf)
   $=WriteLine(5,'[Header]'+@crlf+$Header+@crlf)
   $=Close(5)
  Else
   $=MessageBox("Unable to READ or CREATE"+Chr(10)+$INI+Chr(10)+Chr(10)+"Seek technical assistance !","E R R O R")
   Quit
  EndIf
 Else
  $=MessageBox("Unable to READ or CREATE"+Chr(10)+$INI+Chr(10)+Chr(10)+"Seek technical assistance !","E R R O R")
  Quit
 EndIf
EndFunction
;-----------------------------------------
Function ReadXML
Dim $L,$CNT
If Open(5,$Source,2)=0
$L=ReadLine(5)
While @error = 0
 If Trim($L)='<PlayList>'
  ReDim preserve $PLIST[5,$CNT]
  $PLIST[0,$CNT]=Left(Right(Trim(ReadLine(5)),-6),-7)
  $PLIST[1,$CNT]=Left(Right(Trim(ReadLine(5)),-7),-8)
  $PLIST[2,$CNT]=Left(Right(Trim(ReadLine(5)),-6),-7)
  $PLIST[3,$CNT]=Left(Right(Trim(ReadLine(5)),-7),-8)
  $PLIST[4,$CNT]=Left(Right(Trim(ReadLine(5)),-12),-13)
  $PLIST[5,$CNT]=Left(Right(Trim(ReadLine(5)),-11),-12)
  $CNT=$CNT+1
 EndIf
 $L=ReadLine(5)
Loop
$=Close(5)
$Total=$cnt-1
Else
 Quit
EndIf
EndFunction
;-----------------------------------------
Function WriteXML
If Open(5,$Dest,5)=0
$= WriteLine(5,$Header+@crlf)
For $L = 0 to $Total ;ubound($PLIST,1)
 $= WriteLine(5,' <PlayList>'+@crlf)
 $= WriteLine(5,'  <Show>'+$PLIST[0,$L]+'</Show>'+@crlf)
 $= WriteLine(5,'  <Index>'+$PLIST[1,$L]+'</Index>'+@crlf)
 If $PLIST[2,$L] <>""
  $= WriteLine(5,'  <From>'+$PLIST[2,$L]+'</From>'+@crlf)
 Else
  $= WriteLine(5,'  <From />'+@crlf)
 EndIf
 If $PLIST[3,$L] <>""
  $= WriteLine(5,'  <Until>'+$PLIST[3,$L]+'</Until>'+@crlf)
 Else
  $= WriteLine(5,'  <Until />'+@crlf)
 EndIf
 $= WriteLine(5,'  <UniqueName>'+$PLIST[4,$L]+'</UniqueName>'+@crlf)
 $= WriteLine(5,'  <FileNames>'+$PLIST[5,$L]+'</FileNames>'+@crlf)
 $= WriteLine(5,' </PlayList>'+@crlf)
Next
$= WriteLine(5,$Footer+@crlf)
$=Close(5)
EndIf
EndFunction
;-----------------------------------------
;FUNCTION   GUIDialog()
;AUTHOR   Lonkero
Function GUIDialog($_title, optional $_root, optional $_mode)
 Dim $
 $=CreateObject("shell.application")
 $GUIDialog=$.BrowseForFolder(0,$_title,0+$_mode,$_root).self.path
 If Not Len($GUIDialog) Exit 1 EndIf
EndFunction
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Sat Oct 06, 2007 12:37 am    Post subject: Reply with quote

The drive map to unc is a useful function which I am sure will get some use but it is not the issue here:
The real Playlist.xml is located on a share on a remote network PC which is running a media wall. The commercial playlist scheduling software will only run on that PC which means interrupting the display to edit things. Not what I consider well designed. ! As it is simply making an XML file I thought it would be quicker to make a scheduler which will work from anywhere. I am not in a position to use a drive mapping to the share so the user (Receptionist) will need to use a UNC path.
The GUIdialog is good at returning a FOLDER when selected but I need the user for clarity to select the PlayList.XML file then have the folder path returned.
I am not aware of the XML method you mentioned however for simple string manipulation like this I think this way will probably be as quick.
If it was not for my limited knowledge of .net and the need for the scheduler to look like the version the user has learned, I could have coded this as a console text version in half the time!

Re:indexes. I need to be able to equate the displayed lines with the array lines so as things are visually changed I can use the index to update the array. There is more info in the array than is displated.
When a user selects a line ( Need to stop multi line select!) I want to only return the index number of that line rather than text from the listview as the index will directly equate to the array where ALL the information I need is stored. The less string evalustion the quicker it will be.

With a textbox, you click in the box and type what you want. With listviews it is not so easy. I think to edit the 'from - to' or to add a job means a separate form.

I will give the mods above a try and see how it goes.
Is there a .net method for selecting a file ?

The INI file is to remember preferences and save the user having to navigate the domain every time.
I have opted for the particular method used as traditional .ini files don't lend themselves to multiline content.

Whats with the Check boxes... How to re-fresh the display. With mouse it works, by setting value 0 or 1 it does not change !
________
Extreme Q Vaporizer


Last edited by MACE1 on Sat Mar 12, 2011 5:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Mon Oct 08, 2007 5:40 pm    Post subject: Reply with quote

Checkboxes in a Listview can be manipulated programmatically using the following code:

Uncheck
Code:

$ListView1.Items.Item($X).Checked = 0


Check
Code:

$ListView1.Items.Item($X).Checked = -1


I think you may want to use FullRowSelect property for the ListView, so you can select each row by clicking on any column of that row.

Code:

$ListView1.FullRowSelect = -1


I'm not sure what you mean by .NET method to select files. Are you asking for a .NET method to select files from a GUI dialog (like GUIDialog) or programmatically select files (like Scripting.FileSystemObject)?
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Tue Oct 09, 2007 9:50 pm    Post subject: Reply with quote

Confused
Trying to make a GUI UDF for .net

Got this far todate by looking at others work but not sure what events etc I will need...

Code:

Function FileDialog
$Form = $System.Form()
$Form.CreateControl()
$Form.Text = "Kixforms Media Player"
$Form.FormBorderStyle = $System.FormBorderStyle_None
$Form.TransparencyKey = $System.Color.Magenta
$Form.ClientWidth = 250
$Form.ClientHeight = 250

$FILTER_FILES = "Playlist (*.XML)|*.xml|All files (*.*)|*.*"
$OpenFileDialog = $System.OpenFileDialog()
$OpenFileDialog.Filter = $FILTER_FILES
$OpenFileDialog.InitialDirectory = $MY

$FolderBrowserDialog = $System.FolderBrowserDialog()
$FolderBrowserDialog.ShowNewFolderButton = 0
$FolderBrowserDialog.Description = "Locate the folder containing 'PlayList.XML'"

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

EndFunction

________
Mflb


Last edited by MACE1 on Fri Feb 18, 2011 5:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Sat Oct 13, 2007 12:38 pm    Post subject: Reply with quote

Don't know where to find the necessary info. to get this file dialog to work so simply built a form to do the job.
Code:

Function FileDialog($Path, $FileType, Optional $TITLE)
If $TITLE = ""
 $TITLE="Select files of type '"+$FileType+"'"
Endif
Dim $HT, $WD, $sl, $Dcount, $sdir, $X, $MaxDlen
$dcount = 0
$maxdlen = 0
$sl=len($filetype)
; Read the file content of $Path into array
$sfile=Dir($Path)
WHILE NOT @error
; Identify Files of Type $FileType
IF GetFileAttr($Path + $sfile) <> 16 AND right($sfile,$sl) = $filetype
 $dcount=$dcount+1
 redim preserve $sdir[$dcount]
 $sdir[$dcount] = $sfile
 $x=len($sfile)
 IF $x > $maxdlen
  $maxdlen = $x
 ENDIF
ENDIF
$sfile = Dir()
LOOP
If $MaxDlen >0
$HT=($dcount*15)+80
if $HT > 640
 $HT=640
Endif
$WD=($maxdlen*5)+50

$FileForm = $System.Form()
$FileForm.Size = $System.Size($WD,$HT) ;(Width,Height)
$FileForm.FormBorderStyle = 1
$FileForm.Text = $TITLE
$FileForm.maximizebox = 0
$FileForm.minimizebox = 0
$FileForm.ShowInTaskBar = 0
$FileForm.icon = $system.icon.frombitmap(TSK_Icon())
$FileForm.center

$FileLV = $System.ListView()
$FileLV.Height = $HT-60
$FileLV.Width = $WD-5
$FileLV.Left = 0
$FileLV.Top = 0
;$FileLV.Dock = 2
$FileLV.KeyDown = "KeyDownEvent()"
$FileLV.KeyPress = "SelectItemEvent()"
$FileLV.Click = "OnClick()"
$FileLV.DoubleClick = 'OK_Enter()'
$FileLV.MultiSelect = 0  ;False
$FileLV.Sorting = 1  ;Ascending
$FileLV.View = $System.View_List
$FileLV.AutoArrange = "True"
$nul = $FileForm.Controls.Add($FileLV)

$TextBox = $System.TextBox()
$TextBox.Left = 0
$TextBox.Top = $HT-56
$TextBox.Width = $WD - 35
$nul = $FileForm.Controls.Add($TextBox)

$OKEnter = $System.Button()
$OKEnter.Click = "OK_Enter()"
$OKEnter.Name = "OKEnter"
$OKEnter.Text = "OK"
$OKEnter.Width = 30
$OKEnter.Left = $WD-34
$OKEnter.Top = $HT-56
$nul = $FileForm.Controls.Add($OKEnter)
$FileForm.AcceptButton = $OKEnter

for each $x in $Sdir
 If $X<>""
  $ = $FileLV.Items.Add($system.listviewitem($x))
 Endif
next

$PADSsched.hide ; Hide Main Form
$FileForm.Show  ;Displays the Form
While $FileForm.Visible and $Selected=""
   $Nul = Execute($FileForm.DoEvents())
Loop
$FileForm.close
$PADSsched.show

Else
 $=messagebox($TITLE+chr(10)+$PresDir,"NO FILES FOUND !",,10)
Endif
EndFunction


I REALLY would like pointing to the Info for these system forms PLEASE !!
________
LAMBORGHINI ALAR


Last edited by MACE1 on Fri Feb 18, 2011 5:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Sat Oct 13, 2007 12:47 pm    Post subject: Reply with quote

Rolling Eyes
When I add an item I can simply add the data to $PLIST[x,y] but when removing an item I need to somehow identify which item was removed and remove it form the PLIST array.
Code:

Function  RemP ; Remove Selected line
Dim $x, $Item
For Each $item in $PlayListView.SelectedItems
  $item.Remove()
; ? $PlayListView.Items.Item($Item).subitem.listviewsubitem(4)
; I need to Identify the subitem string in column 4 or some form of Index number SOMEHOW
; $Total=$Total-1
Next
EndFunction


The same situation applies if I am to edit an entry - How to equate what is selected to the array !

H E L P
________
FORD EXPLORER HISTORY


Last edited by MACE1 on Fri Feb 18, 2011 5:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Wed Oct 17, 2007 4:26 pm    Post subject: SHAWN, ROD - SOMEONE Please Help !!! Reply with quote

After 3 weeks of multiple re-working I still can neither get an index line number or TEXT back out of the listview to use what I have selected.
(Line 203) RemP lets me remove items from listview but I NEED to know the index/line number for each item removed to update the array.
Similarly I need to set the $Line for passing to a form for editing a line - (Line 75)
I can't find a way of passing back an index number or even the main text to compare against the array. Will those of you who do this regularly put me on the right track PLEASE !!!!
Code:

;XML Playlist Editor
Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
Global $INI
Global $Source
Global $PresDir
Global $Header
Global $Footer
Global $MY
Global $PLIST
Global $Total
Global $REDO
Global $Selected
Global $Line
$INI=@scriptdir+"\"+left(@scriptname,-4)+".ini"
$MY="%DOMAIN%"
:FORM
$ = ReadINI
$ = ReadXML
$ = MakeForm
$ = WriteXML
If $REDO="Y"
 $REDO=""
 Goto Form
Endif
exit 0
;-----------------------------------------
Function MakeForm
Dim $CNT
$MYsched = $System.Form()
$MYsched.FormBorderStyle = 1  ;FormBorderStyle_FixedSingle
$MYsched.MaximizeBox = 0  ;False
$MYsched.ShowInTaskbar = 0  ;False
$MYsched.StartPosition = 0  ;FormStartPosition_Manual
$MYsched.Size = $System.Size(640,350) ;(Width,Height)
$MYsched.Text = "MY Presentation Scheduler"
$MYsched.icon = $system.icon.frombitmap(MY_Icon())
$MYsched.center

$ToolTip = $System.ToolTip()

$ = Listview

$AddBtn = $System.Button()
$AddBtn.Height = 25
$AddBtn.Left = 10
$AddBtn.Text = "Add"
$AddBtn.Top = 290
$AddBtn.Width = 60
$AddBtn.Click = "AddP"
$nul = $MYsched.Controls.Add($AddBtn)
$ToolTip.SetToolTip($AddBtn,"Add an Item to the Playlist")

$RemoveBtn = $System.Button()
$RemoveBtn.Height = 25
$RemoveBtn.Left = 85
$RemoveBtn.Text = "Remove"
$RemoveBtn.Top = 290
$RemoveBtn.Width = 60
$RemoveBtn.Click = "RemP"
$nul = $MYsched.Controls.Add($RemoveBtn)
$ToolTip.SetToolTip($RemoveBtn,"Remove selected items from Playlist")

$EditBtn = $System.Button()
$EditBtn.Height = 25
$EditBtn.Left = 160
$EditBtn.Text = "Edit"
$EditBtn.Top = 290
$EditBtn.Width = 60
$EditBtn.Click = "EditP($LINE)" ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<$LINE is supposed to be defined by selection = Index number!!<<<<<<<<<<<<<<<<<<<<<<<<<<
$nul = $MYsched.Controls.Add($EditBtn)
$ToolTip.SetToolTip($EditBtn,"Edit From & Until details")

$ClearAllBtn = $System.Button()
$ClearAllBtn.Height = 25
$ClearAllBtn.Left = 250
$ClearAllBtn.Text = "Clear All"
$ClearAllBtn.Top = 290
$ClearAllBtn.Width = 60
$ClearAllBtn.Click = "ClearAll"
$nul = $MYsched.Controls.Add($ClearAllBtn)
$ToolTip.SetToolTip($ClearAllBtn,"Un-'tick' ALL items in playlist")

$SelAllBtn = $System.Button()
$SelAllBtn.Height = 25
$SelAllBtn.Left = 330
$SelAllBtn.Text = "Select All"
$SelAllBtn.Top = 290
$SelAllBtn.Width = 60
$SelAllBtn.Click = "SelectAll"
$nul = $MYsched.Controls.Add($SelAllBtn)
$ToolTip.SetToolTip($SelAllBtn,"'Tick' ALL items in playlist")

$NewSBtn = $System.Button()
$NewSBtn.Height = 25
$NewSBtn.Left = 425
$NewSBtn.Text = "New Schedule"
$NewSBtn.Top = 290
$NewSBtn.Width = 90
$NewSBtn.Click = "MakeNew"
$nul = $MYsched.Controls.Add($NewSBtn)
$ToolTip.SetToolTip($NewSBtn,"Remove ALL and start a NEW playlist.")

$PrefBtn = $System.Button()
$PrefBtn.Height = 25
$PrefBtn.Left = 530
$PrefBtn.Text = "Preferences"
$PrefBtn.Top = 290
$PrefBtn.Width = 90
$PrefBtn.click = "Preferences"
$nul = $MYsched.Controls.Add($PrefBtn)
$ToolTip.SetToolTip($PrefBtn,"Set default folder locations.")

$MYsched.Show  ;Displays the Form

While $MYsched.Visible
   $Nul = Execute($MYsched.DoEvents())
Loop
EndFunction
;-----------------------------------------
FUNCTION ListView ; Populate Listview with contents of Playlist.xml = $Plist[x,y]
Dim $CNT, $X
$PlayListView = $System.ListView()
$PlayListView.CheckBoxes = -1  ;True
$PlayListView.Dock = 1  ;Top
$PlayListView.GridLines = -1  ;True
$PlayListView.Height = 285
$PlayListView.MultiSelect = 0  ;False
$PlayListView.Sorting = 2  ;Descending
$PlayListView.AutoArrange = "True"
$PlayListView.View = $System.View_Details
$PlayListView.fullrowselect = -1    ;True
$PlayListView.doubleclick = 'ListViewItemClick("PlayListView","MYsched")'
$PlayListView.KeyPress = 'ListViewItemKey("PlayListView","MYsched")'
$nul = $MYsched.Controls.Add($PlayListView)

$PlayListViewColumn0 = $PlayListView.Columns.Add($System.ColumnHeader("[/]  = Presentation Active",520,$System.HorizontalAlignment_Left))
$PlayListViewColumn1 = $PlayListView.Columns.Add($System.ColumnHeader("From",50,$System.HorizontalAlignment_Center))
$PlayListViewColumn2 = $PlayListView.Columns.Add($System.ColumnHeader("To",50,$System.HorizontalAlignment_Center))

if $TOTAL > 0
For $CNT = 1 to $TOTAL
$X=$CNT-1
$ = execute("$$PlayListViewItem$X = $$PlayListView.Items.Add($$System.ListViewItem($$PLIST[5,$$CNT]))")
If $PLIST[0,$CNT]='TRUE'
 $ = execute("$$PlayListViewItem$X.Checked = 1")
Else
 $ = execute("$$PlayListViewItem$X.Checked = 0")
Endif
$ = execute("$$PlayListViewItem$X.ForeColor = $$System.Color.FromName('WindowText')")
$ = execute("$$PlayListViewItem$X.UseItemStyleForSubItems = 1")  ;True
$ = execute("$$PlayListViewItem$X = $$PlayListView.Items.Item($$X).SubItems.Add($$System.ListViewSubItem($$PLIST[2,$$CNT]))")
$ = execute("$$PlayListViewItem$X = $$PlayListView.Items.Item($$X).SubItems.Add($$System.ListViewSubItem($$PLIST[3,$$CNT]))")
next
Endif
EndFunction
;-----------------------------------------
FUNCTION ListViewItemKey($lv,$lvform) ; User Keyboard ENTER
 Dim $key,$LX
 $LX="$"+$LV
 $ = execute("$$key = $LX.KeyPressEventArgs.KeyChar")
  If $key = chr(13)
   $ = ListViewItemClick($lv,$lvform)
  ENDIF
ENDFUNCTION
;-----------------------------------------
FUNCTION ListViewItemClick($lv,$lvform) ; User Double Click Line
Dim $Pres
  $lv = "$"+$lv
  $lvform = "$"+$lvform
  $ = execute("$$Pres = $LV.SelectedItems.Item(3).Text")
$=messagebox($Pres,"Selected")
; Trying to return entry in Column 3 = Playlist item.
ENDFUNCTION
;-----------------------------------------
Function  AddP ; Add to List
$=FileDialog($PresDir+"\", "MY", "Select a MY file.")
If $Selected <>""
dim $CNT
$CNT = $total+1
redim preserve $PLIST[5,$CNT]
$PLIST[0,$CNT]='FALSE'
$PLIST[1,$CNT]=$CNT
$PLIST[4,$CNT]="P"+cstr($CNT)
$PLIST[5,$CNT]=$PresDir+"\"+$Selected
$Selected=""
$ = execute("$$PlayListViewItem$total = $$PlayListView.Items.Add($$System.ListViewItem($$PLIST[5,$$CNT]))")
$ = execute("$$PlayListViewItem$total.Checked = 0")
$ = execute("$$PlayListViewItem$total.ForeColor = $$System.Color.FromName('WindowText')")
$ = execute("$$PlayListViewItem$total.UseItemStyleForSubItems = 1")  ;True
$ = execute("$$PlayListViewItem$total = $$PlayListView.Items.Item($$total).SubItems.Add($$System.ListViewSubItem($$PLIST[3,$$CNT]))")
$ = execute("$$PlayListViewItem$total = $$PlayListView.Items.Item($$total).SubItems.Add($$System.ListViewSubItem($$PLIST[2,$$CNT]))")
$TOTAL=$CNT
Endif
EndFunction
;-----------------------------------------
Function  RemP ; Remove Selected line
Dim $x, $Item
For Each $item in $PlayListView.SelectedItems
 $Total=$Total-1
  $item.Remove()
;$ = execute("$$X = $$PlayListViewItem$item.text")
;$Line = $PlayListView.Items.Item($item).text
If @error <>0
 ? @serror
endif
Next
EndFunction
;-----------------------------------------
Function  ClearAll  ; Untick ALL
Dim $X
For $X = 1 to $Total
 $PLIST[0,$X]='False'
 $PlayListView.Items.Item($X-1).Checked = 0
next
EndFunction
;-----------------------------------------
Function  SelectAll  ; Tick All
Dim $X
For $X = 1 to $Total
 $PLIST[0,$X]='TRUE'
 $PlayListView.Items.Item($X-1).Checked = 1
next
EndFunction
;-----------------------------------------
Function MakeNew
 $Total=0
 redim $PLIST[5,0]
 $PlayListView.Items.clear()
EndFunction
;-----------------------------------------
Function Preferences
$MYsched.hide ; Hide Main Form
$MYschedpref = $System.Form()
$MYschedpref.FormBorderStyle = 1  ;FormBorderStyle_FixedSingle
$MYschedpref.MaximizeBox = 0  ;False
$MYschedpref.MinimizeBox = 0  ;False
$MYschedpref.ShowInTaskbar = 0  ;False
$MYschedpref.Size = $System.Size(400,150) ;(Width,Height)
$MYschedpref.Text = "Presentation Scheduler folder preferences"
$MYschedpref.icon = $system.icon.frombitmap(MY_Icon())
$MYschedpref.center

$PLlabx = $System.label()
$PLlabx.Height = 15
$PLlabx.Left = 50
$PLlabx.top = 15
$PLlabx.width=340
$PLlabx.Text = "FOLDER containing the 'Playlist.xml' file ="
$nul = $MYschedPREF.Controls.Add($PLlabx)

$PLlab = $System.label()
$PLlab.Height = 15
$PLlab.Left = 50
$PLlab.top = 34
$PLlab.width=340
If $Source = ""
 $PLlab.Text = "%userprofile%\MY Documents"
Else
 $PLlab.Text = $Source
Endif
$nul = $MYschedPREF.Controls.Add($PLlab)

$PLBtn = $System.Button()
$PLBtn.Height = 25
$PLBtn.Left = 10
$PLBtn.Top = 20
$PLBtn.Width = 30
$PLBtn.Text = "..."
$PLBtn.Click = 'PLpref'
$nul = $MYschedPREF.Controls.Add($PLBtn)
;$ToolTip.SetToolTip($PLBtn,"FOLDER containing the Playlist.xml")

$Fileslabx = $System.label()
$Fileslabx.Height = 15
$Fileslabx.Left = 50
$Fileslabx.Top = 70
$Fileslabx.width=340
$Fileslabx.Text = "FOLDER containing the Presentations ="
$nul = $MYschedPREF.Controls.Add($Fileslabx)

$Fileslab = $System.label()
$Fileslab.Height = 15
$Fileslab.Left = 50
$Fileslab.Top = 90
$Fileslab.width=340
If $PresDir = ""
 $Fileslab.Text = "%userprofile%\MY Documents"
Else
 $Fileslab.Text = $PresDir
Endif
$nul = $MYschedPREF.Controls.Add($Fileslab)

$FilesBtn = $System.Button()
$FilesBtn.Height = 25
$FilesBtn.Left = 10
$FilesBtn.Top = 77
$FilesBtn.Width = 30
$FilesBtn.Text = "..."
$FilesBtn.Click = 'FilePref'
$nul = $MYschedPREF.Controls.Add($FilesBtn)
;$ToolTip.SetToolTip($FilesBtn,"FOLDER containing the Presentations")

$MYschedpref.show
While $MYschedpref.Visible
 $= Execute($MYschedpref.DoEvents)
Loop
$MYschedpref.close
If $Source = ""  or $PresDir = ""
   $=messagebox("You MUST select the location Folder for"+chr(10)+"'PlayList.xml' and the PRESENTATIONS"+chr(10)+"in order to proceed !","REQUIRED INFORMATION NOT SET",,10)
   quit
Endif

$MYsched.show ; Show Main Form
EndFunction
;-----------------------------------------
Function PLpref
  $L=GUIDialog("Identify the 'FOLDER' containing 'PlayList.xml' file",$MY,16384)
  If @error=0
   if exist($L+"\PlayList.xml")
    $source=$L
    $PLlab.Text = $Source
    $ = WriteINI
    $MYsched.close
    $REDO="Y"
  Endif
  If $Source = ""
   $=messagebox("You MUST select the location Folder for"+chr(10)+"'PlayList.xml' in order to proceed!","REQUIRED INFORMATION NOT SET",,10)
   quit
  Endif
EndFunction
;-----------------------------------------
Function FILEpref
  $L=GUIDialog("Identify the Default PRESENTATIONS 'folder'",$MY)
  If @error=0 and exist($L)
   $PresDir=$L
   $Fileslab.Text = $PresDir
   $ = WriteINI
   $MYsched.close
   $REDO="Y"
  Endif
  If $PresDir = ""
   $=messagebox("You MUST select the location Folder for"+chr(10)+"the PRESENTATIONS folder to proceed!","REQUIRED INFORMATION NOT SET",,10)
   quit
  Endif
EndFunction
;-----------------------------------------
Function ReadINI
 If open(5,$INI,2)=0
  $L=readline(5)
  While @error=0
   SELECT
    CASE $L='[Source]'
     $Source=readline(5)
    CASE $L='[Presentations]'
     $PresDir=readline(5)
    CASE $L='[Footer]'
     $Footer=readline(5)
    CASE $L='[Header]'
     while @error=0
      $Header=$Header+readline(5)+@crlf
     loop
   EndSelect
  $L=readline(5)
  Loop
  $=close(5)
 Else
   $=MakeINI
 EndIf
If $Source="" or $PresDir=""
 $=presentations
Endif
EndFunction
;-----------------------------------------
Function MakeINI
Dim $L
 If not exist($INI)
  $Footer='</NewDataSet>'

  $Header='<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="PlayList" msdata:CaseSensitive="False">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Show" type="xs:boolean" minOccurs="0" />
                <xs:element name="Index" type="xs:short" minOccurs="0" />
                <xs:element name="From" type="xs:string" minOccurs="0" />
                <xs:element name="Until" type="xs:string" minOccurs="0" />
                <xs:element name="UniqueName" type="xs:string" minOccurs="0" />
                <xs:element name="FileNames" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>'
  $ = Preferences
  $ = WriteINI
 Else
  $=messagebox("Unable to READ or CREATE"+chr(10)+$INI+chr(10)+chr(10)+"Seek technical assistance !","E R R O R")
  Quit
 Endif
EndFunction
;-----------------------------------------
Function WriteINI
If $Source = "" or $PresDir=""
 exit
Endif
 If Exist($INI)
  del @scriptdir+"\"+left(@scriptname,-4)+".inx"
  move $ini @scriptdir+"\"+left(@scriptname,-4)+".inx"
 Endif
 If open(5,$INI,5)=0
   $=writeline(5,'[Source]'+@crlf+$source+@crlf)
   $=writeline(5,'[Presentations]'+@crlf+$PresDir+@crlf)
   $=writeline(5,'[Footer]'+@crlf+$Footer+@crlf)
   $=writeline(5,'[Header]'+@crlf+$Header)
   $=close(5)
 Else
   $=messagebox("Unable to READ or CREATE"+chr(10)+$INI+chr(10)+chr(10)+"Seek technical assistance !","E R R O R")
   Quit
 EndIf
EndFunction
;-----------------------------------------
Function ReadXML
Dim $L,$CNT
If open(5,$Source+"\Playlist.xml",2)=0
 $L=readline(5)
 While @error = 0
 If trim($L)='<PlayList>'
  $CNT=$CNT+1
  redim preserve $PLIST[5,$CNT]
  $PLIST[0,$CNT]=left(right(trim(readline(5)),-6),-7)
  $PLIST[1,$CNT]=left(right(trim(readline(5)),-7),-8)
  $PLIST[2,$CNT]=left(right(trim(readline(5)),-6),-7)
  $PLIST[3,$CNT]=left(right(trim(readline(5)),-7),-8)
  $PLIST[4,$CNT]=left(right(trim(readline(5)),-12),-13)
  $PLIST[5,$CNT]=left(right(trim(readline(5)),-11),-12)
 EndIF
 $L=readline(5)
 Loop
 $Total=$CNT
 $=close(5)
Else
 $=MakeNew
Endif
EndFunction
;-----------------------------------------
Function WriteXML
If $PLIST[5,1]<>""
If Open(5,$Source+"\Playlist.tmp",5)=0
$= WRITELINE(5,$Header+@crlf)
For $L = 1 to $Total
If $PLIST[5,$L]<>""
 $= WRITELINE(5,' <PlayList>'+@crlf)
 $= WRITELINE(5,'  <Show>'+$PLIST[0,$L]+'</Show>'+@crlf)
 $= WRITELINE(5,'  <Index>'+$PLIST[1,$L]+'</Index>'+@crlf)
 If $PLIST[2,$L] <>""
  $= WRITELINE(5,'  <From>'+$PLIST[2,$L]+'</From>'+@crlf)
 Else
  $= WRITELINE(5,'  <From />'+@crlf)
 Endif
 If $PLIST[3,$L] <>""
  $= WRITELINE(5,'  <Until>'+$PLIST[3,$L]+'</Until>'+@crlf)
 Else
  $= WRITELINE(5,'  <Until />'+@crlf)
 Endif
 $= WRITELINE(5,'  <UniqueName>'+$PLIST[4,$L]+'</UniqueName>'+@crlf)
 $= WRITELINE(5,'  <FileNames>'+$PLIST[5,$L]+'</FileNames>'+@crlf)
 $= WRITELINE(5,' </PlayList>'+@crlf)
Endif
next
$= WRITELINE(5,$Footer+@crlf)
$=close(5)
If exist($Source+"\Playlist.old")
 del $Source+"\Playlist.old"
Endif
If exist($Source+"\Playlist.xml")
 move  $Source+"\Playlist.xml" $Source+"\Playlist.old" /c
Endif
If exist($Source+"\Playlist.tmp")
 move  $Source+"\Playlist.tmp" $Source+"\Playlist.xml" /c
Endif
else
 ? $Source+" _ "+@serror
EndIf
Endif
EndFunction
;-----------------------------------------
Function FileDialog($Path, $FileType, Optional $TITLE)
If $TITLE = ""
 $TITLE="Select files of type '"+$FileType+"'"
Endif
Dim $HT, $WD, $sl, $Dcount, $sdir, $X, $MaxDlen
$dcount = 0
$maxdlen = 0
$sl=len($filetype)
; Read the file content of $Path into array
$sfile=Dir($Path)
WHILE NOT @error
; Identify Files of Type $FileType
IF GetFileAttr($Path + $sfile) <> 16 AND right($sfile,$sl) = $filetype
 $dcount=$dcount+1
 redim preserve $sdir[$dcount]
 $sdir[$dcount] = $sfile
 $x=len($sfile)
 IF $x > $maxdlen
  $maxdlen = $x
 ENDIF
ENDIF
$sfile = Dir()
LOOP
If $MaxDlen >0
$HT=($dcount*15)+80
if $HT > 640
 $HT=640
Endif
$WD=($maxdlen*5)+50

$FileForm = $System.Form()
$FileForm.Size = $System.Size($WD,$HT) ;(Width,Height)
$FileForm.FormBorderStyle = 1
$FileForm.Text = $TITLE
$FileForm.maximizebox = 0
$FileForm.minimizebox = 0
$FileForm.ShowInTaskBar = 0
$FileForm.icon = $system.icon.frombitmap(MY_Icon())
$FileForm.center

$FileLV = $System.ListView()
$FileLV.Height = $HT-60
$FileLV.Width = $WD-5
$FileLV.Left = 0
$FileLV.Top = 0
;$FileLV.Dock = 2
$FileLV.KeyDown = "KeyDownEvent()"
$FileLV.KeyPress = "SelectItemEvent()"
$FileLV.Click = "OnClick()"
$FileLV.DoubleClick = 'OK_Enter()'
$FileLV.MultiSelect = 0  ;False
$FileLV.Sorting = 1  ;Ascending
$FileLV.View = $System.View_List
$FileLV.AutoArrange = "True"
$nul = $FileForm.Controls.Add($FileLV)

$TextBox = $System.TextBox()
$TextBox.Left = 0
$TextBox.Top = $HT-56
$TextBox.Width = $WD - 35
$nul = $FileForm.Controls.Add($TextBox)

$OKEnter = $System.Button()
$OKEnter.Click = "OK_Enter()"
$OKEnter.Name = "OKEnter"
$OKEnter.Text = "OK"
$OKEnter.Width = 30
$OKEnter.Left = $WD-34
$OKEnter.Top = $HT-56
$nul = $FileForm.Controls.Add($OKEnter)
$FileForm.AcceptButton = $OKEnter

for each $x in $Sdir
 If $X<>""
  $ = $FileLV.Items.Add($system.listviewitem($x))
 Endif
next

$MYsched.hide ; Hide Main Form
$FileForm.Show  ;Displays the Form
While $FileForm.Visible and $Selected=""
   $Nul = Execute($FileForm.DoEvents())
Loop
$FileForm.close
$MYsched.show

Else
 $=messagebox($TITLE+chr(10)+$PresDir,"NO FILES FOUND !",,10)
Endif
EndFunction
;-----------------------------------------
Function KeyDownEvent()
   $KeyCode = $FileLV.KeyDownEventArgs.KeyCode
   If $KeyCode = 37 Or $KeyCode = 38 Or $KeyCode = 39 Or $KeyCode = 40
         $TextBox.Text = $FileLV.FocusedItem.Text
   EndIf
EndFunction
;-----------------------------------------
Function onclick()
         $TextBox.Text = $FileLV.FocusedItem.Text
EndFunction
;-----------------------------------------
Function SelectItemEvent()
  $TextBox.Text = $FileLV.FocusedItem.Text
   If $FileLV.KeyPressEventArgs.KeyChar = chr(13)
    If $TextBox.Text <>""
     $Selected=$TextBox.Text
    Endif
   Endif
EndFunction
;-----------------------------------------
Function OK_Enter()
  $TextBox.Text = $FileLV.FocusedItem.Text
    If $TextBox.Text <>""
     $Selected=$TextBox.Text
    Endif
EndFunction
;-----------------------------------------
FUNCTION EditP($NO)
Dim $X
$PlaylistEdit = $System.Form()
$PlaylistEdit.Font = $System.Font("Tahoma",9,0) ;Regular
$PlaylistEdit.Left = 8
$PlaylistEdit.MaximizeBox = 0  ;False
$PlaylistEdit.MinimizeBox = 0  ;False
$PlaylistEdit.Size = $System.Size(175,150) ;(Width,Height)
$PlaylistEdit.Text = "EDIT From - To"
$PlaylistEdit.center

$Continuous = $System.CheckBox()
$Continuous.Left = 55
$Continuous.Text = "Continuous"
$Continuous.Top = 80
$Continuous.Width = 90
$Continuous.CheckChanged = 'ContCC'
If $PLIST[2,$No] <>"" or $PLIST[3,$No] <>""
 $Continuous.checked = 0
Else
 $Continuous.checked = -1
Endif
$nul = $PlaylistEdit.Controls.Add($Continuous)

$ContOr = $System.Label()
$ContOr.Height = 20
$ContOr.Left = 27
$ContOr.Text = "OR"
$ContOr.TextAlign = 64  ;MiddleRight
$ContOr.Top = 82
$ContOr.Width = 25
$nul = $PlaylistEdit.Controls.Add($ContOr)

$OK = $System.button()
$OK.Height = 23
$OK.Left = 140
$OK.Text = "OK"
$OK.Top = 0
$OK.Width = 29
$OK.click = 'OK-Enter($NO)'
$nul = $PlaylistEdit.Controls.Add($OK)


$FromLEd = $System.Label()
$FromLEd.Height = 20
$FromLEd.Left = 20
$FromLEd.Text = "FROM"
$FromLEd.TextAlign = 64  ;MiddleRight
$FromLEd.Top = 30
$FromLEd.Width = 40
$nul = $PlaylistEdit.Controls.Add($FromLEd)

$From#LEd = $System.Label()
$From#LEd.Height = 20
$From#LEd.Left = 100
$From#LEd.Text = ":"
$From#LEd.TextAlign = 64  ;MiddleRight
$From#LEd.Top = 30
$From#LEd.Width = 5
$nul = $PlaylistEdit.Controls.Add($From#LEd)

$ToLEd = $System.Label()
$ToLEd.Height = 20
$ToLEd.Left = 30
$ToLEd.Text = "TO"
$ToLEd.TextAlign = 64  ;MiddleRight
$ToLEd.Top = 55
$ToLEd.Width = 30
$nul = $PlaylistEdit.Controls.Add($ToLEd)

$To#LEd = $System.Label()
$To#LEd.Height = 20
$To#LEd.Left = 100
$To#LEd.Text = ":"
$To#LEd.TextAlign = 64  ;MiddleRight
$To#LEd.Top = 55
$To#LEd.Width = 5
$nul = $PlaylistEdit.Controls.Add($To#LEd)

$HrMiLEd = $System.Label()
$HrMiLEd.Height = 15
$HrMiLEd.Left = 37
$HrMiLEd.Text = "[24] Hours Mins."
$HrMiLEd.TextAlign = 32  ;MiddleCenter
$HrMiLEd.Top = 10
$HrMiLEd.Width = 100
$nul = $PlaylistEdit.Controls.Add($HrMiLEd)

$FrHHTB = $System.TextBox()
$FrHHTB.Height = 20
$FrHHTB.Left = 68
If $PLIST[2,$No] <>""
 $FrHHTB.Text = left($PLIST[2,$No],2)
Else
 $FrHHTB.Text = "HH"
Endif
$FrHHTB.Top = 30
$FrHHTB.Width = 30
$FrHHTB.LostFocus = 'EditFT("FrHH")'
$FrHHTB.KeyDown = 'EditFTKP($NO,"FH")'
$nul = $PlaylistEdit.Controls.Add($FrHHTB)

$FrMMTB = $System.TextBox()
$FrMMTB.Height = 20
$FrMMTB.Left = 105
If $PLIST[2,$No] <>""
 $FrMMTB.Text = right($PLIST[2,$No],2)
Else
 $FrMMTB.Text = "MM"
Endif
$FrMMTB.Top = 30
$FrMMTB.Width = 30
$FrMMTB.LostFocus = 'EditFT("FrMM")'
$FrMMTB.KeyDown = 'EditFTKP($NO,"FM")'
$nul = $PlaylistEdit.Controls.Add($FrMMTB)

$ToHHTB = $System.TextBox()
$ToHHTB.Height = 20
$ToHHTB.Left = 68
If $PLIST[3,$No] <>""
 $ToHHTB.Text = left($PLIST[3,$No],2)
Else
 $ToHHTB.Text = "HH"
Endif
$ToHHTB.Top = 55
$ToHHTB.Width = 30
$ToHHTB.LostFocus = 'EditFT("ToHH")'
$ToHHTB.KeyDown = 'EditFTKP($NO,"TH")'
$nul = $PlaylistEdit.Controls.Add($ToHHTB)

$ToMMTB = $System.TextBox()
$ToMMTB.Height = 20
$ToMMTB.Left = 105
If $PLIST[3,$No] <>""
 $ToMMTB.Text = right($PLIST[3,$No],2)
Else
 $ToMMTB.Text = "MM"
Endif
$ToMMTB.Top = 55
$ToMMTB.Width = 30
$ToMMTB.LostFocus = 'EditFT("ToMM")'
$ToMMTB.KeyDown = 'EditFTKP($NO,"TM")'
$nul = $PlaylistEdit.Controls.Add($ToMMTB)

$PlaylistEdit.Show  ;Displays the Form

While $PlaylistEdit.Visible
 $ = Execute($PlaylistEdit.DoEvents())
Loop
EndFunction
;-----------------------------------------
Function EditFT($Sw)
Select
 CASE $Sw = "FrHH"
 If val($FrHHTB.Text) < 1
  $FrHHTB.Text="00"
 Endif
 If val($FrHHTB.Text) > 23
  $FrHHTB.Text="23"
 EndIf
 CASE $Sw = "FrMM"
 If val($FrMMTB.Text) < 1
  $FrMMTB.Text="00"
 Endif
 If val($FrMMTB.Text) > 59
  $FrMMTB.Text="59"
 EndIf
 CASE $Sw = "ToHH"
 If val($ToHHTB.Text) < 1
  $ToHHTB.Text="00"
 Endif
 If val($ToHHTB.Text) > 23
  $ToHHTB.Text="23"
 EndIf
 CASE $Sw = "ToMM"
 If val($ToMMTB.Text) < 1
  $ToMMTB.Text="00"
 Endif
 If val($ToMMTB.Text) > 59
  $ToMMTB.Text="59"
 EndIf
EndSelect
EndFunction
;-----------------------------------------
Function EditFTKP($No,$Sw)
$Continuous.checked = 0
Select
 CASE $Sw = "FH"
 If $PLIST[2,$No] ="" and val($FrHHTB.Text) < 1
  $FrHHTB.Text="00"
 Else
  $FrHHTB.Text=left($FrHHTB.Text,2)
 EndIf
 CASE $Sw = "FM"
 If $PLIST[2,$No] ="" and val($FrMMTB.Text) < 1
  $FrMMTB.Text="00"
 Else
  $FrMMTB.Text=left($FrMMTB.Text,2)
 EndIf
 CASE $Sw = "TH"
 If $PLIST[3,$No] ="" and val($ToHHTB.Text) < 1
  $ToHHTB.Text="00"
 Else
  $ToHHTB.Text=left($ToHHTB.Text,2)
 EndIf
 CASE $Sw = "TM"
 If $PLIST[3,$No] ="" and val($ToMMTB.Text) < 1
  $ToMMTB.Text="00"
 Else
  $ToMMTB.Text=left($ToMMTB.Text,2)
 EndIf
EndSelect
EndFunction
;-----------------------------------------
Function ContCC
If $Continuous.checked = 1
 $FrHHTB.Text=""
 $FrMMTB.Text=""
 $ToHHTB.Text=""
 $ToMMTB.Text=""
Endif
EndFunction
;-----------------------------------------
Function OK-Enter($No)
If $Continuous.checked = -1
 $PLIST[2,$No] = ""
 $PLIST[3,$No] = ""
Else
 $PLIST[2,$No] = right("0"+cstr(val($FrHHTB.Text)),2)+"."+right("0"+cstr(val($FrMMTB.Text)),2)
 $PLIST[3,$No] = right("0"+cstr(val($ToHHTB.Text)),2)+"."+right("0"+cstr(val($ToMMTB.Text)),2)
 If $PLIST[2,$No] = $PLIST[3,$No]
  $Continuous.checked = -1
  $PLIST[2,$No] = ""
  $PLIST[3,$No] = ""
 Endif
 If val($PLIST[2,$No]) > val($PLIST[3,$No])
  $X = $PLIST[2,$No]
  $PLIST[2,$No] = $PLIST[3,$No]
  $PLIST[3,$No] = $X
 Endif
 $PLIST[2,$No]=Join(Split($PLIST[2,$No],'.'),':')
 $PLIST[3,$No]=Join(Split($PLIST[3,$No],'.'),':')
Endif
$PlaylistEdit.close
EndFunction
;-----------------------------------------
FUNCTION MY_Icon()
$MY_icon = "
Qk02BAAAAAAAADYAAAAoAAAAEAAAABAAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAANrm6Dy30NOZr8rN1LHLz/KzzNDxtc7SzrjQ0ofq8fIjAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA8fb3BLrR1ZumxMn/o8LH/6TCyP+kw8j/o8LI/6LCx/+iwsf/
rMjN9dro6W////8DAAAAAAAAAAAAAAAA9vv7BL7U17Kfv8T/pcPJ/6XEyf+lxcz/psjP/6bI
zv+lxMr/psTJ/6PCx/+gwMX/0eHkngAAAAAAAAAAAAAAAMna3pKevsT/psTJ/6XEyv+qy9L/
rL6+/6qwqP+rtbD/rcjM/6bIz/+lw8n/pcPI/6HAxv/e6etfAAAAAOfw8TOnxcr7pcPI/6XF
y/+tyMz/pJB+/5NlRP+PXjr/kF89/5p0V/+ts63/p8nQ/6bEyf+iwsf/sMrO2vL4+AzJ3N6Z
oMDF/6bEyf+ry9H/o4t2/4lUL/+MXzz/ils5/41fPf+KWTb/kF89/664tf+mx87/psTJ/6LB
xv/H2t1TudHV1aLBx/+myM7/rLSw/45cOP+XblD+lWxO/6eGbf+YcFL/lGtL/5htT/+fgmr/
q8vR/6XEyf+iwcf/xNfbn67Kzu6kw8j/p8rS/6ecjv+IVC//up+L/ZlyVv/Aqpr/w66e/8m2
qP+gfGH/kWdH/67Fx/+lxMr/psTJ/6nGy6quys7upMPI/6fK0v+mmoz/jFo3/8Krmv+ukHr/
vqeW/66Qef/YzML/k2lJ/5NoSP+uxMf/pcXK/6bEyf+oxcqquNHU2KLCx/+myM//qrCq/5Vn
R/+uj3r/o4Fm/6iHbv+bdVj/m3VZ/5dtTv+dfmb/q8rQ/6XEyf+iwsf/wdbZpMXZ256hwcb/
pcTJ/6vK0P+ghG7/hVAq/4tcOv+LXDr/jV89/4pZNf+OXTr/rbax/6bIzv+mxMn/ocDG/9rm
6Fvo8fNCpMPI/6XDyP+lxcv/rcbK/6KKdf+RYkD/jFo3/45dOf+Yb1H/rK+n/6jK0f+mxMj/
o8LH/7DLz+P1+fsaAAAAAMPY26Sfv8X/psTJ/6XFy/+qy9H/rLq3/6uqov+rsKn/rcXI/6fJ
0P+lw8j/psTJ/6LBxv/X5eZrAAAAAAAAAAD3+/sTudHU06DAxf+mxMn/pcTJ/6XGzf+nydH/
psjP/6XEyv+mxMn/psTI/6HAxv+30NShAAAAAAAAAAAAAAAAAAAAAPX5+hS/1diqocHG/6LC
x/+kw8f/psTJ/6XDyP+kwsf/o8LH/6DAxfvA1tmJ3enrBAAAAAAAAAAAAAAAAAAAAAAAAAAA
9vn6Ad7p60e40NWxscvP7abEye+oxcvxscvQ47zU157V5OY4AAAAAAAAAAAAAAAAAAAAAA==
"
$MY_icon = $system.bitmap.frombase64string($MY_icon)
ENDFUNCTION
;-----------------------------------------
;FUNCTION   GUIDialog()
;
;AUTHOR   Lonkero
;
;ACTION      GUI for selecting folder/file/computer/printer...
;
;SYNTAX   GUIDialog(TITLE,[ROOT][,MODE])
;
;PARAMETERS
;      TITLE
;       - Title to show in dialog
;      ROOT
;       - Optional. Specifies the root of the Browse dialog box.
;       The user cannot browse higher in the architecture than this folder.
;       If this value is not specified, the root of the Browse dialog box is the desktop.
;      MODE
;       - Optional. Changes the mode to show in dialog:
;      2   = Do not include network folders below the domain level in the dialog box's tree view control.
;      16   = Include an edit control in the browse dialog box that allows the user to type the name of an item.
;      4096   = Only return computers. If the user selects anything other than a computer, the OK button is grayed.
;      8192   = Only return printers. If the user selects anything other than a printer, the OK button is grayed.
;      16384   = The browse dialog box will display files as well as folders.
;
;RETURNS
;      the full path to folder, or error if user pressed cancel.
;
;DEPENDENCIES   Minimum operating systems: Windows 2000, Windows ME
;
;EXAMPLE
;      GUIdialog("kix ass")
;      if @error
;       "user pressed cancel"
;      endif
;
;CODE
function GUIDialog($_title, optional $_root, optional $_mode)
 dim $
 $=createobject("shell.application")
 $GUIDialog=$.BrowseForFolder(0,$_title,0+$_mode,$_root).self.path
 if not len($GUIDialog) exit 1 endif
endfunction
;-----------------------------------------

________
Gift Cards


Last edited by MACE1 on Fri Feb 18, 2011 5:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Wed Oct 17, 2007 4:46 pm    Post subject: Reply with quote

Hi MACE1,

Here is another way of removing the selected item and getting the index of that item (I included the other bits of code from your RemP function) :

Code:

Dim $i

For $i = 0 to $PlayListView.Items.Count - 1
   If $PlayListView.Items.Item($i).Selected = -1
      $Total=$Total-1
      $PlayListView.Items.Item($i).Remove()
      If @error <>0
          ? @serror
      EndIf
      ;$i = index of array
   EndIf
Next


In regards to $LINE, here is the code to get the selected listview item:

Code:

Dim $i

For $i = 0 to $PlayListView.Items.Count - 1
   If $PlayListView.Items.Item($i).Selected = -1
      ;$i = selected listview item/index of array
   EndIf
Next


In all honesty, once you load the array into the listview, you can make the listview act as your active array and at the end save the listview items to your file. Let me know if you need addt'l help. Wink
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Wed Oct 17, 2007 7:59 pm    Post subject: Reply with quote

Very Happy
I'll develope this after dinner... Thanks

The display list only holds part of the data hence the dual arrays in this case.
I would actually PREFER not to have both but at the moment even after the last 3 weeks dredging through .net manuals I am still very unsure how to use listviews properly. I really need to find some material which shows how to properly structure things to read equivalent line numbers (Index) and to access individual column entries, particularly when they are in collections.

POINT ME TO SOME GOOD REFERENCE MATERIAL, DOES NOT NECESSARILY HAVE TO BE IN KIXforms SO LONG AS IT IDENTIFIES THE STRUCTURES CLEARLY.
________
Kurt adolff


Last edited by MACE1 on Fri Feb 18, 2011 5:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Wed Oct 17, 2007 9:57 pm    Post subject: DRATS - Pearly Reply with quote

Looks like I am going to have to re-work everything as its impossible to equate a fixed array with the listview as the index on the listview changes as it autosorts etc.
This now begs the questions;
1] How do I specifically edit/add the subitems and retrieve said items from columns 0,1,2 when required.
2] How can I make invisible columns in which to hold non visible data in a collection = row ?

The way it is currently built I use the array to read in and write out data. Now I will need to hold ALL information in the listview collections whether visible or not.

If collection $i is -1 = selected then I need to pass each of the column details into a line array 0 to 6. What do I need to do ?
I modify these details in line array and need to update the collection $i entry, What to do to update rather than add ?
________
Grow medical marijuana


Last edited by MACE1 on Fri Feb 18, 2011 5:19 pm; edited 1 time in total
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Wed Oct 17, 2007 10:57 pm    Post subject: Reply with quote

Here's the answer to Question #1

Taking the same code I have posted earlier...

Code:

;Gets total number of subitems for working item
;Adds new subitems for working item
For $i = 0 to $PlayListView.Items.Count - 1
      If $PlayListView.Items.Item($i).Selected = -1
         ;$Count is the total number of subitems for this item.
        $Count = $PlayListView.Items.Item($i).SubItems.Count
        ;This add new subitems where $text is value for new subitem
        $PlayListView.Items.Item($i).SubItems.Add($text)
      EndIf
Next

;Retrieves all subitems for working item
For $i = 0 to $PlayListView.Items.Count - 1
      If $PlayListView.Items.Item($i).Selected = -1
         For $j = 0 $PlayListView.Items.Item($i).SubItems.Count - 1
         ;Gets each subitem value for working item
           ? $PlayListView.Items.Item($i).SubItems.Item($j).Text
        Next
      EndIf
Next
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