Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/VB/VideoPortal/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/VB/VideoPortal/Default.aspx.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Collections
Imports DevExpress.Web.ASPxDataView
Imports DevExpress.Web.ASPxClasses
Imports System.Threading

Partial Public Class _Default
	Inherits System.Web.UI.Page
	Private Const TagNameRouteValueKey As String = "tagName", WatchVideoTitleRouteValueKey As String = "watchVideoTitle", StatisticsVideoTitleRouteValueKey As String = "statisticsVideoTitle", NavigationViewControlPath As String = "~/Controls/NavigationView.ascx", VideoViewControlPath As String = "~/Controls/VideoView.ascx", StatisticsViewControlPath As String = "~/Controls/StatisticsView.ascx"

	Protected ReadOnly Property TagName() As String
		Get
			Return GetRouteDataValue(TagNameRouteValueKey)
		End Get
	End Property

	Protected ReadOnly Property WatchVideoTitle() As String
		Get
			Return GetRouteDataValue(WatchVideoTitleRouteValueKey)
		End Get
	End Property

	Protected ReadOnly Property StatisticsVideoTitle() As String
		Get
			Return GetRouteDataValue(StatisticsVideoTitleRouteValueKey)
		End Get
	End Property

	Protected Function GetRouteDataValue(ByVal key As String) As String
		If RouteData.Values(key) IsNot Nothing Then
			Return Server.UrlDecode(RouteData.Values(key).ToString())
		Else
			Return String.Empty
		End If
	End Function

	Protected Sub ShowVideoTabs(ByVal videoTitle As String)
		Dim encodedTitle = Server.UrlEncode(videoTitle)
		tcVideo.Tabs.FindByName("Video").NavigateUrl = "~/Watch/" & encodedTitle
		tcVideo.Tabs.FindByName("Statistics").NavigateUrl = "~/Statistics/" & encodedTitle
		tcVideo.Visible = True
	End Sub

	Protected Sub InitializeNavigationView()
		Dim navigationView = TryCast(LoadControl(NavigationViewControlPath), NavigationView)
		navigationView.TagName = TagName
		viewPlaceholder.Controls.Add(navigationView)
		tcVideo.Visible = False
	End Sub

	Protected Sub InitializeVideoView()
		Dim videoViewControl = TryCast(LoadControl(VideoViewControlPath), VideoView)
		videoViewControl.VideoTitle = WatchVideoTitle
		viewPlaceholder.Controls.Add(videoViewControl)
		ShowVideoTabs(WatchVideoTitle)
		tcVideo.ActiveTab = tcVideo.Tabs.FindByName("Video")
	End Sub

	Protected Sub InitializeStatisticsView()
		Dim statisticsView = TryCast(LoadControl(StatisticsViewControlPath), StatisticsView)
		statisticsView.VideoTitle = StatisticsVideoTitle
		viewPlaceholder.Controls.Add(statisticsView)
		ShowVideoTabs(StatisticsVideoTitle)
		tcVideo.ActiveTab = tcVideo.Tabs.FindByName("Statistics")
	End Sub

	Protected Overrides Sub OnInit(ByVal e As EventArgs)
		If (Not String.IsNullOrEmpty(WatchVideoTitle)) Then
			InitializeVideoView()
		ElseIf (Not String.IsNullOrEmpty(StatisticsVideoTitle)) Then
			InitializeStatisticsView()
		Else
			InitializeNavigationView()
		End If
		MyBase.OnInit(e)
	End Sub
End Class