// Constructor public MainPage() { InitializeComponent(); BuildApplicationBars(); // Set the data context of the listbox control to the sample data DataContext = App.ViewModel; this.Loaded += new RoutedEventHandler(MainPage_Loaded); WebRequestsBuilder.GetFriendsResponseReceived += new WebRequestsBuilder.GetFriendsResponseEventsHandler(WebRequestsBuilder_GetFriendsResponseReceived); WebRequestsBuilder.GetContactsResponseReceived += new WebRequestsBuilder.GetContactsResponseEventsHandler(WebRequestsBuilder_GetContactsResponseReceived); WebRequestsBuilder.UserOnlineStateResponseReceived += new WebRequestsBuilder.UserOnlineStateResponseEventsHandler(WebRequestsBuilder_UserOnlineStateReceived); WebRequestsBuilder.GetMessageResponseReceived += new WebRequestsBuilder.GetMessageResponseEventsHandler(WebRequestsBuilder_GetMessageReceived); WebRequestsBuilder.GetMessagesResponseReceived += new WebRequestsBuilder.GetMessagesResponseEventsHandler(WebRequestsBuilder_GetMessagesResponseReceived); WebRequestsBuilder.GetFlagsResetResponseReceived += new WebRequestsBuilder.GetFlagsResetResponseEventsHandler(WebRequestsBuilder_GetFlagsResetReceived); WebRequestsBuilder.GetUsersReceived += new WebRequestsBuilder.GetUsersEventsHandler(WebRequestsBuilder_GetUsersReceived); apiMethodRequest = new WebRequestsBuilder(); //apiMethodRequest.SendRequest(Authorization.AccessToken, "friends.get", new Dictionary<string, string> { { "uid", "" }, { "fields", "uid, first_name, last_name, photo" }, { "order", "hints" } }); apiMethodRequest.SendRequest(Authorization.AccessToken, "messages.getLongPollServer", new Dictionary<string, string> { }); apiMethodRequest.SendRequest(Authorization.AccessToken, "execute", new Dictionary<string, string> { { "code", "var a=API.messages.getDialogs();var b=API.users.get({\"uids\":[email protected]%[email protected]_active, \"fields\":\"uid, first_name, last_name, photo, online\"}); return {\"messages\":a, \"uids\":b};" } }); //apiMethodRequest.SendRequest(Authorization.AccessToken, "account.setOnline", new Dictionary<string, string> { }); if (!IsolatedStorageSettings.ApplicationSettings.Contains("ContactsIsSynced")) ContactsFirstRunStackPanel.Visibility = System.Windows.Visibility.Visible; else { ContactsFirstRunStackPanel.Visibility = System.Windows.Visibility.Collapsed; //BackgroundWorker worker = new BackgroundWorker(); //worker.DoWork += (ob, ex) => { ex.Result = new ContactsListBuilder().LoadData(new List<VkResponseData>()); }; //worker.RunWorkerCompleted += (obc, exc) => { ContactsLongListSelector.ItemsSource = exc.Result as List<Group<ContactsItemViewModel>>; }; //worker.RunWorkerAsync(); ContactsLongListSelector.ItemsSource = new ContactsListBuilder().LoadData(new List<VkResponseData>()); } if (IsolatedStorageSettings.ApplicationSettings.Contains("FriendsIsSynced")) FriendsLongListSelector.ItemsSource = new FriendsListBuilder().LoadData(null); //BackgroundWorker worker = new BackgroundWorker(); //worker.DoWork += (o, e) => { apiMethodRequest.SendRequest(Authorization.AccessToken, "friends.get", new Dictionary<string, string> { { "uid", "" }, { "fields", "uid, first_name, last_name, photo" }, { "order", "hints" } }); }; //worker.RunWorkerAsync(); apiMethodRequest.SendRequest(Authorization.AccessToken, "friends.get", new Dictionary<string, string> { { "uid", "" }, { "fields", "uid, first_name, last_name, photo" }, { "order", "hints" } }); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { apiMethodRequest = new WebRequestsBuilder(); VkApi.WebRequestsBuilder.GetMessagesHistoryResponseReceived += new WebRequestsBuilder.GetMessagesHistoryResponseEventsHandler(WebRequestsBuilder_GetMessagesHistoryResponseReceived); VkApi.WebRequestsBuilder.GetMessageResponseReceived += new WebRequestsBuilder.GetMessageResponseEventsHandler(WebRequestsBuilder_GetMessageReceived); VkApi.WebRequestsBuilder.GetMessageSendReceived += new WebRequestsBuilder.GetMessageSendEventsHandler(WebRequestsBuilder_GetMessageSendReceived); VkApi.WebRequestsBuilder.GetAttachmentReceived += new WebRequestsBuilder.GetAttachmentEventsHandler(WebRequestsBuilder_GetAttachmentReceived); VkApi.WebRequestsBuilder.GetUploadServerReceived += new WebRequestsBuilder.GetUploadServerEventsHandler(WebRequestsBuilder_GetUploadServerReceived); VkApi.WebRequestsBuilder.GetUploadedImageReceived += new WebRequestsBuilder.GetUploadImageEventsHandler(WebRequestsBuilder_GetUploadedImageReceived); MessageTemplateItemViewModel.MessageDeleteResponseReceived += new MessageTemplateItemViewModel.MessageDeleteEventsHandler(MessageTemplateItemViewModel_MessageDeleteResponseReceived); if (onceNavigate) { if (attachImg.Count == 0) { intermediateAppBar = messagesAppBar; ApplicationBar = messagesAppBar; } else { BuildApplicationBars(); intermediateAppBar = messageWithAttachment; ApplicationBar = messageWithAttachment; } base.OnNavigatedTo(e); } else intermediateAppBar = messagesAppBar; onceNavigate = true; }