-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSendMessage.vb
177 lines (160 loc) · 6.5 KB
/
SendMessage.vb
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
' --------------------------------------------------------------------------
' Copyrights
'
' Portions created by or assigned to Cursive Systems, Inc. are
' Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact
' information for Cursive Systems, Inc. is available at
' http://www.cursive.net/.
'
' License
'
' Jabber-Net is licensed under the LGPL.
' See LICENSE.txt for details.
' --------------------------------------------------------------------------
Public Class SendMessage
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private m_jc As jabber.client.JabberClient
Public Sub New(ByRef jc As jabber.client.JabberClient)
MyBase.New()
m_jc = jc
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
Public Sub New(ByRef jc As jabber.client.JabberClient, ByVal toJid As String)
Me.New(jc)
txtTo.Text = toJid
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents btnSend As System.Windows.Forms.Button
Friend WithEvents txtSubject As System.Windows.Forms.TextBox
Friend WithEvents txtTo As System.Windows.Forms.TextBox
Friend WithEvents label2 As System.Windows.Forms.Label
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents txtBody As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.btnCancel = New System.Windows.Forms.Button()
Me.btnSend = New System.Windows.Forms.Button()
Me.txtSubject = New System.Windows.Forms.TextBox()
Me.txtTo = New System.Windows.Forms.TextBox()
Me.label2 = New System.Windows.Forms.Label()
Me.label1 = New System.Windows.Forms.Label()
Me.txtBody = New System.Windows.Forms.TextBox()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCancel, Me.btnSend, Me.txtSubject, Me.txtTo, Me.label2, Me.label1})
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(312, 72)
Me.Panel1.TabIndex = 0
'
'btnCancel
'
Me.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right)
Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnCancel.Location = New System.Drawing.Point(256, 41)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(48, 23)
Me.btnCancel.TabIndex = 11
Me.btnCancel.Text = "Cancel"
'
'btnSend
'
Me.btnSend.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right)
Me.btnSend.Location = New System.Drawing.Point(256, 9)
Me.btnSend.Name = "btnSend"
Me.btnSend.Size = New System.Drawing.Size(48, 23)
Me.btnSend.TabIndex = 10
Me.btnSend.Text = "Send"
'
'txtSubject
'
Me.txtSubject.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.txtSubject.Location = New System.Drawing.Point(64, 42)
Me.txtSubject.Name = "txtSubject"
Me.txtSubject.Size = New System.Drawing.Size(184, 20)
Me.txtSubject.TabIndex = 9
Me.txtSubject.Text = ""
'
'txtTo
'
Me.txtTo.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.txtTo.Location = New System.Drawing.Point(64, 10)
Me.txtTo.Name = "txtTo"
Me.txtTo.Size = New System.Drawing.Size(184, 20)
Me.txtTo.TabIndex = 7
Me.txtTo.Text = ""
'
'label2
'
Me.label2.Location = New System.Drawing.Point(8, 41)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(48, 23)
Me.label2.TabIndex = 8
Me.label2.Text = "Subject:"
'
'label1
'
Me.label1.Location = New System.Drawing.Point(8, 9)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(48, 23)
Me.label1.TabIndex = 6
Me.label1.Text = "To:"
'
'txtBody
'
Me.txtBody.Dock = System.Windows.Forms.DockStyle.Fill
Me.txtBody.Location = New System.Drawing.Point(0, 72)
Me.txtBody.Multiline = True
Me.txtBody.Name = "txtBody"
Me.txtBody.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtBody.Size = New System.Drawing.Size(312, 194)
Me.txtBody.TabIndex = 1
Me.txtBody.Text = ""
'
'SendMessage
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(312, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtBody, Me.Panel1})
Me.Name = "SendMessage"
Me.Text = "SendMessage"
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim msg As New jabber.protocol.client.Message(m_jc.Document)
msg.To = New jabber.JID(txtTo.Text)
If txtSubject.Text <> "" Then
msg.Subject = txtSubject.Text
End If
msg.Body = txtBody.Text
m_jc.Write(msg)
Me.Close()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
End Class