File: MyProgressDialog.vb

package info (click to toggle)
mono-basic 2.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 18,852 kB
  • ctags: 809
  • sloc: cs: 8,852; makefile: 516; sh: 307
file content (142 lines) | stat: -rw-r--r-- 6,332 bytes parent folder | download
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
'
' MyProgressDialog.vb
'
' Authors:
'   Rolf Bjarne Kvinge (RKvinge@novell.com>
'
' Copyright (C) 2007 Novell (http://www.novell.com)
'
' Permission is hereby granted, free of charge, to any person obtaining
' a copy of this software and associated documentation files (the
' "Software"), to deal in the Software without restriction, including
' without limitation the rights to use, copy, modify, merge, publish,
' distribute, sublicense, and/or sell copies of the Software, and to
' permit persons to whom the Software is furnished to do so, subject to
' the following conditions:
' 
' The above copyright notice and this permission notice shall be
' included in all copies or substantial portions of the Software.
' 
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
' EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
' MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
' NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
' LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
' OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'
#If NET_VER >= 2.0 Then
#If TARGET_JVM = False Then 'Windows.Forms Not Supported by Grasshopper

Imports System.Net

Namespace Microsoft.VisualBasic.Devices
    Friend Class MyProgressDialog
        Inherits System.Windows.Forms.Form

        Private WithEvents m_Client As Net.WebClient

        Sub New(ByVal Client As Net.WebClient, ByVal Status As String)
            m_Client = Client
            lblStatus.Text = Status
        End Sub

        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
            MyBase.Dispose(disposing)
        End Sub

        Friend WithEvents cmdCancel As System.Windows.Forms.Button
        Friend WithEvents barProgress As System.Windows.Forms.ProgressBar
        Friend WithEvents lblStatus As System.Windows.Forms.Label

        Private components As System.ComponentModel.IContainer

        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.cmdCancel = New System.Windows.Forms.Button
            Me.barProgress = New System.Windows.Forms.ProgressBar
            Me.lblStatus = New System.Windows.Forms.Label
            Me.SuspendLayout()
            '
            'cmdCancel
            '
            Me.cmdCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.cmdCancel.Location = New System.Drawing.Point(290, 118)
            Me.cmdCancel.Name = "cmdCancel"
            Me.cmdCancel.Size = New System.Drawing.Size(75, 23)
            Me.cmdCancel.TabIndex = 0
            Me.cmdCancel.Text = "Button1"
            Me.cmdCancel.UseVisualStyleBackColor = True
            '
            'barProgress
            '
            Me.barProgress.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
                        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.barProgress.Location = New System.Drawing.Point(12, 92)
            Me.barProgress.Name = "barProgress"
            Me.barProgress.Size = New System.Drawing.Size(353, 20)
            Me.barProgress.TabIndex = 1
            '
            'lblStatus
            '
            Me.lblStatus.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                        Or System.Windows.Forms.AnchorStyles.Left) _
                        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.lblStatus.Location = New System.Drawing.Point(12, 9)
            Me.lblStatus.Name = "lblStatus"
            Me.lblStatus.Size = New System.Drawing.Size(353, 80)
            Me.lblStatus.TabIndex = 2
            Me.lblStatus.Text = "Label1"
            '
            'NetworkProgressDialog
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.CancelButton = Me.cmdCancel
            Me.ClientSize = New System.Drawing.Size(377, 153)
            Me.Controls.Add(Me.lblStatus)
            Me.Controls.Add(Me.barProgress)
            Me.Controls.Add(Me.cmdCancel)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
            Me.MaximizeBox = False
            Me.MinimizeBox = False
            Me.Name = "NetworkProgressDialog"
            Me.ShowInTaskbar = False
            Me.Text = "Working..."
            Me.ResumeLayout(False)

        End Sub

        Private Sub m_Client_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles m_Client.DownloadFileCompleted
            barProgress.Value = 100
            Me.DialogResult = Windows.Forms.DialogResult.OK
            Close()
        End Sub

        Private Sub m_Client_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles m_Client.DownloadProgressChanged
            barProgress.Value = e.ProgressPercentage
        End Sub

        Private Sub m_Client_UploadFileCompleted(ByVal sender As Object, ByVal e As System.Net.UploadFileCompletedEventArgs) Handles m_Client.UploadFileCompleted
            barProgress.Value = 100
            Me.DialogResult = Windows.Forms.DialogResult.OK
            Close()
        End Sub

        Private Sub m_Client_UploadProgressChanged(ByVal sender As Object, ByVal e As System.Net.UploadProgressChangedEventArgs) Handles m_Client.UploadProgressChanged
            barProgress.Value = e.ProgressPercentage
        End Sub

        Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
            m_Client.CancelAsync()
            Me.DialogResult = Windows.Forms.DialogResult.Cancel
            Close()
        End Sub
    End Class
End Namespace
#End If
#End If