1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
namespace MyProg
{
public partial class MainPage : UserControl
{
test.MainSoapClient proxy = new test.MainSoapClient();
test.MainSoapClient friend_connect = new test.MainSoapClient();
string guid;
public MainPage()
{
InitializeComponent();
}
private void ButtonLogin_Click(object sender, RoutedEventArgs e)
{
test.ArrayOfString login_request_tab = new test.ArrayOfString();
login_request_tab.Add(IDcontent.Text);
login_request_tab.Add(PWcontent.Text);
proxy.USER_FunctionsCompleted += new EventHandler<test.USER_FunctionsCompletedEventArgs>(proxy_USER_FunctionsCompleted);
proxy.USER_FunctionsAsync("USER_LOGIN", login_request_tab);
}
void proxy_USER_FunctionsCompleted(object sender, test.USER_FunctionsCompletedEventArgs e)
{
test.ArrayOfString login_response = new test.ArrayOfString();
login_response = (test.ArrayOfString)e.Result;
if (login_response[0] == "1")
{
WelcomeText.Text = "Welcome " + IDcontent.Text;
WelcomeText.Visibility = Visibility.Visible;
LoginField.Visibility = Visibility.Collapsed;
ButtonDisconnect.Visibility = Visibility.Visible;
InterfaceGrid.Visibility = Visibility.Visible;
guid = login_response[1];
Initiate_user_profile();
}
}
void Initiate_user_profile()
{
test.ArrayOfString request_tab_guid = new test.ArrayOfString();
request_tab_guid.Add(guid);
proxy.USER_FunctionsCompleted += new EventHandler<test.USER_FunctionsCompletedEventArgs>(Get_user_infos);
proxy.USER_FunctionsAsync("USER_GETINFO", request_tab_guid);
KeepAlive();
}
void Get_user_infos(object sender, test.USER_FunctionsCompletedEventArgs e)
{
test.ArrayOfString user_profile = new test.ArrayOfString();
user_profile = e.Result;
MyName.Text = user_profile[2];
MyEmail.Text = user_profile[3];
MyMessage.Text = user_profile[6];
}
void KeepAlive()
{
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 2);
timer.Tick += new EventHandler(WS_refreshloop);
timer.Start();
}
void WS_refreshloop(object sender, EventArgs e)
{
test.ArrayOfString request_tab_friend = new test.ArrayOfString();
request_tab_friend.Add(guid);
friend_connect.USER_FunctionsCompleted += new EventHandler<test.USER_FunctionsCompletedEventArgs>(Get_friend_list);
friend_connect.USER_FunctionsAsync("USER_GETFRIENDS", request_tab_friend);
}
void Get_friend_list(object sender, test.USER_FunctionsCompletedEventArgs e)
{
test.ArrayOfString friend_list_response = new test.ArrayOfString();
List<Friends> friend = new List<Friends>();
friend_list_response = (test.ArrayOfString)e.Result;
friend.Add(new Friends() { Friend_guid = friend_list_response[1], Name = friend_list_response[2], Message = friend_list_response[3] });
friend.Add(new Friends() { Friend_guid = friend_list_response[4], Name = friend_list_response[5], Message = friend_list_response[6] });
ContactList.ItemsSource = friend;
} |
Partager