Mini Kabibi Habibi
Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.Utils
Imports DevExpress.XtraNavBar
Imports DevExpress.DXperience.Demos
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports WinRTLiveTiles = DevExpress.XtraBars.WinRTLiveTiles
Namespace DevExpress.WinRTLiveTileManager.Demos
Partial Public Class frmMain
Inherits DevExpress.DXperience.Demos.RibbonMainForm
Public Shared startupModuleName As String
Private Shared firstStart As Boolean = True
Public Sub New()
MyBase.New()
navBarControl1.SmallImages = Nothing
End Sub
#Region "Properties"
Protected Overrides ReadOnly Property DemoName() As String
Get
Return "WinRTLiveTileManager Features Demo (C# code)"
End Get
End Property
#End Region
Protected Overrides Sub SetFormParam()
Me.MinimumSize = New System.Drawing.Size(600, 500)
Me.navBarControl1.Parent.Width = 176
Me.navBarControl1.AllowDrop = False
Me.Icon = ResourceImageHelper.CreateIconFromResources("DevExpress.WinRTLiveTileManager.Demos.WinRTLiveTileManagerMainDemo.ico", GetType(frmMain).Assembly)
End Sub
Protected Overrides Function CreateRibbonMenuManager() As RibbonMenuManager
Return New WinRTLiveTileManagerMenuManager(Me)
End Function
Protected Overrides Sub ShowModule(ByVal name As String, ByVal group As DevExpress.XtraEditors.GroupControl, ByVal lookAndFeel As DevExpress.LookAndFeel.DefaultLookAndFeel, ByVal caption As DevExpress.Utils.Frames.ApplicationCaption)
If (Not String.IsNullOrEmpty(startupModuleName)) Then
DemosInfo.ShowModule(startupModuleName, group, caption, TryCast(RibbonMenuManager, WinRTLiveTileManagerMenuManager))
startupModuleName = Nothing
Else
DemosInfo.ShowModule(name, group, caption, TryCast(RibbonMenuManager, WinRTLiveTileManagerMenuManager))
End If
If firstStart Then
Dim managerList As New List(Of WinRTLiveTiles.WinRTLiveTileManager)()
managerList = ModuleCreator.CreateModules()
firstStart = False
End If
End Sub
Protected Overrides Sub FillNavBar()
DemosInfo.FillNavBar(navBarControl1, DevExpress.XtraNavBar.NavBarGroupStyle.LargeIconsText, True, NavBarImage.Small)
End Sub
Protected Overrides Sub ShowAbout()
DevExpress.Utils.About.AboutForm.Show(GetType(WinRTLiveTiles.WinRTLiveTileManager), DevExpress.Utils.About.ProductKind.DXperienceWin, DevExpress.Utils.About.ProductInfoStage.Registered)
End Sub
Private Const strHasPinnedTiles As String = "Do you want to unpin demo live tiles from the Start screen?"
Protected Overrides Sub OnClosed(ByVal e As EventArgs)
Dim managerList As New List(Of WinRTLiveTiles.WinRTLiveTileManager)()
managerList = ModuleCreator.ManagerList
If (Not ModuleCreator.CheckTilesUnpinned(managerList)) Then
If MessageBox.Show(strHasPinnedTiles, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.Yes Then
For Each manager As WinRTLiveTiles.WinRTLiveTileManager In managerList
manager.RemoveTile()
Next manager
End If
End If
MyBase.OnClosed(e)
End Sub
End Class
Public Class ModuleCreator
Private Shared managerList_Renamed As New List(Of WinRTLiveTiles.WinRTLiveTileManager)()
Public Sub New()
End Sub
Public Shared ReadOnly Property ManagerList() As List(Of WinRTLiveTiles.WinRTLiveTileManager)
Get
Return managerList_Renamed
End Get
End Property
Public Shared Function CreateModules() As List(Of WinRTLiveTiles.WinRTLiveTileManager)
If DemosInfo.Count <= 0 Then
Return Nothing
End If
For i As Integer = 0 To DemosInfo.Count - 1
Dim item As ModuleInfo = DemosInfo.GetItem(i)
Dim v = item.TModule
Dim moduleInterface As ITileManagerContainer = TryCast(v, ITileManagerContainer)
If moduleInterface IsNot Nothing Then
managerList_Renamed.AddRange(moduleInterface.GetModuleTileManagers())
End If
Next i
Return managerList_Renamed
End Function
Public Shared Function CheckTilesUnpinned(ByVal managersList As List(Of WinRTLiveTiles.WinRTLiveTileManager)) As Boolean
If managersList.Count = 0 Then
Return True
End If
For Each manager As WinRTLiveTiles.WinRTLiveTileManager In managersList
If manager.HasPinnedTile Then
Return False
End If
Next manager
Return True
End Function
Private Const strTileNotPinned As String = "A Live Tile for the {0} has not been created within the Windows Start Screen. Click Yes to run the Live Tile Manager and click the Pin button for the {0} item. " & Constants.vbLf & " " & Constants.vbLf & "Do you want to run the Live Tile Manager and add a live tile to the Start Screen?"
Public Shared Function CheckTilePinnedBeforeUpdate(ByVal manager As WinRTLiveTiles.WinRTLiveTileManager) As Boolean
If manager Is Nothing Then
Return True
End If
If (Not manager.HasPinnedTile) Then
If MessageBox.Show(String.Format(strTileNotPinned, manager.ApplicationName), "Add Live Tile", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = System.Windows.Forms.DialogResult.Yes Then
If WinRTLiveTiles.WinRTLiveTileManager.CheckWinRTAppInstalled() Then
manager.ShowLiveTileManager()
Else
WinRTLiveTiles.WinRTAppInstallHelperWindow.Show(False)
Return False
End If
End If
Return False
Else
Return True
End If
End Function
End Class
End Namespace