(08-03-19, 09:44 PM)elgokr كتب : [ -> ]اخى حاتمي
نحن لا نقراء الغيب ولا ننظر باعينك
او نعلم بما تفكر
وضح بضبط ما المشكلة بضبط
لان على تخميني انك تقوم بتنفيذ نفس الكود بدون تغيير مع كل زر
وبالتالى يقوم بفتح نفس الصفحة بالمشروع فانت لا تكون على دراية انه فتح صفحة اخري
حاول تشرح ما تريد فعله تماماً
وما المشكلة التى تقف معك
تحياتى لك
وتمنياتى لك التوفيق
(08-03-19, 09:44 PM)elgokr كتب : [ -> ]اخى حاتمي
نحن لا نقراء الغيب ولا ننظر باعينك
او نعلم بما تفكر
وضح بضبط ما المشكلة بضبط
لان على تخميني انك تقوم بتنفيذ نفس الكود بدون تغيير مع كل زر
وبالتالى يقوم بفتح نفس الصفحة بالمشروع فانت لا تكون على دراية انه فتح صفحة اخري
حاول تشرح ما تريد فعله تماماً
وما المشكلة التى تقف معك
تحياتى لك
وتمنياتى لك التوفيق
كود :
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.CompilerServices
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Runtime.CompilerServices
Imports System.Text
Imports System.Threading
Imports System.Windows.Forms
Public Class Form1
Dim WithEvents Svr As TcpListener
Dim threadListen As Threading.Thread
Dim thrC As New List(Of Threading.Thread)
Dim enc As New System.Text.UTF8Encoding
Dim strHostName As String = System.Net.Dns.GetHostName
Dim originalItems As New List(Of ListViewItem)
Private channels_url As String
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
Try
Me.Svr.Stop()
Catch exception4 As Exception
End Try
Dim thread As Thread
For Each thread In Me.thrC
Try
If thread.IsAlive Then
thread.Abort()
End If
Catch exception5 As Exception
End Try
Next
End
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim localEP As New IPEndPoint(IPAddress.Parse("127.0.0.1"), 19762)
Me.Svr = New TcpListener(localEP)
Try
Me.Svr.Start()
Me.threadListen = New Thread(New ThreadStart(AddressOf Me.StartListen))
Me.threadListen.Start()
Catch exception1 As Exception
End Try
End Sub
Private Sub _Lambda(ByVal a0 As Object)
Me.requestHandler(DirectCast(a0, Object()))
End Sub
Private Sub requestHandler(ByVal param As Object())
Dim client As TcpClient = DirectCast(param(0), TcpClient)
Dim num As Integer = Conversions.ToInteger(param(1))
Dim num2 As Integer = 0
Dim bytes As Byte() = Me.enc.GetBytes("HTTP/1.1 404 Not Found" & ChrW(13) & ChrW(10) & "Refresh: 5; url=/" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "ERROR 404 Not Found.")
Try
Dim buffer As Byte() = New Byte((client.SendBufferSize + 1) - 1) {}
num2 = client.GetStream.Read(buffer, 0, buffer.Length)
Dim str As String = Me.enc.GetString(buffer)
If Not str.Contains("GET /") Then
GoTo Label_034A
End If
Dim num3 As Integer = 0
'Me.TextBox1.Text = str
If Strings.LCase(str).Contains("range: bytes=") Then
Dim str4 As String = Strings.LCase(str).Substring(Strings.LCase(str).IndexOf("range: bytes="))
str4 = str4.Substring(0, str4.IndexOf("-"))
num3 = Conversions.ToInteger(str4.Substring((str4.IndexOf("=") + 1)))
End If
str = str.Replace("GET /", "")
str = str.Substring(0, str.IndexOf(" "))
Try
Do While True
If str.Contains("%") Then
Dim str5 As String = str.Substring((str.IndexOf("%") + 1), 2)
Dim newValue As String = Conversions.ToString(Strings.ChrW(Convert.ToByte(str5, &H10)))
str = str.Replace(("%" & str5), newValue)
Else
GoTo Label_018A
End If
Loop
Catch ex As Exception
End Try
Label_018A:
If (str = "") Then
str = "P2.html"
End If
str = (Application.StartupPath & "\hatmi\" & str)
Dim info As New FileInfo(str)
Dim str2 As String = ""
Dim str3 As String = "HTTP/1.1 200 OK"
If (num3 > 0) Then
str2 = String.Concat(New String() {str2, "Content-Range: bytes ", Conversions.ToString(num3), "-", Conversions.ToString(CLng((info.Length - 1))), "/", Conversions.ToString(info.Length), ChrW(13) & ChrW(10)})
str3 = "HTTP/1.1 206 Partial Content"
End If
Dim buffer4 As Byte() = Me.enc.GetBytes(String.Concat(New String() {str3, ChrW(13) & ChrW(10), str2, "Server: MRI-Server=", My.Application.Info.Version.ToString, ChrW(13) & ChrW(10) & "Connection: Keep-Alive" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10)}))
client.GetStream.Write(buffer4, 0, buffer4.Length)
Dim input As New FileStream(info.FullName, FileMode.Open, FileAccess.Read) With { _
.Position = num3 _
}
Dim buffer3 As Byte() = New BinaryReader(input).ReadBytes(CInt(input.Length))
client.GetStream.Write(buffer3, 0, buffer3.Length)
GoTo Label_0396
Label_034A:
client.GetStream.Write(bytes, 0, bytes.Length)
Catch ex As Exception
If client.Connected Then
client.Close()
End If
End Try
Label_0396:
Try
If client.Connected Then
client.Close()
End If
If ((Not Me.thrC.Item(num) Is Nothing) AndAlso Me.thrC.Item(num).IsAlive) Then
Me.thrC.Item(num).Abort()
End If
Catch exception5 As Exception
End Try
End Sub
Private Sub StartListen()
Do While True
Try
Dim client As TcpClient = Me.Svr.AcceptTcpClient
Dim item As New Thread(New ParameterizedThreadStart(AddressOf Me._Lambda))
item.Start(New Object() {client, Me.thrC.Count})
Me.thrC.Add(item)
Catch exception1 As Exception
End Try
Loop
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
WebBrowser1.Navigate("P2.html")
Me.channels_url = "http://www.smoothhd.com/BigBuckBunny.xml"
Me.chan()
End Sub
Public Sub chan()
My.Computer.FileSystem.CopyFile(Application.StartupPath & "\hatmi\P2.html", Application.StartupPath & "\P2.html", True)
Dim txtFile As String = "P2.html"
Dim hamdane As String = "hatmi"
System.IO.File.WriteAllText(txtFile, System.IO.File.ReadAllText(txtFile).Replace(hamdane, Me.channels_url))
Me.WebBrowser1.Navigate("http://localhost:19762/P2.html")
End Sub
End Class