Esempio n. 1
0
        internal void LoadUser(User user)
        {
            this.user = user;
            name.Text = user.FirstName + " " + user.LastName;
            gender.Text = user.Gender.ToString();
            email.Text = user.Email;
            twitter.Text = string.IsNullOrEmpty(user.Twitter) ? "" :  "@" + user.Twitter;
            facebook.Text = string.IsNullOrEmpty(user.Facebook) ? "" : "http://www.facebook.com/profile.php?id=" + user.Facebook;
            friendStatus.Text = user.FriendStatus;

            if (!string.IsNullOrEmpty(user.Photo))
            {
                string url = user.Photo;
                HttpWebRequest imgRequest = (HttpWebRequest)WebRequest.Create(url);
                imgRequest.Method = "GET";
                HttpWebResponse imgResponse = (HttpWebResponse)imgRequest.GetResponse();
                Bitmap bmp = new Bitmap(imgResponse.GetResponseStream());
                imgResponse.Close();
                picture.SizeMode = PictureBoxSizeMode.StretchImage;
                picture.Image = bmp;
            }
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FoursquareApp.Icons.twitter.gif");
            twitterIcon.SizeMode = PictureBoxSizeMode.StretchImage;
            twitterIcon.Image = new Bitmap(stream);

            stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FoursquareApp.Icons.facebook.jpg");
            facebookIcon.SizeMode = PictureBoxSizeMode.StretchImage;
            facebookIcon.Image = new Bitmap(stream); 
        }
Esempio n. 2
0
        public static User Parse(XmlNode node)
        {
            User user = new User();

            if (node.SelectSingleNode("id") != null)
            {
                user.Id = long.Parse(node.SelectSingleNode("id").InnerText);
            }
            if (node.SelectSingleNode("firstname") != null)
            {
                user.FirstName = node.SelectSingleNode("firstname").InnerText;
            }
            if (node.SelectSingleNode("lastname") != null)
            {
                user.LastName = node.SelectSingleNode("lastname").InnerText;
            }
            if (node.SelectSingleNode("photo") != null)
            {
                user.Photo = node.SelectSingleNode("photo").InnerText;
            }
            if (node.SelectSingleNode("gender") != null)
            {
                user.Gender = (Gender)Enum.Parse(typeof(Gender), node.SelectSingleNode("gender").InnerText, true);
            }
            if (node.SelectSingleNode("email") != null)
            {
                user.Email = node.SelectSingleNode("email").InnerText;
            }
            if (node.SelectSingleNode("twitter") != null)
            {
                user.Twitter = node.SelectSingleNode("twitter").InnerText;
            }
            if (node.SelectSingleNode("facebook") != null)
            {
                user.Facebook = node.SelectSingleNode("facebook").InnerText;
            }
            if (node.SelectSingleNode("friendstatus") != null)
            {
                user.FriendStatus = node.SelectSingleNode("friendstatus").InnerText;
            }

            return user;
        }