Messenger/MSGer.tk/AddPartner.cs

67 lines
2.5 KiB
C#
Raw Normal View History

2014-04-25 21:55:43 +00:00
using GlacialComponents.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
public partial class AddPartner : ThemedForms
2014-04-25 21:55:43 +00:00
{
public AddPartner()
{
InitializeComponent();
this.Text = Language.Translate("addcontact");
label1.Text = Language.Translate("addcontact");
label2.Text = Language.Translate("addcontact_nameemail");
searchbtn.Text = Language.Translate("addcontact_search");
glacialList1.Columns[0].Text = Language.Translate("username");
gobtn.Text = Language.Translate("addcontact_add");
2014-04-25 21:55:43 +00:00
}
List<UserInfo> FoundUsers = new List<UserInfo>();
2014-04-25 21:55:43 +00:00
private void searchbtn_Click(object sender, EventArgs e)
{
glacialList1.Items.Clear();
foreach (var tmp in UserInfo.KnownUsers)
{
if ((tmp.UserName.Contains(nameText.Text) || tmp.Name.Contains(nameText.Text) || tmp.UserID.ToString() == nameText.Text) && !FoundUsers.Contains(tmp))
{
glacialList1.Items.Add(tmp.UserName);
2014-04-25 21:55:43 +00:00
FoundUsers.Add(tmp);
}
2014-04-25 21:55:43 +00:00
}
}
private void glacialList1_Click(object sender, EventArgs e)
{
int item = glacialList1.HotItemIndex;
if (item >= glacialList1.Items.Count)
return;
//2014.04.18. - Partnerinformáció mutatása
//2014.08.16. - Megvalósítás
if (FoundUsers.Count < item)
(new PartnerInformation(FoundUsers[item])).ShowDialog();
2014-04-25 21:55:43 +00:00
}
private void gobtn_Click(object sender, EventArgs e)
{
if (glacialList1.SelectedItems.Count == 0 || FoundUsers.Count == 0)
2014-04-25 21:55:43 +00:00
return;
string username = ((GLItem)glacialList1.SelectedItems[0]).Text;
string response = Networking.SendRequest("adduser", username, 0, true);
if (response == "Success")
2014-04-25 21:55:43 +00:00
MessageBox.Show("Felhasználó felvéve az ismerőseid közé.");
else
MessageBox.Show("Nem sikerült felvenni a felhasználót az ismerőseid közé.\nLehet, hogy már felvetted, vagy valami hiba történt.\n(" + response + ")");
}
}
}