All pastes #547713 Raw Edit

Untitled

public python v1 · immutable
·published 2007-06-07 13:54 UTC
rendered paste body
# This is actually Boo code.namespace OpenVPNSocketGUIimport Systemimport System.Collectionsimport System.Drawingimport System.Windows.Formsimport System.Netimport System.Net.Socketsinterface VpnStateWatcher:	def VpnStateChange(new_text as string)class VpnState:	[property(State)]	_state_text as string	_watchers as List		_tcpclient as TcpClient	_tcpclient_stream as NetworkStream		def constructor():		self._tcpclient = null		self._tcpclient_stream = null		self._watchers = []	def AddWatcher(watcher as VpnStateWatcher):		self._watchers.Add(watcher)	private def _inform_watchers():		for watcher as VpnStateWatcher in self._watchers:			watcher.VpnStateChange(self._state_text)	def connect(host as string, port as int):		try:			self._tcpclient = TcpClient(host, port)			self._tcpclient_stream = self._tcpclient.GetStream()		except e as System.Net.Sockets.SocketException:			self._tcpclient = null			self._tcpclient_stream = null			self._state_text = "Connection error (${e.Message})"			self._inform_watchers()partial class MainForm(VpnStateWatcher):	vpn_model as VpnState	def constructor():		vpn_model = VpnState()		vpn_model.AddWatcher(self)		// The InitializeComponent() call is required for Windows Forms designer support.		InitializeComponent()			def VpnStateChange(new_text as string):		self.toolStripStatusLabel.Text = new_text		private def MainFormLoad(sender as object, e as System.EventArgs):		pass		private def Button_refreshClick(sender as object, e as System.EventArgs):		vpn_model.connect('127.0.0.1', int.Parse(self.textBox_port.Text))		// TODO: Add constructor code after the InitializeComponent() call.[STAThread]def Main(argv as (string)):	Application.EnableVisualStyles()	Application.SetCompatibleTextRenderingDefault(false)	Application.Run(MainForm())