private void OnGetFormButtonClick(object sender, EventArgs e) { if (CheckData()) { FormRequestInfo info = null; if (!Public) { info = new FormRequestInfo() { CompilationRequestId = Int32.Parse(id.Text), Username = username.Text, Service = service.SelectedItem.ToString(), Token = token.Text }; } else { info = new FormRequestInfo() { CompilationRequestId = Int32.Parse(id.Text), Username = null, Service = null, Token = null }; } if (DataSubmitted != null) { connecting = true; DataSubmitted(this, new FormAccessEventArgs(info)); } } }
/// <summary> /// Show the notification on the screen /// </summary> /// <param name="info">the <see cref="FormInfo"/> object that contein information about the form</param> public void ShowNotification(FormRequestInfo info) { this.formInfo = info; name.Text = info.CompilationRequestId.ToString(); notified.Text = info.Time.ToString(ResourceManager.Instance.Culture); from.Text = info.From; fromPanel.Height = Math.Max(StringMeasure.Measure(from, info.From == null? "" : info.From, from.Bounds).Height, fromLabel.Height); if (info.Username == null || info.Username == "") { type.Text = "Public"; usernamePanel.Hide(); servicePanel.Hide(); tokenPanel.Hide(); contentPanel.Height = 146; } else { type.Text = "Private"; username.Text = info.Username; usernamePanel.Show(); service.Text = info.Service; servicePanel.Show(); token.Text = info.Token; tokenPanel.Show(); contentPanel.Height = 212; } }
private void WaitForMessages() { while (true) { TcpClient tcpClient = null; NetworkStream stream = null; try { FormRequestInfo info = null; if (tcpListener.Pending()) { tcpClient = tcpListener.AcceptTcpClient(); byte[] bytes = new byte[1024]; stream = tcpClient.GetStream(); stream.Read(bytes, 0, bytes.Length); String message = Encoding.UTF8.GetString(bytes, 0, bytes.Length); Debug.WriteLine("LISTENER: Receiver message received " + message); using (StringReader reader = new StringReader(message)) info = serializer.Deserialize(reader) as FormRequestInfo; if (info != null && NotificationReceived != null) { NotificationReceived(this, new NotificationReceivedEventArgs(info)); } stream.Close(); tcpClient.Close(); } Thread.Sleep(1000); } catch (Exception exc) { if (stream != null) { stream.Close(); } if (tcpClient != null) { tcpClient.Close(); } } } }
/// <summary> /// Provides informations about the form selected /// </summary> /// <param name="action"></param> /// <param name="info"></param> public FormSelectionEventArgs(FormAction action, FormRequestInfo info) : base() { this.Action = action; this.RequestInfo = info; }
public NotificationReceivedEventArgs(FormRequestInfo info) { RequestInfo = info; }
/// <summary> /// This class contains informations about the form requested /// </summary> /// <param name="info"></param> public FormAccessEventArgs(FormRequestInfo info) : base() { this.RequestInfo = info; }
public NotificationEventArgs(FormAction action, FormRequestInfo info) : base() { this.Action = action; this.Info = info; }