1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| Imports System.io
Imports System.Xml
Imports System.Threading
Imports System.Windows.Forms
Imports System.ComponentModel
Public Class Media
Dim BinPath As String = Application.StartupPath & "\" 'le chemin vers le repertoire Bin
Dim c_planning As Planning
Dim startApp As DateTime
Dim theFile As FileStream
Dim writer As StreamWriter
Dim opZone As New ParameterizedThreadStart(AddressOf trierBlocsWithContent)
Private Delegate Sub MethodInvoker(ByVal oBlock As Object)
''' <summary>
''' Methode pour laisser les traces de debogages
''' </summary>
''' <param name="str"></param>
''' <remarks></remarks>
Sub Log(ByVal str As String)
Try
writer.WriteLine(DateTime.Now.ToString + " : " + str)
Catch ex As Exception
writer.Close()
theFile.Close()
End Try
End Sub
''' <summary>
''' Merthode permet de faire la Lecture des medias par Bloc
''' </summary>
''' <remarks></remarks>
Public Sub PlayBlocWithContent()
Dim mTimeline As TimeLine
Dim uc As UserControl1
For Each vZone As DataRowView In dv_zone
dv_TimeLine.RowFilter = "ZoneID=" & vZone("ZoneID")
Dim p As Point
'creation des users controle pour chaque zone
uc = New UserControl1
uc.Name = "uc" & vZone("ZoneID")
uc.Height = vZone("ZoneHieght")
uc.Width = vZone("ZoneWidth")
uc.Top = vZone("ZoneTop")
uc.Left = vZone("ZoneLeft")
p.X = vZone("ZoneLeft")
p.Y = vZone("ZoneRight")
uc.Location = p
Me.Controls.Add(uc)
For Each vTimeLine As DataRowView In dv_TimeLine
mTimeline = New TimeLine
mTimeline.TimeLineID = vTimeLine("TimeLineID")
mTimeline.TimeLineName = vTimeLine("TimeLineName")
mTimeline.ZoneID = vTimeLine("ZoneID")
mTimeline.Ajouter_Bloc()
Dim theThread As New Thread(opZone) 'creer pour chaque Zone un Thread
theThread.SetApartmentState(ApartmentState.STA)
theThread.Start(mTimeline)
Next
Next
End Sub
Dim d_content As DateTime = dv_Planning.Item(0).Item("PlanningStartDate")
Dim d_bloc As DateTime = dv_Planning.Item(0).Item("PlanningStartDate")
''' <summary>
''' Methode permet de trie les contenus par Bloc
''' </summary>
''' <remarks></remarks>
'''
Public Sub trierBlocsWithContent(ByVal obj As Object)
Dim vTimeline As New TimeLine
vTimeline.TrieBloc()
vTimeline = CType(obj, TimeLine)
Log("Thread :" & Thread.CurrentThread.Name)
If Me.InvokeRequired Then
Me.Invoke(New MethodInvoker(AddressOf trierBlocsWithContent), vTimeline)
Else
Dim uc As UserControl1
uc = Me.Controls("uc" & vTimeline.ZoneID.ToString())
For i As Integer = 0 To vTimeline.Array_Bloc.Count - 1
Dim c_bloc As Bloc = CType(vTimeline.Array_Bloc.Item(i), Bloc)
If d_bloc.AddSeconds(CType(vTimeline.Array_Bloc.Item(i), Bloc).BlocDuration) >= Now Then
CType(vTimeline.Array_Bloc(i), Bloc).TrieContent()
For Each item As Content In CType(vTimeline.Array_Bloc(i), Bloc).Array_Content
uc.playContent(BinPath & item.MediaURL)
uc.SetBounds(uc.Location.X, uc.Location.Y, uc.Width, uc.Height, BoundsSpecified.All)
Thread.Sleep(1000)
d_content = d_content.AddSeconds(item.contentDuration)
Next
End If
d_bloc = d_bloc.AddSeconds(CType(vTimeline.Array_Bloc.Item(i), Bloc).BlocDuration)
Next
End If
End Sub
''' <summary>
''' chargement de de l'application
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub Media_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
theFile = File.Create(Application.StartupPath + "\log.txt")
writer = New StreamWriter(theFile)
Me.WindowState = FormWindowState.Maximized
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
PlayBlocWithContent()
End Sub
End Class |
Partager