/// This event gets triggered when an item is selected from the UsersListView View ListView. private async void UsersListLiveView_SelectedUserListViewItem(object sender, EventArgs e) { //Ideally this should be some sort of local database selecteduser = teamuserlist.SelectTeamUser(UsersListLiveView.SelectUserID); if (selecteduser == null) return; //Profile Title UserProfileTitleNamewithAtTextBlock.Text = selecteduser.NamewithAtSymbol; //Name Under Photo UserProfileNameBelowPhotoTextBlock.Text = selecteduser.RealNamewithNameFailover; //Presence Symbol Color UserProfileStatusIndicatorBorder.Background = selecteduser.UserPresenceExcludingAwayStatusColor; //Presence Symbol "Z" if (selecteduser.presence == SlackConstants.AWAYSTATUS) { UserProfileZStatusIndicatorBorder.Visibility = Visibility.Visible; UserProfileZStatusIndicatorTextBox.Visibility = Visibility.Visible; } else { UserProfileZStatusIndicatorBorder.Visibility = Visibility.Collapsed; UserProfileZStatusIndicatorTextBox.Visibility = Visibility.Collapsed; } //Role UserProfileRoleTextBlock.Text = selecteduser.profile.title; //Message Button UserProfileMessageTextBlock.Text = "Message " + selecteduser.NamewithAtSymbol; //Email Button if (selecteduser.profile.email.Length > 0) { UserProfileEmailBorder.Visibility = Visibility.Visible; UserProfileEmailTextBlock.Text = selecteduser.profile.email; } else { UserProfileEmailBorder.Visibility = Visibility.Collapsed; } //Skype Button if (selecteduser.profile.skype.Length > 0) { UserProfileSkypeBorder.Visibility = Visibility.Visible; UserProfileSkypeTextBlock.Text = selecteduser.profile.skype; } else { UserProfileSkypeBorder.Visibility = Visibility.Collapsed; } //Phone Button if (selecteduser.profile.phone.Length > 0) { UserProfilePhoneBorder.Visibility = Visibility.Visible; UserProfilePhoneTextBlock.Text = selecteduser.profile.phone; } else { UserProfilePhoneBorder.Visibility = Visibility.Collapsed; } //Profile Photo ImageBrush imagebrush = new ImageBrush(); imagebrush.ImageSource = selecteduser.image_192; UserProfilePhotoBorder.Background = imagebrush; //IsSlackBot if (selecteduser.IsSlackBot == true) { UserProfileNameBelowPhotoTextBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 128, 128, 128)); } else { UserProfileNameBelowPhotoTextBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 170, 52, 255)); } //Network Connection Check, data will still load so this is simply a warning not an error. bool hasNetworkConnection = NetworkInterface.GetIsNetworkAvailable(); if (hasNetworkConnection == false) { var messageDialog = new MessageDialog("No Internet Connection."); messageDialog.Commands.Add(new UICommand("Ok", (command) => { return; })); messageDialog.DefaultCommandIndex = 1; await messageDialog.ShowAsync(); } UserProfileBorder.Visibility = Visibility.Visible; }
/// Parse the JSON string for this specific class and populated UsersList List private async void ParseJSONStringData(string jsonstring) { //Some values can be either "" or null try { JToken token = JObject.Parse(jsonstring); var ok = token.SelectToken("ok"); var members = token.SelectToken("members").ToArray(); if (ok.ToString().ToLower() == "true") { List<User> a = new List<User>(); foreach (var member in members) { User newmember = new User(); newmember.id = member.SelectToken("id").ToString(); newmember.name = member.SelectToken("name").ToString(); if (member.SelectToken(SlackConstants.DELETEDSTATUS) != null) { if (member.SelectToken(SlackConstants.DELETEDSTATUS).ToString().ToLower() == "true") { newmember.deleted = true; } } if (member.SelectToken("is_admin") != null) { if (member.SelectToken("is_admin").ToString().ToLower() == "true") { newmember.is_admin = true; } } if (member.SelectToken("is_owner") != null) { if (member.SelectToken("is_owner").ToString().ToLower() == "true") { newmember.is_owner = true; } } if (member.SelectToken("has_files") != null) { if (member.SelectToken("has_files") != null) { if (member.SelectToken("has_files").ToString().ToLower() == "true") { newmember.has_files = true; } } } if (member.SelectToken("has_2fa") != null) { if (member.SelectToken("has_2fa").ToString().ToLower() == "true") { newmember.has_2fa = true; } } if (member.SelectToken("presence") != null) { if (member.SelectToken("presence").ToString() != "") { newmember.presence = member.SelectToken("presence").ToString(); ; } } //User Profile Class which is a subclass of User UserProfile newmemberprofile = new UserProfile(); JToken profilejtoken = member.SelectToken("profile"); if (profilejtoken.SelectToken("first_name") != null) { newmemberprofile.first_name = profilejtoken.SelectToken("first_name").ToString(); } if (profilejtoken.SelectToken("last_name") != null) { newmemberprofile.last_name = profilejtoken.SelectToken("last_name").ToString(); } if (profilejtoken.SelectToken("real_name") != null) { newmemberprofile.real_name = profilejtoken.SelectToken("real_name").ToString(); } if (profilejtoken.SelectToken("title") != null) { newmemberprofile.title = profilejtoken.SelectToken("title").ToString(); } if (profilejtoken.SelectToken("email") != null) { newmemberprofile.email = profilejtoken.SelectToken("email").ToString(); } if (profilejtoken.SelectToken("skype") != null) { newmemberprofile.skype = profilejtoken.SelectToken("skype").ToString(); } if (profilejtoken.SelectToken("phone") != null) { newmemberprofile.phone = profilejtoken.SelectToken("phone").ToString(); } if (profilejtoken.SelectToken("image_24") != null) { newmemberprofile.image_24 = profilejtoken.SelectToken("image_24").ToString(); } if (profilejtoken.SelectToken("image_32") != null) { newmemberprofile.image_32 = profilejtoken.SelectToken("image_32").ToString(); } if (profilejtoken.SelectToken("image_48") != null) { newmemberprofile.image_48 = profilejtoken.SelectToken("image_48").ToString(); } if (profilejtoken.SelectToken("image_72") != null) { newmemberprofile.image_72 = profilejtoken.SelectToken("image_72").ToString(); } if (profilejtoken.SelectToken("image_192") != null) { newmemberprofile.image_192 = profilejtoken.SelectToken("image_192").ToString(); } newmember.profile = newmemberprofile; a.Add(newmember); } teamlist = a; teamfulllist = a; //Save Good Parsable results only if (teamlist != null) { if (teamlist.Count > 0) { await saveJSONStringToLocalFile(USERLISTFILENAME, jsonstring); } } } } catch (Exception ex) { string s = ex.Message; } }