LzmTW.uSystem.uWindows.uForms + ProgressFormHelper

Author:水如烟  

Namespace  LzmTW.uSystem.uWindows.uForms
    
Public   Class  ProgressFormHelper
        
Private   Sub   New ()
        
End Sub

        
Private   Shared  gForm  As  ProgressForm
        
Private   Shared  gInternalSyncObject  As   Object
        
Private   Shared  gIsShowing  As   Boolean   =   False

        
Private   Shared   ReadOnly   Property  InternalSyncObject()  As   Object
            
Get
                
If  gInternalSyncObject  Is   Nothing   Then
                    
Dim  tmpObj  As   New   Object
                    System.Threading.Interlocked.CompareExchange(gInternalSyncObject, tmpObj, 
Nothing )
                
End   If
                
Return  gInternalSyncObject
            
End   Get
        
End Property

        
Private   Shared   Function  CreateInstance()  As  ProgressForm
            
SyncLock  InternalSyncObject
                
If  gForm  Is   Nothing   OrElse  gForm.IsDisposed  Then
                    gForm 
=   New  ProgressForm
                
End   If
            
End   SyncLock

            
Return  gForm
        
End Function

        
Public   Shared   Sub  Show( ByVal  style  As  ProgressFormStyle)
            CreateInstance()
            gForm.Show(style)

            gIsShowing 
=   True
        
End Sub

        
Public   Shared   Sub  Show( ByVal  action  As  Threading.ThreadStart,  ByVal  style  As  ProgressFormStyle)
            CreateInstance()
            gForm.Show(action, style)

            gIsShowing 
=   True
        
End Sub

        
Public   Shared   Sub  Show( ByVal  action  As  Threading.ThreadStart,  ByVal  ctr  As   Object ByVal  style  As  ProgressFormStyle)
            CreateInstance()
            gForm.Show(action, ctr, style)

            gIsShowing 
=   True
        
End Sub

        
Public   Shared   Sub  Show( ByVal  action  As  Threading.ThreadStart,  ByVal  ctr  As   Object ByVal  actionInstance  As   Object ByVal  style  As  ProgressFormStyle)
            CreateInstance()
            gForm.Show(action, ctr, actionInstance, style)

            gIsShowing 
=   True
        
End Sub

        
Public   Shared   Sub  Close()
            
If  gForm  IsNot   Nothing   AndAlso   Not  gForm.IsDisposed  Then
                gForm.Close()
                gIsShowing 
=   False
            
End   If
        
End Sub

        
Public   Shared   Sub  SendMessage( ByVal  s  As   String )
            
If  gIsShowing  Then  uThreading.CrossThread.SetControlPropertyValue(gForm.MessageLabel,  " Text " , s,  Nothing )
        
End Sub

        
Public   Shared   Sub  SendMessage( ByVal   format   As   String ByVal  args()  As   Object )
            SendMessage(uString.Format(
format , args))
        
End Sub

        
Public   Shared   Sub  SetText( ByVal  s  As   String )
            
If  gIsShowing  Then  uThreading.CrossThread.SetControlPropertyValue(gForm,  " Text " , s,  Nothing )
        
End Sub

        
Public   Shared   Sub  SetText( ByVal   format   As   String ByVal  args()  As   Object )
            SetText(uString.Format(
format , args))
        
End Sub

    
End Class


    
Public   Enum  ProgressFormStyle
        OnlyMessage
        ProgressWithCancel
        ProgressWithNoCancel
    
End Enum

    
Friend   Enum  ProgressFormActionResult
        Finish
        Cancel
    
End Enum
End Namespace

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值