void ShowListOfConversation(int countConversation, string[] answer) { int beginIndex = 2; BottomPanelShow(); I = Human.Parse(answer, beginIndex); // if (answer.Length > 5) I.Avatar = answer[5]; scrollPanel = new ScrollPanel(); scrollPanel.Size = new Size(Width - scrollPanel.scrollPadding, Height - header.Height - bottomPanel.Height); scrollPanel.Location = new Point(0, header.Bottom + 1); Body.Controls.Add(scrollPanel); aLotOfDownloaded = true; beginIndex = 8; for (int i = 0; i < countConversation; i++) { Human currentFriend = new Human(); currentFriend = Human.Parse(answer, beginIndex); int numberOfUnread = int.Parse(answer[beginIndex + 6]); ShowConversationPanel(currentFriend); beginIndex += 7; } aLotOfDownloaded = false; scrollPanel.ContentAdded = false; ClientSocketHandler.BeginRecive(); }
private void LoginButton_Click(object sender, EventArgs e) { string login = loginTextBox.Text; string password = passwordTextBox.Text; ClientSocketHandler.SendToServer("Login " + login + " " + password); string[] answerFromServer; answerFromServer = ClientSocketHandler.WaitReciveFromServer().Split(); if (answerFromServer[0] == "Ok") { visibleErrorLogin = false; ClearBody(); ShowListOfConversation(int.Parse(answerFromServer[1]), answerFromServer); return; } else if (visibleErrorLogin) { return; } visibleErrorLogin = true; ShowErrorLogin(); }
private void AddButton_Click(object sender, EventArgs e) { Control control = (Control)sender; Human newFriend = (Human)control.Tag; AddFriend = newFriend; ClientSocketHandler.SendToServer("AddFriend " + newFriend.UserId); Close(); }
private void ScrollPanel_requestDownload(object sender, EventArgs e) { if (downloaded || endCommon) { return; } downloaded = true; countQuery++; ClientSocketHandler.SendToServer("Select " + countQuery); }
void OpenConversation(int number) { int id1 = I.UserId; int id2 = friend[number].UserId; if (id1 > id2) { int temp = id1; id1 = id2; id2 = temp; } ClientSocketHandler.SendToServer("Read " + id1 + " " + id2 + " 0"); }
private void ScrollPanel_requestDownload(object sender, EventArgs e) { if (downloaded || endCommon) { return; } downloaded = true; countQuery++; int id1 = (I.UserId < friend.UserId) ? I.UserId : friend.UserId; int id2 = (I.UserId < friend.UserId) ? friend.UserId : I.UserId; ClientSocketHandler.SendToServer("Read " + id1 + " " + id2 + " " + countQuery); }
private void TextBox_KeyDown(object sender, KeyEventArgs e) { TextBox textBox = (TextBox)sender; if (e.KeyCode == Keys.Enter) { if (e.Shift) { return; } string messageText = textBox.Text; textBox.Text = ""; ShowMessage(messageText, true, false); ClientSocketHandler.SendToServer("Message " + friend.UserId + " " + messageText); } }
private void CompleteButton_Click(object sender, EventArgs e) { string login = loginTextbox.Text; string password = passwordTextbox.Text; if (login.Contains(" ") || password.Contains(" ")) { loginTextbox.Text = ""; passwordTextbox.Text = ""; } if (loginTextbox.Text == "" || passwordTextbox.Text == "") { return; } ClientSocketHandler.SendToServer ("Regestration " + login + " " + password + " " + I.ToString()); string answer = ClientSocketHandler.WaitReciveFromServer(); string[] parametr = answer.Split(); if (parametr[0] == "Ok") { ClearBody(); I.UserId = int.Parse(parametr[1]); Sizes(); Body.Padding = new Padding(0); Body.BackColor = bodyColor; BottomPanelShow(); } else { loginTextbox.Text = ""; passwordTextbox.Text = ""; } }
public AddFriendScreen() { Color labelColor = Color.Gray; double ratio = 1 / 94.0; unit = Width * ratio; int padding = (int)(unit * 5); Width = (int)(Width * 2.9); Height = (int)(Height * 1.5); unit *= 1.5; leftPanel = new Panel(); leftPanel.BackColor = Color.White; leftPanel.Location = new Point(0, header.Bottom + padding); leftPanel.Size = new Size((int)(38.6 * padding), Height - header.Height - padding); Body.Controls.Add(leftPanel); Panel firstPanel = new Panel(); firstPanel.BackColor = Color.FromArgb(250, 251, 252); firstPanel.Size = new Size(leftPanel.Width, (int)(13.5 * unit)); leftPanel.Controls.Add(firstPanel); Label peopleLable = new Label(); peopleLable.Text = "Люди "; peopleLable.Font = new Font("Tahoma", 10, FontStyle.Bold); peopleLable.AutoSize = true; peopleLable.Location = new Point(padding, (int)(5 * unit)); firstPanel.Controls.Add(peopleLable); Label countLable = new Label(); countLable.Text = "100"; countLable.AutoSize = true; countLable.Font = new Font("Tahoma", 11); countLable.ForeColor = Color.FromArgb(147, 147, 147); countLable.Location = new Point(peopleLable.Right, peopleLable.Top); firstPanel.Controls.Add(countLable); BunifuSeparator firstLine = new BunifuSeparator(); firstLine.LineColor = lineColor; firstLine.Height = 1; firstLine.Location = new Point(0, firstPanel.Height - firstLine.Height); firstLine.Width = leftPanel.Width; firstPanel.Controls.Add(firstLine); Panel secondPanel = new Panel(); secondPanel.Size = new Size(leftPanel.Width, (int)(11.0 * unit)); secondPanel.Location = new Point(0, firstPanel.Bottom + 1); leftPanel.Controls.Add(secondPanel); PictureBox searchPicture = new PictureBox(); searchPicture.Image = Properties.Resources.search; searchPicture.SizeMode = PictureBoxSizeMode.StretchImage; searchPicture.Size = new Size ((int)(4.8 * unit), (int)(4.8 * unit)); int topImage = GetLeftPosition(searchPicture.Height, secondPanel.Height); searchPicture.Location = new Point(padding, topImage); secondPanel.Controls.Add(searchPicture); resetPicture = new PictureBox(); resetPicture.Visible = false; resetPicture.Image = Properties.Resources.reset; resetPicture.SizeMode = PictureBoxSizeMode.StretchImage; resetPicture.Size = new Size ((int)(3.5 * unit), (int)(3.5 * unit)); topImage = GetLeftPosition(resetPicture.Height, secondPanel.Height); resetPicture.Location = new Point (secondPanel.Width - resetPicture.Width - padding, topImage); resetPicture.MouseEnter += ResetPicture_MouseEnter; resetPicture.MouseLeave += ResetPicture_MouseLeave; resetPicture.Click += ResetPicture_Click; secondPanel.Controls.Add(resetPicture); textBox = new TextBox(); textBox.Font = chatFont; textBox.BorderStyle = BorderStyle.None; textBox.Size = new Size (secondPanel.Width - resetPicture.Width - searchPicture.Width - 4 * padding, secondPanel.Height); int textBoxTop = GetLeftPosition(textBox.Height, secondPanel.Height); textBox.Location = new Point(searchPicture.Right + padding, textBoxTop); textBox.TextChanged += TextBox_TextChanged; textBox.KeyPress += TextBox_KeyPress; shadowLabel = new Label(); shadowLabel.Text = "Начните вводить любое имя"; shadowLabel.Font = chatFont; shadowLabel.AutoSize = true; shadowLabel.Enabled = false; shadowLabel.Location = new Point(textBox.Left + 1, textBox.Top); secondPanel.Controls.Add(shadowLabel); secondPanel.Controls.Add(textBox); BunifuSeparator secondLine = new BunifuSeparator(); secondLine.LineColor = lineColor; secondLine.Height = 1; secondLine.Location = new Point(0, secondPanel.Height - secondLine.Height); secondLine.Width = leftPanel.Width; secondPanel.Controls.Add(secondLine); scrollPanel = new ScrollPanel(); scrollPanel.Size = new Size(leftPanel.Width - scrollPanel.scrollPadding, leftPanel.Height - secondPanel.Bottom); scrollPanel.Location = new Point(0, secondPanel.Bottom + 1); scrollPanel.requestDownload += ScrollPanel_requestDownload; leftPanel.Controls.Add(scrollPanel); Panel rightPanel = new Panel(); rightPanel.BackColor = Color.White; rightPanel.Location = new Point(leftPanel.Right + padding, leftPanel.Top); rightPanel.Size = new Size(Width - rightPanel.Left, leftPanel.Height); Body.Controls.Add(rightPanel); int topBegin = (int)(rightPanel.Height / 5.0); BunifuSeparator topLine = new BunifuSeparator(); topLine.LineColor = lineColor; topLine.Location = new Point(padding, topBegin); topLine.Width = rightPanel.Width - 2 * padding; rightPanel.Controls.Add(topLine); Label ageLabel = new Label(); ageLabel.Text = "Возраст"; ageLabel.Font = boldChatFont; ageLabel.AutoSize = true; ageLabel.ForeColor = labelColor; int bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; ageLabel.Location = new Point(padding, bottomLastControl); rightPanel.Controls.Add(ageLabel); int dropWidth = (int)(rightPanel.Width / 2.5); fromAgeDrop = new ComboBox(); fromAgeDrop.DropDownStyle = ComboBoxStyle.DropDown; fromAgeDrop.Width = dropWidth; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; fromAgeDrop.Location = new Point(padding, bottomLastControl + padding); DropDownComplete(fromAgeDrop, "От", 14, 80); fromAgeDrop.SelectedIndexChanged += FromAgeDrop_SelectedIndexChanged; rightPanel.Controls.Add(fromAgeDrop); Label separatorLabel = new Label(); separatorLabel.Text = "-"; separatorLabel.Font = boldChatFont; separatorLabel.AutoSize = true; separatorLabel.Location = new Point (fromAgeDrop.Right + 1, fromAgeDrop.Top); rightPanel.Controls.Add(separatorLabel); toAgeDrop = new ComboBox(); toAgeDrop.Width = dropWidth; toAgeDrop.DropDownStyle = ComboBoxStyle.DropDown; toAgeDrop.Location = new Point (separatorLabel.Right + 1, fromAgeDrop.Top); DropDownComplete(toAgeDrop, "До", 14, 80); toAgeDrop.SelectedIndexChanged += ToAgeDrop_SelectedIndexChanged; rightPanel.Controls.Add(toAgeDrop); Label genderLabel = new Label(); genderLabel.Text = "Пол"; genderLabel.Font = boldChatFont; genderLabel.AutoSize = true; genderLabel.ForeColor = labelColor; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; rightPanel.Controls.Add(genderLabel); genderLabel.Location = new Point(padding, bottomLastControl + toAgeDrop.Margin.Bottom + padding); genderLabel.Margin = new Padding(3); RadioButton female = new RadioButton(); female.Font = chatFont; female.Text = "Женский"; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; female.Location = new Point(padding, bottomLastControl + padding); rightPanel.Controls.Add(female); RadioButton male = new RadioButton(); male.Font = chatFont; male.Text = "Мужской"; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; male.Location = new Point(padding, bottomLastControl); rightPanel.Controls.Add(male); RadioButton any = new RadioButton(); any.Font = chatFont; any.Text = "Любой"; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; any.Location = new Point(padding, bottomLastControl); rightPanel.Controls.Add(any); BunifuSeparator middleLine = new BunifuSeparator(); middleLine.LineColor = lineColor; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; middleLine.Location = new Point(padding, bottomLastControl); middleLine.Width = rightPanel.Width - 2 * padding; rightPanel.Controls.Add(middleLine); CheckBox fotoCheckBox = new CheckBox(); fotoCheckBox.Text = "с фотографией"; fotoCheckBox.Font = chatFont; fotoCheckBox.AutoSize = true; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; fotoCheckBox.Location = new Point(padding, bottomLastControl); rightPanel.Controls.Add(fotoCheckBox); CheckBox onlineCheckBox = new CheckBox(); onlineCheckBox.Text = "сейчас на сайте"; onlineCheckBox.Font = chatFont; onlineCheckBox.AutoSize = true; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; onlineCheckBox.Location = new Point(padding, bottomLastControl + padding); rightPanel.Controls.Add(onlineCheckBox); BunifuSeparator bottomLine = new BunifuSeparator(); bottomLine.LineColor = lineColor; bottomLastControl = rightPanel.Controls[rightPanel.Controls.Count - 1].Bottom; bottomLine.Location = new Point(padding, bottomLastControl); bottomLine.Width = rightPanel.Width - 2 * padding; rightPanel.Controls.Add(bottomLine); ClientSocketHandler.SendToServer("Select 0"); }