private void OnClientChannelEnter(object sender, ClientEventArgs e) { if (e.clientName == User.strName) { string channelName = e.clientChannelName; addTab(new ChannelControl(channelName, e.clientChannelMsg), channelName, true); // User enter to channel and want a list of all users in clientSendToServer.SendToServer(Command.List, "ChannelUsers", channelName); } }
private void ProccesAndExecuteInputs(string login, string email) { if (login != string.Empty && new System.Net.NetworkCredential(string.Empty, SecurePassword).Password != string.Empty && new System.Net.NetworkCredential(string.Empty, SecurePasswordRepeart).Password != string.Empty && email != string.Empty) { Regex rgx = new Regex(@"^(?=[a-z])[-\w.]{0,23}([a-zA-Z\d])$"); bool loginRegex = rgx.IsMatch(login); if (login.Length < 5 && login.Length > 23) { MessageBox.Show("Your username must be between 5 and 23 chars", "Error validation", MessageBoxButton.OK, MessageBoxImage.Error); } else if (!loginRegex) { MessageBox.Show("Your username must contain only a-z or 0-9 extample michael123", "Error validation", MessageBoxButton.OK, MessageBoxImage.Error); } else if (SecurePassword.Length < 6 && SecurePasswordRepeart.Length < 6) { MessageBox.Show("Your password must be highter than 6 chars", "Error validation", MessageBoxButton.OK, MessageBoxImage.Error); } else if (new System.Net.NetworkCredential(string.Empty, SecurePassword).Password != new System.Net.NetworkCredential(string.Empty, SecurePasswordRepeart).Password) { MessageBox.Show("Password and Repeat Password are not the same", "Error validation", MessageBoxButton.OK, MessageBoxImage.Error); } else if (email.Length == 0) { MessageBox.Show("Enter an email.", "Error validation", MessageBoxButton.OK, MessageBoxImage.Error); } else if (!Regex.IsMatch(email, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { MessageBox.Show("Enter a valid email.", "Error validation", MessageBoxButton.OK, MessageBoxImage.Error); } else { App.Client.strName = login; clientSendToServer.SendToServer(Command.Registration, clientSendToServer.CalculateChecksum (new System.Net.NetworkCredential(string.Empty, SecurePassword).Password), email); if (!ReceivePackageFromServer.IsClientStartReceive) { ReceivePackageFromServer.BeginReceive(); } } } else { MessageBox.Show("Fill in the fields", "Error validation", MessageBoxButton.OK, MessageBoxImage.Information); } }
public void SendLoginAndEncryptPass(string UserName, SecureString password) { try { App.Client.strName = UserName; ClientSendToServer clientSendToServer = ClientSendToServer.Instance; clientSendToServer.SendToServer(Command.Login, clientSendToServer.CalculateChecksum(new System.Net.NetworkCredential(string.Empty, password).Password), (loginNotyfi ? "1" : null)); if (!ReceivePackageFromServer.IsClientStartReceive) { ReceivePackageFromServer.BeginReceive(); } } catch (Exception ex) { MessageBox.Show(string.Format("Unexpected error!{0}{1}", Environment.NewLine, ex.Message), "Error validation", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void SetHeader(UIElement header, string name, ref ObservableCollection <object> tabControlItems, bool channel = false) { tabControlName = name; isChannel = channel; // Container for header controls var dockPanel = new DockPanel(); dockPanel.Children.Add(header); tb = tabControlItems; if (isChannel) { getMessageFromServer.ClientKickFromChannel += OnClientKickFromChannel; getMessageFromServer.ClientDeleteChannel += OnClientDeleteChannel; getMessageFromServer.ClientBanFromChannel += OnClientBanFromChannel; getMessageFromServer.ClientChannelLeave += OnClientChannelLeave; } // Close button to remove the tab var closeButton = new TabCloseButton(); closeButton.Click += (sender, e) => { if (tabControlName != "Main") { tb.Remove(this); if (isChannel) { clientSendToServer.SendToServer(Command.leaveChannel, tabControlName); } } else { MessageBox.Show("Cannot close Main Tab!", "Gold Chat: " + App.Client.strName, MessageBoxButton.OK, MessageBoxImage.Error); } }; dockPanel.Children.Add(closeButton); // Set the header Header = dockPanel; }
private void SendFileInfo() { clientSendToServer.SendToServer(Command.sendFile, NameOfUserToSendFile, getFileLen().ToString(), parseDirIntoFileName()); }